使用下列在我的應用程序,它是安靜的執行罰款,一次又一次畫上一個GLKView一個CIImage直到我使用的是iOS < = 10.1從AVCaptureOutput -didOutputSampleBuffer
收到代碼。*自從更新到iOS 10.2後,無法在GLKView上繪製CIImage幾幀後?
更新設備到iOS 9.2.1後它已停止工作。我打電話給它幾幀應用程序崩潰與低內存警告。而在iOS 10.1.1及更低版本中,即使在iPhone 5S等較早的設備上,我也能順利運行該應用程序。
[_glkView bindDrawable];
if (self.eaglContext != [EAGLContext currentContext])
[EAGLContext setCurrentContext:self.eaglContext];
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
if (ciImage) {
[_ciContext drawImage:ciImage inRect:gvRect fromRect:dRect];
}
[_glkView display];
這就是我如何製作CIImage。
- (CIImage*)ciImageFromPixelBuffer:(CVPixelBufferRef)pixelBuffer ofSampleBuffer:(CMSampleBufferRef)sampleBuffer {
CIImage *croppedImage = nil;
CFDictionaryRef attachments = CMCopyDictionaryOfAttachments(kCFAllocatorDefault, sampleBuffer, kCMAttachmentMode_ShouldPropagate);
CIImage *ciImage = [CIImage imageWithCVPixelBuffer:pixelBuffer options:(NSDictionary *)attachments];
if (attachments)
CFRelease(attachments);
croppedImage = ciImage;
CIFilter *scaleFilter = [CIFilter filterWithName:@"CILanczosScaleTransform"];
[scaleFilter setValue:croppedImage forKey:@"inputImage"];
[scaleFilter setValue:[NSNumber numberWithFloat:self.zoom_Resize_Factor == 1 ? 0.25 : 0.5] forKey:@"inputScale"];
[scaleFilter setValue:[NSNumber numberWithFloat:1.0] forKey:@"inputAspectRatio"];
croppedImage = [scaleFilter valueForKey:@"outputImage"];
NSDictionary *options = @{(id)kCIImageAutoAdjustRedEye : @(false)};
NSArray *adjustments = [ciImage autoAdjustmentFiltersWithOptions:options];
for (CIFilter *filter in adjustments) {
[filter setValue:croppedImage forKey:kCIInputImageKey];
croppedImage = filter.outputImage;
}
CIFilter *selectedFilter = [VideoFilterFactory getFilterWithType:self.selectedFilterType]; //This line needs to be removed from here
croppedImage = [VideoFilterFactory applyFilter:selectedFilter OnImage:croppedImage];
CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
return croppedImage;
}
這裏是imgur鏈路導致VM跟蹤和OpenGL ES器械的http://imgur.com/a/u6Vyo。它易於理解。謝謝。
如果繞過CIFilter相關處理會發生什麼情況? –
好吧,我通過像素緩衝區,因爲它是glkview它沒有崩潰或有任何影響。但爲什麼發生這種事? – khunshan