ofxCv undistort AR Drone camera not working

I’ve been working on a project using the ofxFaceTracker addon and an AR Drone 2.0.

As the AR Drone sends its video stream using its own video encapsulation (PaVE) I’ve managed to adapt a c++ file found online to a buggy addon for openframeworks that displays the video stream fine.

As the AR Drone uses a wide angle lens, it really needs to be undistorted to be used for facetracker. And that is my problem.

The addon decodes the frames using PIX_FMT_BGR24:

// convert context
convertContext_RGB = sws_getContext(codecContext->width, codecContext->height,
                                    codecContext->pix_fmt, codecContext->width, codecContext->height,
                                    PIX_FMT_BGR24, SWS_SPLINE, 0, 0, 0);

The resulting frame is then set into a cv::Mat * using:

frame->create(codecContext->height,        //height of frame
              codecContext->width,         //width of frame
                     CV_8UC3);             //CV type
        frame->data = pictureRGB->data[0]; //fill with data

The resulting Mat frame is then called from within my app, and displays fine using drawMat(*video.frame, 0, 0);
Video is the ARDrone video addon, and frame the Mat.

However, if I try to perform undistortion using calibration.undistort(*video.frame); the frame is not undistorted.
I have also tried to create a temp Mat, and copy the frame to that, and use that, not working. Copying it to an ofImage and then using calibration.undistort(toCv(tempImg)) and calling tempImg.update() afterwards is also changes nothing to the image.

The image just keeps looking the same, whatever I do. I am positive that it is not the calibration file, as if I use a ofVideoGrabber testcam and pass that to calibration, it does the undistortion (obviously leading to a very distorted image using the webcam of my Mac.
calibration.undistort(toCv(testcam),toCv(tempImg)); tempImg.update();

Does anyone have any idea what is going wrong here? As my experience is very limited, is must be a stupid setting or wrong image type somewhere, but I’ve been stuck on this for two days now, and need some sleep :slight_smile: Thanks in advance!

I’m running osx 10.9.2, using xcode 5 and OF release 0.8.1.