summaryrefslogtreecommitdiff
path: root/src/apps
diff options
context:
space:
mode:
Diffstat (limited to 'src/apps')
-rw-r--r--src/apps/cam/camera_session.cpp18
-rw-r--r--src/apps/cam/main.cpp5
-rw-r--r--src/apps/cam/main.h1
3 files changed, 24 insertions, 0 deletions
diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
index 066e397b..8447f932 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<std::string, libcamera::Orientation> 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 5d8a57bc..179cc376 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 <count> 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 526aecec..4aa959b3 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,