Move cv::Rect_
This commit is contained in:
parent
addf0309ec
commit
62adc01980
modules
core
imgproc/src
legacy
objdetect/src
ts/src
@ -524,58 +524,6 @@ typedef Vec<double, 4> Vec4d;
|
||||
typedef Vec<double, 6> Vec6d;
|
||||
|
||||
|
||||
//////////////////////////////// Rect_ ////////////////////////////////
|
||||
|
||||
/*!
|
||||
The 2D up-right rectangle class
|
||||
|
||||
The class represents a 2D rectangle with coordinates of the specified data type.
|
||||
Normally, cv::Rect ~ cv::Rect_<int> is used.
|
||||
*/
|
||||
template<typename _Tp> class CV_EXPORTS Rect_
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
|
||||
//! various constructors
|
||||
Rect_();
|
||||
Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height);
|
||||
Rect_(const Rect_& r);
|
||||
Rect_(const CvRect& r);
|
||||
Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz);
|
||||
Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2);
|
||||
|
||||
Rect_& operator = ( const Rect_& r );
|
||||
//! the top-left corner
|
||||
Point_<_Tp> tl() const;
|
||||
//! the bottom-right corner
|
||||
Point_<_Tp> br() const;
|
||||
|
||||
//! size (width, height) of the rectangle
|
||||
Size_<_Tp> size() const;
|
||||
//! area (width*height) of the rectangle
|
||||
_Tp area() const;
|
||||
|
||||
//! conversion to another data type
|
||||
template<typename _Tp2> operator Rect_<_Tp2>() const;
|
||||
//! conversion to the old-style CvRect
|
||||
operator CvRect() const;
|
||||
|
||||
//! checks whether the rectangle contains the point
|
||||
bool contains(const Point_<_Tp>& pt) const;
|
||||
|
||||
_Tp x, y, width, height; //< the top-left corner, as well as width and height of the rectangle
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
\typedef
|
||||
|
||||
shorter aliases for the most popular cv::Point_<>, cv::Size_<> and cv::Rect_<> specializations
|
||||
*/
|
||||
typedef Rect_<int> Rect;
|
||||
|
||||
|
||||
/*!
|
||||
The rotated 2D rectangle.
|
||||
|
||||
|
@ -1785,7 +1785,6 @@ template<typename _Tp> static inline bool operator != (const Size_<_Tp>& a, cons
|
||||
template<typename _Tp> inline Rect_<_Tp>::Rect_() : x(0), y(0), width(0), height(0) {}
|
||||
template<typename _Tp> inline Rect_<_Tp>::Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height) : x(_x), y(_y), width(_width), height(_height) {}
|
||||
template<typename _Tp> inline Rect_<_Tp>::Rect_(const Rect_<_Tp>& r) : x(r.x), y(r.y), width(r.width), height(r.height) {}
|
||||
template<typename _Tp> inline Rect_<_Tp>::Rect_(const CvRect& r) : x((_Tp)r.x), y((_Tp)r.y), width((_Tp)r.width), height((_Tp)r.height) {}
|
||||
template<typename _Tp> inline Rect_<_Tp>::Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz) :
|
||||
x(org.x), y(org.y), width(sz.width), height(sz.height) {}
|
||||
template<typename _Tp> inline Rect_<_Tp>::Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2)
|
||||
@ -1836,9 +1835,6 @@ template<typename _Tp> inline _Tp Rect_<_Tp>::area() const { return width*height
|
||||
template<typename _Tp> template<typename _Tp2> inline Rect_<_Tp>::operator Rect_<_Tp2>() const
|
||||
{ return Rect_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y),
|
||||
saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height)); }
|
||||
template<typename _Tp> inline Rect_<_Tp>::operator CvRect() const
|
||||
{ return cvRect(saturate_cast<int>(x), saturate_cast<int>(y),
|
||||
saturate_cast<int>(width), saturate_cast<int>(height)); }
|
||||
|
||||
template<typename _Tp> inline bool Rect_<_Tp>::contains(const Point_<_Tp>& pt) const
|
||||
{ return x <= pt.x && pt.x < x + width && y <= pt.y && pt.y < y + height; }
|
||||
|
@ -284,6 +284,53 @@ typedef Size_<int> Size2i;
|
||||
typedef Size_<float> Size2f;
|
||||
typedef Size2i Size;
|
||||
|
||||
|
||||
|
||||
//////////////////////////////// Rect_ ////////////////////////////////
|
||||
|
||||
/*!
|
||||
The 2D up-right rectangle class
|
||||
|
||||
The class represents a 2D rectangle with coordinates of the specified data type.
|
||||
Normally, cv::Rect ~ cv::Rect_<int> is used.
|
||||
*/
|
||||
template<typename _Tp> class CV_EXPORTS Rect_
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
|
||||
//! various constructors
|
||||
Rect_();
|
||||
Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height);
|
||||
Rect_(const Rect_& r);
|
||||
Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz);
|
||||
Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2);
|
||||
|
||||
Rect_& operator = ( const Rect_& r );
|
||||
//! the top-left corner
|
||||
Point_<_Tp> tl() const;
|
||||
//! the bottom-right corner
|
||||
Point_<_Tp> br() const;
|
||||
|
||||
//! size (width, height) of the rectangle
|
||||
Size_<_Tp> size() const;
|
||||
//! area (width*height) of the rectangle
|
||||
_Tp area() const;
|
||||
|
||||
//! conversion to another data type
|
||||
template<typename _Tp2> operator Rect_<_Tp2>() const;
|
||||
|
||||
//! checks whether the rectangle contains the point
|
||||
bool contains(const Point_<_Tp>& pt) const;
|
||||
|
||||
_Tp x, y, width, height; //< the top-left corner, as well as width and height of the rectangle
|
||||
};
|
||||
|
||||
/*!
|
||||
\typedef
|
||||
*/
|
||||
typedef Rect_<int> Rect;
|
||||
|
||||
} // cv
|
||||
|
||||
#endif //__OPENCV_CORE_TYPES_HPP__
|
@ -685,6 +685,14 @@ typedef struct CvRect
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
#ifdef __cplusplus
|
||||
CvRect(int _x = 0, int _y = 0, int w = 0, int h = 0): x(_x), y(_y), width(w), height(h) {}
|
||||
template<typename _Tp>
|
||||
CvRect(const cv::Rect_<_Tp>& r): x(cv::saturate_cast<int>(r.x)), y(cv::saturate_cast<int>(r.y)), width(cv::saturate_cast<int>(r.width)), height(cv::saturate_cast<int>(r.height)) {}
|
||||
template<typename _Tp>
|
||||
operator cv::Rect_<_Tp>() const { return cv::Rect_<_Tp>((_Tp)x, (_Tp)y, (_Tp)width, (_Tp)height); }
|
||||
#endif
|
||||
}
|
||||
CvRect;
|
||||
|
||||
|
@ -3052,7 +3052,7 @@ cvResetImageROI( IplImage* image )
|
||||
CV_IMPL CvRect
|
||||
cvGetImageROI( const IplImage* img )
|
||||
{
|
||||
CvRect rect = { 0, 0, 0, 0 };
|
||||
CvRect rect;
|
||||
if( !img )
|
||||
CV_Error( CV_StsNullPtr, "Null pointer to image" );
|
||||
|
||||
|
@ -400,7 +400,7 @@ cvConvexHull2( const CvArr* array, void* hull_storage,
|
||||
|
||||
CvMat* mat = 0;
|
||||
CvContour contour_header;
|
||||
union { CvContour c; CvSeq s; } hull_header;
|
||||
CvSeq hull_header;
|
||||
CvSeqBlock block, hullblock;
|
||||
CvSeq* ptseq = 0;
|
||||
CvSeq* hullseq = 0;
|
||||
@ -456,7 +456,7 @@ cvConvexHull2( const CvArr* array, void* hull_storage,
|
||||
hullseq = cvMakeSeqHeaderForArray(
|
||||
CV_SEQ_KIND_CURVE|CV_MAT_TYPE(mat->type)|CV_SEQ_FLAG_CLOSED,
|
||||
sizeof(contour_header), CV_ELEM_SIZE(mat->type), mat->data.ptr,
|
||||
mat->cols + mat->rows - 1, &hull_header.s, &hullblock );
|
||||
mat->cols + mat->rows - 1, &hull_header, &hullblock );
|
||||
cvClearSeq( hullseq );
|
||||
}
|
||||
|
||||
@ -522,7 +522,7 @@ CV_IMPL CvSeq* cvConvexityDefects( const CvArr* array,
|
||||
int rev_orientation;
|
||||
|
||||
CvContour contour_header;
|
||||
union { CvContour c; CvSeq s; } hull_header;
|
||||
CvSeq hull_header;
|
||||
CvSeqBlock block, hullblock;
|
||||
CvSeq *ptseq = (CvSeq*)array, *hull = (CvSeq*)hullarray;
|
||||
|
||||
@ -575,7 +575,7 @@ CV_IMPL CvSeq* cvConvexityDefects( const CvArr* array,
|
||||
hull = cvMakeSeqHeaderForArray(
|
||||
CV_SEQ_KIND_CURVE|CV_MAT_TYPE(mat->type)|CV_SEQ_FLAG_CLOSED,
|
||||
sizeof(CvContour), CV_ELEM_SIZE(mat->type), mat->data.ptr,
|
||||
mat->cols + mat->rows - 1, &hull_header.s, &hullblock );
|
||||
mat->cols + mat->rows - 1, &hull_header, &hullblock );
|
||||
}
|
||||
|
||||
is_index = CV_SEQ_ELTYPE(hull) == CV_SEQ_ELTYPE_INDEX;
|
||||
|
@ -1046,7 +1046,7 @@ cvFitEllipse2( const CvArr* array )
|
||||
CV_IMPL CvRect
|
||||
cvBoundingRect( CvArr* array, int update )
|
||||
{
|
||||
CvRect rect = { 0, 0, 0, 0 };
|
||||
CvRect rect;
|
||||
CvContour contour_header;
|
||||
CvSeq* ptseq = 0;
|
||||
CvSeqBlock block;
|
||||
|
@ -529,7 +529,7 @@ namespace cv{
|
||||
}
|
||||
return;
|
||||
}
|
||||
CvRect roi={0,0,0,0};
|
||||
CvRect roi;
|
||||
if (!CV_IS_MAT(patch))
|
||||
{
|
||||
roi = cvGetImageROI((IplImage*)patch);
|
||||
|
@ -292,8 +292,8 @@ icvSnake8uC1R( unsigned char *src,
|
||||
int leftshift = x ? 1 : 0;
|
||||
int bottomshift = MIN( 1, roi.height - (y + 1)*WTILE_SIZE );
|
||||
int rightshift = MIN( 1, roi.width - (x + 1)*WTILE_SIZE );
|
||||
CvRect g_roi = { x*WTILE_SIZE - leftshift, y*WTILE_SIZE - upshift,
|
||||
leftshift + WTILE_SIZE + rightshift, upshift + WTILE_SIZE + bottomshift };
|
||||
CvRect g_roi(x*WTILE_SIZE - leftshift, y*WTILE_SIZE - upshift,
|
||||
leftshift + WTILE_SIZE + rightshift, upshift + WTILE_SIZE + bottomshift);
|
||||
CvMat _src1;
|
||||
cvGetSubArr( &_src, &_src1, g_roi );
|
||||
|
||||
|
@ -71,7 +71,7 @@ void CV_PyrSegmentationTest::run( int /*start_from*/ )
|
||||
CvPoint* cp = _cp;
|
||||
CvPoint* cp2 = _cp2;
|
||||
CvConnectedComp *dst_comp[3];
|
||||
CvRect rect[3] = {{50,50,21,21}, {0,0,128,128}, {33,33,11,11}};
|
||||
CvRect rect[3] = {CvRect(50,50,21,21), CvRect(0,0,128,128), CvRect(33,33,11,11)};
|
||||
double a[3] = {441.0, 15822.0, 121.0};
|
||||
|
||||
/* ippiPoint cp3[] ={130,130, 150,130, 150,150, 130,150}; */
|
||||
|
@ -1574,9 +1574,9 @@ cvHaarDetectObjectsForROC( const CvArr* _img,
|
||||
CvSize sz(cvRound( img->cols/factor ), cvRound( img->rows/factor ));
|
||||
CvSize sz1(sz.width - winSize0.width + 1, sz.height - winSize0.height + 1);
|
||||
|
||||
CvRect equRect = { icv_object_win_border, icv_object_win_border,
|
||||
CvRect equRect(icv_object_win_border, icv_object_win_border,
|
||||
winSize0.width - icv_object_win_border*2,
|
||||
winSize0.height - icv_object_win_border*2 };
|
||||
winSize0.height - icv_object_win_border*2);
|
||||
|
||||
CvMat img1, sum1, sqsum1, norm1, tilted1, mask1;
|
||||
CvMat* _tilted = 0;
|
||||
@ -1658,7 +1658,7 @@ cvHaarDetectObjectsForROC( const CvArr* _img,
|
||||
const double ystep = std::max( 2., factor );
|
||||
CvSize winSize(cvRound( cascade->orig_window_size.width * factor ),
|
||||
cvRound( cascade->orig_window_size.height * factor ));
|
||||
CvRect equRect = { 0, 0, 0, 0 };
|
||||
CvRect equRect;
|
||||
int *p[4] = {0,0,0,0};
|
||||
int *pq[4] = {0,0,0,0};
|
||||
int startX = 0, startY = 0;
|
||||
@ -1775,7 +1775,7 @@ cvHaarDetectObjectsForROC( const CvArr* _img,
|
||||
|
||||
if( findBiggestObject && rectList.size() )
|
||||
{
|
||||
CvAvgComp result_comp = {{0,0,0,0},0};
|
||||
CvAvgComp result_comp = {CvRect(),0};
|
||||
|
||||
for( size_t i = 0; i < rectList.size(); i++ )
|
||||
{
|
||||
|
@ -124,9 +124,9 @@ CvSeq* cvLatentSvmDetectObjects(IplImage* image,
|
||||
|
||||
for (int i = 0; i < numBoxesOut; i++)
|
||||
{
|
||||
CvObjectDetection detection = {{0, 0, 0, 0}, 0};
|
||||
CvObjectDetection detection = {CvRect(), 0};
|
||||
detection.score = scoreOut[i];
|
||||
CvRect bounding_box = {0, 0, 0, 0};
|
||||
CvRect bounding_box;
|
||||
bounding_box.x = pointsOut[i].x;
|
||||
bounding_box.y = pointsOut[i].y;
|
||||
bounding_box.width = oppPointsOut[i].x - pointsOut[i].x;
|
||||
|
@ -158,7 +158,7 @@ int ArrayTest::prepare_test_case( int test_case_idx )
|
||||
unsigned t = randInt(rng);
|
||||
bool create_mask = true, use_roi = false;
|
||||
CvSize size = sizes[i][j], whole_size = size;
|
||||
CvRect roi = {0,0,0,0};
|
||||
CvRect roi;
|
||||
|
||||
is_image = !cvmat_allowed ? true : iplimage_allowed ? (t & 1) != 0 : false;
|
||||
create_mask = (t & 6) == 0; // ~ each of 3 tests will use mask
|
||||
|
Loading…
x
Reference in New Issue
Block a user