Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>An overlay is just for presentation in the camera picker.</p> <p>You also need to combine these images in your final UIImage (JPEG or TIFF or whatever) you save to disk.</p> <p><a href="https://stackoverflow.com/questions/11262495/issue-on-merging-the-overlay-image-with-capture-image-ios">Other people have had (and have solved) this same problem as you</a>.</p> <p>EDIT, here is some code that <em>may</em> help you out:</p> <pre><code>- (void)captureStillImageWithOverlay:(NSArray *) arrayOfImageFiles { AVCaptureConnection *videoConnection = nil; for (AVCaptureConnection *connection in [[self stillImageOutput] connections]) { for (AVCaptureInputPort *port in [connection inputPorts]) { if ([[port mediaType] isEqual:AVMediaTypeVideo]) { videoConnection = connection; break; } } if (videoConnection) { break; } } NSLog(@"about to request a capture from: %@", [self stillImageOutput]); [[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) { CFDictionaryRef exifAttachments = CMGetAttachment(imageSampleBuffer, kCGImagePropertyExifDictionary, NULL); if (exifAttachments) { NSLog(@"attachements: %@", exifAttachments); } else { NSLog(@"no attachments"); } NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer]; UIImage *image = [[UIImage alloc] initWithData:imageData]; CGSize imageSize = [image size]; UIGraphicsBeginImageContext(imageSize); [image drawInRect:CGRectMake(0, 0, imageSize.width, imageSize.height)]; CGFloat xScaleFactor = imageSize.width / 320; CGFloat yScaleFactor = imageSize.height / 480; for(NSString * imageFileName in arrayOfImageFiles) { // images named @"img1" or @"img1.png" should work UIImage * overlay = [UIImage imageNamed: imageFileName]; if(overlay) { CGSize overlaySize = [overlay size]; [overlay drawInRect:CGRectMake(30 * xScaleFactor, 100 * yScaleFactor, overlaySize.width * xScaleFactor, overlaySize.height * yScaleFactor)]; // rect used in AROverlayViewController was (30,100,260,200) } else { NSLog( @"could not find an image named %@", imageFileName); } } UIImage *combinedImage = UIGraphicsGetImageFromCurrentImageContext(); [self setStillImage:combinedImage]; UIGraphicsEndImageContext(); [image release]; [[NSNotificationCenter defaultCenter] postNotificationName:kImageCapturedSuccessfully object:nil]; }]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload