Patch Detail
Show a patch.
GET /api/patches/3660/?format=api
{ "id": 3660, "url": "https://patchwork.libcamera.org/api/patches/3660/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3660/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200502021045.785979-4-niklas.soderlund@ragnatech.se>", "date": "2020-05-02T02:10:45", "name": "[libcamera-devel,v3,3/3] qcam: Add RAW capture support", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "9291e6099cdb1042bc8a608acaad1be66f9d540d", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3660/mbox/", "series": [ { "id": 869, "url": "https://patchwork.libcamera.org/api/series/869/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=869", "date": "2020-05-02T02:10:42", "name": "qcam: Add RAW capture support", "version": 3, "mbox": "https://patchwork.libcamera.org/series/869/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3660/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3660/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 361CF61459\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 2 May 2020 04:11:24 +0200 (CEST)", "from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 3806cd68-8c1a-11ea-aeed-005056917f90;\n\tSat, 02 May 2020 04:11:22 +0200 (CEST)" ], "X-Halon-ID": "3806cd68-8c1a-11ea-aeed-005056917f90", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 2 May 2020 04:10:45 +0200", "Message-Id": "<20200502021045.785979-4-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.26.2", "In-Reply-To": "<20200502021045.785979-1-niklas.soderlund@ragnatech.se>", "References": "<20200502021045.785979-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 3/3] qcam: Add RAW capture support", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "X-List-Received-Date": "Sat, 02 May 2020 02:11:25 -0000" }, "content": "Add a toolbar button that captures RAW data to disk. The button is only\nenabled if the camera is configured to provide a raw stream to the\napplication.\n\nOnly when the capture action is triggered will a request with a raw\nbuffer be queued to the camera.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n* Changes since v2\n- Use a file dialog\n- Make DNG optional depending on libtiff\n---\n src/qcam/assets/feathericons/feathericons.qrc | 1 +\n src/qcam/main_window.cpp | 64 ++++++++++++++++++-\n src/qcam/main_window.h | 4 ++\n 3 files changed, 68 insertions(+), 1 deletion(-)", "diff": "diff --git a/src/qcam/assets/feathericons/feathericons.qrc b/src/qcam/assets/feathericons/feathericons.qrc\nindex c4eb7a0be6884373..fc8213928ece70ea 100644\n--- a/src/qcam/assets/feathericons/feathericons.qrc\n+++ b/src/qcam/assets/feathericons/feathericons.qrc\n@@ -1,5 +1,6 @@\n <!DOCTYPE RCC><RCC version=\"1.0\">\n <qresource>\n+<file>./aperture.svg</file>\n <file>./camera-off.svg</file>\n <file>./play-circle.svg</file>\n <file>./save.svg</file>\ndiff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 0bd9f3583ea4f6d4..458da479a9b21b73 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -27,6 +27,10 @@\n #include <libcamera/camera_manager.h>\n #include <libcamera/version.h>\n \n+#if HAVE_TIFF\n+#include \"dng_writer.h\"\n+#endif\n+\n using namespace libcamera;\n \n /**\n@@ -48,7 +52,8 @@ public:\n };\n \n MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n-\t: options_(options), cm_(cm), allocator_(nullptr), isCapturing_(false)\n+\t: saveRaw_(nullptr), options_(options), cm_(cm), allocator_(nullptr),\n+\t isCapturing_(false), captureRaw_(false)\n {\n \tint ret;\n \n@@ -144,6 +149,16 @@ int MainWindow::createToolbars()\n \taction->setShortcut(QKeySequence::SaveAs);\n \tconnect(action, &QAction::triggered, this, &MainWindow::saveImageAs);\n \n+#if HAVE_TIFF\n+\t/* Save Raw action. */\n+\taction = toolbar_->addAction(QIcon::fromTheme(\"camera-photo\",\n+\t\t\t\t\t\t QIcon(\":aperture.svg\")),\n+\t\t\t\t \"Save Raw\");\n+\taction->setEnabled(false);\n+\tconnect(action, &QAction::triggered, this, &MainWindow::captureRaw);\n+\tsaveRaw_ = action;\n+#endif\n+\n \treturn 0;\n }\n \n@@ -369,6 +384,10 @@ int MainWindow::startCapture()\n \n \tadjustSize();\n \n+\t/* Configure the raw capture button. */\n+\tif (saveRaw_)\n+\t\tsaveRaw_->setEnabled(config_->size() == 2);\n+\n \t/* Allocate and map buffers. */\n \tallocator_ = new FrameBufferAllocator(camera_);\n \tfor (StreamConfiguration &config : *config_) {\n@@ -474,6 +493,9 @@ void MainWindow::stopCapture()\n \t\treturn;\n \n \tviewfinder_->stop();\n+\tif (saveRaw_)\n+\t\tsaveRaw_->setEnabled(false);\n+\tcaptureRaw_ = false;\n \n \tint ret = camera_->stop();\n \tif (ret)\n@@ -524,6 +546,31 @@ void MainWindow::saveImageAs()\n \twriter.write(image);\n }\n \n+void MainWindow::captureRaw()\n+{\n+\tcaptureRaw_ = true;\n+}\n+\n+void MainWindow::processRaw(FrameBuffer *buffer)\n+{\n+#if HAVE_TIFF\n+\tQString defaultPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);\n+\tQString filename = QFileDialog::getSaveFileName(this, \"Save DNG\", defaultPath,\n+\t\t\t\t\t\t\t\"DNG Files (*.dng)\");\n+\n+\tif (filename != \"\") {\n+\t\tconst MappedBuffer &mapped = mappedBuffers_[buffer];\n+\t\tDNGWriter::write(filename.toStdString().c_str(), camera_.get(),\n+\t\t\t\t rawStream_->configuration(), buffer,\n+\t\t\t\t mapped.memory);\n+\t}\n+#endif\n+\t{\n+\t\tQMutexLocker locker(&mutex_);\n+\t\tfreeBuffers_[rawStream_].enqueue(buffer);\n+\t}\n+}\n+\n /* -----------------------------------------------------------------------------\n * Request Completion Handling\n */\n@@ -566,6 +613,9 @@ void MainWindow::processCapture()\n \t/* Process buffers. */\n \tif (buffers.count(vfStream_))\n \t\tprocessViewfinder(buffers[vfStream_]);\n+\n+\tif (buffers.count(rawStream_))\n+\t\tprocessRaw(buffers[rawStream_]);\n }\n \n void MainWindow::processViewfinder(FrameBuffer *buffer)\n@@ -598,5 +648,17 @@ void MainWindow::queueRequest(FrameBuffer *buffer)\n \n \trequest->addBuffer(vfStream_, buffer);\n \n+\tif (captureRaw_) {\n+\t\tQMutexLocker locker(&mutex_);\n+\n+\t\tif (!freeBuffers_[rawStream_].isEmpty()) {\n+\t\t\trequest->addBuffer(rawStream_,\n+\t\t\t\t\t freeBuffers_[rawStream_].dequeue());\n+\t\t\tcaptureRaw_ = false;\n+\t\t} else {\n+\t\t\tqWarning() << \"No free buffer available for RAW capture\";\n+\t\t}\n+\t}\n+\n \tcamera_->queueRequest(request);\n }\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex 4856ecc10729159c..295ecc537e9d45bf 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -55,6 +55,8 @@ private Q_SLOTS:\n \tvoid toggleCapture(bool start);\n \n \tvoid saveImageAs();\n+\tvoid captureRaw();\n+\tvoid processRaw(FrameBuffer *buffer);\n \n \tvoid queueRequest(FrameBuffer *buffer);\n \n@@ -75,6 +77,7 @@ private:\n \tQToolBar *toolbar_;\n \tQAction *startStopAction_;\n \tQComboBox *cameraCombo_;\n+\tQAction *saveRaw_;\n \tViewFinder *viewfinder_;\n \n \tQIcon iconPlay_;\n@@ -96,6 +99,7 @@ private:\n \n \t/* Capture state, buffers queue and statistics */\n \tbool isCapturing_;\n+\tbool captureRaw_;\n \tStream *vfStream_;\n \tStream *rawStream_;\n \tstd::map<Stream *, QQueue<FrameBuffer *>> freeBuffers_;\n", "prefixes": [ "libcamera-devel", "v3", "3/3" ] }