Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ To use this target clang format must be installed, preferably clang-format-18
```
sudo apt install clang-format-18
```
or using pip
```
python -m pip install clang-format~=18.0
```

And to apply formatting
```
Expand Down
5 changes: 4 additions & 1 deletion bindings/python/src/pipeline/PipelineBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ void PipelineBindings::bind(pybind11::module& m, void* pCallstack) {
.def_readwrite("pipelineVersion", &GlobalProperties::pipelineVersion)
.def_readwrite("cameraTuningBlobSize", &GlobalProperties::cameraTuningBlobSize, DOC(dai, GlobalProperties, cameraTuningBlobSize))
.def_readwrite("cameraTuningBlobUri", &GlobalProperties::cameraTuningBlobUri, DOC(dai, GlobalProperties, cameraTuningBlobUri))
.def_readwrite("cameraSocketTuningBlobSize", &GlobalProperties::cameraSocketTuningBlobSize, DOC(dai, GlobalProperties, cameraSocketTuningBlobSize))
.def_readwrite("cameraSocketTuningBlobUri", &GlobalProperties::cameraSocketTuningBlobUri, DOC(dai, GlobalProperties, cameraSocketTuningBlobUri))
.def_readwrite("xlinkChunkSize", &GlobalProperties::xlinkChunkSize, DOC(dai, GlobalProperties, xlinkChunkSize))
.def_readwrite("sippBufferSize", &GlobalProperties::sippBufferSize, DOC(dai, GlobalProperties, sippBufferSize))
.def_readwrite("sippDmaBufferSize", &GlobalProperties::sippDmaBufferSize, DOC(dai, GlobalProperties, sippDmaBufferSize));
Expand Down Expand Up @@ -156,7 +158,8 @@ void PipelineBindings::bind(pybind11::module& m, void* pCallstack) {
static_cast<AssetManager& (Pipeline::*)()>(&Pipeline::getAssetManager),
py::return_value_policy::reference_internal,
DOC(dai, Pipeline, getAssetManager))
.def("setCameraTuningBlobPath", &Pipeline::setCameraTuningBlobPath, py::arg("path"), DOC(dai, Pipeline, setCameraTuningBlobPath))
.def("setCameraTuningBlobPath", py::overload_cast<const fs::path&>(&Pipeline::setCameraTuningBlobPath), py::arg("path"), DOC(dai, Pipeline, setCameraTuningBlobPath))
.def("setCameraTuningBlobPath", py::overload_cast<CameraBoardSocket, const fs::path&>(&Pipeline::setCameraTuningBlobPath), py::arg("socket"), py::arg("path"), DOC(dai, Pipeline, setCameraTuningBlobPath, 2))
.def("setXLinkChunkSize", &Pipeline::setXLinkChunkSize, py::arg("sizeBytes"), DOC(dai, Pipeline, setXLinkChunkSize))
.def("setSippBufferSize", &Pipeline::setSippBufferSize, py::arg("sizeBytes"), DOC(dai, Pipeline, setSippBufferSize))
.def("setSippDmaBufferSize", &Pipeline::setSippDmaBufferSize, py::arg("sizeBytes"), DOC(dai, Pipeline, setSippDmaBufferSize))
Expand Down
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 "f81edb9c2328ee1f80a6f80c3fade0af0076a3ff")
set(DEPTHAI_DEVICE_SIDE_COMMIT "67c2d2856fedb2772ec66ed42f16ea08062bbcab")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
7 changes: 7 additions & 0 deletions include/depthai/pipeline/Pipeline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "depthai/pipeline/PipelineSchema.hpp"
#include "depthai/properties/GlobalProperties.hpp"
#include "depthai/utility/RecordReplay.hpp"
#include "depthai/common/CameraBoardSocket.hpp"

namespace dai {

Expand Down Expand Up @@ -55,6 +56,7 @@ class PipelineImpl : public std::enable_shared_from_this<PipelineImpl> {
PipelineSchema getPipelineSchema(SerializationType type = DEFAULT_SERIALIZATION_TYPE) const;
Device::Config getDeviceConfig() const;
void setCameraTuningBlobPath(const fs::path& path);
void setCameraTuningBlobPath(CameraBoardSocket socket, const fs::path& path);
void setXLinkChunkSize(int sizeBytes);
GlobalProperties getGlobalProperties() const;
void setGlobalProperties(GlobalProperties globalProperties);
Expand Down Expand Up @@ -419,6 +421,11 @@ class Pipeline {
void setCameraTuningBlobPath(const fs::path& path) {
impl()->setCameraTuningBlobPath(path);
}

/// Set a camera IQ (Image Quality) tuning blob, used for specific board socket
void setCameraTuningBlobPath(CameraBoardSocket socket, const fs::path& path) {
impl()->setCameraTuningBlobPath(socket, path);
}

/**
* Set chunk size for splitting device-sent XLink packets, in bytes. A larger value could
Expand Down
11 changes: 11 additions & 0 deletions include/depthai/properties/GlobalProperties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ struct GlobalProperties : PropertiesSerializable<Properties, GlobalProperties> {
*/
std::string cameraTuningBlobUri;

/**
* Socket specific camera tuning blob size in bytes
*/
std::unordered_map<CameraBoardSocket, std::uint32_t> cameraSocketTuningBlobSize;
/**
* Socket specific camera tuning blob uri
*/
std::unordered_map<CameraBoardSocket, std::string> cameraSocketTuningBlobUri;

/**
* Chunk size for splitting device-sent XLink packets, in bytes. A larger value could
* increase performance, with 0 disabling chunking. A negative value won't modify the
Expand Down Expand Up @@ -79,6 +88,8 @@ DEPTHAI_SERIALIZE_EXT(GlobalProperties,
pipelineVersion,
cameraTuningBlobSize,
cameraTuningBlobUri,
cameraSocketTuningBlobSize,
cameraSocketTuningBlobUri,
calibData,
eepromId,
xlinkChunkSize,
Expand Down
10 changes: 10 additions & 0 deletions src/pipeline/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@ void PipelineImpl::setCameraTuningBlobPath(const fs::path& path) {
globalProperties.cameraTuningBlobSize = static_cast<uint32_t>(asset->data.size());
}

void PipelineImpl::setCameraTuningBlobPath(CameraBoardSocket socket, const fs::path& path) {
std::string assetKey = "camTuning";
assetKey += "_" + std::to_string(static_cast<int>(socket));

auto asset = assetManager.set(assetKey, path);

globalProperties.cameraSocketTuningBlobUri[socket] = asset->getRelativeUri();
globalProperties.cameraSocketTuningBlobSize[socket] = static_cast<uint32_t>(asset->data.size());
}

void PipelineImpl::setXLinkChunkSize(int sizeBytes) {
globalProperties.xlinkChunkSize = sizeBytes;
}
Expand Down
13 changes: 13 additions & 0 deletions tests/src/ondevice_tests/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@ TEST_CASE("std::filesystem::path with AssetManager, StereoDepth") {
CHECK_NOTHROW(pipeline.setCameraTuningBlobPath(path4));
pipeline.getAssetManager().remove("camTuning");

CHECK_NOTHROW(pipeline.setCameraTuningBlobPath(CameraBoardSocket::CAM_A, string4.c_str()));
pipeline.getAssetManager().remove("camTuning_0");
CHECK_NOTHROW(pipeline.setCameraTuningBlobPath(CameraBoardSocket::CAM_A, string4));
pipeline.getAssetManager().remove("camTuning_0");
CHECK_NOTHROW(pipeline.setCameraTuningBlobPath(CameraBoardSocket::CAM_A, path4));
pipeline.getAssetManager().remove("camTuning_0");

auto depth = pipeline.create<dai::node::StereoDepth>();
CHECK_NOTHROW(depth->loadMeshFiles(string4.c_str(), string4.c_str()));
depth->getAssetManager().remove("meshLeft");
Expand All @@ -356,6 +363,11 @@ TEST_CASE("std::filesystem::path with AssetManager, StereoDepth") {
CHECK_NOTHROW(pipeline.setCameraTuningBlobPath(widePath4));
pipeline.getAssetManager().remove("camTuning");

CHECK_NOTHROW(pipeline.setCameraTuningBlobPath(CameraBoardSocket::CAM_A, widePath4.c_str()));
pipeline.getAssetManager().remove("camTuning_0");
CHECK_NOTHROW(pipeline.setCameraTuningBlobPath(CameraBoardSocket::CAM_A, widePath4));
pipeline.getAssetManager().remove("camTuning_0");

CHECK_NOTHROW(depth->loadMeshFiles(widePath4.c_str(), widePath4.c_str()));
depth->getAssetManager().remove("meshLeft");
depth->getAssetManager().remove("meshRight");
Expand All @@ -371,6 +383,7 @@ TEST_CASE("std::filesystem::path with AssetManager, StereoDepth") {
const auto stdPath4 = std::filesystem::u8path(string4);
#endif
CHECK_NOTHROW(pipeline.setCameraTuningBlobPath(stdPath4));
CHECK_NOTHROW(pipeline.setCameraTuningBlobPath(CameraBoardSocket::CAM_A, stdPath4));
CHECK_NOTHROW(depth->loadMeshFiles(stdPath4, stdPath4));
#endif

Expand Down
37 changes: 34 additions & 3 deletions utilities/cam_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,24 @@ def socket_type_pair(arg):
is_thermal = True if type in ['th', 'thermal'] else False
return [socket, is_color, is_tof, is_thermal]

def camera_tuning_item(arg: str):
"""
Accept either:
- PATH
- SOCKET,PATH
Returns (socket_or_all, Path).
"""
# Case 1: plain path = global tuning for all cameras
if ',' not in arg:
return ("__all__", Path(arg))

# Case 2: socket,path
socket, path_str = arg.split(',', 1)

if socket not in ALL_SOCKETS:
raise argparse.ArgumentTypeError(f"Unknown camera socket: {socket}")

return (socket, Path(path_str))

parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('-cams', '--cameras', type=socket_type_pair, nargs='+',
Expand All @@ -141,8 +159,8 @@ def socket_type_pair(arg):
help="Downscale the ISP output by this factor")
parser.add_argument('-rs', '--resizable-windows', action='store_true',
help="Make OpenCV windows resizable. Note: may introduce some artifacts")
parser.add_argument('-tun', '--camera-tuning', type=Path,
help="Path to custom camera tuning database")
parser.add_argument('-tun', '--camera-tuning', type=camera_tuning_item, nargs='+', default=[],
help="Camera tuning database. Either a single PATH, which will apply to all cameras, or one or more SOCKET,PATH pairs. Example: -tun /path/to/tuning.db or -tun rgb,/path/to/rgb.db right,/path/to/right.db")
parser.add_argument('-raw', '--enable-raw', default=False, action="store_true",
help='Enable the RAW camera streams')
parser.add_argument('-tofraw', '--tof-raw', action='store_true',
Expand Down Expand Up @@ -357,7 +375,20 @@ def socket_to_socket_opt(socket: dai.CameraBoardSocket) -> str:
streams.append(streamName)

if args.camera_tuning:
pipeline.setCameraTuningBlobPath(str(args.camera_tuning))
if len(args.camera_tuning) == 1 and args.camera_tuning[0][0] == "__all__":
# Single tuning for all cameras
tuning_path = args.camera_tuning[0][1]
print(f'Applying camera tuning from {tuning_path} to all cameras')
pipeline.setCameraTuningBlobPath(str(tuning_path))
else:
# Per-socket tuning
for socket, tuning_path in args.camera_tuning:
if socket == "__all__":
print(f'Cannot apply all tuning to all and specific sockets at the same time.')
exit(1)
cam_socket = cam_socket_opts[socket]
print(f'Applying camera tuning from {tuning_path} to camera socket {socket}')
pipeline.setCameraTuningBlobPath(cam_socket, str(tuning_path))

stereo = None

Expand Down