ios远程摄像头图像处理崩溃

时间:2014-05-08 10:45:39

标签: ios multithreading image-processing sony sony-camera-api

我使用Sony CameraRemoteAPI SDK连接了远程摄像头。相机已成功连接,我正在获取相框。以下代码获取传入的UIImage并分配给UIImageView

- (void) liveviewPaint:(UIImage*)image { @synchronized(self) { [self.liveviewImageView setImage:image]; image = NULL; } }

然后我需要为这个UIImage添加人脸识别。但是当我尝试这样做时,应用程序会耗尽内存并崩溃。如何使用此远程摄像头进行有效的人脸识别?这是我目前的代码

- (void) liveviewPaint:(UIImage*)image { @synchronized(self) { [self performSelectorInBackground:@selector(getFaceDetectedImage:) withObject:image]; if ([[RecognitionAPI getSharedInstance] detectedImage]) { [self.liveviewImageView setImage:[[RecognitionAPI getSharedInstance] detectedImage]]; } else { [self.liveviewImageView setImage:image]; } image = NULL; } }

这里使用一个单独的线程我正在调用面部识别功能(getFaceDetectedImage)。一旦识别出面部,它将被设置为RecognitionAPI类(detectedImage)中的实例变量。如果检测到面部,我将其设置为UIImageView(liveviewImageView)的图像,如下所示 [self.liveviewImageView setImage:[[RecognitionAPI getSharedInstance] detectedImage]];

这是没有面部检测的分配工具的输出。这次应用程序没有崩溃。 enter image description here

这是具有面部检测的分配工具的输出。此次应用崩溃enter image description here

我正在使用苹果内置的CIDetector进行人脸识别。我尝试使用opencv,但那时应用程序也崩溃了。

这是我在控制台中收到的错误

Recognition(483,0x6a51000) malloc: *** mach_vm_map(size=2691072) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Recognition(483,0x6a51000) malloc: *** mach_vm_map(size=675840) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Recognition(483,0x6a51000) malloc: *** mach_vm_map(size=2691072) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Recognition(483,0x6a51000) malloc: *** mach_vm_map(size=675840) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Recognition(483,0x6a51000) malloc: *** mach_vm_map(size=2691072) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Recognition(483,0x6a51000) malloc: ***
另外我总共获得了59个无法完成的线程。这是它的截图。 enter image description here
我想知道如何避免这种崩溃以及如何有效地进行图像处理。我想我需要一个好的设计。有人可以帮忙吗?

0 个答案:

没有答案
相关问题