When CaptureController is being push using navigation controller, camera preview is always portrait. When going to landscape it won't reflect the camera preview. But when it's just a "self.present" it's okay like the sample project. How can I manipulate when orientation is landscape and the camera preview is also landscape. Captured image have correct orientation, just the camera preview.
Lanscape but the camera preview orientaion is portait - Sample image attached:
link here
Solved! This line fix the issue:
(capture.preview.layer as! AVCaptureVideoPreviewLayer).connection.videoOrientation = videoOrientation
Just put it in the delegate function
func capture(capture: Capture, didChangeFrom previousVideoOrientation: AVCaptureVideoOrientation, to videoOrientation: AVCaptureVideoOrientation)
Related
I find that VideoCapture orientation is inconsistent with ImageCapture in the case where Preview orientation is not the same as Device orientation.
For example: if the Device has portrait orientation and the Preview has landscape orientation, VideoCapture (incorrectly) captures a portrait orientation whereas ImageCapture (correctly) captures a landscape orientation.
The same is true if the Device is landscape and the Preview portrait. The behavior is correct and identical for both ImageCapture and VideoCapture if the Device orientation is the same as the Preview orientation.
Adjusting the value of VideoCapture.setTargetRotation( +1) after bindToLifecycle(), rotates the orientation but not in a helpful way. For example with a portrait Device, and a landscape Preview: the capture (correctly) has a landscape format but the contents (incorrectly) is a crop of portrait oriented contents.
I have a custom Preview which provides a texture to implement Preview.SurfaceProvider. And uses Custom Preview viewer whose configuration depends only on Preview.getResolutionInfo().getCropRect() , Preview.getResolutionInfo().getResolution() , Preview.getResolutionInfo().getRotationDegrees(), and front or back camera.
Other than write my own VideoCapture based on the imageAnalysis use case, what can I do to get the expected behavior?
I have a portrait and portrait upside-down app. I present an imagePickerController and it allows me to take pictures which can be either landscape or portrait. after taking a picture, the imagePicker verifies if I want to use the photo that was taken. If I hold my device 'sideways' (in a landscape fashion), the image picker view will dismiss like normal and my original view controller will be displayed, except it is in landscape mode (including the keyboard). This should be impossible because my app only supports portrait orientations.
Any ideas on how to keep my app in portrait mode so that the UI doesn't get messed up?
This is my app before I open the imagePicker:
This is the imagePicker right before I dismiss it. although this screenshot is in portrait mode, please imagine that I am holding the device SIDEWAYS (landscape style):
This is the resulting bugged out screen, that I would like to prevent:
I would first check Info.plist and confirm that the orientation is correct and does not contain any landscape options for either iphone or ipad:
I have a UIImagePickerController with custom overlay. When I open the camera in landscape orientation in iPhone, the camera view is not displayed properly. I don't want the camera view in landscape mode. I want the camera view only to be opened in portrait mode.
Can someone pls help me out on this?.
Thanks in advance.
How can I record a landscape video using a device that is in portrait orientation?
This means that previewLayer width > height
AVCaptureVideoOrientation.LandscapeLeft is not right.
There is a sample project of iOS in developer.apple.com
enter link description here
You need to use AVAssetWriter AVAssetWriterInput
You need to be focus in this method in the MovieRecorder.m
- (void)addVideoTrackWithSourceFormatDescription:(CMFormatDescriptionRef)formatDescription transform:(CGAffineTransform)transform settings:(NSDictionary *)videoSettings
You need to edit the code to do that
I'm going to use UIImagePickerController with source as a camera. by default when i'm capturing the image m able to take the picture in portrait mode. here the problem is that i'm not able to display the same view in landscape mode.
Is there any other way to open the camera in Landscape mode?
Thanks in advance.
First of all there is no way to open camera in Landscape mode So we have to customize views as per our need.
You have to add rotation transformation to picture which will match to landscape view. You can hard code it as ,
Blockquote
CGAffineTransformRotate(CGAffineTransformIdentity, 117.81)"
Blockquote