ReUseX
0.0.5
3D Point Cloud Processing for Building Reuse
Toggle main menu visibility
Loading...
Searching...
No Matches
IVideoModel.hpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2
//
3
// SPDX-License-Identifier: GPL-3.0-or-later
4
5
#pragma once
6
#include "reusex/vision/IData.hpp"
7
#include "reusex/vision/IDataset.hpp"
8
9
#include <memory>
10
11
namespace
reusex::vision
{
12
13
/* IVideoModel is a stateful model interface for video / temporal-sequence
14
* inference. It is intentionally distinct from IModel: whereas
15
* IModel::forward() is a stateless, batch-oriented pass (safe to drive from a
16
* shuffled, multi threaded Dataloader), IVideoModel carries an internal memory
17
* bank that couples consecutive frames. The SAM 3.1 video tracker is the
18
* primary implementation.
19
*
20
* CONTRACT — callers MUST obey the following:
21
* - Feed frames in strict temporal order. The model conditions each frame on
22
* the memory accumulated from previous step() calls. Out-of-order or
23
* shuffled frames produce meaningless results.
24
* - NEVER drive an IVideoModel from the shuffled/multi-worker Dataloader. Use
25
* an ordered single-threaded loop over the dataset indices instead.
26
* - Call reset() at every sequence boundary (e.g. before the first frame of a
27
* new scan/sequence) to clear the memory bank.
28
*
29
* step() I/O contract:
30
* - input.first : a TensorRTData (image + prompts + confidence_threshold).
31
* - input.second : the dataset index / sample id (echoed unchanged on
32
* output).
33
* - output.first : a TensorRTData whose .image is the CV_32S per-pixel label
34
* image (background = -1, class ids 0+), exactly like
35
* TensorRTSam3::forward().
36
* - output.second: echoes input.second so the caller can map results back to
37
* the originating sample.
38
*/
39
class
IVideoModel
{
40
public
:
41
/* Virtual destructor to ensure derived-class cleanup through a base pointer.
42
*/
43
virtual
~IVideoModel
() =
default
;
44
45
/* Clears all temporal state (the memory bank) and returns the model to its
46
* initial condition. Callers MUST invoke this at every sequence boundary
47
* before feeding the first frame of a new sequence.
48
*/
49
virtual
void
reset
() = 0;
50
51
/* Processes a single frame, conditioned on the memory accumulated from all
52
* prior step() calls since the last reset(). See the class-level contract for
53
* the exact input/output semantics.
54
* @param in A Pair whose .first is a TensorRTData frame and whose .second is
55
* the sample index/id.
56
* @return A Pair whose .first is a TensorRTData label image and whose .second
57
* echoes in.second.
58
*/
59
virtual
IDataset::Pair
step
(
const
IDataset::Pair
&in) = 0;
60
};
61
62
}
// namespace reusex::vision
reusex::vision::IDataset::Pair
std::pair< std::unique_ptr< IData >, size_t > Pair
Definition
IDataset.hpp:44
reusex::vision::IVideoModel
Definition
IVideoModel.hpp:39
reusex::vision::IVideoModel::step
virtual IDataset::Pair step(const IDataset::Pair &in)=0
reusex::vision::IVideoModel::reset
virtual void reset()=0
reusex::vision::IVideoModel::~IVideoModel
virtual ~IVideoModel()=default
reusex::vision
Definition
annotate.hpp:12
libs
reusex
include
vision
IVideoModel.hpp
Generated by
1.17.0