From patchwork Tue Sep 22 10:04:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 9704 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C1619BF01C for ; Tue, 22 Sep 2020 10:04:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8362962FE5; Tue, 22 Sep 2020 12:04:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="qjMt04Ij"; dkim-atps=neutral Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA26062FDA for ; Tue, 22 Sep 2020 12:04:12 +0200 (CEST) Received: by mail-wm1-x332.google.com with SMTP id e17so2708434wme.0 for ; Tue, 22 Sep 2020 03:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L4AmPElkGZryXc7UPUCU4tjAIGgErk1azYH9/WZBAVw=; b=qjMt04IjzzAH8CRq5IAJVtAMdbd/+Ktp0GqG0pkRIR25oqdr2kC9SLjTgC/K1Ro70n YqcfT5VdDrue6tL1gqkmGDL+qbvTX8PfkrZfxbrc5AcPWGIBqOXkHO52S1zRYU9sGFlv fQo7f0rSPQc0vdYaZBBqsXnYfGO0EpJC4pxVO9/TdCRBEgN+ro05GiD5YSYDPJWx+EFI HzajpYnhbLWlPItj3HPFJd2hRF5PkMezD1Z6GqPIBURePIa6/4xXIeNtaUkLIftJR2mt iE4iiTh9PLNbPFzVUT/Z3P0w6YfHbIj+DBEnVYGZC8K492LZSuk0LlfmNUswsjR4fnej 08ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L4AmPElkGZryXc7UPUCU4tjAIGgErk1azYH9/WZBAVw=; b=jNqWVEHm1eEjq0899VdTvDFWDZ3zwlozxyGwlRSLOYjm0Egui3QyJ2GjIVApt9Vr1X LdcEhToyLGPvlZpIeeCAZwbrUQ1avvyOU3w1HwAxW4VekAp1j1QW/CJM/wFe6uZJpYmP +m7gUEuPgEQgfRizKcn8xLnF4/Tn6wSZBmWA6KvUbHXGNQidWtwZF8AsWDNf6zuIGevU ihSAgi7AUTmZYyrVg3B6T0HRtZFwxzTTl/UNDhHomJZsqi3fjIVwtL1M/ZdZkGaCPqQy rt1xea1FDVPLVrbf2KCmyxMn7aYVsewFk4YsnlbMPnnKSY26y1nYoEJZ6QqBHhui7MVn 683A== X-Gm-Message-State: AOAM532XC7cJytrEUvEEUiPQDcj3Eyt88ClYTloZurFlHYp3j2FUphfx edYCyidzyI88gPRc8fF9gYTVub6BtZv7iw== X-Google-Smtp-Source: ABdhPJyzX2j1dAqIIsbBfz62f0/dNuXPS3gGkwHrcYPrXsHBOM4MgmoW6NuVRI/Oq96yRr2avbG6LA== X-Received: by 2002:a05:600c:2909:: with SMTP id i9mr151948wmd.160.1600769052078; Tue, 22 Sep 2020 03:04:12 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id g14sm26369595wrv.25.2020.09.22.03.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 03:04:11 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Sep 2020 11:04:00 +0100 Message-Id: <20200922100400.30766-7-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200922100400.30766-1-david.plowman@raspberrypi.com> References: <20200922100400.30766-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 6/6] qcam: Add command line option to test IspCrop control X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This allows the user to request digital zoom by adding, for example, "-z 0.25,0.25,0.5,0.5" which would give a 2x zoom, still centred in the middle of the image. Signed-off-by: David Plowman --- src/qcam/main.cpp | 3 +++ src/qcam/main_window.cpp | 20 ++++++++++++++++++++ src/qcam/main_window.h | 1 + 3 files changed, 24 insertions(+) diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp index f60d3ce..9f8435d 100644 --- a/src/qcam/main.cpp +++ b/src/qcam/main.cpp @@ -38,6 +38,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[]) "renderer", ArgumentRequired, "renderer"); parser.addOption(OptStream, &streamKeyValue, "Set configuration of a camera stream", "stream", true); + parser.addOption(OptZoom, OptionString, + "Specify crop for digital zoom as fractions x,y,width,height e.g. 0.25,0.25,0.5,0.5", + "zoom", ArgumentRequired, "zoom"); OptionsParser::Options options = parser.parse(argc, argv); if (options.isSet(OptHelp)) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 985743f..fb54b15 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -25,6 +25,8 @@ #include #include +#include +#include #include #include "dng_writer.h" @@ -502,6 +504,24 @@ int MainWindow::startCapture() requests.push_back(request); } + /* Set up digital zoom if it was requested on the command line. */ + if (options_.isSet(OptZoom)) { + std::string zoom = options_[OptZoom].toString(); + float x, y, width, height; + + if (sscanf(zoom.c_str(), "%f,%f,%f,%f", &x, &y, &width, &height) == 4) { + Size sensorArea = camera_->properties().get(properties::SensorOutputSize); + Rectangle crop(x * sensorArea.width, + y * sensorArea.height, + width * sensorArea.width, + height * sensorArea.height); + + requests.front()->controls().set(controls::IspCrop, crop); + } else { + qWarning() << "Invalid zoom values - ignoring"; + } + } + /* Start the title timer and the camera. */ titleTimer_.start(2000); frameRateInterval_.start(); diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 5c61a4d..e46eb70 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -39,6 +39,7 @@ enum { OptHelp = 'h', OptRenderer = 'r', OptStream = 's', + OptZoom = 'z', }; class CaptureRequest