-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaffine.cpp
More file actions
56 lines (47 loc) · 1.31 KB
/
affine.cpp
File metadata and controls
56 lines (47 loc) · 1.31 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
45
46
47
48
49
50
51
52
53
54
55
56
#include <cmath>
#include <iostream>
#include <time.h>
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
using namespace std;
using namespace cv;
int main(int argc, char** argv){
Mat img1=imread("pic3.png");
Mat mask=imread("mask.png");
Mat img,test,test_r;
//Mat img2=imread(argv[2]);
Point2f centre(160,120);
Mat M=getRotationMatrix2D(centre,-1,1); // 2nd arg angle degree (anticlk +ve); 1xscale
//cout<<M<<"\n";
//img1.copyTo(img,mask); //apply mask
img1.copyTo(img);
imshow("original_img",img1);
waitKey(10);
imshow("masked_img",img);
waitKey(10);
//imwrite("test.png",img);
Size dsize=img1.size();
int flags=INTER_LINEAR;
const Scalar borderValue=Scalar();
Size S = Size(320,240);
VideoWriter outputVideo;
const string NAME="10.avi";
outputVideo.open(NAME,CV_FOURCC('M','J','P','G'),10, S, true); // 10 FPS
for(int i=0;i<360;i++){
M=getRotationMatrix2D(centre,0,1);
warpAffine(img1,img,M,dsize,INTER_LINEAR,BORDER_CONSTANT,0);
outputVideo.write(img);
}
waitKey(0);
/*
warpAffine(img,img,M,dsize,INTER_LINEAR,BORDER_CONSTANT,0);
imwrite("tx6_r.png",img); //rotated image
namedWindow("rotated_img",1);
imshow("rotated_img",img);
waitKey(0);
*/
}