-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
56 lines (50 loc) · 1.11 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
55
56
#include <iostream>
#include <cstdlib>
#include "opencv2/opencv.hpp"
#include "barrel_distortion.cuh"
int main(int argc, char **argv)
{
using namespace std;
using namespace cv;
Mat input, output;
float K;
float centerX, centerY;
int width, height;
if(argc == 3)
{
input = imread(argv[1], IMREAD_COLOR);
output = Mat(input.rows, input.cols, input.type());
K = atof(argv[2]);
width = input.cols;
height = input.rows;
centerX = width / 2;
centerY = height / 2;
}
else if(argc == 5)
{
input = imread(argv[1], IMREAD_COLOR);
output = Mat(input.rows, input.cols, input.type());
K = atof(argv[2]);
width = input.cols;
height = input.rows;
centerX = atof(argv[3]);
centerY = atof(argv[4]);
}
else
{
cout << "usage: ./barrel_distort_cpp \
<input image> \
<K: coefficient of distortion> \
[x corrdinate of center of distortion (in pixel)] \
[y corrdinate of center of distortion (in pixel)]"
<< endl;
return 1;
}
// barrel distort here
barrelDistortion(input, output,
K, centerX, centerY, width, height);
// show output
imshow("distorted", output);
waitKey();
return 0;
}