-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChapter3.cpp
More file actions
42 lines (33 loc) · 1.13 KB
/
Chapter3.cpp
File metadata and controls
42 lines (33 loc) · 1.13 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
//Reference: https://www.youtube.com/watch?v=2FYm3GOonhk
// 00:52 min
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
/////Resizing images////
using namespace cv;
using namespace std;
int main()
{
string path = "/Users/macbookpro/Desktop/UTEC/OpenCV/opencv3test/Resources/test.png";
Mat img = imread(path);
Mat imgResize;
cout << img.size() << endl;
int size1 = 768 ;
int size2 = 559;
resize(img,imgResize,Size(500,800));
//To scale down without using size (to not mess w dimensions)...
resize(img,imgResize,Size(),0.5,0.5);
//CROPPING IMAGES
//Important to cut object, to add more processing in that specific region
// This region is called region of interest -> ROI
// To crop images, we can use rectangles
Rect roi(200,100,300,400); //Inside here we must define x,y witdh and height
//So from point 100,100. We go 300px to the right, then 250 bottom
Mat imgCrop;
imgCrop = img(roi);
imshow("imgcrop", imgCrop);
imshow("imgRize", img);
imshow("imgRize", imgResize);
waitKey(0);
}