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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm
#include "gpu/testing.hpp"
#include "libvideostitch/imageProcessingUtils.hpp"
#include <cassert>
#include <iostream>
#include <memory>
//#define DUMP_TEST_RESULT
#if defined(DUMP_TEST_RESULT)
#ifdef NDEBUG
#error "This is not supposed to be included in non-debug mode."
#endif
#include "../util/debugUtils.hpp"
#endif
namespace VideoStitch {
namespace Testing {
void testCircle() {
#ifdef DUMP_TEST_RESULT
std::string workingPath =
"C:/Users/Chuong.VideoStitch-09/Documents/GitHub/VideoStitch/VideoStitch-master/lib/src/test/";
#else
std::string workingPath = "";
#endif
std::vector<std::string> autoCropTests;
for (int i = 0; i < 1; i++) {
autoCropTests.push_back(workingPath + "data/autocrop/test" + std::to_string(i) + ".png");
}
std::vector<int> circleXs = {237};
std::vector<int> circleYs = {177};
std::vector<int> circleRadiuses = {260};
for (size_t i = 0; i < autoCropTests.size(); i++) {
int channelCount;
int64_t width, height;
std::vector<unsigned char> data;
int x, y, radius;
if (!Util::ImageProcessing::readImage(autoCropTests[i], width, height, channelCount, data).ok()) {
std::cout << "Test " << i << ": Cannot read " << autoCropTests[i] << std::endl;
ENSURE_EQ(1, 0);
}
#if defined(DUMP_TEST_RESULT)
Status status = Util::ImageProcessing::findCropCircle((int)width, (int)height, &data[0], x, y, radius, nullptr,
*autoCropTests[i]);
if (!status) {
std::cout << "Test " << i << ": " << status.getErrorMessage() << std::endl;
}
#else
Status status = Util::ImageProcessing::findCropCircle((int)width, (int)height, &data[0], x, y, radius);
if (!status.ok()) {
std::cout << "Test " << i << ": " << status.getErrorMessage() << std::endl;
}
std::cout << "Test " << i << ": " << x << " " << y << " " << radius << std::endl;
ENSURE((circleXs[i] - x) <= 2, "x differs more than 2 pixels");
ENSURE((circleYs[i] - y) <= 2, "y differs more than 2 pixels");
ENSURE((circleRadiuses[i] - radius) <= 2, "r differs more than 2 pixels");
#endif
}
}
} // namespace Testing
} // namespace VideoStitch
int main() {
VideoStitch::Testing::testCircle();
return 0;
}