Skip to content

Commit

Permalink
Ffmpeg support (#4)
Browse files Browse the repository at this point in the history
* working on ffmpeg support
* ffmpeg demo
  • Loading branch information
DominikN authored Jan 26, 2024
1 parent 2d484b5 commit fd1a08e
Show file tree
Hide file tree
Showing 9 changed files with 296 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ RUN apt-get update && apt-get install -y \
python3-rosdep

# install everything needed
RUN git clone https://github.com/luxonis/depthai-ros.git /ros2_ws/src -b ${DEPTHAI_ROS_RELEASE} && \
RUN git clone https://github.com/luxonis/depthai-ros.git src/depthai-ros -b ${DEPTHAI_ROS_RELEASE} && \
git clone https://github.com/ros-misc-utilities/ffmpeg_image_transport.git src/ffmpeg_image_transport && \
vcs import src < src/ffmpeg_image_transport/ffmpeg_image_transport.repos && \
rm -rf /etc/ros/rosdep/sources.list.d/20-default.list && \
rosdep init && \
rosdep update --rosdistro $ROS_DISTRO && \
rosdep install --from-paths src --ignore-src -r -y && \
source /opt/ros/$ROS_DISTRO/setup.bash && \
MAKEFLAGS="-j1 -l1" colcon build
MAKEFLAGS="-j1 -l1" colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-core

Expand Down
2 changes: 2 additions & 0 deletions demo/oak-1-ffmpeg/.env.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DISPLAY=${DISPLAY:?err}
LIBGL_ALWAYS_SOFTWARE=1
3 changes: 3 additions & 0 deletions demo/oak-1-ffmpeg/.env.gpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DISPLAY=${DISPLAY:?err}
NVIDIA_VISIBLE_DEVICES=all
NVIDIA_DRIVER_CAPABILITIES=all
54 changes: 54 additions & 0 deletions demo/oak-1-ffmpeg/camera.params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/oak:
ros__parameters:
# qos_overrides: # group for all the qos settings
# '/oak/rgb/image_raw':
# publisher:
# reliability: best_effort
camera:
i_enable_imu: false
i_enable_ir: false
i_floodlight_brightness: 0
i_ip: ''
i_laser_dot_brightness: 800
i_mx_id: ''
i_nn_type: none
i_pipeline_type: RGB
i_usb_port_id: ''
i_usb_speed: SUPER_PLUS
i_pipeline_dump: false
i_calibration_dump: false
i_external_calibration_path: ''
rgb:
i_board_socket_id: 0
i_simulate_from_topic: false
i_get_base_device_timestamp: false
i_disable_node: false
i_calibration_file: ''
i_enable_preview: false
i_fps: 30.0
i_width: 640
i_height: 360
i_interleaved: false
i_keep_preview_aspect_ratio: true
i_low_bandwidth: true
i_low_bandwidth_quality: 50
i_max_q_size: 30
i_preview_size: 300
i_publish_topic: true
i_resolution: '360'
i_set_isp_scale: false
i_isp_num: 2
i_isp_den: 3
i_output_isp: false
r_exposure: 20000
r_focus: 1
r_iso: 800
r_set_man_exposure: false
r_set_man_focus: false
r_set_man_whitebalance: false
r_whitebalance: 3300
ffmpeg_image_transport:
encoding: libx264
preset: ultrafast
tune: zerolatency
use_sim_time: false
41 changes: 41 additions & 0 deletions demo/oak-1-ffmpeg/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
x-common-config:
&common-config
network_mode: host
ipc: host
environment:
- FASTRTPS_DEFAULT_PROFILES_FILE=/shm-only.xml
- USER

x-cpu-config:
&cpu-config
env_file: .env.cpu

x-gpu-config:
&gpu-config
runtime: nvidia
env_file: .env.gpu

services:
luxonis:
image: husarion/depthai:humble-ffmpeg-support
<<: *common-config
volumes:
- /dev/bus/usb:/dev/bus/usb
- ./camera.params.yaml:/camera.params.yaml
device_cgroup_rules:
- 'c 189:* rmw'
command: >
ros2 launch depthai_ros_driver camera.launch.py
parent_frame:=oak-1-base-frame
params_file:=/camera.params.yaml
rviz:
image: husarion/rviz2:humble-11.2.9-20240111
<<:
- *common-config
- *gpu-config
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- ./default.rviz:/default.rviz
- ./rviz.launch.py:/rviz.launch.py
command: ros2 launch /rviz.launch.py
149 changes: 149 additions & 0 deletions demo/oak-1-ffmpeg/default.rviz
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
Panels:
- Class: rviz_common/Displays
Help Height: 0
Name: Displays
Property Tree Widget:
Expanded:
- /Image1
- /Image1/Topic1
Splitter Ratio: 0.5
Tree Height: 415
- Class: rviz_common/Selection
Name: Selection
- Class: rviz_common/Tool Properties
Expanded:
- /2D Goal Pose1
- /Publish Point1
Name: Tool Properties
Splitter Ratio: 0.5886790156364441
- Class: rviz_common/Views
Expanded:
- /Current View1
Name: Views
Splitter Ratio: 0.5
- Class: rviz_common/Time
Experimental: false
Name: Time
SyncMode: 0
SyncSource: ""
Visualization Manager:
Class: ""
Displays:
- Alpha: 0.5
Cell Size: 1
Class: rviz_default_plugins/Grid
Color: 160; 160; 164
Enabled: true
Line Style:
Line Width: 0.029999999329447746
Value: Lines
Name: Grid
Normal Cell Count: 0
Offset:
X: 0
Y: 0
Z: 0
Plane: XY
Plane Cell Count: 10
Reference Frame: <Fixed Frame>
Value: true
- Class: rviz_default_plugins/Image
Enabled: true
Max Value: 1
Median window: 5
Min Value: 0
Name: Image
Normalize Range: true
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Best Effort
Value: /image_raw/uncompressed
Value: true
Enabled: true
Global Options:
Background Color: 48; 48; 48
Fixed Frame: map
Frame Rate: 30
Name: root
Tools:
- Class: rviz_default_plugins/Interact
Hide Inactive Objects: true
- Class: rviz_default_plugins/MoveCamera
- Class: rviz_default_plugins/Select
- Class: rviz_default_plugins/FocusCamera
- Class: rviz_default_plugins/Measure
Line color: 128; 128; 0
- Class: rviz_default_plugins/SetInitialPose
Covariance x: 0.25
Covariance y: 0.25
Covariance yaw: 0.06853891909122467
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /initialpose
- Class: rviz_default_plugins/SetGoal
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /goal_pose
- Class: rviz_default_plugins/PublishPoint
Single click: true
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /clicked_point
Transformation:
Current:
Class: rviz_default_plugins/TF
Value: true
Views:
Current:
Class: rviz_default_plugins/Orbit
Distance: 10
Enable Stereo Rendering:
Stereo Eye Separation: 0.05999999865889549
Stereo Focal Distance: 1
Swap Stereo Eyes: false
Value: false
Focal Point:
X: 0
Y: 0
Z: 0
Focal Shape Fixed Size: true
Focal Shape Size: 0.05000000074505806
Invert Z Axis: false
Name: Current View
Near Clip Distance: 0.009999999776482582
Pitch: 0.785398006439209
Target Frame: <Fixed Frame>
Value: Orbit (rviz)
Yaw: 0.7903980016708374
Saved: ~
Window Geometry:
Displays:
collapsed: false
Height: 1016
Hide Left Dock: false
Hide Right Dock: false
Image:
collapsed: false
QMainWindow State: 000000ff00000000fd0000000400000000000004d40000035efc020000000afb0000000a0049006d006100670065010000003b0000035e0000002800fffffffb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000000c00430061006d00650072006100000002a1000000e70000000000000000fb0000000c00430061006d0065007200610000000434000000d7000000000000000000000001000001560000035efc0200000004fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003b0000017e000000a000fffffffb000000100044006900730070006c00610079007301000001bf000001da000000c700fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e100000197000000030000073a0000003efc0100000002fb0000000800540069006d006501000000000000073a0000025300fffffffb0000000800540069006d00650100000000000004500000000000000000000001040000035e00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Time:
collapsed: false
Tool Properties:
collapsed: false
Views:
collapsed: false
Width: 1850
X: 70
Y: 27
4 changes: 4 additions & 0 deletions demo/oak-1-ffmpeg/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
run:
#!/bin/bash
xhost +local:docker
docker compose up
22 changes: 22 additions & 0 deletions demo/oak-1-ffmpeg/rviz.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
return LaunchDescription([
# Launch RViz2 with a default configuration
Node(
package='rviz2',
executable='rviz2',
name='rviz2',
arguments=['-d', '/default.rviz'],
output='screen'
),
# Launch image_transport to republish images
Node(
package='image_transport',
executable='republish',
name='republish',
arguments=['ffmpeg', 'in/ffmpeg:=/oak/rgb/image_raw/ffmpeg', 'raw', 'out:=/image_raw/uncompressed'],
output='screen'
),
])
17 changes: 17 additions & 0 deletions demo/oak-1-ffmpeg/shm-only.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
<transport_descriptors>
<transport_descriptor>
<transport_id>shm_transport</transport_id>
<type>SHM</type>
</transport_descriptor>
</transport_descriptors>
<participant profile_name="SHMParticipant" is_default_profile="true">
<rtps>
<userTransports>
<transport_id>shm_transport</transport_id>
</userTransports>
<useBuiltinTransports>false</useBuiltinTransports>
</rtps>
</participant>
</profiles>

0 comments on commit fd1a08e

Please sign in to comment.