When you're not using the camera, you can stop the image buffers from streaming.
You should also disconnect from (close) the camera if you're done using it.
To use the Camera library, you would have called
camera_open(), typically with
read/write permissions, and started the viewfinder (streaming image buffers),
as shown in the code snippet below.
For brevity, we've omitted error checking and handling, but your production application code
should do this.
...
...
camera_handle_t cameraHandle;
camera_open(CAMERA_UNIT_1, CAMERA_MODE_RW | CAMERA_MODE_ROLL, &cameraHandle);
camera_set_vf_mode(cameraHandle, CAMERA_VFMODE_VIDEO);
camera_start_viewfinder(cameraHandle, NULL, NULL, NULL);
...
...
To stop streaming image buffers from the camera, call
camera_stop_viewfinder().
But before your application is done using the camera, ensure that you call the
corresponding
camera_stop_*() functions.
Here are some examples of the
camera_stop_*() calls to make before you call
camera_close():
After you have called the
camera_stop_* functions,
only then can you call
camera_close() to disconnect from the camera
and free its resources and also the camera handle.
If you called
camera_open() with the
CAMERA_MODE_WRITE mode,
but you don't call
camera_close(), other applications
can't access the viewfinder, camera configuration settings,
or camera roll (
CAMERA_MODE_ROLL mode).
Note: If you are using
Screen,
you must release the resources allocated by
Screen. This requires
deallocating windows or contexts that you created, including the viewfinder window that you created and the parent window
if you no longer require it. For instance, you can call
screen_destroy_window() and
screen_destroy_context().
For more information, see the
Screen Developer's Guide.
Here's a code snippet demonstrating how to stop the viewfinder and disconnect from the camera.
Again, we've excluded error handling for brevity.
// Code from first snippet, which includes declaring cameraHandle, goes here
...
...
camera_stop_viewfinder(cameraHandle);
camera_close(cameraHandle);
The handle that you pass to
camera_close() must be the handle
you got from calling
camera_open(), otherwise undefined results may occur.