OpenCV detect iphone orientation - iphone

I have a site where users can upload video. When testing some video uploads that are processed with OpenCV and Python, if the video was recorded on an iPhone it always assumes the video was taken in landscape mode by rotating the phone 90 degrees to the left, such that videos in portrait mode are sideways and videos taken in the other landscape direction (90 degrees to the right) are upside down.
I know I can use OpenCV to rotate videos, but is there a way to detect:
a) if the video is even taken with an iPhone or not
b) if so, what the orientation should be, how much to rotate the video by

OpenCV is an computer vision library, for your problem you can't use OpenCV (AFAIK). What you need is to get the metadata of the video. Metadata contains the all the information you need about that video. Here you can see what does metadata contains. You should search how to extract metadata from a video. Take a look at this.
Good luck!

Related

Correcting Video Orientation in iOS

I am developing a video app in which user can merge different videos present in Asset Library. I am able to join the videos but I am facing the orientation issues.
For example, if a video is landscape right and other is landscape left, the second video will be joined upside down. Moreover, I have tried different codes available at stackExchange, however if i apply those codes to portrait videos, they can be transformed to landscape right but leaving black margins on the sides.
Is there any way that when I select a video to be inserted in my project, first its orientation should be checked, if it is other then landscape right, it should be rotated accordingly and in the end if the original video was portrait, the video should be resized as the native player do when we play a video in full screen mode.
Thanks in advance.

How to know the orientation of video in Objective-C?

I am developing an app in which I am taking a video from photo-library.
the video may be taken in portrait or in landscape mode.
I want to know the orientation of video so that based on that i can rotate stand play it in MPMoviePlayerController.
I did try it with AVAssetImageGenerator but its taking time and sometimes not generating image as required.

AVCapture not working well with retina screen

I am trying to use AVCapture in my app to capture the image and post it to a server, but I have a problem with this framework:
With a normal iPhone screen, this framework work very well, but with a retina screen, the AVCamera doesn't work well: The iPhone's video is zooming in to the target higher than the camera, so my camera is too close to the object I want to shoot.
I researched this and saw that the retina device's default camera has this problem too. The image camera and the video camera have different scale zooming, and the AVCamera probably uses the video camera so the target is higher than the image camera. But I want to take the picture with the image camera with AVCapture, how can i do it?

Applying Effect to iPhone Camera Preview "Video" Using OpenGL

My goal is to write a custom camera view controller that:
Can take photos in all four interface orientations with both the back and, when available, front camera.
Properly rotates and scales the preview "video" as well as the full resolution photo.
Allows a (simple) effect to be applied to BOTH the preview "video" and full resolution photo.
My previous effort is documented in this question. My latest attempt was to modify Apple's sample GLVideoFrame (from WWDC 2010). However, I have not been able to get the iPhone 4 to display the preview "video" properly when the session preset is AVCaptureSessionPresetPhoto.
Has anyone tried this or know why the example doesn't work with this preset?
Apple's example uses a preset with 640x480 video dimensions and a default texture size of 1280x720. The iPhone 4 back camera delivers only 852x640 when the preset is AVCaptureSessionPresetPhoto.
iOS device camera video/photo dimensions when preset is AVCaptureSessionPresetPhoto:
iPhone 4 back: video is 852x640 & photos are 2592x1936
iPhone 4 front: video & photos are 640x480
iPod Touch 4G back: video & photos are 960x720
iPod Touch 4G front: video & photos are 640x480
iPhone 3GS: video is 512x384 & photos are 2048x1536
Update
I got the same garbled video result when switching Brad Larson's ColorTracking example (blog post) to use the AVCaptureSessionPresetPhoto.
The issue is that AVCaptureSessionPresetPhoto is now context-aware and runs in different resolutions based on whether you are displaying video or still image captures.
The live preview is different for this mode because it pads the rows with extra bytes. I'm guessing this is some sort of hardware optimization.
In any case, you can see how I solved the problem here:
iOS CVImageBuffer distorted from AVCaptureSessionDataOutput with AVCaptureSessionPresetPhoto
The AVCaptureSessionPresetPhoto is for taking pictures, not capturing live feed. You can read about it here: http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/03_MediaCapture.html
(My belief is that this is actually two different cams or sensors, as they behave very differently, and there's a couple of seconds delay just for switching between the Photo and, say, 640x480).
You can't even use both presets at the same time, and switching between them is a headache as well - How to get both the video output and full photo resolution image in AVFoundation Framework
HTH, although not what you wanted to hear...
Oded.

iPhone Camera pictures from UIImagePickerController are sideways

My application supports taking pictures from iPhone in portrait mode and upload to the server.
However, the pictures taken are appearing in sideways once uploaded to the server.
Please help!
-KC
Keep in mind that the image has an associated imageOrientation property that will determine the correct orientation to display the image.
Images captured used AV Foundation (at least using AVCapture, which I'm using) are taken in landscape mode, so you have to rotate them clockwise before sending to the server.