Use the Camera library API

You can use the Camera library to show a video feed from a live camera or file camera in a few easy steps. This section shows you the basic workflow to use the Camera library.

One important thing to mention is that our examples or the Camera library use the Screen Graphics Subsystem (Screen) to show the image buffers from the camera on a display. For this reason, you should have a basic understanding how to set up Screen to handle image buffers from the Camera library and show them on the display. You don't need to use Screen if you don't want to show the image buffers on a display. You can access the image buffers and process the buffers using event or callback mode. For more information about using Screen and Camera, see Use Screen with the Camera API in this chapter.

These are the steps to use the Camera API to show the image buffers from the camera on a display:
Note: You can see the complete sample code for the workflow from Example: Show Viewfinder window.”
  1. Open the camera. This step is necessary for getting a valid handle to work with the Camera API.
  2. Set the viewfinder mode for camera. Optionally, you can configure settings on the camera.
  3. Use Screen with the Camera API. Screen is required to show the video from the camera on a display. You must do some initial setup.
  4. Start viewfinder and configure camera settings. This step starts processing image buffers (or the imaging datapath) from the camera. Optionally, you can set viewfinder settings ( e.g., rotation, height, and width) and image attributes (e.g., contrast and hue). Though setting configuration settings are optional, it's often necessary in order to set the correct settings on your camera. For example, a camera may use YCbYCr as the default frame format, but you could change it to use RGB8888, provided that format is supported on the camera.
  5. Use Screen to show the viewfinder window. In this step, you use Screen to show the video in a window on the display.
  6. Stop viewfinder and close camera This requires that you stop the viewfinder and the image buffer from streaming. You don't need to disconnect from the camera (close) until you are done using it. For example, you can stop and then start the viewfinder again. For more information, see Stop viewfinder and close camera.”
The previous steps describe the basic workflow for using Camera API. See the following sections for some more advanced tasks you can do with the APIs: