Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

Camera

The Camera type allows you to access viewfinder frames, and take photos and movies. More...

Inherits Item

Properties

Signals

Methods

Detailed Description

Camera is part of the QtMultimedia 5.0 module.

You can use Camera to capture images and movies from a camera, and manipulate the capture and processing settings that get applied to the images. To display the viewfinder you can use VideoOutput with the Camera set as the source.

 import QtQuick 2.0
 import QtMultimedia 5.0

 Item {
     width: 640
     height: 360

     Camera {
         id: camera

         imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash

         exposure {
             exposureCompensation: -1.0
             exposureMode: Camera.ExposurePortrait
         }

         flash.mode: Camera.FlashRedEyeReduction

         imageCapture {
             onImageCaptured: {
                 photoPreview.source = preview  // Show the preview in an Image
             }
         }
     }

     VideoOutput {
         source: camera
         anchors.fill: parent
         focus : visible // to receive focus and capture key events when visible
     }

     Image {
         id: photoPreview
     }
 }

The various settings and functionality of the Camera stack is spread across a few different child properties of Camera.

PropertyDescription
imageCaptureMethods and properties for capturing still images.
videoRecordingMethods and properties for capturing movies.
exposureMethods and properties for adjusting exposure (aperture, shutter speed etc).
focusMethods and properties for adjusting focus and providing feedback on autofocus progress.
flashMethods and properties for controlling the camera flash.
imageProcessingMethods and properties for adjusting camera image processing parameters.

Basic camera state management, error reporting, and simple zoom properties are available in the Camera itself. For integration with C++ code, the mediaObject property allows you to access the standard QtMultimedia camera controls.

Many of the camera settings may take some time to apply, and might be limited to certain supported values depending on the hardware. Some camera settings may be set manually or automatically. These settings properties contain the current set value. For example, when autofocus is enabled the focus zones are exposed in the focus property.

Property Documentation

read-onlyavailability : enumeration

Returns the availability state of the camera.

This is one of:

ValueDescription
AvailableThe camera is available to use
BusyThe camera is usually available to use, but is currently busy. This can happen when some other process needs to use the camera hardware.
UnavailableThe camera is not available to use (there may be no camera hardware)
ResourceMissingThere is one or more resources missing, so the camera cannot be used. It may be possible to try again at a later time.

cameraState : enumeration

The current state of the camera object.

ValueDescription
UnloadedStateThe initial camera state, with the camera not loaded. The camera capabilities (with the exception of supported capture modes) are unknown. This state saves the most power, but takes the longest time to be ready for capture.

While the supported settings are unknown in this state, you can still set the camera capture settings like codec, resolution, or frame rate.

LoadedStateThe camera is loaded and ready to be configured.

In the Idle state you can query camera capabilities, set capture resolution, codecs, and so on.

The viewfinder is not active in the loaded state.

ActiveStateIn the active state the viewfinder frames are available and the camera is ready for capture.

The default camera state is ActiveState.


read-onlycameraStatus : enumeration

The current status of the camera instance.

ValueDescription
ActiveStatusThe camera has been started and can produce data, viewfinder displays video frames.

Depending on backend, changing some camera settings like capture mode, codecs or resolution in ActiveState may lead to changing the camera status to LoadedStatus and StartingStatus while the settings are applied and back to ActiveStatus when the camera is ready.

StartingStatusThe camera is starting in result of state transition to Camera.ActiveState. The camera service is not ready to capture yet.
StoppingStatusThe camera is stopping in result of state transition from Camera.ActiveState to Camera.LoadedState or Camera.UnloadedState.
StandbyStatusThe camera is in the power saving standby mode. The camera may enter standby mode after some time of inactivity in the Camera.LoadedState state.
LoadedStatusThe camera is loaded and ready to be configured. This status indicates the camera device is opened and it's possible to query for supported image and video capture settings, like resolution, framerate and codecs.
LoadingStatusThe camera device loading in result of state transition from Camera.UnloadedState to Camera.LoadedState or Camera.ActiveState.
UnloadingStatusThe camera device is unloading in result of state transition from Camera.LoadedState or Camera.ActiveState to Camera.UnloadedState.
UnloadedStatusThe initial camera status, with camera not loaded. The camera capabilities including supported capture settings may be unknown.
UnavailableStatusThe camera or camera backend is not available.

captureMode : enumeration

ValueDescription
CaptureViewfinderCamera is only configured to display viewfinder.
CaptureStillImagePrepares the Camera for capturing still images.
CaptureVideoPrepares the Camera for capturing video.

read-onlyerrorCode : enumeration

Error state of the camera.

See also QtMultimedia5::Camera::onError.


read-onlyerrorString : string

A description of the current error, if any.


read-onlylockStatus : enumeration

The overall status for all the requested camera locks.

ValueDescription
UnlockedThe application is not interested in camera settings value. The camera may keep this parameter without changes, this is common with camera focus, or adjust exposure and white balance constantly to keep the viewfinder image nice.
SearchingThe application has requested the camera focus, exposure or white balance lock with searchAndLock(). This state indicates the camera is focusing or calculating exposure and white balance.
LockedThe camera focus, exposure or white balance is locked. The camera is ready to capture, application may check the exposure parameters.

The locked state usually means the requested parameter stays the same, except in the cases when the parameter is requested to be constantly updated. For example in continuous focusing mode, the focus is considered locked as long as the object is in focus, even while the actual focusing distance may be constantly changing.


read-onlymediaObject : variant

The media object for the Camera.


Signal Documentation

Camera::onError(errorCode, errorString)

This handler is called when an error occurs. The enumeration value errorCode is one of the values defined below, and a descriptive string value is available in errorString.

ValueDescription
NoErrorNo errors have occurred.
CameraErrorAn error has occurred.
InvalidRequestErrorSystem resource doesn't support requested functionality.
ServiceMissingErrorNo camera service available.
NotSupportedFeatureErrorThe feature is not supported.

Method Documentation

Camera::searchAndLock()

Start focusing, exposure and white balance calculation.

This is appropriate to call when the camera focus button is pressed (or on a camera capture button half-press). If the camera supports autofocusing, information on the focus zones is available through the focus property.


Camera::start()

Starts the camera. Viewfinder frames will be available and image or movie capture will be possible.


Camera::stop()

Stops the camera, but leaves the camera stack loaded.


Camera::unlock()

Unlock focus, exposure and white balance locks.


Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web