Skip to content

Commit 40cf607

Browse files
committed
Merge branch 'develop' into dev_update_detection_parser
2 parents c55f031 + 9e22a3b commit 40cf607

File tree

8 files changed

+124
-14
lines changed

8 files changed

+124
-14
lines changed

.github/workflows/test.workflow.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ jobs:
5454
uses: ./.github/workflows/test_child.yml
5555
with:
5656
flavor: "vanilla"
57-
luxonis_os_versions_to_test: "['1.14.1', '1.15.0', '1.18.3']"
58-
luxonis_os_versions_to_test_rgb: "['1.18.3']"
57+
luxonis_os_versions_to_test: "['1.14.1', '1.18.3', '1.20.5']"
58+
luxonis_os_versions_to_test_rgb: "['1.20.5']"
5959
secrets:
6060
CONTAINER_REGISTRY: ${{ secrets.CONTAINER_REGISTRY }}
6161
HIL_PAT_TOKEN: ${{ secrets.HIL_PAT_TOKEN }}
@@ -66,7 +66,7 @@ jobs:
6666
uses: ./.github/workflows/test_child.yml
6767
with:
6868
flavor: "tsan"
69-
luxonis_os_versions_to_test: "['1.18.3']"
69+
luxonis_os_versions_to_test: "['1.20.5']"
7070
secrets:
7171
CONTAINER_REGISTRY: ${{ secrets.CONTAINER_REGISTRY }}
7272
HIL_PAT_TOKEN: ${{ secrets.HIL_PAT_TOKEN }}
@@ -77,7 +77,7 @@ jobs:
7777
uses: ./.github/workflows/test_child.yml
7878
with:
7979
flavor: "asan-ubsan"
80-
luxonis_os_versions_to_test: "['1.18.3']"
80+
luxonis_os_versions_to_test: "['1.20.5']"
8181
secrets:
8282
CONTAINER_REGISTRY: ${{ secrets.CONTAINER_REGISTRY }}
8383
HIL_PAT_TOKEN: ${{ secrets.HIL_PAT_TOKEN }}
@@ -87,7 +87,7 @@ jobs:
8787
if: needs.precheck.outputs.should_run == 'true'
8888
uses: ./.github/workflows/test_child_windows.yml
8989
with:
90-
luxonis_os_versions_to_test: "['1.18.3']"
90+
luxonis_os_versions_to_test: "['1.20.5']"
9191
secrets:
9292
CONTAINER_REGISTRY: ${{ secrets.CONTAINER_REGISTRY }}
9393
HIL_PAT_TOKEN: ${{ secrets.HIL_PAT_TOKEN }}

cmake/Depthai/DepthaiDeviceRVC4Config.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
set(DEPTHAI_DEVICE_RVC4_MATURITY "snapshot")
44

55
# "version if applicable"
6-
set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+777a261c32c4daf6a0b31093701d6f930f6b8caf")
6+
set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+ae328e69accbf27ad21bafff806a7a549ae2f22d")

cmake/Depthai/DepthaiDeviceSideConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")
33

44
# "full commit hash of device side binary"
5-
set(DEPTHAI_DEVICE_SIDE_COMMIT "b18d476e0adba7541664251cce8c1ba71db16daa")
5+
set(DEPTHAI_DEVICE_SIDE_COMMIT "7a638aee617e9932652076ba4a7a1862ed63f186")
66

77
# "version if applicable"
88
set(DEPTHAI_DEVICE_SIDE_VERSION "")

include/depthai/pipeline/node/Camera.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ class Camera : public DeviceNodeCRTP<DeviceNode, Camera, CameraProperties>, publ
212212
* Get number of frames in outputs pool for all outputs
213213
* @return Number of frames
214214
*/
215-
int getOutputsNumFramesPool() const;
215+
std::optional<int> getOutputsNumFramesPool() const;
216216

217217
/**
218218
* Get maximum size of outputs pool for all outputs
219219
* @return Maximum size in bytes of image manip pool
220220
*/
221-
int getOutputsMaxSizePool() const;
221+
std::optional<size_t> getOutputsMaxSizePool() const;
222222

223223
#ifdef DEPTHAI_HAVE_OPENCV_SUPPORT
224224
/**

include/depthai/properties/CameraProperties.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ struct CameraProperties : PropertiesSerializable<Properties, CameraProperties> {
104104
int numFramesPoolStill = 4; // No max size in bytes for still pool, used in mono and color cameras only, those are deprecated
105105

106106
/** Outputs frame pools */
107-
int numFramesPoolOutputs = 3;
108-
int maxSizePoolOutputs = 10 * 1024 * 1024; // 10MB
107+
std::optional<int> numFramesPoolOutputs;
108+
std::optional<int> maxSizePoolOutputs;
109109

110110
~CameraProperties() override;
111111
};

src/device/DeviceGate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ bool DeviceGate::createSession(bool exclusive) {
9292
// {"fwp_checksum", fwpChecksum},
9393
{"fwp_version", version},
9494
{"library_version", build::VERSION},
95-
{"protected", exclusive}};
95+
{"protected", exclusive},
96+
{"stop_qmmf_server", true}};
9697

9798
spdlog::debug("DeviceGate createSession: {}", createSessionBody.dump());
9899

src/pipeline/node/Camera.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,11 @@ int Camera::getMaxSizePoolIsp() const {
405405
return properties.maxSizePoolIsp;
406406
}
407407

408-
int Camera::getOutputsNumFramesPool() const {
408+
std::optional<int> Camera::getOutputsNumFramesPool() const {
409409
return properties.numFramesPoolOutputs;
410410
}
411411

412-
int Camera::getOutputsMaxSizePool() const {
412+
std::optional<size_t> Camera::getOutputsMaxSizePool() const {
413413
return properties.maxSizePoolOutputs;
414414
}
415415

tests/src/ondevice_tests/pipeline/node/camera_test.cpp

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <catch2/catch_all.hpp>
44
#include <catch2/catch_test_macros.hpp>
55
#include <catch2/generators/catch_generators.hpp>
6+
#include <chrono>
67

78
#include "depthai/capabilities/ImgFrameCapability.hpp"
89
#include "depthai/common/CameraBoardSocket.hpp"
@@ -163,3 +164,111 @@ TEST_CASE("Test how default FPS is generated for a specific output") {
163164
REQUIRE(benchmarkReport->fps == Catch::Approx(FPS_TO_SET).margin(FPS_TO_SET * 0.1));
164165
}
165166
}
167+
168+
TEST_CASE("Camera pool sizes") {
169+
auto firstDevice = dai::Device::getFirstAvailableDevice();
170+
auto isRvc4 = std::get<1>(firstDevice).platform == X_LINK_RVC4;
171+
for(const int overrideQueueSize : (isRvc4 ? std::vector<int>{-1, 2, 17, 3, 50, 4, 5} : std::vector<int>{-1, 2, 17, 3, 4, 5})) {
172+
std::cout << "Testing num frames = " << overrideQueueSize << "\n" << std::flush;
173+
dai::Pipeline pipeline;
174+
std::map<dai::CameraBoardSocket, std::vector<std::tuple<int, int, float>>> streamsRvc4{
175+
// Has to be (for now):
176+
// - without FpsRegulator (different fps per same sensor)(different fps on different sensors also doesn't work right now)
177+
// - without ManipResizer so size should be supported by ISP directly
178+
{dai::CameraBoardSocket::CAM_A, {{640, 480, 30.0f}, {1920, 1440, 30.0f}}},
179+
{dai::CameraBoardSocket::CAM_B, {{640, 400, 30.0f}, {1280, 800, 30.0f}}},
180+
{dai::CameraBoardSocket::CAM_C, {{640, 400, 30.0f}, {1280, 800, 30.0f}}},
181+
};
182+
// RVC2 is more RAM bound so use smaller sizes for the test
183+
std::map<dai::CameraBoardSocket, std::vector<std::tuple<int, int, float>>> streamsRvc2{
184+
// Has to be (for now):
185+
// - not a size supported directly by ISP as then isp is passed trough and the isp pool size value is used not the outputs pool size
186+
{dai::CameraBoardSocket::CAM_A, {{300, 300, 30.0f}}},
187+
{dai::CameraBoardSocket::CAM_B, {{300, 300, 30.0f}, {200, 200, 30.0f}}},
188+
{dai::CameraBoardSocket::CAM_C, {{200, 200, 30.0f}}},
189+
};
190+
auto streams = isRvc4 ? streamsRvc4 : streamsRvc2;
191+
std::vector<std::shared_ptr<dai::MessageQueue>> outQueues;
192+
std::vector<int> outQueuesCounter;
193+
std::vector<std::shared_ptr<dai::node::Camera>> cameras;
194+
auto script = pipeline.create<dai::node::Script>();
195+
// Default size of the pool for RVC2 is 3 and RVC4 is 7
196+
int queueSize = overrideQueueSize == -1 ? (isRvc4 ? 7 : 3) : overrideQueueSize;
197+
for(const auto& [socket, resolutions] : streams) {
198+
auto camera = pipeline.create<dai::node::Camera>()->build(socket);
199+
camera->properties.maxSizePoolOutputs = 1 * 1024 * 1024 * 1024; // 1G size limit to only test num frames limitation
200+
if(overrideQueueSize != -1) {
201+
camera->properties.numFramesPoolOutputs = overrideQueueSize;
202+
}
203+
for(const auto& resolution : resolutions) {
204+
std::string theKey = std::to_string(outQueues.size());
205+
std::string inputName = "in" + theKey;
206+
std::string outputName = "out" + theKey;
207+
camera->requestOutput({std::get<0>(resolution), std::get<1>(resolution)}, std::nullopt, dai::ImgResizeMode::CROP, std::get<2>(resolution))
208+
->link(script->inputs[inputName]);
209+
script->inputs[inputName].setBlocking(false);
210+
script->inputs[inputName].setMaxSize(1000);
211+
outQueues.push_back(script->outputs[outputName].createOutputQueue());
212+
outQueuesCounter.push_back(0);
213+
}
214+
cameras.push_back(camera);
215+
}
216+
int timeToBlock = 20;
217+
std::string scriptContent = isRvc4 ? R"(
218+
from depthai import BenchmarkReport)"
219+
: "";
220+
scriptContent += R"(
221+
import time
222+
223+
all_frames=[]
224+
max_id = )" + std::to_string(outQueues.size() - 1)
225+
+ R"(
226+
start_time = time.time()
227+
while time.time() - start_time < )"
228+
+ std::to_string(timeToBlock) + R"(:
229+
for idx in range(max_id + 1):
230+
the_key = str(idx)
231+
frame = node.inputs["in" + the_key].tryGet()
232+
if frame is not None:
233+
all_frames.append(frame)
234+
out = BenchmarkReport()
235+
node.outputs["out" + the_key].send(out)
236+
all_frames = []
237+
while True:
238+
for idx in range(max_id + 1):
239+
the_key = str(idx)
240+
frame = node.inputs["in" + the_key].tryGet()
241+
if frame is not None:
242+
out = BenchmarkReport()
243+
node.outputs["out" + the_key].send(out)
244+
)";
245+
script->setScript(scriptContent);
246+
pipeline.start();
247+
auto startTime = std::chrono::steady_clock::now();
248+
// Keep frames in script node and check Camera node stops sending frames after buffer limit is hit
249+
while(std::chrono::duration<double>(std::chrono::steady_clock::now() - startTime).count() < timeToBlock - 5) {
250+
for(int idx = 0; idx < outQueues.size(); ++idx) {
251+
auto frame = outQueues[idx]->tryGet();
252+
if(frame) {
253+
++outQueuesCounter[idx];
254+
}
255+
}
256+
}
257+
std::cout << "Got the first part frames\n" << std::flush;
258+
for(const auto& count : outQueuesCounter) {
259+
REQUIRE(count == queueSize);
260+
}
261+
// Check stream still works after script node unblocks the Camera node
262+
while(std::chrono::duration<double>(std::chrono::steady_clock::now() - startTime).count() < timeToBlock + 30) {
263+
for(int idx = 0; idx < outQueues.size(); ++idx) {
264+
auto frame = outQueues[idx]->tryGet();
265+
if(frame) {
266+
++outQueuesCounter[idx];
267+
}
268+
}
269+
}
270+
for(const auto& count : outQueuesCounter) {
271+
REQUIRE(count > queueSize + 200);
272+
}
273+
}
274+
}

0 commit comments

Comments
 (0)