From patchwork Fri Jun 21 16:14:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1502 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 10367600F7 for ; Fri, 21 Jun 2019 18:14:09 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A59B9E0C; Fri, 21 Jun 2019 18:14:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1561133648; bh=Wrhp2qftXZQNb0Emd9HGLPJnBdzpg7oEbuvLHCsDqaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AwWoTgoAz9LHwFYHNdU62HcqR5Y9hZ6qrwFa+KIkPNBDEmcz1qifjuLVkgYNsWFrq QGlrDB1k9yO0ol3TMg9mZ4OlqO/LfBmVM/f7b0qBhEJUSxSueopPVwBUCT868GEO99 Ksqs1jYQpKi+ic1ajeZcVewCiYPHvTKLEYayD+GE= From: Kieran Bingham To: LibCamera Devel Date: Fri, 21 Jun 2019 17:14:01 +0100 Message-Id: <20190621161401.28337-10-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190621161401.28337-1-kieran.bingham@ideasonboard.com> References: <20190621161401.28337-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 9/9] [PoC] QCam: Control demo: A SineWave Brightness X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jun 2019 16:14:09 -0000 As an example of how to add a control to each request, set the Brightness value with a changing value against the buffer time stamps. The Brightness will go up and down following a sine wave to visualise the control effect on the video stream. Signed-off-by: Kieran Bingham --- src/qcam/main_window.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 8c55941f137b..1449e020c815 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -5,6 +5,7 @@ * main_window.cpp - qcam - Main application window */ +#include #include #include #include @@ -219,6 +220,13 @@ void MainWindow::stopCapture() config_.reset(); } +int SineWaveValue(Buffer *buffer) +{ + unsigned int millisec = buffer->timestamp() / 1000000; + constexpr float rads = 2 * M_PI / 180; + return sin(0.036 * rads * millisec) * 100; +} + void MainWindow::requestComplete(Request *request, const std::map &buffers) { @@ -260,6 +268,14 @@ void MainWindow::requestComplete(Request *request, return; } + /* + * A demonstration control, which has a distinct visual effect. + * Scale the brightness up and down with a sine wave. + */ + /* How do we deal with max/min/defaults etc? */ + request->controls()[ManualBrightness] = SineWaveValue(buffer); + request->controls().update(ManualGain, SineWaveValue(buffer)); + request->setBuffers(buffers); camera_->queueRequest(request); }