将两个点转换为矩形(cv :: Rect) [英] Convert two points to a rectangle (cv::Rect)
本文介绍了将两个点转换为矩形(cv :: Rect)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个点(假设是从矩形,它是左上角和右下角)。
I have two points (assumed to be from rectangle, which are its top-left corner & bottom-right corner).
Point pTopLeft;
Point pBottomRight;
我想使用这些点来制定一个cv :: Rect。所以,我尝试了
I want to formulate a cv::Rect using these points. So, I tried
cv::Rect rRect;
rRect.tl() = pTopLeft;
rRect.br() = pBottomRight;
没有错误。但 Rect 似乎不包含任何内容。即,两个点都指示零。所以,我如何制定一个新的Rect对象与任意两点?
There is no error. But the Rect seems to be containing nothing. i.e., both the points are indicating zero. So, How do I formulate a new Rect object with arbitrary two points ?
推荐答案
:br()只是返回副本,而不是引用,尝试一个构造函数:
since Rect::tl() and Rect::br() just return copies, not references, try a constructor:
cv::Rect rRect(pTopLeft, pBottomRight);
这篇关于将两个点转换为矩形(cv :: Rect)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文