every blog every motto: You can do more than you think.
https://blog.csdn.net/weixin_39190382?type=blog
0. 前言
图像信息获取,roi
1. 图像信息获取
// 获取图像信息
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main(){
Mat img = imread("/home/v/home.png");
if(img.empty()){
cout<<"Error: Could not load image."<<endl;
return -1;
}
imshow("img",img);
cout<<"img row: "<<img.rows<<endl;
cout<<"img col: "<<img.cols<<endl;
cout<<"img ch: "<<img.channels()<<endl;
waitKey(0);
return 0;
}
2. 图像ROI
// 获取图像信息
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main(){
Mat img = imread("/home/v/home.png");
if(img.empty()){
cout<<"Error: Could not load image."<<endl;
return -1;
}
imshow("img",img);
// 图像信息
cout<<"img row: "<<img.rows<<endl;
cout<<"img col: "<<img.cols<<endl;
cout<<"img ch: "<<img.channels()<<endl;
// 图像roi
Mat imageROI(img, Rect(100,100,200,150));
imshow("imageROI",imageROI);
waitKey(0);
return 0;
}