Still Image capture using Qt Mobility
hamishwillee
(Talk | contribs) m (Fix typo) |
hamishwillee
(Talk | contribs) m (Text replace - "<code cpp>" to "<code cpp-qt>") |
||
| (6 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| + | {{ArticleMetaData <!-- v1.2 --> | ||
| + | |sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] --> | ||
| + | |installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> | ||
| + | |devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') --> | ||
| + | |sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) --> | ||
| + | |platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later --> | ||
| + | |devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | ||
| + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> | ||
| + | |signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> | ||
| + | |capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | ||
| + | |keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase --> | ||
| + | |language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | ||
| + | |translated-by= <!-- [[User:XXXX]] --> | ||
| + | |translated-from-title= <!-- Title only --> | ||
| + | |translated-from-id= <!-- Id of translated revision --> | ||
| + | |review-by= <!-- After re-review: [[User:username]] --> | ||
| + | |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]] | ||
| + | }} | ||
[[Category:Multimedia]][[Category:Qt Mobility]] | [[Category:Multimedia]][[Category:Qt Mobility]] | ||
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0" | {|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0" | ||
| Line 21: | Line 43: | ||
== Overview == | == Overview == | ||
| − | {{Abstract|visible=true| | + | {{Abstract|visible=true|This article demonstrate how to capture still images using Qt Mobility}} |
== Keywords == | == Keywords == | ||
| Line 33: | Line 55: | ||
== Header File == | == Header File == | ||
| − | <code cpp> | + | <code cpp-qt> |
#include <qcamera.h> | #include <qcamera.h> | ||
#include <qstillimagecapture.h> | #include <qstillimagecapture.h> | ||
| Line 50: | Line 72: | ||
== 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 91: | ||
</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 120: | ||
</code> | </code> | ||
| − | <code cpp> | + | <code cpp-qt> |
void ImageCapture::captureImage() { | void ImageCapture::captureImage() { | ||
if (m_stillImageCapture->isReadyForCapture()) { | if (m_stillImageCapture->isReadyForCapture()) { | ||
| Line 110: | Line 132: | ||
</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 145: | ||
* [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/ | + | * [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)[[Category:MeeGo Harmattan]] [[Category:Symbian]] |
Latest revision as of 04:23, 11 October 2012
Article Metadata
| ID | Creation date | 27th Mar 2010 | |
| Platform | S60 5th Edition | Tested on devices | Nokia N97 Mini |
| Category | Qt Mobility | Subcategory | Multimedia |
| Keywords (APIs, classes, methods, functions): QCamera, QStillImageCapture |
Contents |
Overview
This article demonstrate how to capture still images using Qt Mobility
Keywords
Project configuration file (.Pro file)
- Add the Qt Mobility project configuration option in the .Pro file as shown below
CONFIG += mobility
MOBILITY += multimedia
Header File
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);
}
Classes
- QCamera
- QStillImageCapture
Reference links
- Qt - cross-platform application and UI framework
- Qt Mobility API
- New Qt APIs Beta - Mobility Project
- SDK help
--skumar_rao 16:28, 27 March 2010 (UTC)

