From 5eb5ab6c27ffa1138f0d23048120aed746854fec Mon Sep 17 00:00:00 2001 From: Michael Demetriou Date: Sun, 9 Sep 2012 13:55:46 +0300 Subject: [PATCH] Settings White balance settings animation focus on tap --- CameraParameters.cpp | 23 ++++ CameraParameters.h | 8 ++ CameraThread.cpp | 63 +++++---- CameraThread.h | 6 + qtc_packaging/debian_harmattan/changelog | 5 + rawcam.cpp | 39 +++++- rawcam.pro | 3 +- settings.png | Bin 2536 -> 1629 bytes settings.qml | 158 +++++++++++++++++++++++ style.css | 7 + 10 files changed, 281 insertions(+), 31 deletions(-) create mode 100644 settings.qml diff --git a/CameraParameters.cpp b/CameraParameters.cpp index 025e992..09cd022 100644 --- a/CameraParameters.cpp +++ b/CameraParameters.cpp @@ -4,6 +4,7 @@ #include #include +#include CameraParameters::CameraParameters() { // Set default modes and values @@ -101,6 +102,18 @@ int CameraParameters::getExposureValue(float val){ return (int)abs(powf((val-gamma)/alpha,1/beta)); } +void CameraParameters::setExposureCompensation(float compensation){ + this->exposure.compensation = compensation; +} + +void CameraParameters::setWhiteBalance(int wb){ + this->whiteBalance.value = wb; +} + +void CameraParameters::setWhiteBalanceMode(int wbmode){ + this->whiteBalance.mode = wbmode; +} + void CameraParameters::setGainMode(int mode){ this->gain.mode = mode; } @@ -168,3 +181,13 @@ void CameraParameters::setLastPicture(QString lastPic){ this->lastPicture = lastPic; } +QVariant CameraParameters::getSetting(QString key, QVariant defaultval){ + QSettings settings; + return settings.value(key, defaultval); +} + +void CameraParameters::setSetting(QString key, QVariant val){ + QSettings settings; + settings.setValue(key, val); +} + diff --git a/CameraParameters.h b/CameraParameters.h index 8280b2a..e263854 100644 --- a/CameraParameters.h +++ b/CameraParameters.h @@ -5,6 +5,7 @@ #include #include #include +#include /* The requested state of the camera. All communication between the UI * and the camera control thread passes through a single instance of @@ -30,6 +31,7 @@ class CameraParameters : public QObject { float value; // If in HDR mode, how many shots to take int hdrShots; + float compensation; QString toString(float val); } exposure; @@ -92,6 +94,7 @@ public slots: void setExposureModeMan(); void setExposureValue(float); void setExposureValue(int); + void setExposureCompensation(float); void setGainMode(int); void setGainModeAuto(); @@ -107,6 +110,9 @@ public slots: void setFocusValue(int); void setFocusSpot(int, int); + void setWhiteBalance(int); + void setWhiteBalanceMode(int); + void setFlashOff(); void setFlashHalf(); void setFlashFull(); @@ -114,6 +120,8 @@ public slots: void openLastPicture(); void setLastPicture(QString); + QVariant getSetting(QString, QVariant); + void setSetting(QString, QVariant); signals: // A signal signifying that the camera parameters have changed. diff --git a/CameraThread.cpp b/CameraThread.cpp index 749f5a5..b8c0d35 100644 --- a/CameraThread.cpp +++ b/CameraThread.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "OverlayWidget.h" #include "CameraParameters.h" @@ -65,6 +66,7 @@ void CameraThread::run() { viewfinder.histogram.region = FCam::Rect(0, 0, 640, 480); viewfinder.sharpness.enabled = true; viewfinder.sharpness.size = FCam::Size(16, 12); + viewfinder.whiteBalance = parameters->whiteBalance.value; // A full res photograph. We'll set the exposure, frameTime, and // gain later, after we meter. Default parameters apply (no @@ -115,7 +117,7 @@ void CameraThread::run() { // use the metering the viewfinder has been doing photo.exposure = viewfinder.exposure; photo.gain = viewfinder.gain; - photo.whiteBalance = viewfinder.whiteBalance; + photo.whiteBalance = viewfinder.whiteBalance; if (parameters->flash.mode != CameraParameters::Flash::OFF) photo.addAction(fire); sensor.capture(photo); @@ -128,41 +130,47 @@ void CameraThread::run() { f = sensor.getFrame(); // filewriter doesn't emit a signal when it finishes saving a file so we use a hackish way; //qDebug()<< "before dequeure" << pictureNames; - if (!pictureNames.isEmpty() && pictureNames.length()*2 > writer.savesPending()) emit pictureSaved(QString(pictureNames.dequeue())); + if (!pictureNames.isEmpty() && pictureNames.length() > writer.savesPending()) { + QString newFile = QString(pictureNames.dequeue()); + if (newFile.endsWith(".jpg")) emit pictureSaved(newFile); + } if (f.shot().id == photo.id) { - // Our photo came back, asynchronously save it to disk - // with a unique filename. We use the exposure start - // time for now just so we don't have to keep a - // globally unique numbering. - if (!f.image().valid()) { - printf("ERROR: Photo dropped!\n"); - continue; - } else { - printf("Got a full-res frame\n"); - } - - - char fname[256]; - // Save it as a JPEG - snprintf(fname, 255, "%s/MyDocs/DCIM/photo_%s.jpg", getenv("HOME"), - f.exposureStartTime().toString().c_str()); - writer.saveJPEG(f, fname, 90); - // filewriter doesn't emit a signal when it finishes saving a file so we use a hackish way; - pictureNames.enqueue(QString(fname)); - //qDebug()<< "after enqueue" << pictureNames; + // Our photo came back, asynchronously save it to disk + // with a unique filename. We use the exposure start + // time for now just so we don't have to keep a + // globally unique numbering. + if (!f.image().valid()) { + printf("ERROR: Photo dropped!\n"); + continue; + } else { + printf("Got a full-res frame\n"); + } - // Save it as a DNG - snprintf(fname, 255, "%s/MyDocs/DCIM/photo_%s.dng", getenv("HOME"), + QSettings settings; + char fname[256]; + // Save it as a JPEG + snprintf(fname, 255, "%s/MyDocs/DCIM/photo_%s.jpg", getenv("HOME"), + f.exposureStartTime().toString().c_str()); + writer.saveJPEG(f, fname, 90); + // filewriter doesn't emit a signal when it finishes saving a file so we use a hackish way; + pictureNames.enqueue(QString(fname)); + //qDebug()<< "after enqueue" << pictureNames; + + // Save it as a DNG + snprintf(fname, 255, "%s/MyDocs/DCIM/photo_%s.dng", getenv("HOME"), f.exposureStartTime().toString().c_str()); - writer.saveDNG(f, fname); + if (settings.value("saveDng",true)== true) { + writer.saveDNG(f, fname); + pictureNames.enqueue(QString(fname)); + } } else if (f.shot().id == viewfinder.id) { // update the autofocus and metering algorithms autoFocus.update(f); - autoExpose(&viewfinder, f, sensor.maxGain(), sensor.maxExposure(), 0.5); + autoExpose(&viewfinder, f, sensor.maxGain(), sensor.maxExposure(), 0.5);//, parameters->exposure.compensation); if (parameters->exposure.mode == parameters->exposure.AUTO && parameters->gain.mode == parameters->gain.AUTO) { //we auto expose anyway and then modify the values so nothing left to be done here @@ -188,7 +196,8 @@ void CameraThread::run() { viewfinder.gain = newGain; } } - autoWhiteBalance(&viewfinder, f); + if (parameters->whiteBalance.mode == parameters->whiteBalance.AUTO) autoWhiteBalance(&viewfinder, f); + else viewfinder.whiteBalance = parameters->whiteBalance.value; QString humanReadableExposure; if (viewfinder.exposure >= 1000000) { diff --git a/CameraThread.h b/CameraThread.h index 7b7a437..ba59364 100644 --- a/CameraThread.h +++ b/CameraThread.h @@ -9,6 +9,7 @@ #include #include "CameraParameters.h" #include +#include class OverlayWidget; @@ -52,6 +53,11 @@ public slots: void focus_on() { focus = true; } + + void focus_on_tap() { + QSettings settings; + if(settings.value("focusOnTap",false) == true) focus = true; + } void snapshot() { takeSnapshot = true; diff --git a/qtc_packaging/debian_harmattan/changelog b/qtc_packaging/debian_harmattan/changelog index ad0b3aa..2008644 100644 --- a/qtc_packaging/debian_harmattan/changelog +++ b/qtc_packaging/debian_harmattan/changelog @@ -1,3 +1,8 @@ +rawcam (0.0.6) unstable; urgency=low + * Switching to manual mode from auto keeps current values + + -- Michael Demetriou Sun, 09 Sep 2012 11:23:00 +0300 + rawcam (0.0.5) unstable; urgency=low * diff --git a/rawcam.cpp b/rawcam.cpp index 585c28a..c1e3381 100644 --- a/rawcam.cpp +++ b/rawcam.cpp @@ -12,6 +12,9 @@ #include #include #include +#include +#include +#include #include "CameraThread.h" #include "ExampleOverlayWidget.h" @@ -55,10 +58,12 @@ QString readFile(QString filename) { int main(int argc, char **argv) { QApplication app(argc, argv); + QCoreApplication::setOrganizationName("oob"); + QCoreApplication::setApplicationName("rawcam"); // Make the main window QWidget *window = new QWidget; - QSettings settings("oob", "rawcam"); + QSettings settings; QHBoxLayout *layout = new QHBoxLayout(window); layout->setContentsMargins(0, 0, 0, 0); @@ -86,11 +91,17 @@ int main(int argc, char **argv) { gallery->setObjectName("gallery"); gallery->hide(); + // settings button + QPushButton* settingsBtn = new QPushButton("", window); + settingsBtn->move(780, 340); + settingsBtn->setObjectName("settings"); + // shutter button QPushButton* shutter = new QPushButton(QIcon("/opt/rawcam/shutter.png"),"",window); shutter->setIconSize(QSize(90,90)); shutter->move(750,200); shutter->setObjectName("shutter"); + QObject::connect(shutter, SIGNAL(pressed()), cameraThread, SLOT(focus_on_tap())); QObject::connect(shutter, SIGNAL(released()), cameraThread, SLOT(snapshot())); // t->setStyleSheet("min-height: 100px;" @@ -103,7 +114,7 @@ int main(int argc, char **argv) { MyProximitySensor *prx = new MyProximitySensor(); QObject::connect(prx, SIGNAL(sensorClosed()), cameraThread, SLOT(focus_on())); - QObject::connect(prx, SIGNAL(sensorOpen()), cameraThread, SLOT(focus_off())); +// QObject::connect(prx, SIGNAL(sensorOpen()), cameraThread, SLOT(focus_off())); prx->start(); //exposure info label @@ -302,7 +313,29 @@ int main(int argc, char **argv) { help->setFont(QFont("Nokia Pure Text", 20, 200, false)); help->resize(320,80); help->setObjectName("help"); - + if (settings.value("showHelp",true)==false) help->hide(); + + QDeclarativeView *qmlView = new QDeclarativeView(window); + qmlView->rootContext()->setContextProperty("params", params); + qmlView->setSource(QUrl::fromLocalFile("/opt/rawcam/settings.qml")); + qmlView->hide(); +// qmlView->resize(700,350); + qmlView->move(60, 0); + QObject::connect(settingsBtn,SIGNAL(clicked()), qmlView, SLOT(show())); + //QObject::connect(overlay, SIGNAL(focus(int, int)), qmlView, SLOT(hide())); + + QPropertyAnimation openani(qmlView, "geometry"); + openani.setDuration(200); + openani.setStartValue(QRect(60, 0, 700, 0)); + openani.setEndValue(QRect(60, 0, 700, 350)); + QObject::connect(settingsBtn,SIGNAL(clicked()), &openani, SLOT(start())); + + QPropertyAnimation closeani(qmlView, "geometry"); + closeani.setDuration(200); + closeani.setStartValue(QRect(60, 0, 700, 350)); + closeani.setEndValue(QRect(60, 0, 700, 0)); + QObject::connect(overlay, SIGNAL(focus(int, int)), &closeani, SLOT(start())); + QObject::connect(&closeani, SIGNAL(finished()), qmlView, SLOT(hide())); QTimer::singleShot(8000, help, SLOT(hide())); QObject::connect(help, SIGNAL(clicked()), help, SLOT(hide())); diff --git a/rawcam.pro b/rawcam.pro index 27061d1..ab593d3 100644 --- a/rawcam.pro +++ b/rawcam.pro @@ -8,6 +8,7 @@ INCLUDEPATH += ../../include CONFIG += debug warn_on +QT += declarative CONFIG += qt mobility LIBS += -lpthread -L../.. -ljpeg -lFCam @@ -52,7 +53,7 @@ style.files = style.css \ flashFull.png flashFullGrey.png \ flashHalf.png flashHalfGrey.png \ backCurtain.png backCurtainGrey.png \ - gallery.png settings.png + gallery.png settings.png settings.qml # diff --git a/settings.png b/settings.png index 119f1b3fcebda079ce6d9fc85f9ec1872f5e1e66..714db6b9d84f028e26ea88aea0e585758341832a 100644 GIT binary patch delta 1592 zcmV-82FLm66Wt7uBo78+OGiWi{{a60|De66laVnPe+P6)O+^RX2?+@RA6w~dbpQYb z>PbXFRA}DKnrVy`MG(jT{a8i0Z$xf!K_Fm+4OfV$m|zgmcwit1Mhrv@g7U#H9z^jA z649W15IGWp8cbXbuF4UG7$I^6A*{+`MCA|xS=e3V{`rA^T8#7FPValWY$cO7ucwZ# zuIieqf9i3{0f1{I4UjZUQh!M;{nf(!Hu31EB~?f|Wv+5bdn9d>wADFxNOc83Z(u&K z2{=Q3;Sf*^+y|s;OMxL?$R+9q_5m}2W=ZDf5-2c8(mY8cGN4pS+A3+Yr2XDq>{a3M zno4T!-7Wpw*1P5)NnJDWuaGpyIrl~`Ru~Wbe;u=0TYzam|9rUs&<+>_tOU-*$b27Y z6w1^Auf#B02aK$PeRv}<7dRS`zZ2*l!f0`X!JojLs$&3J`Ngxa7igS>cwB^VH_%O2 z34jJZN?Ld?iAj$ef^UGPst4d*&B8<3_Qe{5coOKMdICTJu-VM-IM5~zaa2U(#{+~6 ze+O0o9ReqJJFo=km=M3aU*I%67l*XUAgoE6q5vNlx&uH_LfWY&%vJ)^6VknA320g%=@v=X`@sv6b_FW3UeZ}f4P%~FN!lT4x1{cpiZUouDrs+0 zfzG-8K)FvmouvK(CfZ!4hB5xLh?}g*lu!a)fwv z^cBFggmfc;Uk&Y|K)DMH?P39+n}Jz@%zBw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zuk`lzrl(JzavJFF z?xuqW50a~^>mL{3@9$4JIXPxe?kg)R+3N{jLI9AXqa&4K#*!$?n0hw1Y#Q|svHz@tZx z(Ad}rolb|ozCMnRY^7x~859Zy$EQ!94wXs;l}ZJ7cXx~JcXoCnF)@)dgIlw4&z4*+ zr;LmYdi(aRSr7dwYiMYoty{MWxixvgoFetEiI+Cwzl6+zOAi|3JMA+EG$g$ z&{rJy>!7jB)zuYYVPOal4~L(hALMd50?"+":"") + (Math.round(expComp.value*100)/100) + " eV" +// font.pixelSize : 17 +// color: "#fff" +// } +// color: "#444444"; +// border.color: "#dddddd" +// radius: 11 +// width: 80 +// height: 30 + +// } +// } +// Row { +// Slider { +// id: expComp +// maximumValue: +4 +// minimumValue: -4 +// value: 0 +// width: 600 +// stepSize: 0.333333333333333 +// valueIndicatorVisible: false +// onValueChanged: params.setExposureCompensation(value); +// } +// } + Component.onCompleted: theme.inverted = true; + } +} diff --git a/style.css b/style.css index 3df9bb1..0444b58 100644 --- a/style.css +++ b/style.css @@ -89,6 +89,13 @@ QPushButton#gallery{ border: 0 none } +QPushButton#settings{ + min-width: 50px; + min-height: 50px; + background: url("/opt/rawcam/settings.png") no-repeat transparent; + border: 0 none +} + QLabel {