Optimize your Camera Application

Optimization techniques that can be applied to your camera application depends largely on what your camera application does.

If you implement your application to use more features and capabilities for rendering your content, the more demands you may put on Screen and the system resources. An implementation can use features that cause Screen to start drivers or create a framebuffer, which can increase the time to show the content on the display.



Figure 1. Optimize your camera application.

In some cases, you can start your camera application before the camera service. Specify this order through your SLM configuration files. One reason why you would start your application before the service is to allow the graphics drivers to load and start in parallel with the camera service.

Screen starts graphics drivers as they are required. If your camera application requires specific graphics drivers, then it's best to start your application before the camera service in your SLM configuration files. If you do this, your application must verify that the camera service is ready before trying to access the camera unit or units. For example, your application must wait until it can access /dev/camera/unitX, where X is the camera unit:

int numCameras = MAX_SIMULTANEOUS_CAMERAS;
...
/* Wait for camera service to be ready before trying to open a camera */
...
int loops = 0;
char cameraPath[64];
snprintf(cameraPath, sizeof(cameraPath), "/dev/camera/unit%d", numCameras);
do {
    if (eaccess(cameraPath, F_OK) == EOK) {
      found = true;
      break;
    } else {
      usleep(CAMERA_POLL_TIME_US);
    }
} while (loops++ < CAMERA_MAX_POLL_LOOPS);
...
        

Otherwise, we generally recommend that you follow the techniques described in the Optimize the Splash Screen Application chapter of Screen's Optimizing Startup Times.