Ask Your Question

iPad Camera input is rotated 180 degrees.

asked 2013-03-09 00:26:35 -0600

kaipyroami gravatar image

I am having trouble with the input from my camera being rotated 180 degrees. In other words, the image is upside down when my cvPoints and text are correct. But when the image is right side up the X and Y locations are referenced off of the bottom right corner instead of the top left. And text is upside down.

Aside from "AVCaptureVideoOrientation" which rotates everything together is there any way to rotate the camera input relative to OpenCV?

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted

answered 2013-04-16 08:03:32 -0600

AlexanderShishkov gravatar image

Maybe you should set correct default rotation:

self.photoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationLandscapeRight;
edit flag offensive delete link more

answered 2013-03-12 05:31:56 -0600

updated 2013-03-27 13:40:58 -0600

Is it possible that you are mixing up coördinate systems and in that case messing up the way you are visualizing the input?

OpenCV coordinate system

Example of OpenCV coördinate system

General coordinate system

image description

Also a common made mistake is switching the cols and row parameter when defining width and height of an image. It is confusing I know. Maybe worth investigating this?

On the other hand, the suggestion of flipping will work, but is just going around the actual problem.

EDIT : looking through the internet, I have found the following image, which suggests the IPAD coordinate system:

IPAD Coordinate System

If considering this coordinate system, considered to the actual OpenCV coordinate system, I guess it is normal that you have a 180 degree shift, since the y - axis is inverted. So take this into consideration and flip your image pixels along the horizontal axis to get good references.

edit flag offensive delete link more


If you take the first image you posted and rotate it 180 degrees that is what I am getting. 0,0 should be in the top left but is in fact in the bottom right.

kaipyroami gravatar imagekaipyroami ( 2013-03-27 13:30:47 -0600 )edit

Check if your webcam drivers have updates?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-03-27 13:32:15 -0600 )edit

I am using iOS (iPad) I am at the current version.

kaipyroami gravatar imagekaipyroami ( 2013-03-27 13:33:40 -0600 )edit

Look at my edit. Have found an example of a project where they used transformations to go to the correct coordinate system for the world. So apply a transformation in order to get correct results :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-03-27 13:42:19 -0600 )edit

answered 2013-03-12 03:54:24 -0600

flip image function can be a quick trick in your case, but maybe you should investigate more to find a more perennial solution...

edit flag offensive delete link more


That is a good idea, I am just trying to limit adding any more extra processing if I can help it. I was thinking that the camera input might be easier to correct than flipping the mat.

kaipyroami gravatar imagekaipyroami ( 2013-03-27 13:32:34 -0600 )edit

Question Tools


Asked: 2013-03-09 00:26:35 -0600

Seen: 5,196 times

Last updated: Apr 16 '13