Hi! I am using this technique:
https://forums.naturalpoint.com/viewtop ... Mat#p48812
to stream a Prime 17W into opencv. It works great, BUT there is a noticeable delay in the displayed Mat frames compared to the original GL from the SDK example. Is this the fault of the Rasterize? Is there anything i can do to speed it up, or minimize the lag?
Thanks!
Bitmap to cv::Mat latency...
Re: Bitmap to cv::Mat latency...
Hi!
The Camera SDK OpenGL samples used camera->Rasterize() as well for getting the camera's image out of the SDK. The Rasterize() function is highly optimized because for any situation where you want to get the entire camera's image for a frame, this is the way you're going to get it.
When using the Prime17W and rasterizing frames to 24-bit per pixel, the simple math is 1664*1088*3 = 5.4 megs per frame. If you're running at 250 FPS, that's 1.3 GB/sec. So it's important to consider the performance impact of what you're attempting.
Details like what video mode, what frame rate, etc are important here also. What type of processing is OpenCV doing on this data?
What are you doing exactly?
The Camera SDK OpenGL samples used camera->Rasterize() as well for getting the camera's image out of the SDK. The Rasterize() function is highly optimized because for any situation where you want to get the entire camera's image for a frame, this is the way you're going to get it.
When using the Prime17W and rasterizing frames to 24-bit per pixel, the simple math is 1664*1088*3 = 5.4 megs per frame. If you're running at 250 FPS, that's 1.3 GB/sec. So it's important to consider the performance impact of what you're attempting.
Details like what video mode, what frame rate, etc are important here also. What type of processing is OpenCV doing on this data?
What are you doing exactly?
Re: Bitmap to cv::Mat latency...
Hi! thanks for your reply...
I am doing pattern recognition, for a type of augmented reality. It actually looks like the latency might be coming from my code pulling frames at irregular intervals, instead of every frame, or every second frame etc, so i am looking into that today.
I have a couple of questions though:
How can i change the frame rate from inside c++?
In GreyscaleMode, the frame is full res, and in MJEG mode, it is quarter size, right? Can i get a half size frame? Or are those my only options?
thanks again!
I am doing pattern recognition, for a type of augmented reality. It actually looks like the latency might be coming from my code pulling frames at irregular intervals, instead of every frame, or every second frame etc, so i am looking into that today.
I have a couple of questions though:
How can i change the frame rate from inside c++?
In GreyscaleMode, the frame is full res, and in MJEG mode, it is quarter size, right? Can i get a half size frame? Or are those my only options?
thanks again!
-
- NaturalPoint Employee
- Posts: 720
- Joined: Mon Jan 19, 2015 11:52 am
Re: Bitmap to cv::Mat latency...
Hi antithing,
I'm glad you seem to be making some progress with this. I have answers to your other questions, below.
You can adjust the frame rate with camera->SetFrameRate(...);
You are correct that the resolution of the MJPEG mode cannot be adjusted.
Cheers,
Steven
--
Steven Andrews
OptiTrack | Customer Support Engineer
I'm glad you seem to be making some progress with this. I have answers to your other questions, below.
You can adjust the frame rate with camera->SetFrameRate(...);
You are correct that the resolution of the MJPEG mode cannot be adjusted.
Cheers,
Steven
--
Steven Andrews
OptiTrack | Customer Support Engineer