问题描述
我是OpenCV的新手(开始使用它两天前),我试图从Kinect的深度图像剪切手形图像,我需要手形图像的手势识别。我有一个 cv :: Mat
类型的图像。我的问题是:
I'm very new to OpenCV (started using it two days ago), I'm trying to cut a hand image from a depth image got from Kinect, I need the hand image for gesture recognition. I have the image as a cv::Mat
type. My questions are:
- 是否有一种方法可以将
cv :: Mat
cvMat
,以便我可以使用cvGetSubRect
方法获取感兴趣区域? -
cv :: Mat
中有任何方法可用于获取图像的一部分吗?
- Is there a way to convert
cv::Mat
tocvMat
so that I can usecvGetSubRect
method to get the Region of interest? - Are there any methods in
cv::Mat
that I can use for getting the part of the image?
我想使用 IplImage
,但我读的地方是 cv :: Mat
I wanted to use IplImage
but I read somewhere that cv::Mat
is the preferred way now.
推荐答案
您可以使用重载的函数调用 $ c> cv :: Mat :
You can use the overloaded function call operator on the cv::Mat
:
cv::Mat img = ...;
cv::Mat subImg = img(cv::Range(0, 100), cv::Range(0, 100));
检查以获取更多信息,以及需要一个 cv :: Rect
的重载函数。请注意,使用这种切片形式创建一个新的矩阵头,但不会复制数据。
Check the OpenCV documentation for more information and for the overloaded function that takes a cv::Rect
. Note that using this form of slicing creates creates a new matrix header, but does not copy the data.
这篇关于OpenCV C ++,使用cv :: Mat获得感兴趣区域(ROI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!