Skip to content

Commit 18f2640

Browse files
committed
basics
1 parent 1b3e989 commit 18f2640

16 files changed

+779
-0
lines changed

basics/.idea/basics.iml

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

basics/.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

basics/.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

basics/.idea/workspace.xml

+222
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

basics/1_program.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
3+
Getting arguments
4+
-----------------
5+
6+
Instructions to run the code
7+
-----------------------------
8+
9+
> g++ 1_program.cpp -o app `pkg-config --cflags --libs opencv`
10+
> ./app water air
11+
12+
*/
13+
14+
#include <opencv2/highgui.hpp>
15+
#include "opencv2/core/core.hpp"
16+
17+
#include <iostream>
18+
using namespace std;
19+
using namespace cv;
20+
21+
int main(int argc,char** argv){
22+
23+
24+
25+
printf("argc = %d\n",argc);
26+
printf("argv = %s\n",argv[0]);
27+
printf("argv = %s\n",argv[1]);
28+
printf("argv = %s\n",argv[2]);
29+
30+
printf("printing in a for loop \n");
31+
32+
for(int i=0;i<argc;++i){
33+
34+
printf("%s\n",argv[i]);
35+
}
36+
37+
return 0;
38+
39+
}
40+

basics/2_program.cpp

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
3+
Reading a image
4+
----------------
5+
6+
Instructions to run the code
7+
-----------------------------
8+
9+
> g++ 2_program.cpp -o app `pkg-config --cflags --libs opencv`
10+
> ./app
11+
12+
*/
13+
14+
15+
16+
#include <opencv2/highgui.hpp>
17+
#include "opencv2/core/core.hpp"
18+
#include <iostream>
19+
20+
21+
//name space
22+
using namespace std;
23+
using namespace cv;
24+
25+
26+
27+
int main(int argc,char** argv){
28+
29+
cv::Mat image;
30+
image = cv::imread("sample_two.jpeg",CV_LOAD_IMAGE_COLOR);
31+
if(!image.data){
32+
std::cout<<"could not open or find image"<<std::endl;
33+
return -1;
34+
}
35+
36+
37+
cv::namedWindow("Display window",cv::WINDOW_AUTOSIZE);
38+
cv::imshow("Display window",image);
39+
40+
cv::waitKey(0);
41+
return 0;
42+
43+
}
44+
45+
// x,y,width,height
46+
// x denotes from how much distance ROI of x start
47+
// y denotes from how much distance ROI of y start
48+
// width denotes how much width the picture should be
49+
// height denotes how much height the picture should be

basics/3_program.cpp

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Reading a image and finding ROI
3+
------------------------------
4+
5+
6+
Instructions to run the code
7+
-----------------------------
8+
9+
> g++ 3_program.cpp -o app `pkg-config --cflags --libs opencv`
10+
> ./app
11+
12+
*/
13+
14+
15+
16+
#include <opencv2/highgui.hpp>
17+
#include "opencv2/core/core.hpp"
18+
19+
#include <iostream>
20+
using namespace std;
21+
using namespace cv;
22+
23+
int main(int argc,char** argv){
24+
25+
Mat image;
26+
27+
image = cv::imread("sample_two.jpeg",CV_LOAD_IMAGE_COLOR);
28+
if(!image.data){
29+
cout <<"could not open or find image"<< endl;
30+
return -1;
31+
}
32+
33+
34+
Mat D(image,Rect(50,50,100,100)); //using a rectangle
35+
// Rect(x,y,width,height)
36+
// from point 50,50 (x,y) 100 pixels to right and 100 pixels down are taken .
37+
38+
39+
40+
namedWindow("Display window",cv::WINDOW_AUTOSIZE);
41+
imshow("Display window",D);
42+
43+
waitKey(0);
44+
return 0;
45+
46+
}
47+
48+
// x,y,width,height
49+
// x denotes from how much distance ROI of x start
50+
// y denotes from how much distance ROI of y start
51+
// width denotes how much width the picture should be
52+
// height denotes how much height the picture should be

0 commit comments

Comments
 (0)