سؤال

Is there an easy way of detecting whether the camera is running while using GPUImage?

Currently to start the camera I run:

[_camera startCameraCapture];

and

[_camera stopCameraCapture];

to stop it.

I have found though that if I run startCameraCapture a few times in a row then I get memory problems.

This means that either I need to structure my app with set procedures so a start can only be followed with a stop or I need to determine whether the camera is running and then only stop it if it is running (and vice versa)

Currently I am using

[_camera pauseCameraCapture];
[_camera resumeCameraCapture];

But these are not ideal as when we build up the complexity there will be too many permutations to make sure that a resume always follows a pause.

Any help would be very appreciated

هل كانت مفيدة؟

المحلول

If you call startCameraCapture when the camera is already running, this call will simply be ignored. So this should not cause any memory problems, as long as you don't initiate new _camera instances every time. (You can check the implementation of startCameraCapture in GPUImageVideoCamera.m.)

If you are seeing memory problems, it's most likely from some other places. You may post more code here, or use instruments to track down the issue.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top