thể trùng lặp:
Understanding region of interest in openCV 2.4OpenCV tiểu hình ảnh từ một hình ảnh Mat
tôi muốn có được một tiểu hình ảnh (một trong những giới hạn bởi các hộp màu đỏ bên dưới) từ một hình ảnh (Định dạng Mat). Làm thế nào để tôi làm điều này?
đây là tiến bộ của tôi cho đến nay:
include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat imgray, thresh;
vector<vector<Point> >contours;
vector<Point> cnt;
vector<Vec4i> hierarchy;
Point leftmost;
Mat im = imread("igoy1.jpg");
cvtColor(im, imgray, COLOR_BGR2GRAY);
threshold(imgray, thresh, 127, 255, 0);
findContours(thresh, contours, hierarchy, RETR_TREE,CHAIN_APPROX_SIMPLE);
}
Câu hỏi này như đã được hỏi và trả lời, ít nhất là [ở đây] (http://stackoverflow.com/questions/12705817/understanding-region-of-interest- in-opencv-2-4/12706208 # 12706208) và [ở đó] (http://stackoverflow.com/questions/12369697/access-sub-matrix-of-a-multidimensional-mat-in-opencv/12370641#12370641) – remi