ros-drivers / video_stream_opencv

A package to open video streams and publish them in ROS using the opencv videocapture mechanism
227 stars 159 forks source link

video_stream_opencv fails to publish #117

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hello everyone!

I'm trying to use the video_stream_opencv package (installed using sudo apt-get install ros-noetic-video-stream-opencv) on my Raspberry Pi 4B running Ubuntu Mate 20.04 64-bit and ROS noetic.

I'm using a Raspberry Pi Camera Module V2 that appears as /dev/video0. Input test using test_video_resource.py works perfectly fine.

user@user-rpi4b:~/Documents/camera` test$ python3 test_video_resource.py 0
Trying to open resource:  /dev/video0
Correctly opened resource, starting to show feed.

stream

Now, I'm having trouble when I run the webcam.launch file (as default with no modifications), as it seems to stop at some point of the initialization, and because there is no timeout error, I can't properly understand what's going on. It always stops at the same line. The following code is what I get in the terminal:

user@user-rpi4b:~$ roslaunch video_stream_opencv webcam.launch video_stream_provider:=0
... logging to /home/user/.ros/log/651094f0-54ed-11ee-9b5f-e9334d5bdcf2/roslaunch-user-rpi4b-2233.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://192.168.1.169:44491/

SUMMARY
========

PARAMETERS
 * /rosdistro: noetic
 * /rosversion: 1.16.0
 * /webcam/webcam_stream/buffer_queue_size: 1
 * /webcam/webcam_stream/camera_info_url: 
 * /webcam/webcam_stream/camera_name: webcam
 * /webcam/webcam_stream/flip_horizontal: False
 * /webcam/webcam_stream/flip_vertical: False
 * /webcam/webcam_stream/fps: 30.0
 * /webcam/webcam_stream/frame_id: webcam_optical_frame
 * /webcam/webcam_stream/height: 0
 * /webcam/webcam_stream/loop_videofile: False
 * /webcam/webcam_stream/set_camera_fps: 30.0
 * /webcam/webcam_stream/start_frame: 0
 * /webcam/webcam_stream/stop_frame: -1
 * /webcam/webcam_stream/video_stream_provider: 0
 * /webcam/webcam_stream/width: 0

NODES
  /webcam/
    webcam_image_view (image_view/image_view)
    webcam_stream (video_stream_opencv/video_stream)

ROS_MASTER_URI=http://192.168.1.100:11311

process[webcam/webcam_stream-1]: started with pid [2244]
process[webcam/webcam_image_view-2]: started with pid [2245]
[ INFO] [1679940785.464760854]: Initializing nodelet with 4 worker threads.
[ INFO] [1679940786.236388659]: Camera name: webcam
[ INFO] [1679940786.236545712]: Provided camera_info_url: ''
[ INFO] [1679940786.236620377]: Publishing with frame_id: webcam_optical_frame
[ INFO] [1679940786.236709134]: Setting camera FPS to: 30
[ INFO] [1679940786.236779300]: Throttling to fps: 30
[ INFO] [1679940786.236848743]: Setting buffer size for capturing frames to: 1
[ INFO] [1679940786.236923038]: Flip horizontal image is: false
[ INFO] [1679940786.237011610]: Flip vertical image is: false
[ INFO] [1679940786.237074794]: Video start frame is: 0
[ INFO] [1679940786.237137163]: Video stop frame is: -1

Because the launch file never completes the initialization, it never publishes data into the topics and image_view never loads, so I'm not able to echo any of the package topics. There was one random time it completed the initialization and the image_view window popped up, but it was all black with no image and nothing was being published.

I also tried camera.launch and video_file.launch with no positive results.

ghost commented 1 year ago

So, I've just found out firewall was enabled and active on my RPi, and that was causing the whole issue. I was able to ping both machines but then, I tried to use netcat to establish communication between both of them over a specified port and nothing happened. After some time, I was able to find the root of the problem, and once the firewall was deactivated, video_stream_opencv completed initialization and started publishing correctly on the corresponding topics.

Somehow, image is all black, so there's still something I'm missing, but I'm going to continue on my own, close this issue and open a new one if necessary lol.