Slow Framerate warpIntoMe()

Hey all,
Working with warpintoMe method in the opencv addon. There is a massive fps drop when i use warpintome();.

	if(vidGrabber.isFrameNew()) {  
		colorImg.setFromPixels(vidGrabber.getPixels(), CVW, CVH);  
		warped.warpIntoMe(grayImage, camHands.fHandles, camPts);  
		if(bLearnBakground == true) {  
			grayBg = grayImage;  
			bLearnBakground = false;  
		grayDiff.absDiff(grayBg, grayImage);  
		contourFinder.findContours(grayDiff, 60, (340*240)/3, 10, false);  

is there a better wy to do this. Im trying to do a setup for camera to projection calab.

how slow? what kind of size image?

I haven’t experienced it too slow before – I’m on a pc. doesn’t seem to have an impact.

I could be wrong, but I think theo has had some experience with this being slow on a mac… I’ll ping him…

take care!!

yeah - this is one of the functions that is quite a bit slower on a mac.

The reason for this is the openCV library included with the addon is optimized for size not speed.

The easiest thing for you to do is use the openCV Library that I compiled for Laser Tag 2.0 (this will be included by default in the next release).

I think using the optimized lib gave us framerate improvements from 28fps to 50fps and this is mainly due to the warpIntoMe

If you link against the openCV 1.1 Framework you get get an extra 5fps on top of that - but it is a little more hacky to do.

The framework is here though if you want it:…-rk-1.1.dmg



I was getting about 14fps with 640x480 video w/ wrapintome() w/o i was getting about 60 ++ frames. Thanks a bunch I’m going to try this optimized version, I let you know.


ahh - 640 480 warp is always going to be quite slow - its a super expensive operation - but see how the optimized openCV does.

another technique is do do masking instead and then warp your coordinates based on the quad.

we have this as an option for laser tag as it is very fast and it is just as good except for very small (pixel sized) points.

worked way faster install the optimized version hitting 35fps with 640x480 video and 1200 particles all talking to each other.



There is also a cvRemap function on OpenCV which allows you to use precalculated pixel offsets.
This only makes sense if the warp does not change much but I believe it should be faster otherwise.

Have not tested this for your case but I got quite some extras speed for doing undistortions + rigid body transformations.

oh nice - I’ll have to play with that - cvWarp is a killer :slight_smile:

remap could also be useful for simple lens undistortion.
I completely forgot that opencv had this functionality. interesting…

nice particles vanderlin - saw them on your blog !!!


Can you get it to do 320 240 though?
Specs say 720 480 at 30fps.

hey todd,

what capture card are using with your mac?
looks like an aver from the photo but I didn’t think they did OS X.

always curious about apple capture hardware.


Thanks worked with some of you ‘algo’ examples from processing.

Im using
just did a test t 320 x 240 im getting about 60++ fps at 720x480 about 30++ fps. The optimized version of opencv works wonders better. would love to try cvRemap idea. Need to look into it. Let me know if you find anything.

Thanks again guys for all the help.