Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8990031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:24:27+00:00 2026-06-15T22:24:27+00:00

I am building a prototype app on iOS, and I’m cannibalizing some Apple sample

  • 0

I am building a prototype app on iOS, and I’m cannibalizing some Apple sample code to do it (thin ice, I know—this code uses goto statements :\ ). I am using the AVCam project from Session 520 – What’s New in Camera Capture. I don’t need video capture capability, just still photos.

The device inputs and outputs are set up thusly:

    // Init the device inputs
    AVCaptureDeviceInput *newVideoInput = [[AVCaptureDeviceInput alloc] initWithDevice:[self backFacingCamera] error:nil];
    AVCaptureDeviceInput *newAudioInput = [[AVCaptureDeviceInput alloc] initWithDevice:[self audioDevice] error:nil];


    // Setup the still image file output
    AVCaptureStillImageOutput *newStillImageOutput = [[AVCaptureStillImageOutput alloc] init];
    NSDictionary *outputSettings = @{AVVideoCodecKey: AVVideoCodecJPEG};
    [newStillImageOutput setOutputSettings:outputSettings];


    // Create session (use default AVCaptureSessionPresetHigh)
    AVCaptureSession *newCaptureSession = [[AVCaptureSession alloc] init];


    // Add inputs and output to the capture session
    if ([newCaptureSession canAddInput:newVideoInput]) {
        [newCaptureSession addInput:newVideoInput];
    }
    if ([newCaptureSession canAddInput:newAudioInput]) {
        [newCaptureSession addInput:newAudioInput];
    }
    if ([newCaptureSession canAddOutput:newStillImageOutput]) {
        [newCaptureSession addOutput:newStillImageOutput];
    }

    [self setStillImageOutput:newStillImageOutput];
    [self setVideoInput:newVideoInput];
    [self setAudioInput:newAudioInput];
    [self setSession:newCaptureSession];

And here is the method that’s called when I tap the shutter button:

- (void) captureStillImage
{
    AVCaptureConnection *stillImageConnection = [[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo];
    if ([stillImageConnection isVideoOrientationSupported])
        [stillImageConnection setVideoOrientation:orientation];

    [[self stillImageOutput]
        captureStillImageAsynchronouslyFromConnection:stillImageConnection
             completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {

                 ALAssetsLibraryWriteImageCompletionBlock completionBlock = ^(NSURL *assetURL, NSError *error) {
                     if (error)
                     {
                         if ([[self delegate] respondsToSelector:@selector(captureManager:didFailWithError:)])
                         {
                             [[self delegate] captureManager:self didFailWithError:error];
                         }
                     }
                 };

                 if (imageDataSampleBuffer != NULL)
                 {
                     NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
                     ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

                     UIImage *image = [[UIImage alloc] initWithData:imageData];

                     if ([self.delegate respondsToSelector:@selector(captureManagerCapturedImage:)])
                     {
                         dispatch_async(dispatch_get_main_queue(), ^{
                             [self.delegate captureManagerCapturedImage:image];
                         });
                     }

                     [library writeImageToSavedPhotosAlbum:[image CGImage]
                                               orientation:(ALAssetOrientation)[image imageOrientation]
                                           completionBlock:completionBlock];

                 }
                 else
                 {
                     completionBlock(nil, error);
                 }

                 if ([[self delegate] respondsToSelector:@selector(captureManagerStillImageCaptured:)])
                 {
                     [[self delegate] captureManagerStillImageCaptured:self];
                 }
             }];
}

This code successfully captures an image and saves it to the library. However, at some point while I was working on it, it changed from capturing 5-megapixel 4:3 images to capturing 1920×1080 16:9 images. I can’t find anywhere that the aspect ratio is specified, and I didn’t change any of the code relating to the configuration of the camera, capture sessions, or capture connection. Why did my camera start taking 16:9 photos?

Update: I just re-ran Apple’s original sample code, and it appears that it is also saving 16:9 images captured directly from the video. It is quite possible that I was insane before, or I took a test shot with Camera.app and was looking at that. So my real question is, how do I show a live feed from the camera on the screen while I’m shooting, and take a full-resolution photo. I can’t use UIImagePickerController, because I need to be able to overlay things on top of the live camera feed.

Update 2: I was able to solve this by throwing out the AVCapture code I was using. It turns out that UIImagePickerController does what I needed. I didn’t realize you could overlay custom controls – I thought it took over the whole screen until you were done taking a picture.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:24:29+00:00Added an answer on June 15, 2026 at 10:24 pm

    If you’re capturing frames from a video source, you’ll end up with a resolution of 16:9. Capturing frames from a video source and taking photos are different things.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a little prototype app to test Location Services. My app uses both
I have an app prototype that was working on Iphone4 + iOS 4.3, build
I am building the prototype for an Android app that should result in a
I am building a small app which captures mouse clicks. I wrote the prototype
I am building a prototype hybrid app with a Flex3 RIA client and backend
i'm building a RoR app for facebook using FBML and the Prototype JavaScript library.
I am building an iPhone audio app using Audio Sessions. Prototype was functioning till
I am building a prototype of a windows phone 7 app using d:DesignData in
Im building this Digital Signage prototype for a master thesis. Im using WPF and
I am building a prototype app with OpenCV. The app currently does not do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.