From 03b4927134f4fdf4bdb9a782ceb3fac5e50ad0f6 Mon Sep 17 00:00:00 2001 From: dominikn Date: Fri, 26 Jan 2024 22:55:06 +0100 Subject: [PATCH] ffmpeg demo --- demo/oak-1-ffmpeg/.env.cpu | 2 + demo/oak-1-ffmpeg/.env.gpu | 3 + demo/oak-1-ffmpeg/camera.params.yaml | 54 ++++++++++ demo/oak-1-ffmpeg/compose.yaml | 41 ++++++++ demo/oak-1-ffmpeg/default.rviz | 149 +++++++++++++++++++++++++++ demo/oak-1-ffmpeg/justfile | 4 + demo/oak-1-ffmpeg/rviz.launch.py | 22 ++++ demo/oak-1-ffmpeg/shm-only.xml | 17 +++ 8 files changed, 292 insertions(+) create mode 100644 demo/oak-1-ffmpeg/.env.cpu create mode 100644 demo/oak-1-ffmpeg/.env.gpu create mode 100644 demo/oak-1-ffmpeg/camera.params.yaml create mode 100644 demo/oak-1-ffmpeg/compose.yaml create mode 100644 demo/oak-1-ffmpeg/default.rviz create mode 100644 demo/oak-1-ffmpeg/justfile create mode 100644 demo/oak-1-ffmpeg/rviz.launch.py create mode 100644 demo/oak-1-ffmpeg/shm-only.xml diff --git a/demo/oak-1-ffmpeg/.env.cpu b/demo/oak-1-ffmpeg/.env.cpu new file mode 100644 index 0000000..2ddee24 --- /dev/null +++ b/demo/oak-1-ffmpeg/.env.cpu @@ -0,0 +1,2 @@ +DISPLAY=${DISPLAY:?err} +LIBGL_ALWAYS_SOFTWARE=1 diff --git a/demo/oak-1-ffmpeg/.env.gpu b/demo/oak-1-ffmpeg/.env.gpu new file mode 100644 index 0000000..4b923f3 --- /dev/null +++ b/demo/oak-1-ffmpeg/.env.gpu @@ -0,0 +1,3 @@ +DISPLAY=${DISPLAY:?err} +NVIDIA_VISIBLE_DEVICES=all +NVIDIA_DRIVER_CAPABILITIES=all \ No newline at end of file diff --git a/demo/oak-1-ffmpeg/camera.params.yaml b/demo/oak-1-ffmpeg/camera.params.yaml new file mode 100644 index 0000000..1fd23ee --- /dev/null +++ b/demo/oak-1-ffmpeg/camera.params.yaml @@ -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 \ No newline at end of file diff --git a/demo/oak-1-ffmpeg/compose.yaml b/demo/oak-1-ffmpeg/compose.yaml new file mode 100644 index 0000000..b6cd526 --- /dev/null +++ b/demo/oak-1-ffmpeg/compose.yaml @@ -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 \ No newline at end of file diff --git a/demo/oak-1-ffmpeg/default.rviz b/demo/oak-1-ffmpeg/default.rviz new file mode 100644 index 0000000..e04af2f --- /dev/null +++ b/demo/oak-1-ffmpeg/default.rviz @@ -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: + 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: + 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 diff --git a/demo/oak-1-ffmpeg/justfile b/demo/oak-1-ffmpeg/justfile new file mode 100644 index 0000000..e575a8e --- /dev/null +++ b/demo/oak-1-ffmpeg/justfile @@ -0,0 +1,4 @@ +run: + #!/bin/bash + xhost +local:docker + docker compose up \ No newline at end of file diff --git a/demo/oak-1-ffmpeg/rviz.launch.py b/demo/oak-1-ffmpeg/rviz.launch.py new file mode 100644 index 0000000..e57ec50 --- /dev/null +++ b/demo/oak-1-ffmpeg/rviz.launch.py @@ -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' + ), + ]) \ No newline at end of file diff --git a/demo/oak-1-ffmpeg/shm-only.xml b/demo/oak-1-ffmpeg/shm-only.xml new file mode 100644 index 0000000..9b9149d --- /dev/null +++ b/demo/oak-1-ffmpeg/shm-only.xml @@ -0,0 +1,17 @@ + + + + + shm_transport + SHM + + + + + + shm_transport + + false + + + \ No newline at end of file