Closed xiechangwu closed 6 years ago
This sounds like side-effects of USB buffer overflows. It happens whenever the host PC is not pulling USB buffers from the device fast enough. At the moment, librealsense just passes such partial frames to the application.
This can be verified by printing out the value of buf.bytesused
at uvc-v4l2.cpp:344.
During normal streaming this value should equal to _buffers[buf.index].length
, but during overflows it would be lower.
The overflows themselves are either caused by high CPU usage in parallel to streaming, or just a weak CPU (perhaps CPU is being thermal-throttled? In this case cooling can have big effect)
As a possible work-around I have previously recommended to increase the number of URBs in uvcvideo from 5 to about 8 (change #define UVC_URBS 5
in /drivers/media/usb/uvc/uvcvideo.h
, rebuild and replace the Kernel module). In theory this should increase the queue size between USB layer and UVC driver, reducing partial frames at expense of some extra latency. However, this might have other unexpected side-effects and would not be recommended in production environment.
P.S. Just to make sure, you are using V4L back-end and not LIBUVC, correct?
Hi, dorodnic. Thanks very much for you help.
I tried with your solution by changed UVC_URBS to 8/16 , UVC_MAX_VIDEO_BUFFERS to 64 but neither of them has any effects for this problem.
Good news is, buf.bytesused and _buffers[buf.index].length were acts as you expected. I add "LOG_WARNING("buf.bytesused=" << buf.bytesused << " sub->buffers[buf.index].length:" << sub->buffers[buf.index].length);" within uvc-v4l2.cpp:344. And the logs are as follows:
rs.warn: Subdevice 1 frame status 0x1 rs.warn: buf.bytesused=3932160 sub->buffers[buf.index].length:4147200 rs.warn: buf.bytesused=4147200 sub->buffers[buf.index].length:4147200 rs.warn: buf.bytesused=589064 sub->buffers[buf.index].length:589064 rs.warn: Subdevice 1 frame status 0x1 rs.warn: buf.bytesused=3953664 sub->buffers[buf.index].length:4147200 rs.warn: buf.bytesused=589064 sub->buffers[buf.index].length:589064 rs.warn: Subdevice 1 frame status 0x1 rs.warn: buf.bytesused=3910656 sub->buffers[buf.index].length:4147200 rs.warn: buf.bytesused=3459072 sub->buffers[buf.index].length:4147200 rs.warn: buf.bytesused=589064 sub->buffers[buf.index].length:589064 rs.warn: Subdevice 1 frame status 0x1 rs.warn: buf.bytesused=3867648 sub->buffers[buf.index].length:4147200 rs.warn: buf.bytesused=3437568 sub->buffers[buf.index].length:4147200 rs.warn: buf.bytesused=4147200 sub->buffers[buf.index].length:4147200 rs.warn: buf.bytesused=614400 sub->buffers[buf.index].length:614400 rs.warn: buf.bytesused=4147200 sub->buffers[buf.index].length:4147200 rs.warn: buf.bytesused=3932160 sub->buffers[buf.index].length:4147200 rs.warn: buf.bytesused=614400 sub->buffers[buf.index].length:614400 rs.warn: buf.bytesused=4147200 sub->buffers[buf.index].length:4147200 rs.warn: buf.bytesused=589064 sub->buffers[buf.index].length:589064
@dorodnic
@dorodnic Please note that this issue only appears for R200, the SR300 doesn't has this problem. While I using two SR300 for image capture, this problem also disappeared. Is it caused by an additional picture called "infrared" when using R200?
If you are enabling Infrared and Infrared2 on the R200 in your application, this would be the first thing to disable. However, it might be that your target platform simply struggles to handle two 1080P streams + depth data. What is the CPU utilization when the problem is happening? When you are requesting RGB data from librealsense, we are internally doing YUY to RGB conversion, and it is known to be very CPU intensive. Even if SSE instructions are available and enabled, this might be too much for some hosts to handle and keep up with the USB transfer. Could you try your test, but ask for YUY format instead of RGB in the sample App? (You could consider offloading YUY to RGB conversion to the GPU. We are not doing any of that inside librealsense to avoid adding OpenCL as a dependency, but I know it has been done before)
@dorodnic
Any suggestions? Thanks!
For best support, post issues in the RealSense Community.
Hello,
Do you still need help with this issue?
Best regards, Jesus Intel Customer Support
Left is the image for R200, and right for SR300.
Summary:
Source code what I've changed: //dev->enable_stream(rs::stream::depth, rs::preset::best_quality); //dev->enable_stream(rs::stream::color, rs::preset::best_quality); TO dev->enable_stream(rs::stream::depth, 640, 480, rs::format::z16, 30); dev->enable_stream(rs::stream::color, 1920, 1080, rs::format::rgb8, 30);