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  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Camera

The Camera API provides control of system camera devices. Providing support for still or video image capture with sound support.

Namespace

The QtMobility APIs are placed into the QtMobility namespace. This is done to facilitate the future migration of QtMobility APIs into Qt. See the Quickstart guide for an example on how the namespace impacts on application development.

Overview

The Camera API allows high level control of various aspects of still images and video. Camera is a part of the Multimedia API and this relationship is apparent when you notice that certain core classes are subclassed from some Multimedia base classes including QMediaObject and QMediaControl.

Still Images

In order to capture an image we need to create a QCamera object and use it to initialize a QVideoWidget, so we can see where the camera is pointing - a viewfinder. The camera object is also used to initialize a new QCameraImageCapture object, imageCapture. All that is then needed is to start the camera, lock it so that the settings are not changed while the image capture occurs, capture the image, and finally unlock the camera ready for the next photo.

 camera = new QCamera;
 viewFinder = new QCameraViewfinder;
 camera->setViewfinder(viewFinder);
 viewFinder->show();

 imageCapture = new QCameraImageCapture(camera);

 camera->setCaptureMode(QCamera::CaptureStillImage);
 camera->start();

 //on half pressed shutter button
 camera->searchAndLock();

 //on shutter button pressed
 imageCapture->capture();

 //on shutter button released
 camera->unlock();

Alternatively, we could have used a QGraphicsVideoItem as a viewfinder.

Video Clips

Previously we saw code that allowed the capture of a still image. Recording video requires the use of a QMediaRecorder object and a QAudioCaptureSource for sound.

To record video we need to create a camera object as before but this time as well as creating a viewfinder, we will also initialize a media recorder object.

 camera = new QCamera;
 mediaRecorder = new QMediaRecorder(camera);

 camera->setCaptureMode(QCamera::CaptureVideo);
 camera->start();

 //on shutter button pressed
 mediaRecorder->record();

Signals from the mediaRecorder can be connected to slots to react to changes in the state of the recorder or error events. Recording itself starts with the record() function of mediaRecorder being called, this causes the signal stateChanged() to be emitted. The recording process can be changed with the record(), pause(), stop() and setMuted() slots in QMediaRecorder.

When the camera is in video mode, as decided by the application, then as the shutter button is pressed the camera is locked as before but instead the record() function in QMediaRecorder is used.

Focus

Focusing is managed by the classes QCameraFocus and QCameraFocusControl. QCameraFocus allows the developer to set the general policy by means of the enums for the FocusMode and the FocusPointMode. FocusMode deals with settings such as AutoFocus, ContinuousFocus and InfinityFocus, whereas FocusPointMode deals with the various focus zones within the view. FocusPointMode has support for face recognition, center focus and a custom focus where the focus point can be specified.

Cancelling Asynchronous Operations

Various operations such as image capture and auto focusing occur asynchrously. These operations can often be cancelled by the start of a new operation as long as this is supported by the backend. For image capture, the operation can be cancelled by calling cancelCapture(). For AutoFocus, autoexposure or white balance cancellation can be done by calling QCamera::unlock(QCamera::LockFocus).

Camera Controls

Control NameDescription
camerathe interface for system camera devices
exposureIncludes: flash mode; flash power; metering mode; aperture; shutter speed, iso setting
focusIncludes: optical zoom; digital zoom; focus point; focus zones
image processingwhite balance; contrast; saturation; sharpen; denoise
lockshandles the locking and unlocking of camera devices

Classes

QCamera

Interface for system camera devices

QCameraExposure

Interface for exposure related camera settings

QCameraFocus

Interface for focus and zoom related camera settings

QCameraImageCapture

Used for the recording of media content

QCameraImageProcessing

Interface for focus and zoom related camera settings

QCameraViewfinder

Camera viewfinder widget

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 53
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  4. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le blog Digia au hasard

Logo

Déploiement d'applications Qt Commercial sur les tablettes Windows 8

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

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 qtmobility-1.2
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