Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

(Difference between revisions)

Still Image capture using Qt Mobility

From Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Fix typo)
hamishwillee (Talk | contribs)
m (Hamishwillee -)
 
(7 intermediate revisions by 2 users 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|Still Image capture 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 123: Line 126:
 
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
 
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
 
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
 
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
* [http://qt.nokia.com/developer/new-qt-apis 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)
 
--[[User:Skumar rao|Skumar rao]] 16:28, 27 March 2010 (UTC)

Latest revision as of 05: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 05:19.
124 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×