assert( src_contour->total == 4 );
for( i = 0; i < 4; i++ )
{
- CvPoint2D32f pt = cvPointTo32f(*(CvPoint*)cvGetSeqElem(src_contour, i));
+ CvPoint * onePoint = (CvPoint*)cvGetSeqElem(src_contour, i);
+ CV_Assert(onePoint != NULL);
+ CvPoint2D32f pt = cvPointTo32f(*onePoint);
CvCBCorner* corner = &(*out_corners)[quad_count*4 + i];
memset( corner, 0, sizeof(*corner) );
break;
}
- assert( edge != 0 );
+ CV_Assert( edge != 0 );
next_edge = edge->next[ofs];
if( prev_edge )
const struct DynamicFnEntry* e = NULL;
if (ID < CUSTOM_FUNCTION_ID)
{
- assert(ID >= 0 && ID < (int)(sizeof(opencl_fn_list)/sizeof(opencl_fn_list[0])));
+ CV_Assert(ID >= 0 && ID < (int)(sizeof(opencl_fn_list)/sizeof(opencl_fn_list[0])));
e = opencl_fn_list[ID];
}
#ifdef HAVE_OPENCL_SVM
else if (ID >= SVM_FUNCTION_ID_START && ID < SVM_FUNCTION_ID_END)
{
ID = ID - SVM_FUNCTION_ID_START;
- assert(ID >= 0 && ID < (int)(sizeof(opencl_svm_fn_list)/sizeof(opencl_svm_fn_list[0])));
+ CV_Assert(ID >= 0 && ID < (int)(sizeof(opencl_svm_fn_list)/sizeof(opencl_svm_fn_list[0])));
e = opencl_svm_fn_list[ID];
}
#endif
cur = cur->next;
}
- assert( par_info != 0 );
+ CV_Assert( par_info != 0 );
/* if current contour is a hole and previous contour is a hole or
current contour is external and previous contour is external then
cvConvexHull2( const CvArr* array, void* hull_storage,
int orientation, int return_points )
{
- union { CvContour* c; CvSeq* s; } hull;
- hull.s = 0;
-
CvMat* mat = 0;
CvContour contour_header;
CvSeq hull_header;
ptseq = cvPointSeqFromMat( CV_SEQ_KIND_GENERIC, array, &contour_header, &block );
}
- if( CV_IS_STORAGE( hull_storage ))
+ bool isStorage = isStorageOrMat(hull_storage);
+
+ if(isStorage)
{
if( return_points )
{
}
else
{
- if( !CV_IS_MAT( hull_storage ))
- CV_Error(CV_StsBadArg, "Destination must be valid memory storage or matrix");
-
mat = (CvMat*)hull_storage;
if( (mat->cols != 1 && mat->rows != 1) || !CV_IS_MAT_CONT(mat->type))
int total = ptseq->total;
if( total == 0 )
{
- if( mat )
+ if( !isStorage )
CV_Error( CV_StsBadSize,
"Point sequence can not be empty if the output is matrix" );
- return hull.s;
+ return 0;
}
cv::AutoBuffer<double> _ptbuf;
else
cvSeqPushMulti(hullseq, h0.ptr(), (int)h0.total());
- if( mat )
+ if (isStorage)
+ {
+ return hullseq;
+ }
+ else
{
if( mat->rows > mat->cols )
mat->rows = hullseq->total;
else
mat->cols = hullseq->total;
+ return 0;
}
- else
- {
- hull.s = hullseq;
- hull.c->rect = cvBoundingRect( ptseq,
- ptseq->header_size < (int)sizeof(CvContour) ||
- &ptseq->flags == &contour_header.flags );
- }
-
- return hull.s;
}
cv::Mat image = cv::cvarrToMat(src_image);
std::vector<cv::Vec2f> l2;
std::vector<cv::Vec4i> l4;
- CvSeq* result = 0;
CvMat* mat = 0;
CvSeq* lines = 0;
elemSize = sizeof(int)*4;
}
- if( CV_IS_STORAGE( lineStorage ))
+ bool isStorage = isStorageOrMat(lineStorage);
+
+ if( isStorage )
{
lines = cvCreateSeq( lineType, sizeof(CvSeq), elemSize, (CvMemStorage*)lineStorage );
}
- else if( CV_IS_MAT( lineStorage ))
+ else
{
mat = (CvMat*)lineStorage;
linesMax = lines->total;
cvClearSeq( lines );
}
- else
- CV_Error( CV_StsBadArg, "Destination is not CvMemStorage* nor CvMat*" );
iparam1 = cvRound(param1);
iparam2 = cvRound(param2);
int nlines = (int)(l2.size() + l4.size());
- if( mat )
+ if( !isStorage )
{
if( mat->cols > mat->rows )
mat->cols = nlines;
cv::Mat lx = method == CV_HOUGH_STANDARD || method == CV_HOUGH_MULTI_SCALE ?
cv::Mat(nlines, 1, CV_32FC2, &l2[0]) : cv::Mat(nlines, 1, CV_32SC4, &l4[0]);
- if( mat )
+ if (isStorage)
{
- cv::Mat dst(nlines, 1, lx.type(), mat->data.ptr);
- lx.copyTo(dst);
+ cvSeqPushMulti(lines, lx.ptr(), nlines);
}
else
{
- cvSeqPushMulti(lines, lx.ptr(), nlines);
+ cv::Mat dst(nlines, 1, lx.type(), mat->data.ptr);
+ lx.copyTo(dst);
}
}
- if( !mat )
- result = lines;
- return result;
+ if( isStorage )
+ return lines;
+ return 0;
}
double param1, double param2,
int min_radius, int max_radius )
{
- CvSeq* result = 0;
-
CvMat stub, *img = (CvMat*)src_image;
CvMat* mat = 0;
CvSeq* circles = 0;
else if( max_radius <= min_radius )
max_radius = min_radius + 2;
- if( CV_IS_STORAGE( circle_storage ))
+ bool isStorage = isStorageOrMat(circle_storage);
+
+ if(isStorage)
{
circles = cvCreateSeq( CV_32FC3, sizeof(CvSeq),
sizeof(float)*3, (CvMemStorage*)circle_storage );
}
- else if( CV_IS_MAT( circle_storage ))
+ else
{
mat = (CvMat*)circle_storage;
circles_max = circles->total;
cvClearSeq( circles );
}
- else
- CV_Error( CV_StsBadArg, "Destination is not CvMemStorage* nor CvMat*" );
switch( method )
{
CV_Error( CV_StsBadArg, "Unrecognized method id" );
}
- if( mat )
+ if (isStorage)
+ return circles;
+ else
{
if( mat->cols > mat->rows )
mat->cols = circles->total;
else
mat->rows = circles->total;
}
- else
- result = circles;
- return result;
+ return 0;
}
/* helper tables */
extern const uchar icvSaturate8u_cv[];
-#define CV_FAST_CAST_8U(t) (assert(-256 <= (t) && (t) <= 512), icvSaturate8u_cv[(t)+256])
+#define CV_FAST_CAST_8U(t) ( (-256 <= (t) && (t) <= 512) ? icvSaturate8u_cv[(t)+256] : 0 )
#define CV_CALC_MIN_8U(a,b) (a) -= CV_FAST_CAST_8U((a) - (b))
#define CV_CALC_MAX_8U(a,b) (a) += CV_FAST_CAST_8U((b) - (a))
#include "opencv2/core/sse_utils.hpp"
+inline bool isStorageOrMat(void * arr)
+{
+ if (CV_IS_STORAGE( arr ))
+ return true;
+ else if (CV_IS_MAT( arr ))
+ return false;
+ else
+ CV_Error( CV_StsBadArg, "Destination is not CvMemStorage* nor CvMat*" );
+ return false;
+}
+
#endif /*__OPENCV_CV_INTERNAL_H_*/
integral(_image, image_sums, image_sqsums, CV_32F, CV_32F);
int type = image_sums.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
+ CV_Assert(cn >= 1 && cn <= 4);
ocl::Kernel k("matchTemplate_CCOEFF_NORMED", ocl::imgproc::match_template_oclsrc,
format("-D CCOEFF_NORMED -D T=%s -D T1=%s -D cn=%d", ocl::typeToStr(type), ocl::typeToStr(depth), cn));
sscanf( stage, "%d%n", &rects, &dl );
stage += dl;
- CV_DbgAssert( rects >= 2 && rects <= CV_HAAR_FEATURE_MAX );
+ CV_Assert( rects >= 2 && rects <= CV_HAAR_FEATURE_MAX );
for( k = 0; k < rects; k++ )
{
int channels = images[0].channels();
int CV_32FCC = CV_MAKETYPE(CV_32F, channels);
+ CV_Assert(channels >= 1 && channels <= 3);
dst.create(LDR_SIZE, 1, CV_32FCC);
Mat response = dst.getMat();