forked from augcog/OpenARK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Detector.cpp
42 lines (35 loc) · 1.13 KB
/
Detector.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "Detector.h"
#include "DetectionParams.h"
namespace ark {
Detector::Detector(DetectionParams::Ptr params)
: params(params ? params : DetectionParams::DEFAULT) {
callback = std::bind(&Detector::callbackHelper, this, std::placeholders::_1);
}
void Detector::update(const cv::Mat & image)
{
this->image = image;
detect(this->image);
lastCamera = nullptr;
onSameFrame = false;
}
void Detector::update(DepthCamera & camera)
{
// stop if the camera is still on the same frame as before
if (onSameFrame && lastCamera == &camera) return;
this->image = camera.getXYZMap();
detect(this->image);
if (lastCamera != &camera) {
if (lastCamera) lastCamera->removeUpdateCallback(lastUpdateCallbackID);
lastUpdateCallbackID = camera.addUpdateCallback(callback);
}
lastCamera = &camera;
}
void Detector::setParams(const DetectionParams::Ptr params)
{
this->params = params;
}
void Detector::callbackHelper(DepthCamera & camera)
{
onSameFrame = false;
}
}