-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
54 lines (45 loc) · 1.48 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "CatMullRomSpline.h"
using namespace std;
using namespace cv;
int main(int argc, char*argv[])
{
//input vector containing discrete points
vector<Point2d> input;
//input.push_back(Point2d(-510, -520));
input.push_back(Point2d(50,50));
input.push_back(Point2d(300,250));
input.push_back(Point2d(550,200));
input.push_back(Point2d(800,600));
//input.push_back(Point2d(900,900));
// Call the algorithm
vector<Point2d> Output = catMullRomSpline(input);
cout<<"Total Number of Interpolated Points : "<<Output.size()<<" points"<<endl;
// defining image of type CV_8UC3 with white background
Mat img(2000, 2000, CV_8UC3, Scalar(255, 255, 255));
// mark discrete points with red color
for (int i = 0 ; i< input.size(); i++)
{
int x = 1000 + input[i].x ;
int y = 1000 - input[i].y ;
circle(img, Point2d(x, y),1, Scalar(0, 0, 255), 15, 8, 2);
}
// mark continuos interpolated path with green color
for (int i = 0 ; i< Output.size(); i++)
{
int x = 1000 + Output[i].x ;
int y = 1000 - Output[i].y ;
circle(img, Point2d(x, y),1, Scalar(0, 255, 0), 8, 8, 2);
}
// output the final image
imshow("Output", img);
waitKey(0);
return 0;
}