Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: autofocus is missing when using libcamera #194

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/capturer/libcamera_capturer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ std::shared_ptr<LibcameraCapturer> LibcameraCapturer::Create(Args args) {
auto ptr = std::make_shared<LibcameraCapturer>(args);
ptr->Init(args.device);
ptr->SetFps(args.fps)
.SetAutofocus()
.SetRotation(args.rotation_angle)
.SetFormat(args.width, args.height)
.StartCapture();
Expand Down Expand Up @@ -96,6 +97,14 @@ LibcameraCapturer &LibcameraCapturer::SetFps(int fps) {
return *this;
}

LibcameraCapturer &LibcameraCapturer::SetAutofocus() {
controls_.set(libcamera::controls::AfMode, libcamera::controls::AfModeEnum::AfModeContinuous);

DEBUG_PRINT(" AutoFocus: %d", libcamera::controls::AfModeEnum::AfModeContinuous);

return *this;
}

LibcameraCapturer &LibcameraCapturer::SetRotation(int angle) {
if (angle == 90) {
camera_config_->orientation = libcamera::Orientation::Rotate90;
Expand Down
1 change: 1 addition & 0 deletions src/capturer/libcamera_capturer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class LibcameraCapturer : public VideoCapturer {

LibcameraCapturer &SetFormat(int width, int height);
LibcameraCapturer &SetFps(int fps);
LibcameraCapturer &SetAutofocus();
LibcameraCapturer &SetRotation(int angle);

void Init(std::string device);
Expand Down