PDA

View Full Version : Seed up the application



Daniel983
November 26, 2007, 12:54:21
Hi!

I'm making an appllication for image processing. Exactly I've to track the position of a moving object into a static background, as fast as possible: in particular I would like working at 30fps and process every frame.
I've follwed the callback example and I'm able to call frameready() method for each frame. I convert every frame in Ipl image to use OpenCV library. If I do simple background-foreground subtraction for detect the object, the application appears to work fine, but if I looking for the position of the object
(using connected component) the time processing grow up.

My question are not about opencv but I want know:

1. To process every frame is faster and more indicate using a listener or a frame filter?

2. My images are 1024x768, you suggest to reduce the size of the image to process using a ROI filter? If yes how I can do this?

3. For create the Sink I use the follow

smart_ptr<FrameHandlerSink> pSink = FrameHandlerSink::create( acceptedTypes , 1);

but I've not clear the function of the number of buffer (I set it to 1), it influences the speed of the application?


___________
Thanks,
Daniel

Stefan Geissler
November 26, 2007, 13:45:55
Hi Daniel


1. To process every frame is faster and more indicate using a listener or a frame filter?

In your case, the listener is more suitable.



2. My images are 1024x768, you suggest to reduce the size of the image to process using a ROI filter? If yes how I can do this?

As shown in the documentation:
smart_com <iframefilter> pFilter = FilterLoader::createFilter( "ROI", // Filter name.
"" ); // Module file.
At
http://www.imagingcontrol.com/support/documentation/class/stdfilterROI.htm

Using an ROI reduces the amount of data. May be the ROI is not really what you need. If you have only know portions of the image, in that the objects are moving, then you may create small images (array of bytes) of these portions and process them.
For example if you have a cross (e.g. a street crossing), then you may have three images of the streets to be extracted from the main image. Then you may reduce the amount of pixels to be processind by 30 to 50 %. This depends on your scene.



3. For create the Sink I use the follow

smart_ptr<FrameHandlerSink> pSink = FrameHandlerSink::create( acceptedTypes , 1);

Please use at mininum 2 image buffers. If you only use one, then you will receive no second buffer, while your application processes the image. This slows down your application by 50%.

Additionally you should avoid copying the frames too often. This is too time expensive. You should also use the smalled possible image format, e.g Y800 if you only need gray scale images and your image processing libraries allow these formats.

Daniel983
November 26, 2007, 15:38:16
As every time thank you very much for yours suggest Stefan!

Only another question: to convert frame into Ipl image I use memorycopy command as follow

memcpy(pOpenCVImage->imageData, pBuffer->getPtr(), iImageSize );

you think it is too expansive do it for every frame and it is better for me do not use opencv, or I can continue to use it?

Thanks

Daniele

Stefan Geissler
November 26, 2007, 16:45:50
Hi Daniel,

This is a very good question and unfortunatelly I am not able to answer it. But i suspect, there is no other solution.