-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.cpp
53 lines (47 loc) · 1.53 KB
/
demo.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
43
44
45
46
47
48
49
50
51
52
53
#include <libSVM.h>
int threshold = 100;
int color = 0;
int main(int argc, char **argv)
{
std::string path = std::string(argv[1]);
std::string image = std::string(argv[2]);
std::string type = std::string(argv[3]);
std::cout << path << " " << image << std::endl;
initSvmKernal(path, 64, 16, 8, 4, 9);
if (type == "m")
{
auto start = std::chrono::system_clock::now();
std::vector<roiInfo> batch;
cv::Mat testImg, proc, dst;
testImg = cv::imread(image);
preProcess(testImg, proc, threshold, color); // dst, dstImg are processed images.
cv::imwrite("process.png", proc);
doDetect(testImg, proc, true, batch);
cv::imwrite("result.png", testImg);
auto end = std::chrono::system_clock::now();
std::cout << "inference time: " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
}
else if (type == "v")
{
cv::VideoCapture cap;
cap.open(image);
if (!cap.isOpened())
return 1;
cv::Mat frame;
while (1)
{
std::vector<roiInfo> batch;
cap >> frame;
if (frame.empty())
break;
cv::Mat dst;
cv::Mat dstImg;
preProcess(frame, dst, threshold, color);
cv::imshow("process", dst);
doDetect(frame, dst, true,batch);
cv::imshow("result", frame);
cv::waitKey(1);
}
cap.release();
}
}