CameraX VideoCapture orientation is inconsistent with ImageCapture orientation - orientation

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?

Related

Is it possible to autorotate AVPlayer even if the device turned on "Lock Portrait Orientation"?

I want to play a video with AVPlayerViewController() from Apple's AVKit framework. well, the video plays nicely, auto rotate works well and rotate smoothly. But, is it possible to autorotate that (so it could rotate to landscape or rotate to portrait, not just one of it) even if the device turned on "Lock Portrait Orientation" ?
What i mean for "Lock Portrait Orientation" is the one from device's Control Center like this : Lock Portrait Orientation

Check the app orientation in iOS (not the device orientation)

Until now, I used to use this code to check if my device is in a portrait or landscape mode:
if (UIDeviceOrientationIsPortrait(UIDevice.current.orientation)){
//portrait
}else {
//landscape
}
But I discovered that this variable check the real position of the device in the 3D space. So if my iPad or iPhone is in a portrait mode and I put it on a table, parallel to the ground, the orientation will not be considered as portrait.
Is there a variable or something similar that can I check to know the orientation of the app and not the physical orientation?
Use UIApplication.shared.statusBarOrientation: The current orientation of the app's status bar.

Capture API from CosmicMind-Material: Camera preview not correct

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)

Manage orientation landscape and portrait both in a app iPhone

According to my client's requirement I want to set Splash Screen orientation in landscape(right) then the orientation will come in portrait.. any idea how can I implement it?
Just rotate your splash image in an external editor so that is gets displayed in a landscape mode.
Just because you perceive it as landscape doesn't mean it's actually not "rotated portrait".
See your Splash Image will look like this:
Just rotate your image the way you want it to look like...
The iPhone only has a single splash screen, no matter which orientation it launches in. The iPad on the other hand will display a different splash screen image in portrait and in landscape mode.
If your iPhone interface supports both portrait and landscape then you must decide which way round you'd like to display that splash screen image. As Kanan says, design your landscape image (say in Photoshop), then rotate the canvas so that the image is portrait (but the content is still landscape).

Do you need a landscape iPad launch image for app thats just portrait

I have made me app so that device orientation is portrait only, however there it still has a place to put landscape launch image. Will I have to have one? If so can I just have a rotated version of the portrait one (i.e. this will be sideways if the device is held in a landscape manner)?
You don't need to have a landscape default image even if you do support landscape.
If you are only in portrait, then a single image will do.

Resources