Commit bcd0aefb authored by Andrey Kamaev's avatar Andrey Kamaev

Fix gcc build errors and warnings

parent 5eac0419
...@@ -94,14 +94,14 @@ ...@@ -94,14 +94,14 @@
#define QMFB_SPLITBUFSIZE 4096 #define QMFB_SPLITBUFSIZE 4096
#define QMFB_JOINBUFSIZE 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 stride);
int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height, int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height,
int stride); 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 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); int height, int stride);
void jpc_ft_fwdlift_row(jpc_fix_t *a, int numcols, int parity); 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, ...@@ -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 stride)
{ {
int numrows = height; int numrows = height;
...@@ -1568,7 +1568,7 @@ int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, ...@@ -1568,7 +1568,7 @@ int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
int maxcols; int maxcols;
maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE; 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) { for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {
jpc_qmfb_split_colgrp(startptr, numrows, stride, rowparity); jpc_qmfb_split_colgrp(startptr, numrows, stride, rowparity);
jpc_ft_fwdlift_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, ...@@ -1581,7 +1581,7 @@ int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
rowparity); rowparity);
} }
startptr = &a[0]; startptr = (jpc_fix_t*)&a[0];
for (i = 0; i < numrows; ++i) { for (i = 0; i < numrows; ++i) {
jpc_qmfb_split_row(startptr, numcols, colparity); jpc_qmfb_split_row(startptr, numcols, colparity);
jpc_ft_fwdlift_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, ...@@ -1604,7 +1604,7 @@ int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height,
jpc_fix_t *startptr; jpc_fix_t *startptr;
int i; int i;
startptr = &a[0]; startptr = (jpc_fix_t*)&a[0];
for (i = 0; i < numrows; ++i) { for (i = 0; i < numrows; ++i) {
jpc_ft_invlift_row(startptr, numcols, colparity); jpc_ft_invlift_row(startptr, numcols, colparity);
jpc_qmfb_join_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, ...@@ -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; 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) { for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {
jpc_ft_invlift_colgrp(startptr, numrows, stride, rowparity); jpc_ft_invlift_colgrp(startptr, numrows, stride, rowparity);
jpc_qmfb_join_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, ...@@ -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) int stride)
{ {
...@@ -3081,7 +3081,7 @@ int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height, ...@@ -3081,7 +3081,7 @@ int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
int maxcols; int maxcols;
maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE; 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) { for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {
jpc_qmfb_split_colgrp(startptr, numrows, stride, rowparity); jpc_qmfb_split_colgrp(startptr, numrows, stride, rowparity);
jpc_ns_fwdlift_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, ...@@ -3094,7 +3094,7 @@ int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
rowparity); rowparity);
} }
startptr = &a[0]; startptr = (jpc_fix_t*)&a[0];
for (i = 0; i < numrows; ++i) { for (i = 0; i < numrows; ++i) {
jpc_qmfb_split_row(startptr, numcols, colparity); jpc_qmfb_split_row(startptr, numcols, colparity);
jpc_ns_fwdlift_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, ...@@ -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) int height, int stride)
{ {
...@@ -3117,7 +3117,7 @@ int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width, ...@@ -3117,7 +3117,7 @@ int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width,
jpc_fix_t *startptr; jpc_fix_t *startptr;
int i; int i;
startptr = &a[0]; startptr = (jpc_fix_t*)&a[0];
for (i = 0; i < numrows; ++i) { for (i = 0; i < numrows; ++i) {
jpc_ns_invlift_row(startptr, numcols, colparity); jpc_ns_invlift_row(startptr, numcols, colparity);
jpc_qmfb_join_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, ...@@ -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; 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) { for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {
jpc_ns_invlift_colgrp(startptr, numrows, stride, rowparity); jpc_ns_invlift_colgrp(startptr, numrows, stride, rowparity);
jpc_qmfb_join_colgrp(startptr, numrows, stride, rowparity); jpc_qmfb_join_colgrp(startptr, numrows, stride, rowparity);
......
...@@ -135,6 +135,11 @@ CV_INLINE IppiSize ippiSize(int width, int height) ...@@ -135,6 +135,11 @@ CV_INLINE IppiSize ippiSize(int width, int height)
# if defined __AVX__ || (defined _MSC_FULL_VER && _MSC_FULL_VER >= 160040219) # if defined __AVX__ || (defined _MSC_FULL_VER && _MSC_FULL_VER >= 160040219)
# include <immintrin.h> # include <immintrin.h>
# define CV_AVX 1 # define CV_AVX 1
# if defined(_XCR_XFEATURE_ENABLED_MASK)
# define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK)
# else
# define __xgetbv() 0
# endif
# else # else
# define CV_AVX 0 # define CV_AVX 0
# endif # endif
......
...@@ -183,7 +183,7 @@ bool CvCapture_GStreamer::grabFrame() ...@@ -183,7 +183,7 @@ bool CvCapture_GStreamer::grabFrame()
IplImage * CvCapture_GStreamer::retrieveFrame(int) IplImage * CvCapture_GStreamer::retrieveFrame(int)
{ {
if(!buffer) if(!buffer)
return false; return 0;
if(!frame) { if(!frame) {
gint height, width; gint height, width;
...@@ -193,7 +193,7 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int) ...@@ -193,7 +193,7 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
if(!gst_structure_get_int(structure, "width", &width) || if(!gst_structure_get_int(structure, "width", &width) ||
!gst_structure_get_int(structure, "height", &height)) !gst_structure_get_int(structure, "height", &height))
return false; return 0;
frame = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 3); frame = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 3);
gst_caps_unref(buff_caps); gst_caps_unref(buff_caps);
...@@ -572,7 +572,7 @@ CvVideoWriter* cvCreateVideoWriter_GStreamer(const char* filename, int fourcc, d ...@@ -572,7 +572,7 @@ CvVideoWriter* cvCreateVideoWriter_GStreamer(const char* filename, int fourcc, d
return wrt; return wrt;
delete wrt; delete wrt;
return false; return 0;
} }
void CvCapture_GStreamer::close() void CvCapture_GStreamer::close()
...@@ -746,5 +746,5 @@ CvCapture* cvCreateCapture_GStreamer(int type, const char* filename ) ...@@ -746,5 +746,5 @@ CvCapture* cvCreateCapture_GStreamer(int type, const char* filename )
return capture; return capture;
delete capture; delete capture;
return false; return 0;
} }
...@@ -257,16 +257,97 @@ interpolateKeypoint( float N9[3][9], int dx, int dy, int ds, KeyPoint& kpt ) ...@@ -257,16 +257,97 @@ interpolateKeypoint( float N9[3][9], int dx, int dy, int ds, KeyPoint& kpt )
return ok; 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 #ifdef HAVE_TBB
static tbb::mutex findMaximaInLayer_m; tbb::mutex SURFFindInvoker::findMaximaInLayer_m;
#endif #endif
/* /*
* Find the maxima in the determinant of the Hessian in a layer of the * Find the maxima in the determinant of the Hessian in a layer of the
* scale-space pyramid * scale-space pyramid
*/ */
static void void SURFFindInvoker::findMaximaInLayer( const Mat& sum, const Mat& mask_sum,
findMaximaInLayer( const Mat& sum, const Mat& mask_sum,
const vector<Mat>& dets, const vector<Mat>& traces, const vector<Mat>& dets, const vector<Mat>& traces,
const vector<int>& sizes, vector<KeyPoint>& keypoints, const vector<int>& sizes, vector<KeyPoint>& keypoints,
int octave, int layer, float hessianThreshold, int sampleStep ) int octave, int layer, float hessianThreshold, int sampleStep )
...@@ -367,84 +448,6 @@ findMaximaInLayer( const Mat& sum, const Mat& mask_sum, ...@@ -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<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 struct KeypointGreater
{ {
inline bool operator()(const KeyPoint& kp1, const KeyPoint& kp2) const inline bool operator()(const KeyPoint& kp1, const KeyPoint& kp2) const
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "precomp.hpp" #include "precomp.hpp"
#include <stdio.h> #include <stdio.h>
#include "opencv2/core/internal.hpp"
#if CV_SSE2 || CV_SSE3 #if CV_SSE2 || CV_SSE3
...@@ -780,7 +781,7 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade, ...@@ -780,7 +781,7 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade,
#ifdef CV_HAAR_USE_AVX #ifdef CV_HAAR_USE_AVX
bool haveAVX = false; bool haveAVX = false;
if(cv::checkHardwareSupport(CV_CPU_AVX)) 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; haveAVX = true;
} }
...@@ -867,7 +868,7 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade, ...@@ -867,7 +868,7 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade,
for( i = start_stage; i < cascade->count; i++ ) for( i = start_stage; i < cascade->count; i++ )
{ {
stage_sum = 0.0; stage_sum = 0.0;
int j = 0; j = 0;
float CV_DECL_ALIGNED(32) buf[8]; float CV_DECL_ALIGNED(32) buf[8];
if( cascade->stage_classifier[i].two_rects ) if( cascade->stage_classifier[i].two_rects )
{ {
...@@ -1020,12 +1021,12 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade, ...@@ -1020,12 +1021,12 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade,
} }
else else
#endif #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) if(haveSSE2)
{ {
for( i = start_stage; i < cascade->count; i++ ) 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 ) if( cascade->stage_classifier[i].two_rects )
{ {
for( j = 0; j < cascade->stage_classifier[i].count; j++ ) for( j = 0; j < cascade->stage_classifier[i].count; j++ )
...@@ -1040,7 +1041,7 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade, ...@@ -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 + __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); calc_sum(node->feature.rect[1],p_offset) * node->feature.rect[1].weight);
t = _mm_cmpgt_sd(t, 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));
} }
} }
else else
...@@ -1060,11 +1061,11 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade, ...@@ -1060,11 +1061,11 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade,
__m128d sum = _mm_set_sd(_sum); __m128d sum = _mm_set_sd(_sum);
t = _mm_cmpgt_sd(t, 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); __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; return -i;
} }
} }
......
...@@ -256,7 +256,7 @@ static PyObject *iplimage_tostring(PyObject *self, PyObject *args) ...@@ -256,7 +256,7 @@ static PyObject *iplimage_tostring(PyObject *self, PyObject *args)
cv::Mat img(i); cv::Mat img(i);
size_t esz = img.elemSize(); size_t esz = img.elemSize();
int nrows = img.rows, ncols = img.cols; int nrows = img.rows, ncols = img.cols;
if( !img.isContinuous() ) if( !img.isContinuous() )
img = img.clone(); img = img.clone();
return PyString_FromStringAndSize((char*)img.data, (Py_ssize_t)(esz*nrows*ncols)); return PyString_FromStringAndSize((char*)img.data, (Py_ssize_t)(esz*nrows*ncols));
...@@ -338,7 +338,7 @@ static void cvmat_dealloc(PyObject *self) ...@@ -338,7 +338,7 @@ static void cvmat_dealloc(PyObject *self)
{ {
cvmat_t *pc = (cvmat_t*)self; cvmat_t *pc = (cvmat_t*)self;
Py_XDECREF(pc->data); Py_XDECREF(pc->data);
//cvDecRefData(pc->a); //cvDecRefData(pc->a);
cvFree(&pc->a); cvFree(&pc->a);
PyObject_Del(self); PyObject_Del(self);
} }
...@@ -656,7 +656,7 @@ static void cvmatnd_dealloc(PyObject *self) ...@@ -656,7 +656,7 @@ static void cvmatnd_dealloc(PyObject *self)
{ {
cvmatnd_t *pc = (cvmatnd_t*)self; cvmatnd_t *pc = (cvmatnd_t*)self;
Py_XDECREF(pc->data); Py_XDECREF(pc->data);
cvDecRefData(pc->a); cvDecRefData(pc->a);
cvFree(&pc->a); cvFree(&pc->a);
PyObject_Del(self); PyObject_Del(self);
} }
...@@ -1186,7 +1186,7 @@ static PyObject* cvseq_map_getitem(PyObject *o, PyObject *item) ...@@ -1186,7 +1186,7 @@ static PyObject* cvseq_map_getitem(PyObject *o, PyObject *item)
} }
} }
static static
PySequenceMethods cvseq_sequence = { PySequenceMethods cvseq_sequence = {
cvseq_seq_length, cvseq_seq_length,
NULL, NULL,
...@@ -1606,8 +1606,8 @@ static int convert_to_CvMat(PyObject *o, CvMat **dst, const char *name) ...@@ -1606,8 +1606,8 @@ static int convert_to_CvMat(PyObject *o, CvMat **dst, const char *name)
*dst = m->a; *dst = m->a;
return 1; return 1;
} else if (m->data && m->a->data.ptr){ } else if (m->data && m->a->data.ptr){
*dst = m->a; *dst = m->a;
return 1; return 1;
} }
else { else {
return failmsg("CvMat argument '%s' has no data", name); return failmsg("CvMat argument '%s' has no data", name);
...@@ -2174,7 +2174,7 @@ static int convert_to_CvSubdiv2DEdge(PyObject *o, CvSubdiv2DEdge *dst, const cha ...@@ -2174,7 +2174,7 @@ static int convert_to_CvSubdiv2DEdge(PyObject *o, CvSubdiv2DEdge *dst, const cha
static PyObject *pythonize_CvMat(cvmat_t *m) 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. // buffer object as its data.
CvMat *mat = m->a; CvMat *mat = m->a;
assert(mat->step != 0); assert(mat->step != 0);
...@@ -2204,9 +2204,9 @@ static PyObject *pythonize_CvMat(cvmat_t *m) ...@@ -2204,9 +2204,9 @@ static PyObject *pythonize_CvMat(cvmat_t *m)
static PyObject *pythonize_IplImage(iplimage_t *cva) 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. // 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. // it.
IplImage *ipl = (IplImage*)(cva->a); IplImage *ipl = (IplImage*)(cva->a);
...@@ -2233,7 +2233,7 @@ static PyObject *pythonize_IplImage(iplimage_t *cva) ...@@ -2233,7 +2233,7 @@ static PyObject *pythonize_IplImage(iplimage_t *cva)
static PyObject *pythonize_CvMatND(cvmatnd_t *m, PyObject *backing = NULL) 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. // buffer object as its data.
// //
...@@ -2341,9 +2341,9 @@ static PyObject *FROM_CvSeqOfCvConvexityDefectPTR(CvSeqOfCvConvexityDefect *r) ...@@ -2341,9 +2341,9 @@ static PyObject *FROM_CvSeqOfCvConvexityDefectPTR(CvSeqOfCvConvexityDefect *r)
for (int i = 0; i < r->total; i++) { for (int i = 0; i < r->total; i++) {
CvConvexityDefect *pd = CV_GET_SEQ_ELEM(CvConvexityDefect, r, i); CvConvexityDefect *pd = CV_GET_SEQ_ELEM(CvConvexityDefect, r, i);
PyList_SetItem(pr, i, Py_BuildValue("(ii)(ii)(ii)f", PyList_SetItem(pr, i, Py_BuildValue("(ii)(ii)(ii)f",
pd->start->x, pd->start->y, pd->start->x, pd->start->y,
pd->end->x, pd->end->y, pd->end->x, pd->end->y,
pd->depth_point->x, pd->depth_point->y, pd->depth_point->x, pd->depth_point->y,
pd->depth)); pd->depth));
} }
// This function has copied the CvSeq data into a list. Hence the // This function has copied the CvSeq data into a list. Hence the
...@@ -2360,8 +2360,8 @@ static PyObject *FROM_CvSeqOfCvAvgCompPTR(CvSeqOfCvAvgComp *r) ...@@ -2360,8 +2360,8 @@ static PyObject *FROM_CvSeqOfCvAvgCompPTR(CvSeqOfCvAvgComp *r)
for (int i = 0; i < r->total; i++) { for (int i = 0; i < r->total; i++) {
CvAvgComp *pd = CV_GET_SEQ_ELEM(CvAvgComp, r, i); CvAvgComp *pd = CV_GET_SEQ_ELEM(CvAvgComp, r, i);
PyList_SetItem(pr, i, Py_BuildValue("(iiii)i", PyList_SetItem(pr, i, Py_BuildValue("(iiii)i",
pd->rect.x, pd->rect.y, pd->rect.x, pd->rect.y,
pd->rect.width, pd->rect.height, pd->rect.width, pd->rect.height,
pd->neighbors)); pd->neighbors));
} }
// This function has copied the CvSeq data into a list. Hence the // This function has copied the CvSeq data into a list. Hence the
...@@ -2378,7 +2378,7 @@ static PyObject *FROM_CvSeqOfCvStarKeypointPTR(CvSeqOfCvStarKeypoint *r) ...@@ -2378,7 +2378,7 @@ static PyObject *FROM_CvSeqOfCvStarKeypointPTR(CvSeqOfCvStarKeypoint *r)
for (int i = 0; i < r->total; i++) { for (int i = 0; i < r->total; i++) {
CvStarKeypoint *pd = CV_GET_SEQ_ELEM(CvStarKeypoint, r, i); CvStarKeypoint *pd = CV_GET_SEQ_ELEM(CvStarKeypoint, r, i);
PyList_SetItem(pr, i, Py_BuildValue("(ii)if", PyList_SetItem(pr, i, Py_BuildValue("(ii)if",
pd->pt.x, pd->pt.y, pd->pt.x, pd->pt.y,
pd->size, pd->size,
pd->response)); pd->response));
} }
...@@ -2396,7 +2396,7 @@ static PyObject *FROM_CvSeqOfCvSURFPointPTR(CvSeqOfCvSURFPoint *r) ...@@ -2396,7 +2396,7 @@ static PyObject *FROM_CvSeqOfCvSURFPointPTR(CvSeqOfCvSURFPoint *r)
for (int i = 0; i < r->total; i++) { for (int i = 0; i < r->total; i++) {
CvSURFPoint *pd = CV_GET_SEQ_ELEM(CvSURFPoint, r, i); CvSURFPoint *pd = CV_GET_SEQ_ELEM(CvSURFPoint, r, i);
PyList_SetItem(pr, i, Py_BuildValue("(ff)iiff", PyList_SetItem(pr, i, Py_BuildValue("(ff)iiff",
pd->pt.x, pd->pt.y, pd->pt.x, pd->pt.y,
pd->laplacian, pd->laplacian,
pd->size, pd->size,
pd->dir, pd->dir,
...@@ -2587,7 +2587,7 @@ static PyObject *FROM_CvPoints(CvPoints src) ...@@ -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 */ * so are handwritten here */
static PyObject *pycvWaitKey(PyObject *self, PyObject *args, PyObject *kw) static PyObject *pycvWaitKey(PyObject *self, PyObject *args, PyObject *kw)
...@@ -2808,7 +2808,7 @@ static PyObject *fromarray(PyObject *o, int allowND) ...@@ -2808,7 +2808,7 @@ static PyObject *fromarray(PyObject *o, int allowND)
else if (pai->itemsize == 8) else if (pai->itemsize == 8)
type = CV_64FC1; type = CV_64FC1;
break; break;
} }
if (type == -1) { if (type == -1) {
PyErr_SetString(PyExc_TypeError, "the array type is not supported by OpenCV"); PyErr_SetString(PyExc_TypeError, "the array type is not supported by OpenCV");
...@@ -2826,20 +2826,20 @@ static PyObject *fromarray(PyObject *o, int allowND) ...@@ -2826,20 +2826,20 @@ static PyObject *fromarray(PyObject *o, int allowND)
m->a->step = (int)pai->strides[0]; m->a->step = (int)pai->strides[0];
} else if (pai->nd == 3) { } else if (pai->nd == 3) {
if (pai->shape[2] > CV_CN_MAX) { 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; 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))); 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]; m->a->step = (int)pai->strides[0];
} else { } else {
Py_DECREF(ao); Py_DECREF(ao);
return failmsg("cv.fromarray array can be 2D or 3D only, see allowND argument"), (PyObject*)0; return failmsg("cv.fromarray array can be 2D or 3D only, see allowND argument"), (PyObject*)0;
} }
m->a->data.ptr = (uchar*)pai->data; m->a->data.ptr = (uchar*)pai->data;
//retval = pythonize_foreign_CvMat(m); //retval = pythonize_foreign_CvMat(m);
m->data = o; m->data = o;
m->offset = 0; m->offset = 0;
retval = (PyObject*)m; retval = (PyObject*)m;
} else { } else {
int dims[CV_MAX_DIM]; int dims[CV_MAX_DIM];
int i; int i;
...@@ -2848,13 +2848,13 @@ static PyObject *fromarray(PyObject *o, int allowND) ...@@ -2848,13 +2848,13 @@ static PyObject *fromarray(PyObject *o, int allowND)
cvmatnd_t *m = PyObject_NEW(cvmatnd_t, &cvmatnd_Type); cvmatnd_t *m = PyObject_NEW(cvmatnd_t, &cvmatnd_Type);
ERRWRAP(m->a = cvCreateMatNDHeader(pai->nd, dims, type)); ERRWRAP(m->a = cvCreateMatNDHeader(pai->nd, dims, type));
m->a->data.ptr = (uchar*)pai->data; m->a->data.ptr = (uchar*)pai->data;
m->data = o; m->data = o;
m->offset = 0; m->offset = 0;
retval = (PyObject*)m; retval = (PyObject*)m;
//retval = pythonize_CvMatND(m, ao); //retval = pythonize_CvMatND(m, ao);
} }
Py_DECREF(ao); Py_DECREF(ao);
Py_INCREF(o); Py_INCREF(o);
return retval; return retval;
} }
#endif #endif
...@@ -2875,7 +2875,7 @@ public: ...@@ -2875,7 +2875,7 @@ public:
rr = new float*[len]; rr = new float*[len];
for (Py_ssize_t i = 0; i < len; i++) { for (Py_ssize_t i = 0; i < len; i++) {
PyObject *item = PySequence_Fast_GET_ITEM(fi, i); PyObject *item = PySequence_Fast_GET_ITEM(fi, i);
floats ff; floats ff; ff.f = 0;
if (!convert_to_floats(item, &ff)) if (!convert_to_floats(item, &ff))
return 0; return 0;
rr[i] = ff.f; rr[i] = ff.f;
...@@ -4040,13 +4040,13 @@ static PyObject* init_cv() ...@@ -4040,13 +4040,13 @@ static PyObject* init_cv()
PUBLISH(GC_INIT_WITH_RECT); PUBLISH(GC_INIT_WITH_RECT);
PUBLISH(GC_INIT_WITH_MASK); PUBLISH(GC_INIT_WITH_MASK);
PUBLISH(GC_EVAL); PUBLISH(GC_EVAL);
#include "generated2.i" #include "generated2.i"
#undef PUBLISH #undef PUBLISH
#undef PUBLISHU #undef PUBLISHU
#undef PUBLISH2 #undef PUBLISH2
return m; return m;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment