Camera example

The Camera example application shows you how to work with the Camera library API. The source code for this application is available.

The Camera example that allows you to configure and use cameras connected to your reference image. You can run the Camera example using a configuration that has cameras that are specified. This application is useful to test whether cameras connected to your system work, understand camera settings, and understand how to use the various features for your cameras.

This application is meant to be a reference for learning how to use the Camera APIs to build an application. Here's a summary of the type of options the Camera example provides:
Camera viewfinder
This option allows you to show image buffers captured from a camera on to the display. If your camera is configured correctly, you should see at least one camera connected to your system.
Record video to a file
This option allows you to record the image buffers from a camera to a file in an uncompressed format (.mov/.ucv). You can record from only one of the cameras that's connected to your system, even file cameras (simulated cameras). If you record multiple times, there are multiple files created. The files are recorded in the camera roll, which is the located at the roll directory that's specified at the start of the Sensor service.
Camera stream
Nothing is displayed, but you'll see the frames from the image buffers being sent and a printout indicating what the current frame rate is on the console. The code for this option demonstrates how to get buffers from a camera using the Screen Graphics Subsystem.
Multiple camera video
Show video from one or more cameras. You can choose which cameras to stream video from as well as encode or record the video to an uncompressed video file format (.mov/.ucv). This option synchronizes the start time so that all cameras start providing the output at the same time. In addition, this option stops the output of all cameras at the same time.
EGL viewfinder
This option allows you to show image buffers captured from a camera on to the display, but the images are shown in a texture using the GPU.
Event example
Shows the video using event mode. The example sets up a pulse to be received every time a buffer is received. The buffer is both readable and writable. After the pulse is received, the buffer is acquired and processed by inverting only the luma component. This makes the video show objects in their original color with the brightness inverted. For example, a red light remains red in the video as shown in the following illustration, however, it is dimmer than the surroundings rather than brighter.
Figure 1. Inverted luma.
Exit the example
Stop running the application.

Run the Camera example application

The following describes how to run the Camera example application (camera_example) that's available on the reference image.

  1. Connect to your image using ssh.
  2. If ADAS example is running, type slmctl adas_example in your ssh session to stop it. The application should stop running (you see a blank display).
  3. Type the camera_example to run the Camera example.
    # camera_example
After you run the command, a menu appears. To exit the application, enter Controlc If you are using the default configuration, enter the following menu commands to see the video for the file camera:
  • 1 (Camera viewfinder)
  • 1 (CAMERA_UNIT_1)
  • 2 (CAMERA_VFMODE_VIDEO
  • n
  • n
For more information, see the following examples.

Examples:

The following examples show how to accomplish certain tasks.

Show video from a single camera

This example shows a video stream from a single camera on the display. Here's how you would run the application to show video from one USB camera:
# camera_example  
Select which example you want to run: 
	1) Camera viewfinder
	2) Record video to a file
	3) Camera stream
	4) Multiple camera video
	5) EGL viewfinder
	6) Event example
	x) Exit the example
1
Select which of the following 1 cameras you want to use:
	1) CAMERA_UNIT_1
Enter Choice:
1
Select which of the following VF modes you want to use:
	2) CAMERA_VFMODE_VIDEO
Enter Choice:
2
Do you want to modify the viewfinder configuration (y/n)?
n
Choose from the following options:
	e) Modify exposure
	i) Modify image attributes
	l) Lock 3A
	v) Modify viewfinder configuration
	w) Modify whitebalance
	x) Exit the example

            

Example: Modify the exposure for one camera

Here is how you can modify modify the white balance on supported cameras:
# camera_example  
Select which example you want to run: 
	1) Camera viewfinder
	2) Record video to a file
	3) Camera stream
	4) Multiple camera video
	5) EGL viewfinder
	6) Event example
	x) Exit the example
1
Select which of the following 1 cameras you want to use:
	1) CAMERA_UNIT_1
Enter Choice:
1
Select which of the following VF modes you want to use:
	2) CAMERA_VFMODE_VIDEO
Enter Choice:
2
Do you want to modify the viewfinder configuration (y/n)?
n
Do you want to modify image attributes (y/n)?
n
Choose from the following options:
	e) Modify exposure
	i) Modify image attributes
	l) Lock 3A
	v) Modify viewfinder configuration
	w) Modify whitebalance
	x) Exit the example
e
Select the desired exposure mode:
	1) Default
	2) Auto
	3) ISO Priority
	4) Shutter Priority
	5) ISO Shutter Priority
Enter Choice:
4
Select the desired shutter speed value within range of 0.000011 to 0.033249
0.032
Select the desired EV offset within range of -7.584959 to 2.413635
0
Choose from the following options:
	e) Modify exposure
	i) Modify image attributes
	l) Lock 3A
	v) Modify viewfinder configuration
	w) Modify whitebalance
	x) Exit the example
                

Build the Camera example application

On your host computer, the source code is provided for the Camera example application as part of a ZIP file. You can build the source and deploy the binary on to your target system.

  1. A ZIP file installed with the QNX Platform for ADAS - Base is located at installation directory/source/sf-camera-examples-version.zip. You must extract it to get the ZIP file for the camera examples.
  2. In the extraction_directory/source_package_sf_camera directory, there's a README.txt that you can follow to build the application.
  3. Navigate to extraction_directory/source_package_sf_camera/apps/sensor/camera_example/nto/aarch64/so.le and transfer the camera_example file to the /usr/bin/ directory on the target system. For example, you can use the QNX Momentics IDE to transfer the file.
    Note: Ensure that you can create a backup of the original camera_example file before you deploy your newly built version of the Camera example application.
  4. On your target system, in a terminal connection, run the Camera example application.