Skip to content

Commit

Permalink
Merge pull request #194 from TzuHuanTai/193-fix-autofocus-is-missing-…
Browse files Browse the repository at this point in the history
…when-using-libcamera

fix: autofocus is missing when using libcamera
  • Loading branch information
TzuHuanTai authored Oct 13, 2024
2 parents 8b9fa59 + 48dbd82 commit 0be4b72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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

0 comments on commit 0be4b72

Please sign in to comment.