I am designing a camera app in ios. I see that Video uses the whole screen in iphone 5 but camera does not. So I wanted to know the screen width and height of the camera screen that the default camera uses to design my app.
That's because unlike the feed from the video camera, the feed from the camera has a different aspect ratio from the devices screen. To rectify this, you'll need to resize your preview layer to match the aspect ratio of the feed, or you'll need to change the video gravity property of your video preview layer.
Once of these should suffice:
[myPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
[myPreviewLayer setVideoGravity:AVLayerVideoGravityResize];
Related
I'm developing a 3d game on unity and using the 1080x1920 portrait resolution.
When I build and run the project on my phone, which has a 1080x2340 resolution in portrait, it cuts off part of the game (the sides).
red lines indicating where it cuts off
The camera doesn't follow, so the player can "go out of the screen".
How can I fix this, making sure my game looks the same on different resolutions?
(edited to correct resolution order)
Does your play area have a fixed size? If the in-game play area's aspect ratio isn't the same as the device running the game, you'll have to either cut off part of it or include blank space at the top/bottom or left/right. Unity's camera orthographic size dictates how tall the camera view is, but not how wide. The width is just screenAspectRatio * camera orthographic size.
To fix this:
float aspect = Screen.Width / Screen.Height;
myCamera.orthographicSize = Mathf.Max(playAreaHeight, playAreaWidth / aspect);
This will cause the camera's view to be either too wide or too tall rather than too small.
How can i make a sprite size appear 5cm in every screen size and in every resolution in unity 2D? I can use canvas image also depending upon your suggestions i tried everything not working..
Write a script to resize the camera so that the object with world size (Width, Height) always exactly matches the camera horizontally or vertically, and see if you can fix the sprite size,This is my own understanding, and I don't know if it works or not.
Which view mode are you using for your game? Is it landscape or Portrait?
You can use 2960 X 1440 Landscape if you are using landscape mode, and 2960 X 1440 Portrait if you are using portrait mode from the resolution aspect in game mode. These are the highest resolutions for both landscape mode and portrait mode. When you open your game on any other resolution phone the resolution of your sprite will be set accordingly. Always use the highest resolution in this regard.
Have you tried using Screen.dpi?
Screen.dpi
like mentioned in this post?
I am new to unity and I am trying to attach my camera to a fixed background. So I have a camera object, and a sprite object that is the background, but I can't make the camera to be in the exact same height and width of the sprite background.
this is screenshots of my project:
Your camera "size", is actually made up two factors.
Orthographic size.
Aspect ratio of player.
To fit the background into the camera, change player aspect ratio to be same as background image. And then play with size to let the background cover 100% of camera view size.
I hope it is clear what I am saying, if not let me know.
A video size is dimensions: 480 × 270px. Codecs: H.264, AAC
With subtitles and it fit the width but it leave black gap on iphone screen: top and bottom of screen.
Can a video be forced to fit the screen according to height dimensions.
Check out autoresizesSubviews and contentMode View properties of the enclosing control you are having this video in - play with them in the storyboard. For your case, mostly content mode = UIViewContentModeScaleToFill should work.
the aspect ratio for a in iphone 3.x/4.x series is 4:3. any video which is in 4:3 aspect ratio will be played covering fullscreen while playing. You need to be sure that your video is according to the same aspect ratio and in video, there is no black space in original video (by checking it on any desktop's player)
i've a question about UIImagePickerController class reference, in photo-camera mode.
I'm developing an OpenGl game. I should add to game photo-camera features: game should open a window (say for example 200x200 pixels, in the middle of screen), that display in real time a preview of photo-camera IN FRONT OF GL VIEWPORT. So photo-camera preview must be in a window of 200x200 in front of our Gl viewport that display game.
I've some questions:
- main problem is that i've difficult to open UIImagePickerController window in front of our Gl viewport (normally UIImagePickerController window covers all iPhone screen);
which is the better way to capture an image buffer periodically to perform some operations, like face detection (we have library to perform this on a bitmap image) ?
iPhone can reject such approach? It's possible to have this approach with camera (camera preview window that partially overlap an openGl viewport) ?
at the end, it's possible to avoid visualization of camera shutter? I'd like to initialize camera without opening sound and shutter visualization.
This is a screenshot:
http://www.powerwolf.it/temp/UIImagePickerController.jpg
If you want to do something more custom than what Apple intended for the UIImagePickerController, you'll need to use the AV Foundation framework instead. The camera input can be ported to a layer or view. Here is an example that will get you half way there (it is intended for frame capture). You could modify it for face detection by taking sample images using a timer. As long as you use these public APIs, it'll be accepted in the app store. There are a bunch of augmented reality applications that use similar techniques.
http://developer.apple.com/library/ios/#qa/qa2010/qa1702.html