Create a new window on top of camera feed
I have an application for OpenCV where I am looking to create a camera feed and then draw on top of the camera feed. My first thought is that I probably need two windows or views. One to output the camera feed only and the other would be a transparent window sitting on top of the camera feed window that I could draw to. For performance reasons I figure it does not make sense to update the cv::Mat in the window that is outputting the camera feed so I will do it on top of the camera feed in a new window as I will be doing a lot of drawing, computation, and updating. Am I thinking about this in the correct way? Is this something that can be done in OpenCV? If so, how would something like this be setup?
"it does not make sense to update the cv::Mat that is being displayed in the camera feed." - hmm, that sounds like 'premature optimization' don't be afraid of drawing a few lines, it's dead cheap.
So do you think it would be a better idea to draw directly onto the cv::Mat that is being output from my camera? Do you think that this will slow down my FPS if I do all of this logic inside of my camera loop?
compared to what ? ;)
again, profile, and then worry.
So here is the reason that I am concerned. I am performing a SURF detection for keypoints on every cv::Mat that comes off the camera feed. When I detect that I have a good set of matches I need to draw to the cv::Mat. That is all fine except when I was performing SURF detection inside that camera loop I was getting around 3-4 FPS so to increase performance I move the entire SURF detection process to a background thread and now I am getting 12-13 FPS. This is why I am concerned. I feel that to not slow down the camera feed it might be a good idea to draw on top of the camera feed instead of directly to it.
yes, SURF keypoint detection is very expensive, drawing is cheap.
again, profile , don't just guess.
OK, will do. Thank you. I will look into drawing directly to the camera frame.
here's some code:
Thank you. I am using this in my camera feed already, but as I rework my background SURF computations I may want to use it there too.
The tracking code running on the background thread takes 0.234629 sec to run the computation so keeping the cv::Mat's updated in the camera thread lags a bit.