我正在使用AVFoundation攝像頭中的縮放功能,我通過縮放具有AVCaptureVideoPreviewLayer的視圖來實現縮放。 現在我想捕捉縮放圖像。在AVFoundation中捕捉縮放預覽視圖
這裏是我加入AVFoundationVideoPreviewLayer到視圖代碼:
// create a uiview subclass for showing the camera feed
UIView *previewView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 430)];
[[self view] addSubview:previewView];
CGRect layerRect = CGRectMake(0, 0, 320, 430);
[[self avCaptureVideoPreviewLayer] setBounds:layerRect];
[[self previewLayer] setPosition:CGPointMake(CGRectGetMidX(layerRect), CGRectGetMidY(layerRect))];
// add the video previewview layer to the preview view
[[previewView layer] addSublayer:[self avCaptureVideoPreviewLayer]];
進行縮放預覽視圖代碼
// zoom the preview view using core graphics
[previewView setTransform:CGAffineTransformMakeScale(2.0, 2.0)];
現在我想從previewView捕獲該縮放圖像中提前
謝謝。
還有其他更好的解決方案嗎? – kadungon
關於你的崩潰:簡單地先裁剪而不是調整大小來解決你的內存問題。如果您稍後放棄大部分圖像,請勿計算大圖像。 – CipherCom
我試過你的代碼,但我無法弄清楚cameraZoom和最終結果總是隻是空白圖像。你能分享更多嗎? –