Bridge to OpenCV Foxy 20210413

From wikidb
Jump to: navigation, search

The Project Bridge to OpenCV

References

Create Project

 $ cd ~/eepp_ws/src/
 
 $ ros2 pkg create --build-type ament_cmake opencv_ros2sub
     going to create a new package
     package name: opencv_ros2sub
     destination directory: /home/eepp/eepp_ws/src
     package format: 3
     version: 0.0.0
     description: TODO: Package description
     maintainer: ['eepp <eepp@todo.todo>']
     licenses: ['TODO: License declaration']
     build type: ament_cmake
     dependencies: []
     creating folder ./opencv_ros2sub
     creating ./opencv_ros2sub/package.xml
     creating source and include folder
     creating folder ./opencv_ros2sub/src
     creating folder ./opencv_ros2sub/include/opencv_ros2sub
     creating ./opencv_ros2sub/CMakeLists.txt

Files

 ../src/opencv_ros2sub/src
 ../src/opencv_ros2sub

Build

 $ cd ~/eepp_ws

 $ colcon build --symlink-install --parallel-workers 1
     Starting >>> cpp_pubsub
     Finished <<< cpp_pubsub [0.31s]                  
     Starting >>> image_experiment
     Finished <<< image_experiment [0.26s]                  
     Starting >>> opencv_ros2sub
     Finished <<< opencv_ros2sub [1.67s]                  

     Summary: 3 packages finished [2.44s]

Execute

Execute the Image Publisher

TBD: Found in Foxy 7/8/21

 see tensor20210708.txt
 $ ros2 run image_tools cam2image --ros-args -p frequency:=2.0
 [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
 [INFO] [1625764868.106752791] [cam2image]: Publishing image #1
 [INFO] [1625764868.606034554] [cam2image]: Publishing image #2
 [INFO] [1625764869.106041374] [cam2image]: Publishing image #3
 [INFO] [1625764869.605974867] [cam2image]: Publishing image #4

End TBD

TERMINAL 1

 $ source ~/image_ws/install/setup.bash

 $ ros2 run image_publisher image_publisher_node /dev/video0
     [INFO] [1618505195.586979521] [ImagePublisher]: param_change_callback
     [INFO] [1618862018.060864187] [ImagePublisher]: Reset filename as '/dev/video0'
     [INFO] [1618862018.060899412] [ImagePublisher]: File name for publishing image is : /dev/video0
     [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (1758) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module source reported: Could not read from resource.
     [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (888) open OpenCV | GStreamer warning: unable to start pipeline
     [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
     [INFO] [1618862020.729152588] [ImagePublisher]: Flip horizontal image is : false
     [INFO] [1618862020.729282428] [ImagePublisher]: Flip flip_vertical image is : false

TERMINAL 2

 $ ros2 topic list
     /camera_info
     /image_raw
     /parameter_events
     /rosout

 $ ros2 topic echo image_raw
     ---
     header:
       stamp:
         sec: 1617818511
         nanosec: 782709125
       frame_id: camera
     height: 480
     width: 640
     encoding: bgr8
     is_bigendian: 0
     step: 1920
     data:
     - 82
     - 85
     - 82
     -
     ...
     ...

Note the encoding field. See

 include/sensor_msgs/image_encodings.h

Execute the Image Subscriber under Test

TERMINAL 2

 $ ros2 run opencv_ros2sub opencv_exp --ros-args -r image:=image_raw

IMG 2135s.jpeg

The Project Minimum Image Subscriber

find in image_sub project: eepp_ws/src/image_sub/src

OOP Version

Procedural Version

Notes and Logs

CamShift References

FitPC versions