#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);
}
-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;
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);
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);
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);
}
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);
}
-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 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);
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);
}
-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)
{
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);
}
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);
# if defined __AVX__ || (defined _MSC_FULL_VER && _MSC_FULL_VER >= 160040219)
# include <immintrin.h>
# 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
IplImage * CvCapture_GStreamer::retrieveFrame(int)
{
if(!buffer)
- return false;
+ return 0;
if(!frame) {
gint height, width;
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);
return wrt;
delete wrt;
- return false;
+ return 0;
}
void CvCapture_GStreamer::close()
return capture;
delete capture;
- return false;
+ return 0;
}
return ok;
}
+// Multi-threaded construction of the scale-space pyramid
+struct SURFBuildInvoker
+{
+ SURFBuildInvoker( const Mat& _sum, const vector<int>& _sizes,
+ const vector<int>& _sampleSteps,
+ vector<Mat>& _dets, vector<Mat>& _traces )
+ {
+ sum = &_sum;
+ sizes = &_sizes;
+ sampleSteps = &_sampleSteps;
+ dets = &_dets;
+ traces = &_traces;
+ }
+
+ void operator()(const BlockedRange& range) const
+ {
+ for( int i=range.begin(); i<range.end(); i++ )
+ calcLayerDetAndTrace( *sum, (*sizes)[i], (*sampleSteps)[i], (*dets)[i], (*traces)[i] );
+ }
+
+ const Mat *sum;
+ const vector<int> *sizes;
+ const vector<int> *sampleSteps;
+ vector<Mat>* dets;
+ vector<Mat>* traces;
+};
+
+// Multi-threaded search of the scale-space pyramid for keypoints
+struct SURFFindInvoker
+{
+ SURFFindInvoker( const Mat& _sum, const Mat& _mask_sum,
+ const vector<Mat>& _dets, const vector<Mat>& _traces,
+ const vector<int>& _sizes, const vector<int>& _sampleSteps,
+ const vector<int>& _middleIndices, vector<KeyPoint>& _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<Mat>& dets, const vector<Mat>& traces,
+ const vector<int>& sizes, vector<KeyPoint>& keypoints,
+ int octave, int layer, float hessianThreshold, int sampleStep );
+
+ void operator()(const BlockedRange& range) const
+ {
+ for( int i=range.begin(); i<range.end(); i++ )
+ {
+ int layer = (*middleIndices)[i];
+ int octave = i / nOctaveLayers;
+ findMaximaInLayer( *sum, *mask_sum, *dets, *traces, *sizes,
+ *keypoints, octave, layer, hessianThreshold,
+ (*sampleSteps)[layer] );
+ }
+ }
+
+ const Mat *sum;
+ const Mat *mask_sum;
+ const vector<Mat>* dets;
+ const vector<Mat>* traces;
+ const vector<int>* sizes;
+ const vector<int>* sampleSteps;
+ const vector<int>* middleIndices;
+ vector<KeyPoint>* keypoints;
+ int nOctaveLayers;
+ float hessianThreshold;
+
+#ifdef HAVE_TBB
+ static tbb::mutex findMaximaInLayer_m;
+#endif
+};
+
#ifdef HAVE_TBB
-static tbb::mutex findMaximaInLayer_m;
+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<Mat>& dets, const vector<Mat>& traces,
const vector<int>& sizes, vector<KeyPoint>& keypoints,
int octave, int layer, float hessianThreshold, int sampleStep )
}
}
-
-// Multi-threaded construction of the scale-space pyramid
-struct SURFBuildInvoker
-{
- SURFBuildInvoker( const Mat& _sum, const vector<int>& _sizes,
- const vector<int>& _sampleSteps,
- vector<Mat>& _dets, vector<Mat>& _traces )
- {
- sum = &_sum;
- sizes = &_sizes;
- sampleSteps = &_sampleSteps;
- dets = &_dets;
- traces = &_traces;
- }
-
- void operator()(const BlockedRange& range) const
- {
- for( int i=range.begin(); i<range.end(); i++ )
- calcLayerDetAndTrace( *sum, (*sizes)[i], (*sampleSteps)[i], (*dets)[i], (*traces)[i] );
- }
-
- const Mat *sum;
- const vector<int> *sizes;
- const vector<int> *sampleSteps;
- vector<Mat>* dets;
- vector<Mat>* traces;
-};
-
-// Multi-threaded search of the scale-space pyramid for keypoints
-struct SURFFindInvoker
-{
- SURFFindInvoker( const Mat& _sum, const Mat& _mask_sum,
- const vector<Mat>& _dets, const vector<Mat>& _traces,
- const vector<int>& _sizes, const vector<int>& _sampleSteps,
- const vector<int>& _middleIndices, vector<KeyPoint>& _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<range.end(); i++ )
- {
- int layer = (*middleIndices)[i];
- int octave = i / nOctaveLayers;
- findMaximaInLayer( *sum, *mask_sum, *dets, *traces, *sizes,
- *keypoints, octave, layer, hessianThreshold,
- (*sampleSteps)[layer] );
- }
- }
-
- const Mat *sum;
- const Mat *mask_sum;
- const vector<Mat>* dets;
- const vector<Mat>* traces;
- const vector<int>* sizes;
- const vector<int>* sampleSteps;
- const vector<int>* middleIndices;
- vector<KeyPoint>* keypoints;
- int nOctaveLayers;
- float hessianThreshold;
-};
-
struct KeypointGreater
{
inline bool operator()(const KeyPoint& kp1, const KeyPoint& kp2) const
#include "precomp.hpp"
#include <stdio.h>
+#include "opencv2/core/internal.hpp"
#if CV_SSE2 || CV_SSE3
#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;
}
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 )
{
}
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++ )
__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
__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;
}
}
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));
{
cvmat_t *pc = (cvmat_t*)self;
Py_XDECREF(pc->data);
- //cvDecRefData(pc->a);
+ //cvDecRefData(pc->a);
cvFree(&pc->a);
PyObject_Del(self);
}
{
cvmatnd_t *pc = (cvmatnd_t*)self;
Py_XDECREF(pc->data);
- cvDecRefData(pc->a);
+ cvDecRefData(pc->a);
cvFree(&pc->a);
PyObject_Del(self);
}
}
}
-static
+static
PySequenceMethods cvseq_sequence = {
cvseq_seq_length,
NULL,
*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);
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);
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);
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.
//
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
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
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));
}
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,
/************************************************************************/
-/* 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)
else if (pai->itemsize == 8)
type = CV_64FC1;
break;
-
+
}
if (type == -1) {
PyErr_SetString(PyExc_TypeError, "the array type is not supported by OpenCV");
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;
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
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;
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;
}