将旧的Opencv代码转换为新的c++ API,替换cvGetSubRect

Converting old Opencv code to the new C++ API, replacement for cvGetSubRect?

本文关键字:API c++ 替换 cvGetSubRect Opencv 代码 转换      更新时间:2023-10-16

我正在使用C api将一些旧的OpenCV代码转换为OpenCV 2.3中的新c++ api。我想知道取代cvGetSubRect调用的方法是什么?

我有以下cvGetSubRect(some_cv_mat_pointer, another_cv_mat_pointer, some_cv_rect);

在c++ api中与此等价的是什么?

你在源图像上创建一个roi,它会给你一个新的图像-没有实际的像素复制它都是自动发生的

Mat image(.....)     // original image 
Rect roi(10, 20, 100, 50);     // shape of roi            
Mat image_roi = image(roi);    /// really a window into image, copy it if you need to change it
http://opencv.willowgarage.com/documentation/cpp/c + + _cheatsheet.html