VideoCapture Slows Down OpenGL Program

asked 2014-02-16 20:34:03 -0500

Josh123 gravatar image

I've written a pong video game that uses object tracking with a camera to position the paddle of the player. Everything was running smoothly until I begun grabbing input from the camera. Now the game draws very slowly and messes up game play. Is grabbing the images from the camera just slow or is this a combination of opengl and opencv slowing down the program? I am using SDL as well as the highgui module from opencv, is the conflict between the windowing API wrapers causing this issue?

edit retag flag offensive close merge delete

Comments

Have you checked your CPU and RAM usage during the execution of the program? If so then what is the output? How busy is your system? Both of the above will give you some idea about what you are doing and where you are going wrong.

prakharmohan gravatar imageprakharmohan ( 2014-02-17 01:06:51 -0500 )edit

CPU usage is under 50% and RAM usage is 25.8%, perhaps the maximum speed allocated for the single thread running the program is too slow. Would adding another thread to pull camera images remedy this problem? A partial fix I am using right now is slowing down the rate of taking images from the camera (waiting 25ms between each), results are somewhat better, but still not good enough.

Josh123 gravatar imageJosh123 ( 2014-02-20 19:26:30 -0500 )edit

Yes try that. If not tell me, I'll try looking at it over the weekend.

prakharmohan gravatar imageprakharmohan ( 2014-02-20 20:23:02 -0500 )edit

Adding another thread did not increase perfromance. This seems to mean that both OpenGL and OpenCV are using the GPU, thus the slow rendering performance. Any suggestions are appreciated. I can't imagine my program requiring the need for OpenCL (the program is rather small), but it seems the only alternative.

Josh123 gravatar imageJosh123 ( 2014-02-21 16:57:20 -0500 )edit