From patchwork Tue Jun 20 14:29:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18754 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 7EB0EC32AA for ; Tue, 20 Jun 2023 14:29:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 39F27628C3; Tue, 20 Jun 2023 16:29:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1687271364; bh=oYhF7hyz9pKMIn/KeZkRwGYNadMjT4MXJrnrXqTEcBU=; 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=SGfXIaACgHPKYXJxdg+v1zC3NPPI3DvBQHN6CAlkSN49SPQx65hyBLUXiWzG5ioWL T2IlT002yYQsVd7e3RY3914tn5gLSsKM/Zw/FG+1dJDNeYCu27UOEjZfK7kBaVVOkQ OIgxHD3dXsEO+cF1TLe94sAKUqYkbxK3baZBqnxl/ToJi6MnzZbMJqFHJzLOYqln+g AjmiRmYAmsSlX9vjZHUPK4Gf0NKzxsfJpHsOJYyZxhnB9vAmypl1vRU3RaPFy4h550 Du8kz0U2cfYtENlW7SHTECS8I78mQ9pc7CTmqJvFfibcaEBmtXaTSg8SA8TWMy1BGN XrQw1n0P2Yoaw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 00401628C7 for ; Tue, 20 Jun 2023 16:29:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="viDAeOYQ"; dkim-atps=neutral Received: from uno.lan (unknown [IPv6:2001:b07:5d2e:52c9:72c3:346:a663:c82d]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 004B810FE; Tue, 20 Jun 2023 16:28:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1687271325; bh=oYhF7hyz9pKMIn/KeZkRwGYNadMjT4MXJrnrXqTEcBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=viDAeOYQi4So6cuB/f12OXwHeihvDRrapjfuikxDX6167pVpgRZH3t2MzIGGgD4tQ /cXvtNnGgBLTRi3LC3fDxGlL8emAAsvaL2AMuGCBt3WcmjcqE+MrUpq5D9BtdOzzLS ZwFt55sOVJ5cgqeGt33nR7EyDb1rs1gAAqtYBujc= To: libcamera-devel@lists.libcamera.org Date: Tue, 20 Jun 2023 16:29:04 +0200 Message-Id: <20230620142904.72600-5-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230620142904.72600-1-jacopo.mondi@ideasonboard.com> References: <20230620142904.72600-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 4/4] 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: - rot180: Rotate 180 degrees - flip: vertical flip - mirror: horizontal flip Signed-off-by: Jacopo Mondi --- src/apps/cam/camera_session.cpp | 17 +++++++++++++++++ src/apps/cam/main.cpp | 5 +++++ src/apps/cam/main.h | 1 + 3 files changed, 23 insertions(+) -- 2.40.1 diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp index 8fcec6304d66..2d6a1440cde2 100644 --- a/src/apps/cam/camera_session.cpp +++ b/src/apps/cam/camera_session.cpp @@ -65,6 +65,23 @@ CameraSession::CameraSession(CameraManager *cm, return; } + if (options_.isSet(OptOrientation)) { + std::string orient = options_[OptOrientation].toString(); + if (orient == "rot180") { + config->orientation = + libcamera::CameraConfiguration::rotate180; + } else if (orient == "mirror") { + config->orientation = + libcamera::CameraConfiguration::flipRotate0; + } else if (orient == "flip") { + config->orientation = + libcamera::CameraConfiguration::flipRotate180; + } else { + std::cerr << "Invalid orientation " << orient << std::endl; + return; + } + } + /* 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..8698d5eedcf8 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, + "The camera stream image orientation (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,