Ask Your Question

Jim's profile - activity

2017-12-11 19:52:34 -0600 received badge  Popular Question (source)
2014-01-28 06:04:11 -0600 received badge  Student (source)
2014-01-21 22:13:54 -0600 asked a question UIImage to cv::Mat and back to UIImage rotating 90 degrees

I have the following code running in iOS:

UIImage *image = ((ImageViewController *)[self.childViewControllers lastObject]).image;

cv::Mat mat;

UIImageToMat(image, mat);
if (mat.elemSize() > 1)
    cvtColor(mat, mat, CV_BGR2GRAY);

self.image = MatToUIImage(mat);

((ImageViewController *)[self.childViewControllers lastObject]).image = self.image;

My problem is that after running this code, my image is rotated 90 degrees. But only SOME images. (well, only 1 image that I have found so far). MOST images display as expected. I can't figure out why this image is rotating, and it is driving me crazy. I can't risk other images doing this unexpectedly, so I need to figure out what is going on...