问题
Currently I’m working on a project to mirror a camera for a blind spot. The camera got 640 x 480 NTSC signal. The output screen is 854 x 480 NTSC. I grab the camera with an EasyCAP video grabber. On the Banana Pi I installed open cv 2.4.9.
The critical point of this project is that the video on the display needs to be real time. Whenever I comment the line that puts the window into fullscreen, there pop ups a small window and the footage runs without delay and lagg. But when I set the video to full screen, the footage becomes slow, and lags.
Part of the code:
namedWindow("window",0);
setWindowProperty("window",CV_WND_PROP_FULLSCREEN,CV_WINDOW_FULLSCREEN);
while(1){
cap>>image;
flip(image, destination,1);
imshow("window",destination);
waitKey(33); //delay 33 ms
}
How can I fill the screen with the camera footage without losing speed and frames? Is it possible to output the footage directly to the composite output?
回答1:
The problem is that upscaling and drawing is done in software here. The Banana Pi processor is not powerful enough to process the needed throughput with 30 frames per second. This is an educated guess on my side, as even desktop systems can run into lag problems when processing and simultaneously displaying video.
A common solution in the computer vision community for this problem is to use OpenGL for display. Here, the upscaling and display is offloaded to the graphics processor. You can do the same thing on a Banana Pi.
If you compiled OpenCV with OpenGL support, you can try it like this:
namedWindow("window", WINDOW_OPENGL);
imshow("window", destination);
Note that if you use OpenGL, you can also save on the flip operation by using an approprate modelview matrix. For this however you probably need to dive into GL code yourself instead of using imshow.
回答2:
I fixed the whole problem by using:
namedWindow("window",1);
With FLAG 1 stands for WINDOW_AUTOSIZE.
The footage is more real-time now.
I’m using a small monitor, so the window size is nearly the same as the monitor.
来源:https://stackoverflow.com/questions/26178361/why-does-a-full-screen-window-resolution-in-opencv-banana-pi-raspbian-slow