Camera example

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

The Camera example that allows you to configure and use cameras connected to your board. You can run the Camera example using any camera configuration. This application is useful to test whether cameras connected to your system works, understand camera settings, and how to use the various features for your cameras. The application is meant to be a tool for learning how to use the Camera Framework library to build an application and how to use the API.

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

  1. Boot up and connect to your target board using a serial connection, terminal via a network connection (telnet/ftp, ssh/scp), or via the QNX Momentics IDE.
  2. Modify the camera configuration file based on the cameras you have connected to your system. The configuration for the reference image is located at /etc/system/config/camera.conf. You should back up camera.conf file before you modify it. For information about how to configure the cameras in the file, see Configure cameras on the reference image.
  3. After you have modified the camera configuration file and rebooted your system, connect to the target, and type camera_example to run the Camera example application on the target. If you don't see an explicit option to exit, you can use CTRL-C to slay the application. Here's a summary of the type of options the Camera example provides:
    Camera viewfinder
    This option allows you 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 H.264 format. You can record from only one of the cameras that's connected to your system. The camera that you record from can't be file camera. If you record multiple times, there are multiple files created. The files are recorded in the camera roll, which is the located at /accounts/1000/shared/camera by default on the reference image.
    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 H.264-encoded file (.MP4). This option synchronizes the start time so that all cameras start recording or encoding at the same time. In addition, this option stops the recording or encoding of all cameras at the same time.
    EGL viewfinder
    This option allows you show image buffers captured from a camera on to the display, but the images are shown in a texture using the GPU.
    CAUTION:
    Due to a limitation with graphics on the Jacinto 6 EVM board, the frame type of YCbYCr won't work for the EGLviewfinder option, which is usually the default frame type when you run this application. If you run this option using YCBYCr, the application stops working. To correctly run this application, configure the frame type of the image buffer (called format) to use NV12 or RGB8888.

    It's important to note that the frame type formats supported vary from board to board.

    Exit the example
    Stop running the application.

Example: Use a single camera

This example shows a video stream from a single camera on the display. Here's how you would run the application on your target and go through the various menu items:
# 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
        x) Exit the example
1
Select which of the following 4 cameras you want to use:
        1) CAMERA_UNIT_1
        2) CAMERA_UNIT_2
        3) CAMERA_UNIT_3
        4) CAMERA_UNIT_4
1
Select which of the following VF modes you want to use:
        2) CAMERA_VFMODE_VIDEO
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:
        i) Modify image attributes
        l) Lock 3A
        v) Modify viewfinder configuration
        w) Modify whitebalance
        x) Exit the example
x

            

Example: Using multiple cameras

Here's how you would use the Camera example to use four 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
        x) Exit the example
1
Select which of the following 4 cameras you want to use:
        1) CAMERA_UNIT_1
        2) CAMERA_UNIT_2
        3) CAMERA_UNIT_3
        4) CAMERA_UNIT_4
1
Select which of the following VF modes you want to use:
        2) CAMERA_VFMODE_VIDEO
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:
        i) Modify image attributes
        l) Lock 3A
        v) Modify viewfinder configuration
        w) Modify whitebalance
        x) Exit the example
x
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
        x) Exit the example
x

            

Example: Modify the white balance for one camera

Here's how you would use the Camera example to one camera on the system:
# 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
        x) Exit the example
1
Select which of the following 4 cameras you want to use:
        1) CAMERA_UNIT_1
        2) CAMERA_UNIT_2
        3) CAMERA_UNIT_3
        4) CAMERA_UNIT_4
1
Select which of the following VF modes you want to use:
        2) CAMERA_VFMODE_VIDEO
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:
        i) Modify image attributes
        l) Lock 3A
        v) Modify viewfinder configuration
        w) Modify whitebalance
        x) Exit the example
w
Select the desired WB mode:
        1) Default
        2) Auto
        3) Manual (RB Gain)
3
Current value of WB red gain is 128. Do you want to change it (y/n)?
y
Select the desired WB red value within range of 1 to 1023
1023                    
Current value of WB blue gain is 128. Do you want to change it (y/n)?
y
Select the desired WB blue value within range of 1 to 1023                      
1
Choose from the following options:
        i) Modify image attributes
        l) Lock 3A
        v) Modify viewfinder configuration
        w) Modify whitebalance
        x) Exit the example
x
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
        x) Exit the example
x

            

Build the Camera example application

On your host computer, the source code is provided for Camera example. You can build the source and deploy the binary on to your target.

Before you start, you should create an environment variable called HOME. The environment should be set to a directory where you want to work with the files and it shouldn't have any spaces within the path. In addition, the directories should be delimited using a forward-slash ("/"). For example, on Windows don't use C:\Documents and Settings\Administrator. Instead, use something such as C:\qnx_install\adas because the space in the name doesn't work with the provided Makefiles.
  1. In a command prompt, copy camera_example_ADAS1.0_[buildstamp].zip, where buildstamp is a numeric value representing an internal build number to location on your computer, such as %HOME%/qnx_install/adas.
  2. If you are running on a Windows host, type bash in your command prompt.
  3. Navigate to the location that you copied the ZIP file, and type unzip camera_example_ADAS1.0_[buildstamp].zip.
  4. A directory should be created called camera_example, navigate into that directory, and type make all.
  5. Navigate to nto/arm/o.le.v7 and transfer the camera_example file to your the /usr/bin/ directory on the target. For example, you can use the IDE to transfer the file.
    Note: Ensure that you can create a backup of the original camera_example executable before you deploy your newly built version of the Camera example application.
  6. On your target, in a terminal connection, type camera_example to run the application.