Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ The following environment variables can be set to alter default behavior of the
| DEPTHAI_ZOO_MODELS_PATH | (Default) depthai_models - Folder where zoo model description files are stored |
| DEPTHAI_RECORD | Enables holistic record to the specified directory. |
| DEPTHAI_REPLAY | Replays holistic replay from the specified file or directory. |
| DEPTHAI_REPLAY_LOOP | Loops recorded data (ON by default). |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial | 💤 Low value

Document how to disable looping.

The entry states looping is ON by default but doesn't tell users how to turn it off. Consider noting the accepted falsy values to match the style of other boolean entries (e.g. DEPTHAI_TELEMETRY).

📝 Suggested wording
-| DEPTHAI_REPLAY_LOOP | Loops recorded data (ON by default). |
+| DEPTHAI_REPLAY_LOOP | Loops recorded replay data. Enabled by default; set to `0` or `false` to disable. |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| DEPTHAI_REPLAY_LOOP | Loops recorded data (ON by default). |
| DEPTHAI_REPLAY_LOOP | Loops recorded replay data. Enabled by default; set to `0` or `false` to disable. |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 238, Update the README entry for DEPTHAI_REPLAY_LOOP to
show how to disable looping: state it's ON by default and that setting the
environment variable DEPTHAI_REPLAY_LOOP to a falsy value (e.g. 0, false, no,
off — case-insensitive) will disable looping, matching the boolean style used
for DEPTHAI_TELEMETRY; reference the DEPTHAI_REPLAY_LOOP variable name so
readers can find and use it.

| DEPTHAI_PROFILING | Enables runtime profiling of data transfer between the host and connected devices. Set to 1 to enable. Requires DEPTHAI_LEVEL=debug or lower to print. |
| DEPTHAI_PIPELINE_DEBUGGING | Enables pipeline debugging with state dumps. DEPTHAI_LEVEL=trace is required to print the state dumps. |
| DEPTHAI_AUTOCALIBRATION | Runs recalibration of the stereo pair and, by default, flashes successful calibration to non-volatile memory (EEPROM). `CONTINUOUS`: runs check repetitively; `ON_START`: runs calibration only at the start of the pipeline; `OFF`: no recalibration. The same mode can be configured from code with `pipeline.setAutoCalibrationMode(...)`. If this environment variable is set, it overrides the pipeline-set value. AutoCalibration currently initializes only for stereo inputs at 1280x800. |
Expand Down
5 changes: 5 additions & 0 deletions src/opencv/HolisticRecordReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "depthai/utility/RecordReplay.hpp"
#include "pipeline/Node.hpp"
#include "utility/CompilerWarnings.hpp"
#include "utility/Environment.hpp"

#define UNUSED(x) (void)(x)

Expand Down Expand Up @@ -448,6 +449,8 @@ bool setupHolisticReplay(Pipeline pipeline,

recordConfig.state = RecordConfig::RecordReplayState::REPLAY;

bool loopEnabled = utility::getEnvAs<bool>("DEPTHAI_REPLAY_LOOP", true);

for(auto& node : sources) {
auto nodeS = std::dynamic_pointer_cast<SourceNode>(node);
if(nodeS == nullptr) {
Expand All @@ -466,6 +469,7 @@ bool setupHolisticReplay(Pipeline pipeline,
// replay->setReplayVideo(platform::joinPaths(rootPath, (mxId + "_").append(nodeName).append(".mp4")));
replay->setReplayVideoFile(platform::joinPaths(rootPath, nodeName + videoExt));
replay->setOutFrameType(legacy ? ImgFrame::Type::YUV420p : ImgFrame::Type::NV12);
replay->setLoop(loopEnabled);

auto videoSize = BytePlayer::getVideoSize(replay->getReplayMetadataFile().string());
auto [vidWidth, vidHeight, vidFps] = utility::getVideoSize(replay->getReplayVideoFile().string());
Expand All @@ -489,6 +493,7 @@ bool setupHolisticReplay(Pipeline pipeline,
} else {
auto replay = pipeline.create<dai::node::ReplayMetadataOnly>();
replay->setReplayFile(platform::joinPaths(rootPath, nodeName + ".mcap"));
replay->setLoop(loopEnabled);
replay->out.link(nodeS->getReplayInput());
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/pipeline/node/host/Replay.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdexcept>
#include <thread>

#include "depthai/pipeline/datatype/DatatypeEnum.hpp"
#include "depthai/pipeline/datatype/EncodedFrame.hpp"
Expand Down Expand Up @@ -204,6 +205,11 @@ inline std::shared_ptr<google::protobuf::Message> getProtoMessage(utility::ByteP
return {};
}

inline void waitAndStopPipeline(Node* node) {
std::this_thread::sleep_for(std::chrono::seconds(5));
node->stopPipeline();
}

inline std::chrono::milliseconds getReplayFallbackInterval(const std::optional<float>& fps) {
if(fps.has_value() && fps.value() > 0.1f) {
return std::chrono::milliseconds((uint32_t)roundf(1000.f / fps.value()));
Expand Down Expand Up @@ -290,7 +296,7 @@ void ReplayVideo::run() {
continue;
}
// This will stop even if there is still frames in the pipeline
stopPipeline();
waitAndStopPipeline(this);
break;
} else {
hasMetadata = false;
Expand All @@ -313,7 +319,7 @@ void ReplayVideo::run() {
continue;
}
// This will stop even if there is still frames in the pipeline
stopPipeline();
waitAndStopPipeline(this);
break;
} else {
hasVideo = false;
Expand Down Expand Up @@ -441,7 +447,7 @@ void ReplayMetadataOnly::run() {
continue;
}
// This will stop even if there is still frames in the pipeline
stopPipeline();
waitAndStopPipeline(this);
break;
} else {
throw std::runtime_error("Metadata file contains no messages");
Expand Down