-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsource.cpp
More file actions
60 lines (51 loc) · 1.29 KB
/
source.cpp
File metadata and controls
60 lines (51 loc) · 1.29 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "source.hpp"
bool Source::done() {
return false;
};
VideoSource::VideoSource(VideoCapture vc) {
cap = vc;
}
Markers::Status VideoSource::nextImage(Markers markers, UMat& imgProj) {
UMat img;
// Blow away any buffered frames so we don't lag.
for (int i=0; i<SKIP_FRAMES; i++) {
cap >> img;
}
//TODO: make debug mode
/*
char buf [3];
sprintf(buf, "%03d", sequence++);
std::string filename = "stitchframe-" + to_string(0) + buf + ".jpeg";
cout << filename << endl;
imwrite(filename, img);
*/
Markers::Status status;
if (img.cols > 0) {
status = markers.getArucoOrientedImage(img, imgProj);
if (status == Markers::Status::OK && imgProj.cols == 0) {
status = Markers::Status::ERR;
}
} else {
isDone = true;
status = Markers::Status::ERR;
}
return status;
}
bool VideoSource::done() {
return isDone;
}
ImageSource::ImageSource(vector<UMat> i) {
imgs = i;
}
Markers::Status ImageSource::nextImage(Markers markers, UMat& imgProj) {
UMat img = imgs.front();
imgs.erase(imgs.begin());
Markers::Status status = markers.getArucoOrientedImage(img, imgProj);
if (status == Markers::Status::OK && imgProj.cols == 0) {
status = Markers::Status::ERR;
}
return status;
}
bool ImageSource::done() {
return (imgs.size()==0);
}