Skip to content

Commit

Permalink
Added ability to set the lens position via a float, to enable a more …
Browse files Browse the repository at this point in the history
…precies movement. (#954)

* Added lensPositionRaw to ImgFrame and EncodedFrame
  • Loading branch information
zrezke authored Feb 5, 2024
1 parent 145ca18 commit 636118a
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmake/Depthai/DepthaiDeviceSideConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")

# "full commit hash of device side binary"
set(DEPTHAI_DEVICE_SIDE_COMMIT "f089593893c1b1ccb29c99ccdc9a0e723db57a3b")
set(DEPTHAI_DEVICE_SIDE_COMMIT "fdd7f9e70a4ce94924fb5342b6c3b9ec4712727a")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
13 changes: 13 additions & 0 deletions include/depthai/pipeline/datatype/CameraControl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ class CameraControl : public Buffer {
*/
CameraControl& setManualFocus(uint8_t lensPosition);

/**
* Set a command to specify manual focus position (more precise control).
*
* @param lensPositionRaw specify lens position 0.0f .. 1.0f
* @return CameraControl&
*/
CameraControl& setManualFocusRaw(float lensPositionRaw);

// Exposure
/**
* Set a command to enable auto exposure
Expand Down Expand Up @@ -306,6 +314,11 @@ class CameraControl : public Buffer {
*/
int getLensPosition() const;

/**
* Retrieves lens position, range 0.0f..1.0f.
*/
float getLensPositionRaw() const;

/**
* Set explicit configuration.
* @param config Explicit configuration
Expand Down
6 changes: 6 additions & 0 deletions include/depthai/pipeline/datatype/EncodedFrame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class EncodedFrame : public Buffer {
* Retrieves lens position, range 0..255. Returns -1 if not available
*/
int getLensPosition() const;

/**
* Retrieves lens position, range 0.0f..1.0f. Returns -1 if not available
*/
float getLensPositionRaw() const;

/**
* Retrieves the encoding quality
*/
Expand Down
5 changes: 5 additions & 0 deletions include/depthai/pipeline/datatype/ImgFrame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ class ImgFrame : public Buffer {
*/
int getLensPosition() const;

/**
* Retrieves lens position, range 0.0f..1.0f. Returns -1 if not available
*/
float getLensPositionRaw() const;

// setters
/**
* Retrieves image timestamp related to dai::Clock::now()
Expand Down
10 changes: 10 additions & 0 deletions src/pipeline/datatype/CameraControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ CameraControl& CameraControl::setManualFocus(uint8_t lensPosition) {
return *this;
}

CameraControl& CameraControl::setManualFocusRaw(float lensPositionRaw) {
cfg.setCommand(RawCameraControl::Command::MOVE_LENS_RAW);
cfg.lensPositionRaw = lensPositionRaw;
return *this;
}

// Exposure
CameraControl& CameraControl::setAutoExposureEnable() {
cfg.setCommand(RawCameraControl::Command::AE_AUTO);
Expand Down Expand Up @@ -225,6 +231,10 @@ int CameraControl::getLensPosition() const {
return cfg.lensPosition;
}

float CameraControl::getLensPositionRaw() const {
return cfg.lensPositionRaw;
}

dai::RawCameraControl CameraControl::get() const {
return cfg;
}
Expand Down
3 changes: 3 additions & 0 deletions src/pipeline/datatype/EncodedFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ int EncodedFrame::getColorTemperature() const {
int EncodedFrame::getLensPosition() const {
return frame.cam.lensPosition;
}
float EncodedFrame::getLensPositionRaw() const {
return frame.cam.lensPositionRaw;
}
unsigned int EncodedFrame::getQuality() const {
return frame.quality;
}
Expand Down
4 changes: 4 additions & 0 deletions src/pipeline/datatype/ImgFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ int ImgFrame::getLensPosition() const {
return img.cam.lensPosition;
}

float ImgFrame::getLensPositionRaw() const {
return img.cam.lensPositionRaw;
}

// setters
ImgFrame& ImgFrame::setTimestamp(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> tp) {
// Set timestamp from timepoint
Expand Down

0 comments on commit 636118a

Please sign in to comment.