ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello @jayess!

I make some research and this actually could not be implemented. The service will not be able to keep the cameras turned on without the buffer problem. (the first image was shown by the .read() method and after a second or third use of it, it will present the "same" frame because the buffer keeps some frame and the .read method call whatever is in the buffer of the camera). What i finally did was to use a node as a topic publisher to keep the frames in realtime being publish (this is posible is you are working wil low-mid resolution pictures, something like 4k will give you an exponential latency depending on your memory, if so, pease try not to use realtime, but clean your buffer before using using the image, this means use some .read() as a photo rampage and select the last one to continue the flow, as shown next).

~The "10" number depends on the camera, some will have a lower buffer as i have tested. not actual documentation, just testing.

 for i in range(10):  
      ret,frame = camera.read()
 ret,actual_frame = camera.read()

~keeps working with "actual_frame"

As you can see, the for is used just to clean the buffer, this is what i have done so far, because i havent figured if python opencv have a function to clean buffer of the camera var created with cv2.VideoCapture().

hope this could help someone.