Commit 09e05b84 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

parents 0f5d6ae1 1e096c6c
...@@ -94,7 +94,7 @@ void ptsort_(struct pt *pts, int sz) ...@@ -94,7 +94,7 @@ void ptsort_(struct pt *pts, int sz)
// Use stack storage if it's not too big. // Use stack storage if it's not too big.
cv::AutoBuffer<struct pt, 1024> _tmp_stack(sz); cv::AutoBuffer<struct pt, 1024> _tmp_stack(sz);
memcpy(_tmp_stack, pts, sizeof(struct pt) * sz); memcpy(_tmp_stack.data(), pts, sizeof(struct pt) * sz);
int asz = sz/2; int asz = sz/2;
int bsz = sz - asz; int bsz = sz - asz;
...@@ -470,11 +470,11 @@ int quad_segment_agg(int sz, struct line_fit_pt *lfps, int indices[4]){ ...@@ -470,11 +470,11 @@ int quad_segment_agg(int sz, struct line_fit_pt *lfps, int indices[4]){
int rvalloc_pos = 0; int rvalloc_pos = 0;
int rvalloc_size = 3*sz; int rvalloc_size = 3*sz;
cv::AutoBuffer<struct remove_vertex, 0> rvalloc_(std::max(1, rvalloc_size)); cv::AutoBuffer<struct remove_vertex, 0> rvalloc_(std::max(1, rvalloc_size));
memset(rvalloc_, 0, sizeof(rvalloc_[0]) * rvalloc_.size()); // TODO Add AutoBuffer zero fill memset(rvalloc_.data(), 0, sizeof(rvalloc_[0]) * rvalloc_.size()); // TODO Add AutoBuffer zero fill
struct remove_vertex *rvalloc = rvalloc_; struct remove_vertex *rvalloc = rvalloc_.data();
cv::AutoBuffer<struct segment, 0> segs_(std::max(1, sz)); // TODO Add AutoBuffer zero fill cv::AutoBuffer<struct segment, 0> segs_(std::max(1, sz)); // TODO Add AutoBuffer zero fill
memset(segs_, 0, sizeof(segs_[0]) * segs_.size()); memset(segs_.data(), 0, sizeof(segs_[0]) * segs_.size());
struct segment *segs = segs_; struct segment *segs = segs_.data();
// populate with initial entries // populate with initial entries
for (int i = 0; i < sz; i++) { for (int i = 0; i < sz; i++) {
...@@ -753,8 +753,8 @@ int fit_quad(const Ptr<DetectorParameters> &_params, const Mat im, zarray_t *clu ...@@ -753,8 +753,8 @@ int fit_quad(const Ptr<DetectorParameters> &_params, const Mat im, zarray_t *clu
// efficiently computed for any contiguous range of indices. // efficiently computed for any contiguous range of indices.
cv::AutoBuffer<struct line_fit_pt, 64> lfps_(sz); cv::AutoBuffer<struct line_fit_pt, 64> lfps_(sz);
memset(lfps_, 0, sizeof(lfps_[0]) * lfps_.size()); // TODO Add AutoBuffer zero fill memset(lfps_.data(), 0, sizeof(lfps_[0]) * lfps_.size()); // TODO Add AutoBuffer zero fill
struct line_fit_pt *lfps = lfps_; struct line_fit_pt *lfps = lfps_.data();
for (int i = 0; i < sz; i++) { for (int i = 0; i < sz; i++) {
struct pt *p; struct pt *p;
......
...@@ -49,9 +49,9 @@ static inline void _swap_default(zmaxheap_t *heap, int a, int b) ...@@ -49,9 +49,9 @@ static inline void _swap_default(zmaxheap_t *heap, int a, int b)
heap->values[b] = t; heap->values[b] = t;
cv::AutoBuffer<char> tmp(heap->el_sz); cv::AutoBuffer<char> tmp(heap->el_sz);
memcpy(tmp, &heap->data[a*heap->el_sz], heap->el_sz); memcpy(tmp.data(), &heap->data[a*heap->el_sz], heap->el_sz);
memcpy(&heap->data[a*heap->el_sz], &heap->data[b*heap->el_sz], heap->el_sz); memcpy(&heap->data[a*heap->el_sz], &heap->data[b*heap->el_sz], heap->el_sz);
memcpy(&heap->data[b*heap->el_sz], tmp, heap->el_sz); memcpy(&heap->data[b*heap->el_sz], tmp.data(), heap->el_sz);
} }
static inline void _swap_pointer(zmaxheap_t *heap, int a, int b) static inline void _swap_pointer(zmaxheap_t *heap, int a, int b)
......
...@@ -380,12 +380,7 @@ void DISOpticalFlowImpl::precomputeStructureTensor(Mat &dst_I0xx, Mat &dst_I0yy, ...@@ -380,12 +380,7 @@ void DISOpticalFlowImpl::precomputeStructureTensor(Mat &dst_I0xx, Mat &dst_I0yy,
} }
} }
AutoBuffer<float> sum_xx_buf(ws), sum_yy_buf(ws), sum_xy_buf(ws), sum_x_buf(ws), sum_y_buf(ws); AutoBuffer<float> sum_xx(ws), sum_yy(ws), sum_xy(ws), sum_x(ws), sum_y(ws);
float *sum_xx = (float *)sum_xx_buf;
float *sum_yy = (float *)sum_yy_buf;
float *sum_xy = (float *)sum_xy_buf;
float *sum_x = (float *)sum_x_buf;
float *sum_y = (float *)sum_y_buf;
for (int j = 0; j < ws; j++) for (int j = 0; j < ws; j++)
{ {
sum_xx[j] = 0.0f; sum_xx[j] = 0.0f;
......
...@@ -383,7 +383,12 @@ public: ...@@ -383,7 +383,12 @@ public:
void removeEntity(const String& name) { void removeEntity(const String& name) {
SceneNode& node = _getSceneNode(sceneMgr, name); SceneNode& node = _getSceneNode(sceneMgr, name);
node.getAttachedObject(name)->detachFromParent(); node.getAttachedObject(name)->detachFromParent();
// only one of the following will do something
sceneMgr->destroyLight(name);
sceneMgr->destroyEntity(name); sceneMgr->destroyEntity(name);
sceneMgr->destroyCamera(name);
sceneMgr->destroySceneNode(&node); sceneMgr->destroySceneNode(&node);
} }
......
...@@ -254,11 +254,11 @@ static void quantizedOrientations(const Mat& src, Mat& magnitude, ...@@ -254,11 +254,11 @@ static void quantizedOrientations(const Mat& src, Mat& magnitude,
float * ptr0y = (float *)sobel_dy.data; float * ptr0y = (float *)sobel_dy.data;
float * ptrmg = (float *)magnitude.data; float * ptrmg = (float *)magnitude.data;
const int length1 = static_cast<const int>(sobel_3dx.step1()); const int length1 = static_cast<int>(sobel_3dx.step1());
const int length2 = static_cast<const int>(sobel_3dy.step1()); const int length2 = static_cast<int>(sobel_3dy.step1());
const int length3 = static_cast<const int>(sobel_dx.step1()); const int length3 = static_cast<int>(sobel_dx.step1());
const int length4 = static_cast<const int>(sobel_dy.step1()); const int length4 = static_cast<int>(sobel_dy.step1());
const int length5 = static_cast<const int>(magnitude.step1()); const int length5 = static_cast<int>(magnitude.step1());
const int length0 = sobel_3dy.cols * 3; const int length0 = sobel_3dy.cols * 3;
for (int r = 0; r < sobel_3dy.rows; ++r) for (int r = 0; r < sobel_3dy.rows; ++r)
......
...@@ -443,7 +443,7 @@ void computeCorresps(const Mat& K, const Mat& K_inv, const Mat& Rt, ...@@ -443,7 +443,7 @@ void computeCorresps(const Mat& K, const Mat& K_inv, const Mat& Rt,
const double * Kt_ptr = Kt.ptr<const double>(); const double * Kt_ptr = Kt.ptr<const double>();
AutoBuffer<float> buf(3 * (depth1.cols + depth1.rows)); AutoBuffer<float> buf(3 * (depth1.cols + depth1.rows));
float *KRK_inv0_u1 = buf; float *KRK_inv0_u1 = buf.data();
float *KRK_inv1_v1_plus_KRK_inv2 = KRK_inv0_u1 + depth1.cols; float *KRK_inv1_v1_plus_KRK_inv2 = KRK_inv0_u1 + depth1.cols;
float *KRK_inv3_u1 = KRK_inv1_v1_plus_KRK_inv2 + depth1.rows; float *KRK_inv3_u1 = KRK_inv1_v1_plus_KRK_inv2 + depth1.rows;
float *KRK_inv4_v1_plus_KRK_inv5 = KRK_inv3_u1 + depth1.cols; float *KRK_inv4_v1_plus_KRK_inv5 = KRK_inv3_u1 + depth1.cols;
...@@ -621,7 +621,7 @@ void calcRgbdLsmMatrices(const Mat& image0, const Mat& cloud0, const Mat& Rt, ...@@ -621,7 +621,7 @@ void calcRgbdLsmMatrices(const Mat& image0, const Mat& cloud0, const Mat& Rt,
const double * Rt_ptr = Rt.ptr<const double>(); const double * Rt_ptr = Rt.ptr<const double>();
AutoBuffer<float> diffs(correspsCount); AutoBuffer<float> diffs(correspsCount);
float* diffs_ptr = diffs; float* diffs_ptr = diffs.data();
const Vec4i* corresps_ptr = corresps.ptr<Vec4i>(); const Vec4i* corresps_ptr = corresps.ptr<Vec4i>();
...@@ -694,10 +694,10 @@ void calcICPLsmMatrices(const Mat& cloud0, const Mat& Rt, ...@@ -694,10 +694,10 @@ void calcICPLsmMatrices(const Mat& cloud0, const Mat& Rt,
const double * Rt_ptr = Rt.ptr<const double>(); const double * Rt_ptr = Rt.ptr<const double>();
AutoBuffer<float> diffs(correspsCount); AutoBuffer<float> diffs(correspsCount);
float * diffs_ptr = diffs; float * diffs_ptr = diffs.data();
AutoBuffer<Point3f> transformedPoints0(correspsCount); AutoBuffer<Point3f> transformedPoints0(correspsCount);
Point3f * tps0_ptr = transformedPoints0; Point3f * tps0_ptr = transformedPoints0.data();
const Vec4i* corresps_ptr = corresps.ptr<Vec4i>(); const Vec4i* corresps_ptr = corresps.ptr<Vec4i>();
......
...@@ -925,7 +925,7 @@ void CvHOGEvaluator::integralHistogram( const Mat &img, std::vector<Mat> &histog ...@@ -925,7 +925,7 @@ void CvHOGEvaluator::integralHistogram( const Mat &img, std::vector<Mat> &histog
Mat qangle( gradSize, CV_8U ); Mat qangle( gradSize, CV_8U );
AutoBuffer<int> mapbuf( gradSize.width + gradSize.height + 4 ); AutoBuffer<int> mapbuf( gradSize.width + gradSize.height + 4 );
int* xmap = (int*) mapbuf + 1; int* xmap = mapbuf.data() + 1;
int* ymap = xmap + gradSize.width + 2; int* ymap = xmap + gradSize.width + 2;
const int borderType = (int) BORDER_REPLICATE; const int borderType = (int) BORDER_REPLICATE;
...@@ -937,7 +937,7 @@ void CvHOGEvaluator::integralHistogram( const Mat &img, std::vector<Mat> &histog ...@@ -937,7 +937,7 @@ void CvHOGEvaluator::integralHistogram( const Mat &img, std::vector<Mat> &histog
int width = gradSize.width; int width = gradSize.width;
AutoBuffer<float> _dbuf( width * 4 ); AutoBuffer<float> _dbuf( width * 4 );
float* dbuf = _dbuf; float* dbuf = _dbuf.data();
Mat Dx( 1, width, CV_32F, dbuf ); Mat Dx( 1, width, CV_32F, dbuf );
Mat Dy( 1, width, CV_32F, dbuf + width ); Mat Dy( 1, width, CV_32F, dbuf + width );
Mat Mag( 1, width, CV_32F, dbuf + width * 2 ); Mat Mag( 1, width, CV_32F, dbuf + width * 2 );
......
...@@ -495,7 +495,7 @@ namespace cv{ ...@@ -495,7 +495,7 @@ namespace cv{
int rows = dst.rows, cols = dst.cols; int rows = dst.rows, cols = dst.cols;
AutoBuffer<float> _wc(cols); AutoBuffer<float> _wc(cols);
float * const wc = (float *)_wc; float * const wc = _wc.data();
const float coeff0 = 2.0f * (float)CV_PI / (cols - 1); const float coeff0 = 2.0f * (float)CV_PI / (cols - 1);
const float coeff1 = 2.0f * (float)CV_PI / (rows - 1); const float coeff1 = 2.0f * (float)CV_PI / (rows - 1);
......
...@@ -51,7 +51,7 @@ This section describes experimental algorithms for 2d feature detection. ...@@ -51,7 +51,7 @@ This section describes experimental algorithms for 2d feature detection.
@defgroup xfeatures2d_nonfree Non-free 2D Features Algorithms @defgroup xfeatures2d_nonfree Non-free 2D Features Algorithms
This section describes two popular algorithms for 2d feature detection, SIFT and SURF, that are This section describes two popular algorithms for 2d feature detection, SIFT and SURF, that are
known to be patented. Use them at your own risk. known to be patented. You need to set the OPENCV_ENABLE_NONFREE option in cmake to use those. Use them at your own risk.
@defgroup xfeatures2d_match Experimental 2D Features Matching Algorithm @defgroup xfeatures2d_match Experimental 2D Features Matching Algorithm
......
...@@ -339,7 +339,7 @@ namespace { ...@@ -339,7 +339,7 @@ namespace {
AutoBuffer<uchar> _buf((img.cols+16)*3*(sizeof(int) + sizeof(uchar)) + 128); AutoBuffer<uchar> _buf((img.cols+16)*3*(sizeof(int) + sizeof(uchar)) + 128);
uchar* buf[3]; uchar* buf[3];
buf[0] = _buf; buf[1] = buf[0] + img.cols; buf[2] = buf[1] + img.cols; buf[0] = _buf.data(); buf[1] = buf[0] + img.cols; buf[2] = buf[1] + img.cols;
int* cpbuf[3]; int* cpbuf[3];
cpbuf[0] = (int*)alignPtr(buf[2] + img.cols, sizeof(int)) + 1; cpbuf[0] = (int*)alignPtr(buf[2] + img.cols, sizeof(int)) + 1;
cpbuf[1] = cpbuf[0] + img.cols + 1; cpbuf[1] = cpbuf[0] + img.cols + 1;
......
...@@ -112,6 +112,8 @@ namespace cv ...@@ -112,6 +112,8 @@ namespace cv
namespace xfeatures2d namespace xfeatures2d
{ {
#ifdef OPENCV_ENABLE_NONFREE
/*! /*!
SIFT implementation. SIFT implementation.
...@@ -341,7 +343,7 @@ static float calcOrientationHist( const Mat& img, Point pt, int radius, ...@@ -341,7 +343,7 @@ static float calcOrientationHist( const Mat& img, Point pt, int radius,
float expf_scale = -1.f/(2.f * sigma * sigma); float expf_scale = -1.f/(2.f * sigma * sigma);
AutoBuffer<float> buf(len*4 + n+4); AutoBuffer<float> buf(len*4 + n+4);
float *X = buf, *Y = X + len, *Mag = X, *Ori = Y + len, *W = Ori + len; float *X = buf.data(), *Y = X + len, *Mag = X, *Ori = Y + len, *W = Ori + len;
float* temphist = W + len + 2; float* temphist = W + len + 2;
for( i = 0; i < n; i++ ) for( i = 0; i < n; i++ )
...@@ -754,7 +756,7 @@ static void calcSIFTDescriptor( const Mat& img, Point2f ptf, float ori, float sc ...@@ -754,7 +756,7 @@ static void calcSIFTDescriptor( const Mat& img, Point2f ptf, float ori, float sc
int rows = img.rows, cols = img.cols; int rows = img.rows, cols = img.cols;
AutoBuffer<float> buf(len*6 + histlen); AutoBuffer<float> buf(len*6 + histlen);
float *X = buf, *Y = X + len, *Mag = Y, *Ori = Mag + len, *W = Ori + len; float *X = buf.data(), *Y = X + len, *Mag = Y, *Ori = Mag + len, *W = Ori + len;
float *RBin = W + len, *CBin = RBin + len, *hist = CBin + len; float *RBin = W + len, *CBin = RBin + len, *hist = CBin + len;
for( i = 0; i < d+2; i++ ) for( i = 0; i < d+2; i++ )
...@@ -1197,5 +1199,14 @@ void SIFT_Impl::detectAndCompute(InputArray _image, InputArray _mask, ...@@ -1197,5 +1199,14 @@ void SIFT_Impl::detectAndCompute(InputArray _image, InputArray _mask,
} }
} }
#else // ! #ifdef OPENCV_ENABLE_NONFREE
Ptr<SIFT> SIFT::create( int, int, double, double, double )
{
CV_Error(Error::StsNotImplemented,
"This algorithm is patented and is excluded in this configuration; "
"Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library");
}
#endif
} }
} }
...@@ -115,6 +115,8 @@ namespace cv ...@@ -115,6 +115,8 @@ namespace cv
namespace xfeatures2d namespace xfeatures2d
{ {
#ifdef OPENCV_ENABLE_NONFREE
static const int SURF_ORI_SEARCH_INC = 5; static const int SURF_ORI_SEARCH_INC = 5;
static const float SURF_ORI_SIGMA = 2.5f; static const float SURF_ORI_SIGMA = 2.5f;
static const float SURF_DESC_SIGMA = 3.3f; static const float SURF_DESC_SIGMA = 3.3f;
...@@ -676,7 +678,7 @@ struct SURFInvoker : ParallelLoopBody ...@@ -676,7 +678,7 @@ struct SURFInvoker : ParallelLoopBody
/* Extract a window of pixels around the keypoint of size 20s */ /* Extract a window of pixels around the keypoint of size 20s */
int win_size = (int)((PATCH_SZ+1)*s); int win_size = (int)((PATCH_SZ+1)*s);
CV_Assert( imaxSize >= win_size ); CV_Assert( imaxSize >= win_size );
Mat win(win_size, win_size, CV_8U, winbuf); Mat win(win_size, win_size, CV_8U, winbuf.data());
if( !upright ) if( !upright )
{ {
...@@ -1005,6 +1007,16 @@ Ptr<SURF> SURF::create(double _threshold, int _nOctaves, int _nOctaveLayers, boo ...@@ -1005,6 +1007,16 @@ Ptr<SURF> SURF::create(double _threshold, int _nOctaves, int _nOctaveLayers, boo
return makePtr<SURF_Impl>(_threshold, _nOctaves, _nOctaveLayers, _extended, _upright); return makePtr<SURF_Impl>(_threshold, _nOctaves, _nOctaveLayers, _extended, _upright);
} }
#else // ! #ifdef OPENCV_ENABLE_NONFREE
Ptr<SURF> SURF::create(double, int, int, bool, bool)
{
CV_Error(Error::StsNotImplemented,
"This algorithm is patented and is excluded in this configuration; "
"Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library");
}
#endif
} }
} }
...@@ -64,6 +64,26 @@ void cv::cuda::SURF_CUDA::releaseMemory() { throw_no_cuda(); } ...@@ -64,6 +64,26 @@ void cv::cuda::SURF_CUDA::releaseMemory() { throw_no_cuda(); }
#else // !defined (HAVE_CUDA) #else // !defined (HAVE_CUDA)
#if (!defined (OPENCV_ENABLE_NONFREE))
#define throw_no_nonfree CV_Error(Error::StsNotImplemented, \
"This algorithm is patented and is excluded in this configuration; " \
"Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library");
cv::cuda::SURF_CUDA::SURF_CUDA() { throw_no_nonfree }
cv::cuda::SURF_CUDA::SURF_CUDA(double, int, int, bool, float, bool) { throw_no_nonfree }
int cv::cuda::SURF_CUDA::descriptorSize() const { throw_no_nonfree }
void cv::cuda::SURF_CUDA::uploadKeypoints(const std::vector<KeyPoint>&, GpuMat&) { throw_no_nonfree }
void cv::cuda::SURF_CUDA::downloadKeypoints(const GpuMat&, std::vector<KeyPoint>&) { throw_no_nonfree }
void cv::cuda::SURF_CUDA::downloadDescriptors(const GpuMat&, std::vector<float>&) { throw_no_nonfree }
void cv::cuda::SURF_CUDA::operator()(const GpuMat&, const GpuMat&, GpuMat&) { throw_no_nonfree }
void cv::cuda::SURF_CUDA::operator()(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, bool) { throw_no_nonfree }
void cv::cuda::SURF_CUDA::operator()(const GpuMat&, const GpuMat&, std::vector<KeyPoint>&) { throw_no_nonfree }
void cv::cuda::SURF_CUDA::operator()(const GpuMat&, const GpuMat&, std::vector<KeyPoint>&, GpuMat&, bool) { throw_no_nonfree }
void cv::cuda::SURF_CUDA::operator()(const GpuMat&, const GpuMat&, std::vector<KeyPoint>&, std::vector<float>&, bool) { throw_no_nonfree }
void cv::cuda::SURF_CUDA::releaseMemory() { throw_no_nonfree }
#else // OPENCV_ENABLE_NONFREE
namespace cv { namespace cuda { namespace device namespace cv { namespace cuda { namespace device
{ {
namespace surf namespace surf
...@@ -431,5 +451,6 @@ void cv::cuda::SURF_CUDA::releaseMemory() ...@@ -431,5 +451,6 @@ void cv::cuda::SURF_CUDA::releaseMemory()
} }
#endif // !defined (HAVE_CUDA) #endif // !defined (HAVE_CUDA)
#endif // !defined (OPENCV_ENABLE_NONFREE)
#endif #endif
...@@ -57,6 +57,8 @@ namespace cv ...@@ -57,6 +57,8 @@ namespace cv
namespace xfeatures2d namespace xfeatures2d
{ {
#ifdef OPENCV_ENABLE_NONFREE
enum { ORI_SEARCH_INC=5, ORI_LOCAL_SIZE=(360 / ORI_SEARCH_INC) }; enum { ORI_SEARCH_INC=5, ORI_LOCAL_SIZE=(360 / ORI_SEARCH_INC) };
static inline int calcSize(int octave, int layer) static inline int calcSize(int octave, int layer)
...@@ -463,6 +465,8 @@ bool SURF_OCL::calcOrientation(UMat &keypoints) ...@@ -463,6 +465,8 @@ bool SURF_OCL::calcOrientation(UMat &keypoints)
return kerOri.run(2, globalThreads, localThreads, true); return kerOri.run(2, globalThreads, localThreads, true);
} }
#endif // ! #ifdef OPENCV_ENABLE_NONFREE
} }
} }
......
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