From patchwork Thu Oct 19 14:01:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19159 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 774DBC32BA for ; Thu, 19 Oct 2023 14:02:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 437C062992; Thu, 19 Oct 2023 16:02:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1697724122; bh=Bc1cx3+5KkrNkgSxu51mTmO/e8HEdedyOAAJ9VgfzTM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=E240sUaNA6zWt3ek2KSDUdCux7VZXyBrwS7wbVheX/pcb0jbUagDsYLAPaXZ2lN1P pgxE2uh+h2ILJUsZN+n04bcsRkb7nYOqjOY5uF2Ih0n6vDAYAW5EUESdg7sNBmpaVP vpInLIT66+IEkxNSN6UDA/GZZb9BbIMHZRJhN4qoMvzXWM6IOV8h95X1pKTXGd/uVY fsBAoCmBKpDMgcHWV8zuKutAcuZ7nazQmvQkUAk4hgO/zwt2AWz/QBj7VZ6q4eJ9wE MkAluzWmM3ekpCidsDEygtT411hs5VBh3hIJUOtNVrHViAwHCOyuAQBqa+lQJuObKT 4HxrHQuiRlNFg== 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 4430B62992 for ; Thu, 19 Oct 2023 16:01:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rxqeuSLP"; dkim-atps=neutral Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 308F61211; Thu, 19 Oct 2023 16:01:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1697724106; bh=Bc1cx3+5KkrNkgSxu51mTmO/e8HEdedyOAAJ9VgfzTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rxqeuSLPgygtplafKhMKBlSQYqqp5M1DF2rs1zbFDF9S89OtdInXzT/Sup48Q3jn1 g727eOHamhndky6V5ff02b/GPkvPGNJC17KR9yq2iuXhjBnhPk2FQvipUQQpZpXyTW GvPadV2rjl9j0rI4HZiby5vhhTFKlG/11A4YKunc= To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Oct 2023 16:01:32 +0200 Message-ID: <20231019140133.32090-12-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019140133.32090-1-jacopo.mondi@ideasonboard.com> References: <20231019140133.32090-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 11/12] apps: cam: Add option to set stream orientation 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a '--orientation|-o' option to the cam test application to set an orientation to the image stream. Supported values are the ones obtained by applying flips to the camera sensor: - rot0: no rotation - rot180: rotate 180 degrees - flip: vertical flip - mirror: horizontal flip Signed-off-by: Jacopo Mondi Reviewed-by: David Plowman --- src/apps/cam/camera_session.cpp | 18 ++++++++++++++++++ src/apps/cam/main.cpp | 5 +++++ src/apps/cam/main.h | 1 + 3 files changed, 24 insertions(+) diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp index 066e397b5f47..8447f932dfc7 100644 --- a/src/apps/cam/camera_session.cpp +++ b/src/apps/cam/camera_session.cpp @@ -65,6 +65,24 @@ CameraSession::CameraSession(CameraManager *cm, return; } + if (options_.isSet(OptOrientation)) { + std::string orientOpt = options_[OptOrientation].toString(); + static const std::map orientations{ + { "rot0", libcamera::Orientation::Rotate0 }, + { "rot180", libcamera::Orientation::Rotate180 }, + { "mirror", libcamera::Orientation::Rotate0Mirror }, + { "flip", libcamera::Orientation::Rotate180Mirror }, + }; + + auto orientation = orientations.find(orientOpt); + if (orientation == orientations.end()) { + std::cerr << "Invalid orientation " << orientOpt << std::endl; + return; + } + + config->orientation = orientation->second; + } + /* Apply configuration if explicitly requested. */ if (StreamKeyValueParser::updateConfiguration(config.get(), options_[OptStream])) { diff --git a/src/apps/cam/main.cpp b/src/apps/cam/main.cpp index 5d8a57bc14e5..179cc3769b03 100644 --- a/src/apps/cam/main.cpp +++ b/src/apps/cam/main.cpp @@ -133,6 +133,11 @@ int CamApp::parseOptions(int argc, char *argv[]) "Capture until interrupted by user or until frames captured", "capture", ArgumentOptional, "count", false, OptCamera); + + parser.addOption(OptOrientation, OptionString, + "Desired image orientation (rot0, rot180, mirror, flip)", + "orientation", ArgumentRequired, "orientation", false, + OptCamera); #ifdef HAVE_KMS parser.addOption(OptDisplay, OptionString, "Display viewfinder through DRM/KMS on specified connector", diff --git a/src/apps/cam/main.h b/src/apps/cam/main.h index 526aecece3f3..4aa959b32e13 100644 --- a/src/apps/cam/main.h +++ b/src/apps/cam/main.h @@ -17,6 +17,7 @@ enum { OptList = 'l', OptListProperties = 'p', OptMonitor = 'm', + OptOrientation = 'o', OptSDL = 'S', OptStream = 's', OptListControls = 256,