Modify the system to run a custom application

The default application that the reference image starts is the Camera MUX 2x2 application (camera_mux2x2). The Camera MUX 2x2 application shows a 2x2 grid of the image buffers or video streams from four cameras.

Here's what a video feed from four cameras could look like:


Figure 1. Camera MUX 2x2 application

You may want to change the system configuration so that it starts a custom application instead (e.g., an application that shows video feeds from six cameras), or run the application later. In the latter case, in the /etc/slm-config-platform.xml file, remove the camera_mux2x2 component, and then delete the <SLM:depend>camera</SLM:depend> dependency from all the other components in the file.

If you want to replace the Camera MUX 2x2 application with your own camera application, perform these steps:
  1. Build your application and then transfer the binary and required files to the reference image. For example, you can use the QNX Momentics IDE to transfer your binary. Before you transfer the binary, don't forget to make your reference image writable by running the mount -uw /base command.
  2. Backup the /etc/slm-config-platform.xml and modify it to run your application instead of the default camera-mux2x2 binary.
    For example, find the camera_mux2x2 component:
    ...
    ...
    <SLM:component name="camera_mux2x2">
       <SLM:command>/base/usr/bin/camera_mux2x2</SLM:command>
    </SLM:component>
    ...
    ...              
    Then, change it to run your binary instead. For example, now the camera_mux2x2 component runs a custom binary called myowncameramuxapp:
    ...
    ...
    <SLM:component name="camera_mux2x2">
       <SLM:command>/base/usr/bin/myowncameramuxapp</SLM:command>
    </SLM:component>
    ...
    ...                   
    Note: In the implementation of your application, you should poll and check that the camera is available because there isn't any dependency on the camera service, which means it's possible that your application may come up at the same time as the camera service and it may take some time for the cameras to be available. For information about how to write your camera application, see the Camera Framework Developer's Guide.
  3. Modify the camera component to indicate the number of the last camera unit number to wait for to start. If you have four cameras, that are configured as CAMERA_UNIT_1, CAMERA_UNIT_2, CAMERA_UNIT_3, and CAMERA_UNIT_4, then keep the number as 4 (i.e., camera4-start.run). For example, if you have fewer cameras, such as three, change the file to camera3-start.run; if you have more cameras, such as six, change the file to camera6-start.run. The previous examples presume the cameras are configured in sequential order. In the reference image, here's what the camera component looks like in the slm-config-platform.xml file:
    ...
    ...
    <SLM:component name="camera">
       <SLM:command launch="builtin">no_op</SLM:command>
       <SLM:waitfor wait="pathname">/dev/shmem/camera4-start.run</SLM:waitfor>
    </SLM:component>
    ...
    ...           
    Because the maximum enumerator for the camera unit number is CAMERA_UNIT_8, if you specified camera9-start.run, that camera won't run, and you'll need to wait until the startup timeout occurs, which is approximately 10 seconds. The number that you specify as part of the filename indicates the files to put in the /dev/camera directory, which maps to the camera's unit number that's specified in your camera configuration file.

    For example, if the cameras in your camera configuration are configured as CAMERA_UNIT_1, CAMERA_UNIT_2, CAMERA_UNIT_5, and CAMERA_UNIT_7, that's four cameras, but you would set the camera component to /dev/shmem/camera7-start.run to indicate the unit number of the last camera to come up is CAMERA_UNIT_7. As mentioned earlier, as each camera starts, you should see a file representing that camera that came up in the /dev/camera directory. So in this example, you should see unit1, unit2, unit5, and unit7 as files in the /dev/camera directory. The components that have a dependency (i.e., <SLM:depend> specified) on the camera component only start after the camera component has started and begun capturing image buffers. For example, networking (iopkt) won't start until the camera component starts (or a time-out occurs).

    ...
    ...
    <SLM:component name="iopkt">
        <SLM:command>io-pkt-v6-hc</SLM:command>
        <SLM:args>-d dm814x-j6 -p tcpip</SLM:args>
        <SLM:waitfor wait="pathname">/dev/socket</SLM:waitfor>
        <SLM:depend>camera</SLM:depend>
        <SLM:stop stop="signal">SIGTERM</SLM:stop>
    </SLM:component>
Note: The Camera MUX 2x2 application implements the described approach to determine when the cameras are ready in the system. This implementation is one approach. You can choose to implement a similar approach or develop one that suites the requirements for your application.