From b4d0f0c3338186aaeec73c6bdf4f7174c613e3eb Mon Sep 17 00:00:00 2001 From: lxowalle Date: Wed, 24 Jul 2024 11:41:01 +0800 Subject: [PATCH] * add set_awb to config white balance --- components/vision/include/maix_camera.hpp | 15 +++++++++++++-- .../vision/port/linux/maix_camera_v4l2.hpp | 5 +++++ components/vision/src/maix_camera.cpp | 17 +++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/components/vision/include/maix_camera.hpp b/components/vision/include/maix_camera.hpp index 77a5e678..c181cb62 100644 --- a/components/vision/include/maix_camera.hpp +++ b/components/vision/include/maix_camera.hpp @@ -338,8 +338,9 @@ namespace maix::camera int saturation(int value = -1); /** - * Set/Get white balance mode + * Set/Get white balance mode (deprecated interface) * @attention This method will affect the isp and thus the image, so please be careful with it. + * This interface may be deprecated in the future, and there may be incompatibilities in the definition of the parameters of the new interface * @param value value = 0, means set white balance to auto mode, value = 1, means set white balance to manual mode, default is auto mode. * @return returns awb mode * @maixpy maix.camera.Camera.awb_mode @@ -347,8 +348,18 @@ namespace maix::camera int awb_mode(int value = -1); /** - * Set/Get exposure mode + * Set/Get white balance mode + * @attention This method will affect the isp and thus the image, so please be careful with it. + * @param value value = 0, means set white balance to manual mode, value = 1, means set white balance to auto mode, default is auto mode. + * @return returns awb mode + * @maixpy maix.camera.Camera.set_awb + */ + int set_awb(int mode = -1); + + /** + * Set/Get exposure mode (deprecated interface) * @attention This method will affect the isp and thus the image, so please be careful with it. + * This interface may be deprecated in the future, and there may be incompatibilities in the definition of the parameters of the new interface * @param value value = 0, means set exposure to auto mode, value = 1, means set exposure to manual mode, default is auto mode. * @return returns exposure mode * @maixpy maix.camera.Camera.exp_mode diff --git a/components/vision/port/linux/maix_camera_v4l2.hpp b/components/vision/port/linux/maix_camera_v4l2.hpp index 9df62157..fc6f9ea4 100644 --- a/components/vision/port/linux/maix_camera_v4l2.hpp +++ b/components/vision/port/linux/maix_camera_v4l2.hpp @@ -1031,6 +1031,11 @@ namespace maix::camera return -1; } + int set_awb(int value) + { + return -1; + } + int exp_mode(int value) { return -1; diff --git a/components/vision/src/maix_camera.cpp b/components/vision/src/maix_camera.cpp index 9177a558..cb6273f9 100644 --- a/components/vision/src/maix_camera.cpp +++ b/components/vision/src/maix_camera.cpp @@ -456,6 +456,23 @@ namespace maix::camera return _impl->awb_mode(value); } + int Camera::set_awb(int value) { + if (_impl == NULL) + return err::ERR_NOT_INIT; + + if (!this->is_opened()) { + return err::ERR_NOT_OPEN; + } + + if (value == 0) { + value = 1; + } else if (value > 0) { + value = 0; + } + + return _impl->awb_mode(value) == 0 ? 1 : 0; + } + int Camera::exp_mode(int value) { if (_impl == NULL) return err::ERR_NOT_INIT;