×
Namespaces

Variants
Actions
(Difference between revisions)

Still Image capture using Qt Mobility

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Addition to article of: Category:MeeGo Category:Symbian. (Add platform categories))
hamishwillee (Talk | contribs)
m (Hamishwillee -)
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
[[Category:Multimedia]][[Category:Qt Mobility]]
+
[[Category:Qt Mobility]][[Category:MeeGo Harmattan]][[Category:Symbian]][[Category:Camera]][[Category:Imaging]]
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
{{ArticleMetaData <!-- v1.2 -->
|-
+
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
|'''ID''' ||
+
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|'''Creation date''' || 27th Mar 2010
+
|devices= Nokia N97 Mini
|-
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
|'''Platform''' || S60 5th Edition  
+
|platform= S60 5th Edition  
|'''Tested on devices''' || Nokia N97 Mini
+
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
|-
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|'''Category''' || Qt Mobility
+
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
|'''Subcategory''' || Multimedia
+
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
|-
+
|keywords= QCamera, QStillImageCapture
|}
+
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
+
|translated-by= <!-- [[User:XXXX]] -->
 
+
|translated-from-title= <!-- Title only -->
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|translated-from-id= <!-- Id of translated revision -->
|-
+
|review-by= <!-- After re-review: [[User:username]] -->
|'''Keywords (APIs, classes, methods, functions)''': QCamera, QStillImageCapture
+
|review-timestamp= <!-- After re-review: YYYYMMDD -->
|}
+
|update-by= <!-- After significant update: [[User:username]]-->
 
+
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20100327
 +
|author= [[User:Skumar rao]]
 +
}}
  
 
== Overview ==  
 
== Overview ==  
{{Abstract|visible=true|This article demonstrate how to capture still images using Qt Mobility}}
+
{{Abstract|This article demonstrate how to capture still images using Qt Mobility}}
  
 
== Keywords ==
 
== Keywords ==
Line 33: Line 36:
  
 
== Header File ==
 
== Header File ==
<code cpp>
+
<code cpp-qt>
 
#include <qcamera.h>
 
#include <qcamera.h>
 
#include <qstillimagecapture.h>
 
#include <qstillimagecapture.h>
Line 50: Line 53:
  
 
== Source File ==
 
== Source File ==
<code cpp>
+
<code cpp-qt>
 
void ImageCapture::InitCamera() {
 
void ImageCapture::InitCamera() {
 
     QByteArray cameraDevices = QCamera::availableDevices()[0];
 
     QByteArray cameraDevices = QCamera::availableDevices()[0];
Line 69: Line 72:
 
</code>
 
</code>
  
<code cpp>
+
<code cpp-qt>
 
void ImageCapture::error(QCamera::Error e) {
 
void ImageCapture::error(QCamera::Error e) {
 
       switch (e) {
 
       switch (e) {
Line 98: Line 101:
 
</code>
 
</code>
  
<code cpp>
+
<code cpp-qt>
 
void ImageCapture::captureImage() {
 
void ImageCapture::captureImage() {
 
     if (m_stillImageCapture->isReadyForCapture()) {
 
     if (m_stillImageCapture->isReadyForCapture()) {
Line 110: Line 113:
 
</code>
 
</code>
  
<code cpp>
+
<code cpp-qt>
 
void ImageCapture::imageCaptured(const QString &fileName, const QImage &preview) {
 
void ImageCapture::imageCaptured(const QString &fileName, const QImage &preview) {
 
     QMessageBox::information(this, "Image Capatured", fileName);
 
     QMessageBox::information(this, "Image Capatured", fileName);
Line 125: Line 128:
 
* [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project]
 
* [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project]
 
* SDK help
 
* SDK help
--[[User:Skumar rao|Skumar rao]] 16:28, 27 March 2010 (UTC)[[Category:MeeGo]] [[Category:Symbian]]
+
--[[User:Skumar rao|Skumar rao]] 16:28, 27 March 2010 (UTC)

Latest revision as of 08:19, 14 June 2013

Article Metadata
Tested with
Devices(s): Nokia N97 Mini
Compatibility
Platform(s): S60 5th Edition
Symbian
Article
Keywords: QCamera, QStillImageCapture
Created: skumar_rao (27 Mar 2010)
Last edited: hamishwillee (14 Jun 2013)

Contents

[edit] Overview

This article demonstrate how to capture still images using Qt Mobility

[edit] Keywords

[edit] Project configuration file (.Pro file)

  • Add the Qt Mobility project configuration option in the .Pro file as shown below
CONFIG += mobility
MOBILITY += multimedia

[edit] Header File

#include <qcamera.h>
#include <qstillimagecapture.h>
 
public slots:
void captureImage();
void error(QCamera::Error);
void imageCaptured(const QString &fileName, const QImage &preview);
private:
void InitCamera();
 
private:
QCamera* m_camera;
QStillImageCapture* m_stillImageCapture;

[edit] Source File

void ImageCapture::InitCamera() {
QByteArray cameraDevices = QCamera::availableDevices()[0];
m_camera = new QCamera(cameraDevices);
 
connect(m_camera, SIGNAL(error(QCamera::Error)), this, SLOT(error(QCamera::Error)));
 
m_camera->setFocusMode(QCamera::AutoFocus);
 
m_stillImageCapture = new QStillImageCapture(m_camera);
connect(m_stillImageCapture, SIGNAL(imageCaptured(QString,QImage)), this, SLOT(imageCaptured(QString,QImage)));
 
if (m_camera->state() == QCamera::ActiveState) {
m_camera->stop();
}
m_camera->start();
}
void ImageCapture::error(QCamera::Error e) {
switch (e) {
case QCamera::CameraError: {
QMessageBox::warning(this, "Camera error", "General camera error");
break;
}
case QCamera::NotReadyToCaptureError: {
QMessageBox::warning(this, "Camera error", "Camera not ready to capture image");
break;
}
case QCamera::InvalidRequestError: {
QMessageBox::warning(this, "Camera error", "Invalid request");
break;
}
case QCamera::ServiceMissingError: {
QMessageBox::warning(this, "Camera error", "Service missing");
break;
}
case QCamera::NotSupportedFeatureError: {
QMessageBox::warning(this, "Camera error", "Not supported feature");
break;
}
default:
break;
};
}
void ImageCapture::captureImage() {
if (m_stillImageCapture->isReadyForCapture()) {
m_stillImageCapture->capture(QString("camera_capture.jpg"));
}
else {
QMessageBox::warning(this, "Camera error", "Camera not ready");
}
 
}
void ImageCapture::imageCaptured(const QString &fileName, const QImage &preview) {
QMessageBox::information(this, "Image Capatured", fileName);
}

[edit] Classes

  • QCamera
  • QStillImageCapture

[edit] Reference links

--skumar_rao 16:28, 27 March 2010 (UTC)

This page was last modified on 14 June 2013, at 08:19.
101 page views in the last 30 days.