-
Notifications
You must be signed in to change notification settings - Fork 4
/
mainCvtoolstest.cpp
37 lines (23 loc) · 1.02 KB
/
mainCvtoolstest.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 <unistd.h>
#include <opencv2/opencv.hpp>
#include "cvtools.h"
int main(){
cv::Mat im = cv::imread("lena.png", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat scaleRotationMatrix = cv::getRotationMatrix2D(cv::Point2f(im.cols/2.0, im.rows/2.0), 10.0, 1.0);
cv::Mat imTransformed;
cv::warpAffine(im, imTransformed, scaleRotationMatrix, im.size());
cv::Mat translationMatrix = (cv::Mat_<float>(2,3) << 1, 0, 0, 0, 1, 0);
cv::warpAffine(imTransformed, imTransformed, translationMatrix, imTransformed.size(), CV_INTER_LINEAR, cv::BORDER_CONSTANT, 0.0);
cv::imwrite("im.png", im);
cv::imwrite("imTransformed.png", imTransformed);
// try to recover scale and rotation
float scale, rotation;
cv::Point2f shift;
cvtools::phaseCorrelate(im, imTransformed, scale, rotation, shift);
std::cout << scale << std::endl << rotation << std::endl << shift << std::endl;
// cv::namedWindow("im1", CV_WINDOW_AUTOSIZE);
// cv::imshow("im1", im1);
// cv::waitKey();
return 0;
}