Issue with Capturing photo using AVFoundation without flash and with Flash - ios

I'm trying to capture image using avfoundation framework without Flash and with Flash but i could not capture original image instead gives me black colour image while capturing it without Flash.
With the same code i can capture an image with lighting mode with Auto Flash, In that case i can able to see only part of image which has full light but not actual image.
I've set flashmode to AVCaptureFlashModeAuto.
Even with AVCaptureFlashModeOn captured image shows darker as compared to the original preview.
Help me to get it solved as i'm not able to find any solution.
Thanks.

Related

AVFoundation format for different aspect ratio

I am using AVFoundation for my camera app. I am using live video frames to grab picture using AVCaptureVideoDataOutput.
Right now i do filter all supported formats for device and then pick highest supported resolution for format.
So for example i do get 4032*3024 resolution supported format on iPhone 8/7 which i am using as active format. i do filter from videoSupportedFramRateRanges.
I would like to know how i can render video with 4:3 resolution so i can see black bars on side of camera.
I did play with AVCaptureVideoPreviewlayer properties and found that if i use resizeAspectFill it shows camera full screen but if i just dont assign then it adds black bars on side. (I assume .resize is default property) but i am not sure whether this is right approach to show/hide black bars.
In my opinion this is working because currently i am picking highest supported resolution format which in this case is 4032*3024 due to which its working since its 4:3 aspect ratio.
Basically i want make sure i show video in 4:3 format size view in some scenario with black bars and in some scenario full screen which i am already doing.
Open questions
Is there any way i can make sure i can show always 4:3 aspect ratio video feed.
How i can show black bars with 4:3
also after showing black bar how I can get camera area without black bars?
Thanks!

AVMutableVideoComposition image overlay low quality

I am creating a feature where a user can record a video of themselves, and superimposed on this video is a view that displays an image and some text. When they are done recording, I am using AVFoundation's composition classes to composite the video and the view (as an image) into one video file, and output this in the next scene in a custom video player. The problem is that while the view's resolution is crystal clear in the record scene, after the composition (and after the AVExportSession completes) the resulting video's overlayed view quality is not clsoe to the actual view quality. I am converting the view to an image, and then setting the contents of an overlay layer as this image's CGImage, which, as I have checked, still has the same quality as the original view. The problem occurs when I apply the composition, and the image becomes blurry. Does anyone have any idea why this might be happening?
If you need to see the code, please feel free to ask! I can also provide screenshots.
Thank you!
It could happen when initiating your UIImage, iOS automatically pick #2x or #3x image source for you corresponding to your device.
Let say you get image size using size property like image.size, it gives you #1x size, and you might reduce your image size from #2x or #3x to #1x, you get a bad quality image output, because JPEG or PNG resize algorithms.

How to set zoom level of camera using AVFoundation framework in IOS?

I am developing a custom camera in which the camera is set to the Image Capture mode. I need to increase the zoom level of camera preview according to the app requirements. The preview currently being displayed is perfect I just need to increase the zoom-out in current preview. I searched over internet but didn't find any solution. Please tell me how can I do this. I am attaching the example image for better understanding. first image is of my camera app and second image is of Scanner Pro app which shows view with more covered area while I focus both the apps for the same object on the same distance. My camera don't have any space but the Scanner camera has spacing all over the image. Both the camera are on the same distance from the paper.
i don't know whether you still need this answer. Probably not, but still for you and everyone else looking out:
When you set the Session Preset, try using SessionPresetPhotofor the device object. This should resolve the weird zoom issue.
Your preview view is probably spilling over the edge of the screen. Make sure it is a 4:3 aspect ratio and that it doesn’t overflow your screen edges. With that you should see more of your image.

How to crop a video in iOS

I was having a look at the RosyWriter Sample Code provided by Apple as a starting point and I'd like to find a way how to crop a video.
So i have the full resolution video from the iPhones Camera, but I just want to use a cropped part of it (and also rotate this subpart).
I figured that in captureOutput:didOutputSampleBuffer: fromConnection: i can modify each frame by modifying the CMSampleBufferRef that i get passed in.
So my questions now are:
Is this the right place to crop my video?
Where do I specify that the final video (that get's saved to disc) has a smaller resolution than the full video captured by AVCaptureSession? Setting the AVVideoWidthKey and AVVideoHeightKey has no effect.
How can I crop the video and still have good performance?
Any help is appreciated!
Thanks a lot!
EDIT:
Maybe I just need to know how I can make a video that was shot in portrait a landscape one by turning the images of the video by 90 degrees and then zoom in to fit the width again...?!?
In AVVideoSetttings.h there is the AVVideoScalingModeKey. This key combined with the defined values control how the video is scaled/cropped when encoding the images to the video container. For example if you specified a value of AVVideoScalingModeFit then cropping is used. Check out the header for how other values effect the video images.

Captureing Image And Printing dat in desired Size

I want to capture a image from a web cam and i want to print dat captured image in desired size.
consider taking a screenshot programatically and cropping it. if this is not possible, you should talk to the hardware directly by using the driver.
also please provide more info on os, webcam make and programming platform,

Resources