From patchwork Wed Aug 25 10:29:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 13484 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 06013BD87D for ; Wed, 25 Aug 2021 10:29:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 93C766890C; Wed, 25 Aug 2021 12:29:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Y/48r2fS"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EEEEA60504 for ; Wed, 25 Aug 2021 12:29:41 +0200 (CEST) Received: from Monstersaurus.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9D5686EE; Wed, 25 Aug 2021 12:29:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1629887381; bh=3oKST/urWWgQbReo2GFUkIWeAC4wwOMgBkN8KLOj5V0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y/48r2fStUFgEHoUCGRjuXpvtPlnZd/bhASTrcSvBJ5SYw/Kpk3pqbNNxxD68br3e 8J6mQWxHah+420UWSk0paXbTl2vidAPZOkJGtBMmhBPKi+sW+L+jLBDPr1s5ntPaIY B35mNZWO8GeucHBIt9K65DJixReJfZUF0vIpJVDk= From: Kieran Bingham To: libcamera devel Date: Wed, 25 Aug 2021 11:29:33 +0100 Message-Id: <20210825102937.3740405-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210825102937.3740405-1-kieran.bingham@ideasonboard.com> References: <20210825102937.3740405-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] Documentation: application-developer: Remove irrelevant TODO 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 TODO has no real meaning, and isn't an action. Remove it. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Documentation/guides/application-developer.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index fb6a80a57eb7..b79241bd9317 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -7,8 +7,6 @@ This tutorial shows how to create a C++ application that uses libcamera to interface with a camera on a system, capture frames from it for 3 seconds, and write metadata about the frames to standard out. -.. TODO: Check how much of the example code runs before camera start etc? - Application skeleton -------------------- From patchwork Wed Aug 25 10:29:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 13485 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 2CCB0BD87D for ; Wed, 25 Aug 2021 10:29:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8126F688A5; Wed, 25 Aug 2021 12:29:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SVtyXCkW"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 40A4560504 for ; Wed, 25 Aug 2021 12:29:42 +0200 (CEST) Received: from Monstersaurus.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E5C2024F; Wed, 25 Aug 2021 12:29:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1629887382; bh=+77L0Ce0EN4tecp0krQE96tYw1/P0PiPYN5IedfGpvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SVtyXCkWLYUgKJaOq26oH6miy45MfdTJhT1k4+cIgMA+E33D6WBlV8IKvmHe8nP1X CxW8GMfvWZ1soT/xuAunaog1uPT60h9jeSDrYftCu9Nz3LnyalK9sKookrb5ZIciij FIpJFYmxP57WxcwweQABwjtJ3qbF5EW4/9HxZ6sk= From: Kieran Bingham To: libcamera devel Date: Wed, 25 Aug 2021 11:29:34 +0100 Message-Id: <20210825102937.3740405-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210825102937.3740405-1-kieran.bingham@ideasonboard.com> References: <20210825102937.3740405-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] Documentation: application-developer: Clean up build instructions 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" The build and run instructions read as if meson is the only way to compile the application. Although this is recommended, it is not required - adapt the language to fit better. While here, fix the naming of the simple_cam meson object to match the other usages of 'simple-cam'. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Documentation/guides/application-developer.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index b79241bd9317..442d8e6a512e 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -563,8 +563,8 @@ uses, so needs to do the following: Build and run instructions -------------------------- -To build the application, use the `Meson build system`_ which is also the -official build system of the libcamera library. +To build the application, we recommend that you use the `Meson build system`_ +which is also the official build system of the libcamera library. Make sure both ``meson`` and ``libcamera`` are installed in your system. Please refer to your distribution documentation to install meson and install the most @@ -617,7 +617,7 @@ accordingly. In this example, the application file has been named project('simple-cam', 'cpp') - simpler_cam = executable('simple-cam', + simple_cam = executable('simple-cam', 'simple-cam.cpp', dependencies: dependency('libcamera', required : true)) From patchwork Wed Aug 25 10:29:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 13486 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 8CB2FC3241 for ; Wed, 25 Aug 2021 10:29:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5837568915; Wed, 25 Aug 2021 12:29:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="I/M75Ilo"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8392960504 for ; Wed, 25 Aug 2021 12:29:42 +0200 (CEST) Received: from Monstersaurus.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2F4956EE; Wed, 25 Aug 2021 12:29:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1629887382; bh=tfqZw3AByu5F5pLe+NPcrF7kuScVn8SeUIuTT9vH+sY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I/M75IlojjGcW81gYvsGgv1W1wIjknkuH9k73YyTqIRy3S2ngFPtQ+YyxaaAb8Atz gYKiWciA1MEPR46EtBSD2RQGKIhjrBIj2ER2uIocJaKzMiMyYHDULK+GI1Mzzihx7/ Kc1UHuqH/zl7Qg3P8hu7ZT9usCX379eKCMzJ3oE4= From: Kieran Bingham To: libcamera devel Date: Wed, 25 Aug 2021 11:29:35 +0100 Message-Id: <20210825102937.3740405-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210825102937.3740405-1-kieran.bingham@ideasonboard.com> References: <20210825102937.3740405-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] Documentation: application-developer: Recommend unique_ptr for CameraManager 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" The CameraManager object should be deleted when it is no longer used to prevent it from leaking. When the application closes, the memory will be released, but it would show up in reports from memory validation tools such as valgrind if not handled correctly. Recommend best-practices in the guide and ensure it is automatically cleaned up when the CameraManager goes out of scope. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Documentation/guides/application-developer.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index 442d8e6a512e..e2ed79d5173e 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -61,11 +61,15 @@ variable for the camera to support the event call back later: std::shared_ptr camera; Create a Camera Manager instance at the beginning of the main function, and then -start it. An application should only create a single Camera Manager instance. +start it. An application must only create a single Camera Manager instance. + +The CameraManager can be stored in a unique_ptr to automate deleting the +instance when it is no longer used, but care must be taken to ensure all cameras +are released explicitly. .. code:: cpp - CameraManager *cm = new CameraManager(); + std::unique_ptr cm = std::make_unique(); cm->start(); During the application initialization, the Camera Manager is started to @@ -560,6 +564,9 @@ uses, so needs to do the following: return 0; +In this instance the CameraManager will automatically be deleted by the +unique_ptr implementation when it goes out of scope. + Build and run instructions -------------------------- From patchwork Wed Aug 25 10:29:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 13487 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 2CB7EBD87D for ; Wed, 25 Aug 2021 10:29:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E4D1E688E4; Wed, 25 Aug 2021 12:29:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tu0VRdyO"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C4FE160504 for ; Wed, 25 Aug 2021 12:29:42 +0200 (CEST) Received: from Monstersaurus.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6EBB024F; Wed, 25 Aug 2021 12:29:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1629887382; bh=DXDjloYdW+OI6qoiD2w/P7rtA84Ry682Oj9x9Kctvew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tu0VRdyOthyCgrMzNYhkIlPMvDUhhyHTMks7clwrbDMoi9h9SacfZ1vN+OmdbaAgv b+Yy289uIHso0CNMVGfPjtvGADd7WjWeSxro+qhSTRF9FbGIOujO2g5gZZ5qg3fCZy mo0i+n1fO4r30MxSYZJRZuN3CMN0vS19s8nIN8Yw= From: Kieran Bingham To: libcamera devel Date: Wed, 25 Aug 2021 11:29:36 +0100 Message-Id: <20210825102937.3740405-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210825102937.3740405-1-kieran.bingham@ideasonboard.com> References: <20210825102937.3740405-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] Documentation: application-developer: Fix reference to cam BufferWriter 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" The BufferWriter class has been replaced by the FileSink. Adapt the reference, to match the source code. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Documentation/guides/application-developer.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index e2ed79d5173e..5f43af9e5a7a 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -466,10 +466,10 @@ and the bytes used by planes. A completed buffer contains of course image data which can be accessed through the per-plane dma-buf file descriptor transported by the ``FrameBuffer`` instance. An example of how to write image data to disk is available in the -`BufferWriter class`_ which is a part of the ``cam`` utility application in the +`FileSink class`_ which is a part of the ``cam`` utility application in the libcamera repository. -.. _BufferWriter class: https://git.linuxtv.org/libcamera.git/tree/src/cam/buffer_writer.cpp +.. _FileSink class: https://git.linuxtv.org/libcamera.git/tree/src/cam/file_sink.cpp With the handling of this request completed, it is possible to re-use the buffers by adding them to a new ``Request`` instance with their matching From patchwork Wed Aug 25 10:29:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 13488 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 9C1F2C3241 for ; Wed, 25 Aug 2021 10:29:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 584FE6890C; Wed, 25 Aug 2021 12:29:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MTVgvo1l"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 125D8688A3 for ; Wed, 25 Aug 2021 12:29:43 +0200 (CEST) Received: from Monstersaurus.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ADB706EE; Wed, 25 Aug 2021 12:29:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1629887382; bh=66BFXUTKEQNCZgcAoGPUwsjh8GpNXpEXc1zL94VzaWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MTVgvo1lPOT0XFyK+W59Wyc1SW+JfRPr0Td52NDaBCU1EjXJNzKQUT3EJDG3rNt7d yZ6R6SGwD0zOzfVhvb2F3jfNM49ftwJ+3SmpUxFoFLQ7mThhY69plWEKpNapLG9Gix mwEtUB4bXhAhPQrcK4Br8tLJdkik5VJ5HTifxA5c= From: Kieran Bingham To: libcamera devel Date: Wed, 25 Aug 2021 11:29:37 +0100 Message-Id: <20210825102937.3740405-6-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210825102937.3740405-1-kieran.bingham@ideasonboard.com> References: <20210825102937.3740405-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] Documentation: application-developer: Fix up spelling error 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" Fix a minor spelling error. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Documentation/guides/application-developer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index 5f43af9e5a7a..84c3d95608ab 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -419,7 +419,7 @@ and the bytes used, as described in the `FrameMetadata`_ documentation. const FrameMetadata &metadata = buffer->metadata(); } -For this example application, inside the ``for`` loop from above, we ca print +For this example application, inside the ``for`` loop from above, we can print the Frame sequence number and details of the planes. .. code:: cpp