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.
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)
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; }
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__
\ No newline at end of file
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;
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" );
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;
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 );
}
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;
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;
CV_IMPL CvRect
cvBoundingRect( CvArr* array, int update )
{
- CvRect rect = { 0, 0, 0, 0 };
+ CvRect rect;
CvContour contour_header;
CvSeq* ptseq = 0;
CvSeqBlock block;
}
return;
}
- CvRect roi={0,0,0,0};
+ CvRect roi;
if (!CV_IS_MAT(patch))
{
roi = cvGetImageROI((IplImage*)patch);
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 );
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}; */
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;
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;
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++ )
{
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;
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