diff --git a/README.md b/README.md index f12bf42d84..9c0fe95cb7 100644 --- a/README.md +++ b/README.md @@ -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). | | 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. | diff --git a/src/opencv/HolisticRecordReplay.cpp b/src/opencv/HolisticRecordReplay.cpp index d0e038de9c..29182ba1a2 100644 --- a/src/opencv/HolisticRecordReplay.cpp +++ b/src/opencv/HolisticRecordReplay.cpp @@ -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) @@ -448,6 +449,8 @@ bool setupHolisticReplay(Pipeline pipeline, recordConfig.state = RecordConfig::RecordReplayState::REPLAY; + bool loopEnabled = utility::getEnvAs("DEPTHAI_REPLAY_LOOP", true); + for(auto& node : sources) { auto nodeS = std::dynamic_pointer_cast(node); if(nodeS == nullptr) { @@ -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()); @@ -489,6 +493,7 @@ bool setupHolisticReplay(Pipeline pipeline, } else { auto replay = pipeline.create(); replay->setReplayFile(platform::joinPaths(rootPath, nodeName + ".mcap")); + replay->setLoop(loopEnabled); replay->out.link(nodeS->getReplayInput()); } } diff --git a/src/pipeline/node/host/Replay.cpp b/src/pipeline/node/host/Replay.cpp index 7fc4c48f84..cccc08597e 100644 --- a/src/pipeline/node/host/Replay.cpp +++ b/src/pipeline/node/host/Replay.cpp @@ -1,4 +1,5 @@ #include +#include #include "depthai/pipeline/datatype/DatatypeEnum.hpp" #include "depthai/pipeline/datatype/EncodedFrame.hpp" @@ -204,6 +205,11 @@ inline std::shared_ptr 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& fps) { if(fps.has_value() && fps.value() > 0.1f) { return std::chrono::milliseconds((uint32_t)roundf(1000.f / fps.value())); @@ -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; @@ -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; @@ -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");