-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
44 lines (34 loc) · 1.09 KB
/
main.cpp
File metadata and controls
44 lines (34 loc) · 1.09 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
#include "TangramSolver.h"
int main()
{
//读入单元块
cv::Mat unitsImg = cv::imread("../TangramSolver/unitPatterns/units4.jpg",0);
//读入目标图像
cv::Mat dstImg = cv::imread("../TangramSolver/dstPatterns/d4/09.jpg",0);
//time
double runtime = cv::getTickCount();
//solve
TangramSolver solver;
solver.setFlipEnable(false);
std::vector<std::vector<cv::Point>> resultPos;
bool isSolved = solver.solve(unitsImg,dstImg,resultPos);
//time
runtime = (cv::getTickCount() - runtime) / cv::getTickFrequency();
std::cout<<"runtime:"<<runtime<<std::endl;
//test
if(isSolved)
{
cv::Mat testImg = dstImg.clone();
cv::cvtColor(testImg,testImg,cv::COLOR_GRAY2BGR);
cv::drawContours(testImg,resultPos,-1,cv::Scalar(255,100,30),2);
std::string testImgWinName = "testImg";
cv::namedWindow(testImgWinName,0);
cv::imshow(testImgWinName,testImg);
cv::waitKey();
}
else
{
std::cout<<"failed!"<<std::endl;
}
return 0;
}