【发布时间】:2016-05-06 03:05:39
【问题描述】:
我正在使用 Apple 制造的 AVCam 用于我的自定义相机视图。老实说,如果您第一次看到 AVCamViewController 课堂上发生的事情,这并不容易理解。
现在我对他们如何设置捕获图像的框架感兴趣。我试图找到一些成名者或类似的东西,但我没有找到。
我在谷歌搜索并在这里找到答案AVCam not in fullscreen
但是当我实现该解决方案时,我才意识到它只是制作了与我的视图大小相同的实时相机预览层,但是当应用程序以方法- (IBAction)snapStillImage:(id)sender 保存图像时,图库中的图像仍然是从左侧开始的 2 个条纹和正确的。
我的问题是如何删除这些条纹或苹果在源代码的哪一行设置了这些东西?
还有一个额外的子问题,我如何设置类型只创建照片,因为应用程序要求我“麦克风设置”,我不需要它,只需要制作照片就可以了。
来自苹果的这段代码将图像保存到照片库。
- (IBAction)snapStillImage:(id)sender
{
dispatch_async([self sessionQueue], ^{
// Update the orientation on the still image output video connection before capturing.
[[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] videoOrientation]];
// Flash set to Auto for Still Capture
[AVCamViewController setFlashMode:AVCaptureFlashModeAuto forDevice:[[self videoDeviceInput] device]];
// Capture a still image.
[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
if (imageDataSampleBuffer)
{
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
UIImage *proccessingImage = [SAPAdjustImageHelper adjustImage:image];
NSNumber *email_id = [SAPCoreDataEmailHelper currentEmailId];
[SAPFileManagerHelper addImage:proccessingImage toFolderWithEmailId:email_id];
}
}];
});
}
【问题讨论】:
-
请添加代码或截图预览...
-
根据我的经验,它在 iPhone5 上可以正常工作,但问题只在 iPhone 4 上,对吧???
-
你可以在这里下载代码developer.apple.com/library/ios/samplecode/AVCam/Introduction/… 如上所述。我没有修改任何东西
-
你在 iPhone 5 和 4 上测试过吗?
-
@hmdeep 我在 iPad 上测试它我不知道。它工作得很好,但有条纹,所以这意味着有 2 个黑色区域,当我保存捕获的图像时按下静止按钮,它有 2 个黑色阶梯,就像在电影院中一样))我不知道他们为什么不使用全帧,因为它提供相机,但将帧缩小到另一个尺寸
标签: ios objective-c avcapturesession avcam