diff options
author | Cedric Nugteren <cedric@plumerai.com> | 2023-06-16 12:03:27 +0200 |
---|---|---|
committer | Umang Jain <umang.jain@ideasonboard.com> | 2023-06-18 17:44:29 +0530 |
commit | 5a142438b025b448eedfa67678fe8e169c66f566 (patch) | |
tree | 62441e0068e2c28e1ac9465266210ba42c7a75a4 /src/gstreamer/gstlibcamerasrc.h | |
parent | b9113a86269281ec8cda96140be24e6227abe791 (diff) |
gstreamer: Add enable_auto_focus option to the GStreamer plugin
Cameras such as the PiCam 3 support auto-focus, but the GStreamer plugin
for libcamera does not enable auto-focus. With this patch auto-focus can
be enabled for cameras that support it. By default it is disabled, which
means default behaviour remains unchanged. For cameras that do not
support auto-focus, an error message shows up if auto-focus is enabled.
This was tested on cameras that do not support auto-focus (e.g. PiCam2)
and was tested on a camera that does support auto-focus (PiCam3). The
test involved setting the focus to AfModeContinous and observing it.
However, by not setting "auto-focus-mode" or using AfModeManual as
the "auto-focus-mode" both resulting in auto-focus being disabled.
Bug: https://bugs.libcamera.org/show_bug.cgi?id=188
Signed-off-by: Cedric Nugteren <cedric@plumerai.com>
Reviewed-by: Maarten Lankhorst <dev@lankhorst.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Diffstat (limited to 'src/gstreamer/gstlibcamerasrc.h')
-rw-r--r-- | src/gstreamer/gstlibcamerasrc.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/gstreamer/gstlibcamerasrc.h b/src/gstreamer/gstlibcamerasrc.h index fdea2f10..0a88ba02 100644 --- a/src/gstreamer/gstlibcamerasrc.h +++ b/src/gstreamer/gstlibcamerasrc.h @@ -8,6 +8,8 @@ #pragma once +#include <libcamera/control_ids.h> + #include <gst/gst.h> G_BEGIN_DECLS @@ -17,3 +19,32 @@ G_DECLARE_FINAL_TYPE(GstLibcameraSrc, gst_libcamera_src, GST_LIBCAMERA, SRC, GstElement) G_END_DECLS + +inline GType +gst_libcamera_auto_focus_get_type() +{ + static GType type = 0; + static const GEnumValue values[] = { + { + static_cast<gint>(libcamera::controls::AfModeManual), + "AfModeManual", + "manual-focus", + }, + { + static_cast<gint>(libcamera::controls::AfModeAuto), + "AfModeAuto", + "automatic-auto-focus", + }, + { + static_cast<gint>(libcamera::controls::AfModeContinuous), + "AfModeContinuous", + "continuous-auto-focus", + }, + { 0, NULL, NULL } + }; + + if (!type) + type = g_enum_register_static("GstLibcameraAutoFocus", values); + + return type; +} |