Search code examples
iphonexcodeopencviplimagecoordinate-transformation

iPhone Programming converting IplImage coordinates to UIImage coordinates


I am making an application that shows the video feed in real time and I am processing the frames using OpenCV to detect faces present in them. To do this, I need to convert the frames into UIImage and then IplImage. Then I run the face detection and everything so far works great except that the coordinates captured when a face is detected are those for an IplImage and the origin starts at the bottom right corner... and I need coordinates with a top left origin.

In other words, I need to convert the coordinate points I have with a bottom right origin to coordinates with a top left origin. Does anyone know if there is a function to do this in Xcode? or where I can start to look to create one?

I need the coordinate points and cannot draw directly over the IplImage and convert back to UIImage to display because I am using the coordinate points I get from the face detection to do further processing.

Any help will be greatly appreciated :) Thanks!


Solution

  • If the UIImage and IPLImage are the same height can't you just subtract the y coordinate from the image's height?