ofxCvImage remap for image warping

Hello everyone,

I am quite new in programming, openframeworks and computer vision altogether, so I hope someone could provide some help.

I am trying to do some image morphing in order to create a sequence of transition-frames between two images. For reasons of simplicity I decided to work with optical flow calculation in order to calculate some way to find how the two images have to be warped and after that interpolate the colors of their pixels to get the intermediate frame (or use alpha blending or whatever…).

So now the question is… Does ofxCVImage remap() could help somehow? Does it actually warp an image, and if yes how exactly does it do so? What are the arguments that I have to pass in order to make it work properly?

I hope the question does make sense and I am not really out of time and space with all this stuff. Anyway, I hope to hear from someone.

All the best,

Achilles.

Hi Achilles!

Welcome to OpenFrameworks! If you are new to programming and computer vision then you are about to discover a world of amazing possibilities :grin:

To start with OpenCV, there are three possibilities: ofxOpenCv, ofxCv, OpenCV. ofxCv is an addon for OF, a bunch of code that you can use in addition to OF to build your apps. I recommend you to use it, as it is newer.

What this really does is to wrap around OpenCV to it is easier to use from OF. Someone took their time to make your life more comfortable!

OF -> OpenCV // complex
OF -> ofxCv(OpenCV) // simpler and easier to use

What you really have to have in mind is that all of the calls to ofxCv are really calls to OpenCV, so you can check out their reference to see what the methods are doing. In your case remap() will call cv::remap().

Bear in mind that you can’t use optical flow with remap directly, you have to create a map

Good luck with your project!

Hey Hennio,

Thanks for the reply and thanks for the warm welcome :slight_smile:. I do have in mind that ofxCv actually wraps OpenCV and I am using it at the moment (I am already grateful to the people that have made my life more comfortable :slight_smile:) to calculate the optical flow.

I am not sure how I can make a map but I will look further into it (haven’t even checked the link you attached yet). So, if I understand correctly the variables I have to pass to the remap() function is the mapping in the X and Y directions that will have to use to wrap the image, right?

Anyway, thanks again for the welcoming and the reply.

All the best,

Achilles.

So, if I understand correctly the variables I have to pass to the remap() function is the mapping in the X and Y directions that will have to use to wrap the image, right?

Yep! Check the link, its a stackoverflow answer to your question. I hope it guides you to the solution :slight_smile:

Cheers!

Absolutely…!!! I just checked the link and it actually does exactly what I had in mind (although I had misunderstood some minor details, so I would had ended in the same place where the guy that asked the question was… :yum:). I was thinking too that the optical flow was the correct mapping but now I understand better what I had wrong in my mind. Seems quite easy and straight forward to implement, so I will give it a try and see what happens (fingers crossed :grin:)

Thanks again for all the help,

Achilles.