2010-06-07 45 views
0

如何使用Rect_構造函數中的contains()函數檢查給定點是否包含在矩形中...請給我確切的函數及其參數。當我鍵入此Visual C++ OpenCV 2.1 contains()

Point b(2,2); 
Rect a(10,10,50,50); 
cout<< Rect_::contains(b); 

There is a compile error saying 1>c:\users\kaushal\documents\visual studio 2008\projects\test1\test1.cpp(23) : error C2352: 'cv::Rect_<_Tp>::contains' : illegal call of non-static member function 
1>c:\opencv2.1\include\opencv\cxcore.hpp(385) : see declaration of 'cv::Rect_<_Tp>::contains' 

回答

1

像你想使用的a定義區域的情況下運行的方法來決定a包含b。方法contains不是靜態的,因此您不能在類Rect上調用它。

Point b(2,2); 
Rect a(10,10,50,50); 
cout<< Rect_::contains(b); // error here - contains is not static so can't be called on class 
cout<< a.contains(b); // this is what you want - use instance with knowledge of rect 
+0

好吧,這有幫助...非常感謝!是的,我是初學者!至少就使用vC++和opencv而言...... n是的,我對這個靜態的東西不太瞭解......還是有你的答案! – Kaushal 2010-06-07 17:42:23