#include<iostream>
#include<opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(){
Mat src=imread("/Users/xinshichao/PersonalWork/C++Demo/Pictures/p1.jpeg",IMREAD_UNCHANGED);
if(src.empty()){
printf("could not find the image...\n");
return -1;
}
namedWindow("src",WINDOW_AUTOSIZE);
imshow("src",src);
waitKey(0);
return 0;
}
Demo1输出结果:
👉Demo2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream>
#include<opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(){
Mat src=imread("/Users/xinshichao/PersonalWork/C++Demo/Pictures/p1.jpeg",IMREAD_GRAYSCALE);
if(src.empty()){
printf("could not find the image...\n");
return -1;
}
namedWindow("src",WINDOW_AUTOSIZE);
imshow("src",src);
waitKey(0);
return 0;
}
Demo2输出结果:
👉Demo3:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream>
#include<opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(){
Mat src=imread("/Users/xinshichao/PersonalWork/C++Demo/Pictures/p1.jpeg",IMREAD_COLOR);
if(src.empty()){
printf("could not find the image...\n");
return -1;
}
namedWindow("src",WINDOW_AUTOSIZE);
imshow("src",src);
waitKey(0);
return 0;
}