Documentation: application-developer: Add camera detection check
The simple-cam application has a check to ensure that at least one camera is present before attempting to access the first camera, to avoid a crash. Update the application developer's guide to match this behaviour. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
348df7bc4b
commit
2d5a78f664
1 changed files with 9 additions and 1 deletions
|
@ -109,10 +109,18 @@ the Camera Manager reports as available to applications.
|
|||
Camera devices are stored by the CameraManager in a list accessible by index, or
|
||||
can be retrieved by name through the ``CameraManager::get()`` function. The
|
||||
code below retrieves the name of the first available camera and gets the camera
|
||||
by name from the Camera Manager.
|
||||
by name from the Camera Manager, after making sure that at least one camera is
|
||||
available.
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
if (cm->cameras().empty()) {
|
||||
std::cout << "No cameras were identified on the system."
|
||||
<< std::endl;
|
||||
cm->stop();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::string cameraId = cm->cameras()[0]->id();
|
||||
camera = cm->get(cameraId);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue