-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
36 lines (34 loc) · 1005 Bytes
/
main.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
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
#include<opencv2/aruco.hpp>
#include<opencv2/highgui.hpp>
using namespace cv;
int main()
{
VideoCapture input;
input.open(0);
Ptr<aruco::Dictionary> dictionary= aruco::getPredefinedDictionary(aruco::DICT_6X6_250);
while (input.grab())
{
Mat image,copy;
input.retrieve(image);
image.copyTo(copy);
vector<int> ids;
vector<vector<Point2f>> corners;
aruco::detectMarkers(image,dictionary,corners,ids);
if(ids.size()>0)
{
aruco::drawDetectedMarkers(copy,corners,ids);
for(int i=0;i<corners.size();i++)
{Mat sum=Mat(corners.at(i).at(0))+Mat(corners.at(i).at(1))+Mat(corners.at(i).at(2))+Mat(corners.at(i).at(3));
sum=sum/4;
cout<<sum<<endl<<endl;}
}
imshow("out",copy);
char key=(char)waitKey();
if(key==27)
break;
}
}