Camera Use Cases

The project contains the usage examples of the API that allows to work with camera: settings, capturing, frame processing.

The main purpose is to show not only what features are available to work with the camera, but also how to use them correctly.

The source code of the project is provided under the license, that allows it to be used in third-party applications.

Project Structure

The project has a common structure of an application based on C++ and QML for Aurora OS or Sailfish OS. The features related to the examples are the following:

  • The src directory contains both the main file source and the C++ code of the custom components.
  • QML documents of custom components are located in the qml/components directory.
  • The JavaScript auxiliaries are in the qml/js directory.
  • The pictures used for the UI are located in the qml/images directory.
  • Each use case has its own QML-file in the qml/pages directory.
  • Navigation by examples in the application is implemented in the MainPage.qml file.

Examples

Camera Info

This example shows how to get a list of available cameras and the basic information about each camera.

  • CameraInfoPage.qml is the example page.
  • camerainfomodel.h and camerainfomodel.cpp implement a model that provides a list of available cameras. Each element of the model has properties:
    • description is the human-readable description of the camera;
    • deviceName is the unique ID to identify the camera and may not be human-readable;
    • isDefault is true if the camera is default, false otherwise;
    • isNull is true if the camera info is invalid, false otherwise;
    • orientation is the orientation angle (clockwise, in steps of 90 degrees) of the camera sensor in relation to the display in its natural orientation;
    • position is the physical position of the camera on the hardware system (back face, front face or unspecified).

Camera Properties

This example demonstrates some techniques to read and analyze camera properties using C++.

  • CameraPropertiesPage.qml is the example page. It displays the status of the available properties of the selected camera and also allows you to activate and deactivate the camera using a pull down menu.
  • ConditionItem.qml implements the basic view for a property condition:
    • Theme.presenceColor(Theme.PresenceAvailable) is used for the valid property values;
    • Theme.presenceColor(Theme.PresenceBusy) is used for the invalid property values;
    • Theme.presenceColor(Theme.PresenceOffline) is used for the properties with unknown condition.
  • extendedcamera.h and extendedcamera.cpp implement an extension of QCamera to provide more properties for QML: capture mode, settings of viewfinder, exposure, focus, image processing and recorder. It uses additional classes to export some data types for QML:
  • cameraprovider.h and cameraprovider.cpp implement aprovider of camera by the device name.

Declarative Camera

The application is a main menu with some items:

  • "Camera" - here you can take a photo or record a video from the main or front camera.