views:

128

answers:

1

how to check whether a given point is contained in a rectangle using the contains() function in Rect_ construct... Please give me the exact function and its parameters.Like when i type this

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: 

You want to use the instance of a defining the area to run the method for deciding a contains b. The method contains is not static, therefor you cannot call it on the class 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
Greg Domjan
alright, that helped... thanks a lot!! yep.. i m a beginner! at least as far as using vc++ and opencv is concerned... n yes i don't know much about this static stuff... still got ur answer!!
Kaushal