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:
- camera-usecases.pro file describes the project structure for the qmake build system.
- icons directory contains application icons for different screen resolutions.
- The src directory contains both the main file source and the C++ code of the custom components.
-
qml directory contains the QML source code and the UI resources.
- components derectory contains the custom UI components.
- cover directory contains the application cover implementations.
- icons directory contains the custom UI icons.
- pages directory contains the application pages.
- camera-usecases.qml file provides the application window implementation.
- The JavaScript auxiliaries are in the qml/js 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:
-
descriptionis the human-readable description of the camera; -
deviceNameis the unique ID to identify the camera and may not be human-readable; -
isDefaultistrueif the camera is default,falseotherwise; -
isNullistrueif the camera info is invalid,falseotherwise; -
orientationis the orientation angle (clockwise, in steps of 90 degrees) of the camera sensor in relation to the display in its natural orientation; -
positionis 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
QCamerato 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:-
extendedframeraterange.h and
extendedframeraterange.cpp
implement an extension of
QCamera::FrameRateRange; -
extendedviewfindersettings.h and
extendedviewfindersettings.cpp
implement an extension of
QCameraViewfinderSettings.
-
extendedframeraterange.h and
extendedframeraterange.cpp
implement an extension of
- cameraprovider.h and cameraprovider.cpp implement aprovider of camera by the device name.
Declarative Camera
This example demonstrates how capture a images and record a video and how to change the camera as well as some other camera settings.
- DeclarativeCameraPage.qml implements Qml Camera which using here you can take a photo or record a video from the main or front camera. Metadata is also being filled in their
- CameraSettingsView.qml implements changing some camera settings: - what Camera is used - capture mode - photo resolution CameraImageSettingsView.qml implements changing some camera settings influencing the image: - exposure mode - white balance mode It uses additional classes to export some data types for QML:
- camerasupportedsettings.h and camerasupportedsettings.cpp
Video Filter
This example demonstrates the ability to filter images transmitted to the viewfinder from the main camera using QAbstractVideoFilter. Here you can choose to use one of two filters: grayscale and Inversion.
-
VideoFilterPage.qml
this is an example page that displays the video stream from the camera via VideosOutput.
This component allows you to apply various filters to it through the filters property,
where you can pass objects inherited from QAbstractVideoFilter. Here you can choose to
use one of three filters:
-
fpsvideofilter.h and
fpsvideofilter.cpp
just counts FPS without frame processing and is the base class for the rest of
the filters.
- grayscalevideofilter.h and grayscalevideofilter.cpp converts all frame colors to grayscale.
- inversionvideofilter.h and inversionvideofilter.cpp inverts the color of the frame.
-
fpsvideofilter.h and
fpsvideofilter.cpp
just counts FPS without frame processing and is the base class for the rest of
the filters.
If the image does not change in any way, it means that the filters do not work.
When checking for INOI R7 3.2.2, this functionality did not work, and the message
was displayed in the message log: call_video_filters(): filters have changed a frame! But we don't support changing video frames in filter now.