OpenCV C++,使用 cv::Mat 获取感兴趣区域 (ROI)
我对 OpenCV 很陌生(两天前开始使用它),我正在尝试从 Kinect 获得的深度图像中剪切手部图像,我需要手部图像进行手势识别。我的图像是 cv::Mat
类型。我的问题是:
- 有没有办法将
cv::Mat
转换为cvMat
,以便我可以使用cvGetSubRect
方法来获取感兴趣的区域? cv::Mat
中是否有任何方法可以用来获取图像的一部分?
我想使用 IplImage
但我在某处读到 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:
- 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?
I wanted to use IplImage
but I read somewhere that cv::Mat
is the preferred way now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在
cv::Mat
上使用重载的函数调用运算符:检查OpenCV 文档 了解更多信息以及采用
cv::Rect
的重载函数。请注意,使用这种形式的切片会创建新的矩阵标头,但不会复制数据。You can use the overloaded function call operator on the
cv::Mat
: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 a new matrix header, but does not copy the data.也许另一种方法可能是:
我希望这能有所帮助。
Maybe an other approach could be:
I hope this can help.