Pushing MJPEG frame to AVI file without decompression

Post Reply
Gaspard
Posts: 3
Joined: Tue May 03, 2011 1:37 pm

Pushing MJPEG frame to AVI file without decompression

Post by Gaspard »

Hi all,

I am using a V120:SLIM camera in image mode, not IR.
I am in fact interested in capturing grey images at a high FPS.

In the main loop, I call "rasterize" in order to get the decompressed image and push it in an AVI file with MJPEG compression right away (which is a loss of time). I was wondering if there was a way not to perform the rasterize operation and to store the frame as is in a video file in order to speed up the process ?

Thanks !
Gaspard.
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Pushing MJPEG frame to AVI file without decompression

Post by beckdo »

Hi Gaspard,

The Camera SDK, does what we call 'late MJPEG decoding'. Which means the SDK won't decompress the frame's JPEG image unless you actually try to get the data. By calling Rasterize(), you're basically saying, 'ok I want the image data for this frame'. At which point the Camera SDK will decompress the JPEG and give you the image data. So the decompression is the majority of the delay (~5ms) when you call Rasterize.

You should be able to keep up with the 100 FPS and ideally pass off to the encoding in another thread or threads to keep up.

What frame rate are you able to achieve?

D
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Pushing MJPEG frame to AVI file without decompression

Post by beckdo »

Hey Gaspard,

I had another thought. If do a:

camera->SetLateMJPEGDecompression(false);

It will force the Camera SDK to decode all MJPEG frames. This can be bad, but in your case you want every frame. The up-side is that the decompression will occur on another thread easing the load on your main thread.

Then when you call rasterize it will be _much_ faster.
Gaspard
Posts: 3
Joined: Tue May 03, 2011 1:37 pm

Re: Pushing MJPEG frame to AVI file without decompression

Post by Gaspard »

Hi Doug,

Thanks for your answer !

What I am looking for is to avoid the overhead needed while recompressing the frame when writing in the video file. As the frame is already compressed by the camera, I would like to push it as is in a file without making any decompression. It could be a raw binary file for instance that I can later reopen, decompress and write in an avi file. The point is, I don't see any pointer to data in the "frame" object... Is it possible to have access to the compressed raw data ? A pointer with a size indication would be great !

Gaspard.
LinusA
Posts: 37
Joined: Mon Nov 08, 2010 8:43 am
Location: Aachen, Germany
Contact:

Re: Pushing MJPEG frame to AVI file without decompression

Post by LinusA »

Hey Gaspard,

a search for "compress" in the Camera SDK header files reveals this:

Code: Select all

 Frame* IncomingCompressedFrame(CompressedFrame *frame, bool DataPath=true);
in file camerarev11.h. Although this line (same file)

Code: Select all

int    HardwareFrameRate() { return 250; }
suggests it's not a V120:SLIM camera.

Anyway, just wanted to let you know. I do understand what you'd like to do, but I've got no idea and no business with this :-)
Gaspard
Posts: 3
Joined: Tue May 03, 2011 1:37 pm

Re: Pushing MJPEG frame to AVI file without decompression

Post by Gaspard »

Hi all,

Many thanks for your help LinusA, but it is not working for me...
Doug, I tried your solution, using the :

camera->SetLateMJPEGDecompression(false);

and you are right, the speed up in the rasterize operation is really significant, allowing me to finally recompress straight away without loosing any frame !

Thanks all,
Gaspard.
Post Reply