diff --git a/3rdparty/libjasper/jpc_qmfb.c b/3rdparty/libjasper/jpc_qmfb.c index 925f289fd7..a8460d3cdc 100644 --- a/3rdparty/libjasper/jpc_qmfb.c +++ b/3rdparty/libjasper/jpc_qmfb.c @@ -94,14 +94,14 @@ #define QMFB_SPLITBUFSIZE 4096 #define QMFB_JOINBUFSIZE 4096 -int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, +int jpc_ft_analyze(int *a, int xstart, int ystart, int width, int height, int stride); int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height, int stride); -int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, +int jpc_ns_analyze(int *a, int xstart, int ystart, int width, int height, int stride); -int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width, +int jpc_ns_synthesize(int *a, int xstart, int ystart, int width, int height, int stride); void jpc_ft_fwdlift_row(jpc_fix_t *a, int numcols, int parity); @@ -1556,7 +1556,7 @@ void jpc_ft_invlift_colres(jpc_fix_t *a, int numrows, int numcols, int stride, } -int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, +int jpc_ft_analyze(int *a, int xstart, int ystart, int width, int height, int stride) { int numrows = height; @@ -1568,7 +1568,7 @@ int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, int maxcols; maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE; - startptr = &a[0]; + startptr = (jpc_fix_t*)&a[0]; for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) { jpc_qmfb_split_colgrp(startptr, numrows, stride, rowparity); jpc_ft_fwdlift_colgrp(startptr, numrows, stride, rowparity); @@ -1581,7 +1581,7 @@ int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, rowparity); } - startptr = &a[0]; + startptr = (jpc_fix_t*)&a[0]; for (i = 0; i < numrows; ++i) { jpc_qmfb_split_row(startptr, numcols, colparity); jpc_ft_fwdlift_row(startptr, numcols, colparity); @@ -1604,7 +1604,7 @@ int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height, jpc_fix_t *startptr; int i; - startptr = &a[0]; + startptr = (jpc_fix_t*)&a[0]; for (i = 0; i < numrows; ++i) { jpc_ft_invlift_row(startptr, numcols, colparity); jpc_qmfb_join_row(startptr, numcols, colparity); @@ -1612,7 +1612,7 @@ int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height, } maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE; - startptr = &a[0]; + startptr = (jpc_fix_t*)&a[0]; for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) { jpc_ft_invlift_colgrp(startptr, numrows, stride, rowparity); jpc_qmfb_join_colgrp(startptr, numrows, stride, rowparity); @@ -3068,7 +3068,7 @@ void jpc_ns_invlift_col(jpc_fix_t *a, int numrows, int stride, } -int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, +int jpc_ns_analyze(int *a, int xstart, int ystart, int width, int height, int stride) { @@ -3081,7 +3081,7 @@ int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, int maxcols; maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE; - startptr = &a[0]; + startptr = (jpc_fix_t*)&a[0]; for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) { jpc_qmfb_split_colgrp(startptr, numrows, stride, rowparity); jpc_ns_fwdlift_colgrp(startptr, numrows, stride, rowparity); @@ -3094,7 +3094,7 @@ int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, rowparity); } - startptr = &a[0]; + startptr = (jpc_fix_t*)&a[0]; for (i = 0; i < numrows; ++i) { jpc_qmfb_split_row(startptr, numcols, colparity); jpc_ns_fwdlift_row(startptr, numcols, colparity); @@ -3105,7 +3105,7 @@ int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, } -int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width, +int jpc_ns_synthesize(int *a, int xstart, int ystart, int width, int height, int stride) { @@ -3117,7 +3117,7 @@ int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width, jpc_fix_t *startptr; int i; - startptr = &a[0]; + startptr = (jpc_fix_t*)&a[0]; for (i = 0; i < numrows; ++i) { jpc_ns_invlift_row(startptr, numcols, colparity); jpc_qmfb_join_row(startptr, numcols, colparity); @@ -3125,7 +3125,7 @@ int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width, } maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE; - startptr = &a[0]; + startptr = (jpc_fix_t*)&a[0]; for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) { jpc_ns_invlift_colgrp(startptr, numrows, stride, rowparity); jpc_qmfb_join_colgrp(startptr, numrows, stride, rowparity); diff --git a/modules/core/include/opencv2/core/internal.hpp b/modules/core/include/opencv2/core/internal.hpp index 235abcc3c1..ee4053aafb 100644 --- a/modules/core/include/opencv2/core/internal.hpp +++ b/modules/core/include/opencv2/core/internal.hpp @@ -135,6 +135,11 @@ CV_INLINE IppiSize ippiSize(int width, int height) # if defined __AVX__ || (defined _MSC_FULL_VER && _MSC_FULL_VER >= 160040219) # include # define CV_AVX 1 +# if defined(_XCR_XFEATURE_ENABLED_MASK) +# define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK) +# else +# define __xgetbv() 0 +# endif # else # define CV_AVX 0 # endif diff --git a/modules/highgui/src/cap_gstreamer.cpp b/modules/highgui/src/cap_gstreamer.cpp index ecce0b53b8..e8cf213261 100644 --- a/modules/highgui/src/cap_gstreamer.cpp +++ b/modules/highgui/src/cap_gstreamer.cpp @@ -183,7 +183,7 @@ bool CvCapture_GStreamer::grabFrame() IplImage * CvCapture_GStreamer::retrieveFrame(int) { if(!buffer) - return false; + return 0; if(!frame) { gint height, width; @@ -193,7 +193,7 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int) if(!gst_structure_get_int(structure, "width", &width) || !gst_structure_get_int(structure, "height", &height)) - return false; + return 0; frame = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 3); gst_caps_unref(buff_caps); @@ -572,7 +572,7 @@ CvVideoWriter* cvCreateVideoWriter_GStreamer(const char* filename, int fourcc, d return wrt; delete wrt; - return false; + return 0; } void CvCapture_GStreamer::close() @@ -746,5 +746,5 @@ CvCapture* cvCreateCapture_GStreamer(int type, const char* filename ) return capture; delete capture; - return false; + return 0; } diff --git a/modules/nonfree/src/surf.cpp b/modules/nonfree/src/surf.cpp index 8c601a8b80..9e6ce5464c 100644 --- a/modules/nonfree/src/surf.cpp +++ b/modules/nonfree/src/surf.cpp @@ -257,16 +257,97 @@ interpolateKeypoint( float N9[3][9], int dx, int dy, int ds, KeyPoint& kpt ) return ok; } +// Multi-threaded construction of the scale-space pyramid +struct SURFBuildInvoker +{ + SURFBuildInvoker( const Mat& _sum, const vector& _sizes, + const vector& _sampleSteps, + vector& _dets, vector& _traces ) + { + sum = &_sum; + sizes = &_sizes; + sampleSteps = &_sampleSteps; + dets = &_dets; + traces = &_traces; + } + + void operator()(const BlockedRange& range) const + { + for( int i=range.begin(); i *sizes; + const vector *sampleSteps; + vector* dets; + vector* traces; +}; + +// Multi-threaded search of the scale-space pyramid for keypoints +struct SURFFindInvoker +{ + SURFFindInvoker( const Mat& _sum, const Mat& _mask_sum, + const vector& _dets, const vector& _traces, + const vector& _sizes, const vector& _sampleSteps, + const vector& _middleIndices, vector& _keypoints, + int _nOctaveLayers, float _hessianThreshold ) + { + sum = &_sum; + mask_sum = &_mask_sum; + dets = &_dets; + traces = &_traces; + sizes = &_sizes; + sampleSteps = &_sampleSteps; + middleIndices = &_middleIndices; + keypoints = &_keypoints; + nOctaveLayers = _nOctaveLayers; + hessianThreshold = _hessianThreshold; + } + + static void findMaximaInLayer( const Mat& sum, const Mat& mask_sum, + const vector& dets, const vector& traces, + const vector& sizes, vector& keypoints, + int octave, int layer, float hessianThreshold, int sampleStep ); + + void operator()(const BlockedRange& range) const + { + for( int i=range.begin(); i* dets; + const vector* traces; + const vector* sizes; + const vector* sampleSteps; + const vector* middleIndices; + vector* keypoints; + int nOctaveLayers; + float hessianThreshold; + #ifdef HAVE_TBB -static tbb::mutex findMaximaInLayer_m; + static tbb::mutex findMaximaInLayer_m; #endif +}; + +#ifdef HAVE_TBB +tbb::mutex SURFFindInvoker::findMaximaInLayer_m; +#endif + /* * Find the maxima in the determinant of the Hessian in a layer of the * scale-space pyramid */ -static void -findMaximaInLayer( const Mat& sum, const Mat& mask_sum, +void SURFFindInvoker::findMaximaInLayer( const Mat& sum, const Mat& mask_sum, const vector& dets, const vector& traces, const vector& sizes, vector& keypoints, int octave, int layer, float hessianThreshold, int sampleStep ) @@ -367,84 +448,6 @@ findMaximaInLayer( const Mat& sum, const Mat& mask_sum, } } - -// Multi-threaded construction of the scale-space pyramid -struct SURFBuildInvoker -{ - SURFBuildInvoker( const Mat& _sum, const vector& _sizes, - const vector& _sampleSteps, - vector& _dets, vector& _traces ) - { - sum = &_sum; - sizes = &_sizes; - sampleSteps = &_sampleSteps; - dets = &_dets; - traces = &_traces; - } - - void operator()(const BlockedRange& range) const - { - for( int i=range.begin(); i *sizes; - const vector *sampleSteps; - vector* dets; - vector* traces; -}; - -// Multi-threaded search of the scale-space pyramid for keypoints -struct SURFFindInvoker -{ - SURFFindInvoker( const Mat& _sum, const Mat& _mask_sum, - const vector& _dets, const vector& _traces, - const vector& _sizes, const vector& _sampleSteps, - const vector& _middleIndices, vector& _keypoints, - int _nOctaveLayers, float _hessianThreshold ) - { - sum = &_sum; - mask_sum = &_mask_sum; - dets = &_dets; - traces = &_traces; - sizes = &_sizes; - sampleSteps = &_sampleSteps; - middleIndices = &_middleIndices; - keypoints = &_keypoints; - nOctaveLayers = _nOctaveLayers; - hessianThreshold = _hessianThreshold; - -#ifdef HAVE_TBB - //touch the mutex to ensure that it's initialization is finished - CV_Assert(&findMaximaInLayer_m > 0); -#endif - } - - void operator()(const BlockedRange& range) const - { - for( int i=range.begin(); i* dets; - const vector* traces; - const vector* sizes; - const vector* sampleSteps; - const vector* middleIndices; - vector* keypoints; - int nOctaveLayers; - float hessianThreshold; -}; - struct KeypointGreater { inline bool operator()(const KeyPoint& kp1, const KeyPoint& kp2) const diff --git a/modules/objdetect/src/haar.cpp b/modules/objdetect/src/haar.cpp index 4ba4e7f694..5e2d5324dc 100644 --- a/modules/objdetect/src/haar.cpp +++ b/modules/objdetect/src/haar.cpp @@ -43,6 +43,7 @@ #include "precomp.hpp" #include +#include "opencv2/core/internal.hpp" #if CV_SSE2 || CV_SSE3 @@ -780,7 +781,7 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade, #ifdef CV_HAAR_USE_AVX bool haveAVX = false; if(cv::checkHardwareSupport(CV_CPU_AVX)) - if(_xgetbv(_XCR_XFEATURE_ENABLED_MASK)&0x6)// Check if the OS will save the YMM registers + if(__xgetbv()&0x6)// Check if the OS will save the YMM registers { haveAVX = true; } @@ -867,7 +868,7 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade, for( i = start_stage; i < cascade->count; i++ ) { stage_sum = 0.0; - int j = 0; + j = 0; float CV_DECL_ALIGNED(32) buf[8]; if( cascade->stage_classifier[i].two_rects ) { @@ -1020,12 +1021,12 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade, } else #endif - #if defined CV_HAAR_USE_SSE && CV_HAAR_USE_SSE && !CV_HAAR_USE_AVX //old SSE optimization + #if defined CV_HAAR_USE_SSE && CV_HAAR_USE_SSE && (!defined CV_HAAR_USE_AVX || !CV_HAAR_USE_AVX) //old SSE optimization if(haveSSE2) { for( i = start_stage; i < cascade->count; i++ ) { - __m128d stage_sum = _mm_setzero_pd(); + __m128d vstage_sum = _mm_setzero_pd(); if( cascade->stage_classifier[i].two_rects ) { for( j = 0; j < cascade->stage_classifier[i].count; j++ ) @@ -1040,7 +1041,7 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade, __m128d sum = _mm_set_sd(calc_sum(node->feature.rect[0],p_offset) * node->feature.rect[0].weight + calc_sum(node->feature.rect[1],p_offset) * node->feature.rect[1].weight); t = _mm_cmpgt_sd(t, sum); - stage_sum = _mm_add_sd(stage_sum, _mm_blendv_pd(b, a, t)); + vstage_sum = _mm_add_sd(vstage_sum, _mm_blendv_pd(b, a, t)); } } else @@ -1060,11 +1061,11 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade, __m128d sum = _mm_set_sd(_sum); t = _mm_cmpgt_sd(t, sum); - stage_sum = _mm_add_sd(stage_sum, _mm_blendv_pd(b, a, t)); + vstage_sum = _mm_add_sd(vstage_sum, _mm_blendv_pd(b, a, t)); } } __m128d i_threshold = _mm_set1_pd(cascade->stage_classifier[i].threshold); - if( _mm_comilt_sd(stage_sum, i_threshold) ) + if( _mm_comilt_sd(vstage_sum, i_threshold) ) return -i; } } diff --git a/modules/python/src2/cv2.cv.hpp b/modules/python/src2/cv2.cv.hpp index 3379a14e44..0207189a1a 100644 --- a/modules/python/src2/cv2.cv.hpp +++ b/modules/python/src2/cv2.cv.hpp @@ -256,7 +256,7 @@ static PyObject *iplimage_tostring(PyObject *self, PyObject *args) cv::Mat img(i); size_t esz = img.elemSize(); int nrows = img.rows, ncols = img.cols; - + if( !img.isContinuous() ) img = img.clone(); return PyString_FromStringAndSize((char*)img.data, (Py_ssize_t)(esz*nrows*ncols)); @@ -338,7 +338,7 @@ static void cvmat_dealloc(PyObject *self) { cvmat_t *pc = (cvmat_t*)self; Py_XDECREF(pc->data); - //cvDecRefData(pc->a); + //cvDecRefData(pc->a); cvFree(&pc->a); PyObject_Del(self); } @@ -656,7 +656,7 @@ static void cvmatnd_dealloc(PyObject *self) { cvmatnd_t *pc = (cvmatnd_t*)self; Py_XDECREF(pc->data); - cvDecRefData(pc->a); + cvDecRefData(pc->a); cvFree(&pc->a); PyObject_Del(self); } @@ -1186,7 +1186,7 @@ static PyObject* cvseq_map_getitem(PyObject *o, PyObject *item) } } -static +static PySequenceMethods cvseq_sequence = { cvseq_seq_length, NULL, @@ -1606,8 +1606,8 @@ static int convert_to_CvMat(PyObject *o, CvMat **dst, const char *name) *dst = m->a; return 1; } else if (m->data && m->a->data.ptr){ - *dst = m->a; - return 1; + *dst = m->a; + return 1; } else { return failmsg("CvMat argument '%s' has no data", name); @@ -2174,7 +2174,7 @@ static int convert_to_CvSubdiv2DEdge(PyObject *o, CvSubdiv2DEdge *dst, const cha static PyObject *pythonize_CvMat(cvmat_t *m) { - // Need to make this CvMat look like any other, with a Python + // Need to make this CvMat look like any other, with a Python // buffer object as its data. CvMat *mat = m->a; assert(mat->step != 0); @@ -2204,9 +2204,9 @@ static PyObject *pythonize_CvMat(cvmat_t *m) static PyObject *pythonize_IplImage(iplimage_t *cva) { - // Need to make this iplimage look like any other, with a Python + // Need to make this iplimage look like any other, with a Python // string as its data. - // So copy the image data into a Python string object, then release + // So copy the image data into a Python string object, then release // it. IplImage *ipl = (IplImage*)(cva->a); @@ -2233,7 +2233,7 @@ static PyObject *pythonize_IplImage(iplimage_t *cva) static PyObject *pythonize_CvMatND(cvmatnd_t *m, PyObject *backing = NULL) { // - // Need to make this CvMatND look like any other, with a Python + // Need to make this CvMatND look like any other, with a Python // buffer object as its data. // @@ -2341,9 +2341,9 @@ static PyObject *FROM_CvSeqOfCvConvexityDefectPTR(CvSeqOfCvConvexityDefect *r) for (int i = 0; i < r->total; i++) { CvConvexityDefect *pd = CV_GET_SEQ_ELEM(CvConvexityDefect, r, i); PyList_SetItem(pr, i, Py_BuildValue("(ii)(ii)(ii)f", - pd->start->x, pd->start->y, - pd->end->x, pd->end->y, - pd->depth_point->x, pd->depth_point->y, + pd->start->x, pd->start->y, + pd->end->x, pd->end->y, + pd->depth_point->x, pd->depth_point->y, pd->depth)); } // This function has copied the CvSeq data into a list. Hence the @@ -2360,8 +2360,8 @@ static PyObject *FROM_CvSeqOfCvAvgCompPTR(CvSeqOfCvAvgComp *r) for (int i = 0; i < r->total; i++) { CvAvgComp *pd = CV_GET_SEQ_ELEM(CvAvgComp, r, i); PyList_SetItem(pr, i, Py_BuildValue("(iiii)i", - pd->rect.x, pd->rect.y, - pd->rect.width, pd->rect.height, + pd->rect.x, pd->rect.y, + pd->rect.width, pd->rect.height, pd->neighbors)); } // This function has copied the CvSeq data into a list. Hence the @@ -2378,7 +2378,7 @@ static PyObject *FROM_CvSeqOfCvStarKeypointPTR(CvSeqOfCvStarKeypoint *r) for (int i = 0; i < r->total; i++) { CvStarKeypoint *pd = CV_GET_SEQ_ELEM(CvStarKeypoint, r, i); PyList_SetItem(pr, i, Py_BuildValue("(ii)if", - pd->pt.x, pd->pt.y, + pd->pt.x, pd->pt.y, pd->size, pd->response)); } @@ -2396,7 +2396,7 @@ static PyObject *FROM_CvSeqOfCvSURFPointPTR(CvSeqOfCvSURFPoint *r) for (int i = 0; i < r->total; i++) { CvSURFPoint *pd = CV_GET_SEQ_ELEM(CvSURFPoint, r, i); PyList_SetItem(pr, i, Py_BuildValue("(ff)iiff", - pd->pt.x, pd->pt.y, + pd->pt.x, pd->pt.y, pd->laplacian, pd->size, pd->dir, @@ -2587,7 +2587,7 @@ static PyObject *FROM_CvPoints(CvPoints src) /************************************************************************/ -/* A few functions are too odd to be generated, +/* A few functions are too odd to be generated, * so are handwritten here */ static PyObject *pycvWaitKey(PyObject *self, PyObject *args, PyObject *kw) @@ -2808,7 +2808,7 @@ static PyObject *fromarray(PyObject *o, int allowND) else if (pai->itemsize == 8) type = CV_64FC1; break; - + } if (type == -1) { PyErr_SetString(PyExc_TypeError, "the array type is not supported by OpenCV"); @@ -2826,20 +2826,20 @@ static PyObject *fromarray(PyObject *o, int allowND) m->a->step = (int)pai->strides[0]; } else if (pai->nd == 3) { if (pai->shape[2] > CV_CN_MAX) { - Py_DECREF(ao); + Py_DECREF(ao); return failmsg("cv.fromarray too many channels, see allowND argument"), (PyObject*)0; } ERRWRAP(m->a = cvCreateMatHeader((int)pai->shape[0], (int)pai->shape[1], type + ((int)(pai->shape[2] - 1) << CV_CN_SHIFT))); m->a->step = (int)pai->strides[0]; } else { - Py_DECREF(ao); + Py_DECREF(ao); return failmsg("cv.fromarray array can be 2D or 3D only, see allowND argument"), (PyObject*)0; } m->a->data.ptr = (uchar*)pai->data; //retval = pythonize_foreign_CvMat(m); - m->data = o; - m->offset = 0; - retval = (PyObject*)m; + m->data = o; + m->offset = 0; + retval = (PyObject*)m; } else { int dims[CV_MAX_DIM]; int i; @@ -2848,13 +2848,13 @@ static PyObject *fromarray(PyObject *o, int allowND) cvmatnd_t *m = PyObject_NEW(cvmatnd_t, &cvmatnd_Type); ERRWRAP(m->a = cvCreateMatNDHeader(pai->nd, dims, type)); m->a->data.ptr = (uchar*)pai->data; - m->data = o; - m->offset = 0; - retval = (PyObject*)m; + m->data = o; + m->offset = 0; + retval = (PyObject*)m; //retval = pythonize_CvMatND(m, ao); } Py_DECREF(ao); - Py_INCREF(o); + Py_INCREF(o); return retval; } #endif @@ -2875,7 +2875,7 @@ public: rr = new float*[len]; for (Py_ssize_t i = 0; i < len; i++) { PyObject *item = PySequence_Fast_GET_ITEM(fi, i); - floats ff; + floats ff; ff.f = 0; if (!convert_to_floats(item, &ff)) return 0; rr[i] = ff.f; @@ -4040,13 +4040,13 @@ static PyObject* init_cv() PUBLISH(GC_INIT_WITH_RECT); PUBLISH(GC_INIT_WITH_MASK); PUBLISH(GC_EVAL); - + #include "generated2.i" #undef PUBLISH #undef PUBLISHU -#undef PUBLISH2 - +#undef PUBLISH2 + return m; }