Merge branch 'master' of https://github.com/Itseez/opencv into brief_cl

pull/2027/head
Matthias Bady 11 years ago
commit 67e2d7ec43
  1. 1
      .gitignore
  2. 14
      3rdparty/include/opencl/1.2/CL/cl_platform.h
  3. 2
      apps/haartraining/cvclassifier.h
  4. 2
      doc/tutorials/introduction/linux_install/linux_install.rst
  5. 2
      modules/bioinspired/src/retina.cpp
  6. 6
      modules/calib3d/test/test_cameracalibration.cpp
  7. 2
      modules/calib3d/test/test_chessboardgenerator.hpp
  8. 6
      modules/calib3d/test/test_chesscorners.cpp
  9. 2
      modules/calib3d/test/test_chesscorners_timing.cpp
  10. 2
      modules/calib3d/test/test_main.cpp
  11. 2
      modules/calib3d/test/test_stereomatching.cpp
  12. 18
      modules/contrib/src/adaptiveskindetector.cpp
  13. 8
      modules/contrib/src/ba.cpp
  14. 6
      modules/contrib/src/facerec.cpp
  15. 82
      modules/contrib/src/fuzzymeanshifttracker.cpp
  16. 2
      modules/contrib/src/spinimages.cpp
  17. 1
      modules/core/include/opencv2/core/mat.hpp
  18. 8
      modules/core/include/opencv2/core/mat.inl.hpp
  19. 6
      modules/core/include/opencv2/core/operations.hpp
  20. 2
      modules/core/src/algorithm.cpp
  21. 4
      modules/core/src/arithm.cpp
  22. 232
      modules/core/src/convert.cpp
  23. 20
      modules/core/src/copy.cpp
  24. 11
      modules/core/src/mathfuncs.cpp
  25. 31
      modules/core/src/matrix.cpp
  26. 2
      modules/core/src/system.cpp
  27. 3
      modules/core/src/umatrix.cpp
  28. 78
      modules/core/test/test_arithm.cpp
  29. 2
      modules/cudaimgproc/perf/perf_match_template.cpp
  30. 28
      modules/features2d/src/features2d_init.cpp
  31. 12
      modules/flann/include/opencv2/flann/hierarchical_clustering_index.h
  32. 20
      modules/highgui/doc/user_interface.rst
  33. 6
      modules/highgui/include/opencv2/highgui.hpp
  34. 7
      modules/highgui/include/opencv2/highgui/highgui_c.h
  35. 2
      modules/highgui/src/bitstrm.hpp
  36. 4
      modules/highgui/src/cap_ffmpeg_impl.hpp
  37. 8
      modules/highgui/src/precomp.hpp
  38. 5
      modules/highgui/src/window.cpp
  39. 54
      modules/highgui/src/window_w32.cpp
  40. 82
      modules/imgproc/perf/opencl/perf_blend.cpp
  41. 104
      modules/imgproc/perf/opencl/perf_color.cpp
  42. 302
      modules/imgproc/perf/opencl/perf_filters.cpp
  43. 246
      modules/imgproc/perf/opencl/perf_imgproc.cpp
  44. 210
      modules/imgproc/perf/opencl/perf_imgwarp.cpp
  45. 78
      modules/imgproc/perf/opencl/perf_moments.cpp
  46. 105
      modules/imgproc/perf/opencl/perf_pyramid.cpp
  47. 2
      modules/imgproc/perf/perf_filter2d.cpp
  48. 171
      modules/imgproc/src/canny.cpp
  49. 6
      modules/imgproc/src/color.cpp
  50. 2
      modules/imgproc/src/gcgraph.hpp
  51. 6
      modules/imgproc/src/imgwarp.cpp
  52. 514
      modules/imgproc/src/opencl/canny.cl
  53. 1
      modules/imgproc/src/opencl/resize.cl
  54. 117
      modules/imgproc/test/ocl/test_canny.cpp
  55. 2
      modules/imgproc/test/test_cvtyuv.cpp
  56. 2
      modules/legacy/src/blobtrack.cpp
  57. 4
      modules/legacy/src/enteringblobdetection.cpp
  58. 2
      modules/legacy/src/vecfacetracking.cpp
  59. 2
      modules/ml/src/ml_init.cpp
  60. 4
      modules/nonfree/src/nonfree_init.cpp
  61. 61
      modules/objdetect/perf/opencl/perf_cascades.cpp
  62. 56
      modules/objdetect/perf/perf_cascadeclassifier.cpp
  63. 2
      modules/ocl/include/opencv2/ocl.hpp
  64. 2
      modules/ocl/include/opencv2/ocl/private/opencl_utils.hpp
  65. 4
      modules/ocl/test/test_canny.cpp
  66. 2
      modules/ocl/test/test_match_template.cpp
  67. 2
      modules/ocl/test/test_objdetect.cpp
  68. 2
      modules/ocl/test/utility.hpp
  69. 2
      modules/superres/src/btv_l1.cpp
  70. 2
      modules/superres/src/btv_l1_ocl.cpp
  71. 20
      modules/superres/src/optical_flow.cpp
  72. 32
      modules/ts/include/opencv2/ts/ocl_perf.hpp
  73. 20
      modules/ts/include/opencv2/ts/ocl_test.hpp
  74. 4
      modules/ts/include/opencv2/ts/ts_perf.hpp
  75. 8
      modules/ts/src/ts_perf.cpp
  76. 2
      modules/video/perf/perf_optflowpyrlk.cpp
  77. 2
      modules/video/src/kalman.cpp
  78. 2
      modules/video/src/tvl1flow.cpp
  79. 46
      samples/c/adaptiveskindetector.cpp
  80. 2
      samples/cpp/calibration_artificial.cpp
  81. 4
      samples/cpp/kmeans.cpp
  82. 2
      samples/cpp/tutorial_code/ImgProc/Threshold.cpp

1
.gitignore vendored

@ -1,6 +1,7 @@
*.autosave
*.pyc
*.user
*~
.*.swp
.DS_Store
.sw[a-z]

@ -332,13 +332,13 @@ typedef unsigned int cl_GLenum;
/* Define basic vector types */
#if defined( __VEC__ )
#include <altivec.h> /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */
typedef vector unsigned char __cl_uchar16;
typedef vector signed char __cl_char16;
typedef vector unsigned short __cl_ushort8;
typedef vector signed short __cl_short8;
typedef vector unsigned int __cl_uint4;
typedef vector signed int __cl_int4;
typedef vector float __cl_float4;
typedef __vector unsigned char __cl_uchar16;
typedef __vector signed char __cl_char16;
typedef __vector unsigned short __cl_ushort8;
typedef __vector signed short __cl_short8;
typedef __vector unsigned int __cl_uint4;
typedef __vector signed int __cl_int4;
typedef __vector float __cl_float4;
#define __CL_UCHAR16__ 1
#define __CL_CHAR16__ 1
#define __CL_USHORT8__ 1

@ -340,7 +340,7 @@ typedef enum CvBoostType
CV_LKCLASS = 5, /* classification (K class problem) */
CV_LSREG = 6, /* least squares regression */
CV_LADREG = 7, /* least absolute deviation regression */
CV_MREG = 8, /* M-regression (Huber loss) */
CV_MREG = 8 /* M-regression (Huber loss) */
} CvBoostType;
/****************************************************************************************\

@ -16,7 +16,7 @@ Required Packages
* CMake 2.6 or higher;
* Git;
* GTK+2.x or higher, including headers (libgtk2.0-dev);
* pkgconfig;
* pkg-config;
* Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy);
* ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev;
* [optional] libdc1394 2.x;

@ -312,7 +312,7 @@ RetinaImpl::RetinaImpl(const cv::Size inputSz, const bool colorMode, int colorSa
{
_retinaFilter = 0;
_init(inputSz, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
};
}
RetinaImpl::~RetinaImpl()
{

@ -337,7 +337,7 @@ void CV_CameraCalibrationTest::run( int start_from )
int progress = 0;
int values_read = -1;
sprintf( filepath, "%scameracalibration/", ts->get_data_path().c_str() );
sprintf( filepath, "%scv/cameracalibration/", ts->get_data_path().c_str() );
sprintf( filename, "%sdatafiles.txt", filepath );
datafile = fopen( filename, "r" );
if( datafile == 0 )
@ -1384,7 +1384,7 @@ void CV_StereoCalibrationTest::run( int )
{
char filepath[1000];
char buf[1000];
sprintf( filepath, "%sstereo/case%d/stereo_calib.txt", ts->get_data_path().c_str(), testcase );
sprintf( filepath, "%scv/stereo/case%d/stereo_calib.txt", ts->get_data_path().c_str(), testcase );
f = fopen(filepath, "rt");
Size patternSize;
vector<string> imglist;
@ -1405,7 +1405,7 @@ void CV_StereoCalibrationTest::run( int )
buf[--len] = '\0';
if( buf[0] == '#')
continue;
sprintf(filepath, "%sstereo/case%d/%s", ts->get_data_path().c_str(), testcase, buf );
sprintf(filepath, "%scv/stereo/case%d/%s", ts->get_data_path().c_str(), testcase, buf );
imglist.push_back(string(filepath));
}
fclose(f);

@ -34,7 +34,7 @@ private:
Mat rvec, tvec;
};
};
}
#endif

@ -185,13 +185,13 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename )
switch( pattern )
{
case CHESSBOARD:
folder = string(ts->get_data_path()) + "cameracalibration/";
folder = string(ts->get_data_path()) + "cv/cameracalibration/";
break;
case CIRCLES_GRID:
folder = string(ts->get_data_path()) + "cameracalibration/circles/";
folder = string(ts->get_data_path()) + "cv/cameracalibration/circles/";
break;
case ASYMMETRIC_CIRCLES_GRID:
folder = string(ts->get_data_path()) + "cameracalibration/asymmetric_circles/";
folder = string(ts->get_data_path()) + "cv/cameracalibration/asymmetric_circles/";
break;
}

@ -75,7 +75,7 @@ void CV_ChessboardDetectorTimingTest::run( int start_from )
int idx, max_idx;
int progress = 0;
sprintf( filepath, "%scameracalibration/", ts->get_data_path().c_str() );
sprintf( filepath, "%scv/cameracalibration/", ts->get_data_path().c_str() );
sprintf( filename, "%schessboard_timing_list.dat", filepath );
CvFileStorage* fs = cvOpenFileStorage( filename, 0, CV_STORAGE_READ );
CvFileNode* board_list = fs ? cvGetFileNodeByName( fs, 0, "boards" ) : 0;

@ -1,3 +1,3 @@
#include "test_precomp.hpp"
CV_TEST_MAIN("cv")
CV_TEST_MAIN("")

@ -398,7 +398,7 @@ protected:
void CV_StereoMatchingTest::run(int)
{
string dataPath = ts->get_data_path();
string dataPath = ts->get_data_path() + "cv/";
string algorithmName = name;
assert( !algorithmName.empty() );
if( dataPath.empty() )

@ -55,7 +55,7 @@ void CvAdaptiveSkinDetector::initData(IplImage *src, int widthDivider, int heigh
imgGrayFrame = cvCreateImage(imageSize, IPL_DEPTH_8U, 1);
imgLastGrayFrame = cvCreateImage(imageSize, IPL_DEPTH_8U, 1);
imgHSVFrame = cvCreateImage(imageSize, IPL_DEPTH_8U, 3);
};
}
CvAdaptiveSkinDetector::CvAdaptiveSkinDetector(int samplingDivider, int morphingMethod)
{
@ -80,7 +80,7 @@ CvAdaptiveSkinDetector::CvAdaptiveSkinDetector(int samplingDivider, int morphing
imgLastGrayFrame = NULL;
imgSaturationFrame = NULL;
imgHSVFrame = NULL;
};
}
CvAdaptiveSkinDetector::~CvAdaptiveSkinDetector()
{
@ -93,7 +93,7 @@ CvAdaptiveSkinDetector::~CvAdaptiveSkinDetector()
cvReleaseImage(&imgGrayFrame);
cvReleaseImage(&imgLastGrayFrame);
cvReleaseImage(&imgHSVFrame);
};
}
void CvAdaptiveSkinDetector::process(IplImage *inputBGRImage, IplImage *outputHueMask)
{
@ -190,7 +190,7 @@ void CvAdaptiveSkinDetector::process(IplImage *inputBGRImage, IplImage *outputHu
if (outputHueMask != NULL)
cvCopy(imgFilteredFrame, outputHueMask);
};
}
//------------------------- Histogram for Adaptive Skin Detector -------------------------//
@ -202,12 +202,12 @@ CvAdaptiveSkinDetector::Histogram::Histogram()
float *ranges[] = { range };
fHistogram = cvCreateHist(1, histogramSize, CV_HIST_ARRAY, ranges, 1);
cvClearHist(fHistogram);
};
}
CvAdaptiveSkinDetector::Histogram::~Histogram()
{
cvReleaseHist(&fHistogram);
};
}
int CvAdaptiveSkinDetector::Histogram::findCoverageIndex(double surfaceToCover, int defaultValue)
{
@ -221,7 +221,7 @@ int CvAdaptiveSkinDetector::Histogram::findCoverageIndex(double surfaceToCover,
}
}
return defaultValue;
};
}
void CvAdaptiveSkinDetector::Histogram::findCurveThresholds(int &x1, int &x2, double percent)
{
@ -244,7 +244,7 @@ void CvAdaptiveSkinDetector::Histogram::findCurveThresholds(int &x1, int &x2, do
x2 = GSD_HUE_UT;
else
x2 += GSD_HUE_LT;
};
}
void CvAdaptiveSkinDetector::Histogram::mergeWith(CvAdaptiveSkinDetector::Histogram *source, double weight)
{
@ -285,4 +285,4 @@ void CvAdaptiveSkinDetector::Histogram::mergeWith(CvAdaptiveSkinDetector::Histog
}
}
}
};
}

@ -940,7 +940,7 @@ static void fjac(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, C
#endif
};
}
static void func(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* estim, void* /*data*/) {
//just do projections
CvMat _Mi;
@ -979,17 +979,17 @@ static void func(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, C
cvTranspose( _mp2, estim );
cvReleaseMat( &_mp );
cvReleaseMat( &_mp2 );
};
}
static void fjac_new(int i, int j, Mat& point_params, Mat& cam_params, Mat& A, Mat& B, void* data) {
CvMat _point_params = point_params, _cam_params = cam_params, _Al = A, _Bl = B;
fjac(i,j, &_point_params, &_cam_params, &_Al, &_Bl, data);
};
}
static void func_new(int i, int j, Mat& point_params, Mat& cam_params, Mat& estim, void* data) {
CvMat _point_params = point_params, _cam_params = cam_params, _estim = estim;
func(i,j,&_point_params,&_cam_params,&_estim,data);
};
}
void LevMarqSparse::bundleAdjust( std::vector<Point3d>& points, //positions of points in global coordinate system (input and output)
const std::vector<std::vector<Point2d> >& imagePoints, //projections of 3d points for every camera

@ -872,7 +872,7 @@ CV_INIT_ALGORITHM(Eigenfaces, "FaceRecognizer.Eigenfaces",
obj.info()->addParam(obj, "labels", obj._labels, true);
obj.info()->addParam(obj, "eigenvectors", obj._eigenvectors, true);
obj.info()->addParam(obj, "eigenvalues", obj._eigenvalues, true);
obj.info()->addParam(obj, "mean", obj._mean, true));
obj.info()->addParam(obj, "mean", obj._mean, true))
CV_INIT_ALGORITHM(Fisherfaces, "FaceRecognizer.Fisherfaces",
obj.info()->addParam(obj, "ncomponents", obj._num_components);
@ -881,7 +881,7 @@ CV_INIT_ALGORITHM(Fisherfaces, "FaceRecognizer.Fisherfaces",
obj.info()->addParam(obj, "labels", obj._labels, true);
obj.info()->addParam(obj, "eigenvectors", obj._eigenvectors, true);
obj.info()->addParam(obj, "eigenvalues", obj._eigenvalues, true);
obj.info()->addParam(obj, "mean", obj._mean, true));
obj.info()->addParam(obj, "mean", obj._mean, true))
CV_INIT_ALGORITHM(LBPH, "FaceRecognizer.LBPH",
obj.info()->addParam(obj, "radius", obj._radius);
@ -890,7 +890,7 @@ CV_INIT_ALGORITHM(LBPH, "FaceRecognizer.LBPH",
obj.info()->addParam(obj, "grid_y", obj._grid_y);
obj.info()->addParam(obj, "threshold", obj._threshold);
obj.info()->addParam(obj, "histograms", obj._histograms, true);
obj.info()->addParam(obj, "labels", obj._labels, true));
obj.info()->addParam(obj, "labels", obj._labels, true))
bool initModule_contrib()
{

@ -41,7 +41,7 @@ CvFuzzyPoint::CvFuzzyPoint(double _x, double _y)
{
x = _x;
y = _y;
};
}
bool CvFuzzyCurve::between(double x, double x1, double x2)
{
@ -51,37 +51,37 @@ bool CvFuzzyCurve::between(double x, double x1, double x2)
return true;
return false;
};
}
CvFuzzyCurve::CvFuzzyCurve()
{
value = 0;
};
}
CvFuzzyCurve::~CvFuzzyCurve()
{
// nothing to do
};
}
void CvFuzzyCurve::setCentre(double _centre)
{
centre = _centre;
};
}
double CvFuzzyCurve::getCentre()
{
return centre;
};
}
void CvFuzzyCurve::clear()
{
points.clear();
};
}
void CvFuzzyCurve::addPoint(double x, double y)
{
points.push_back(CvFuzzyPoint(x, y));
};
}
double CvFuzzyCurve::calcValue(double param)
{
@ -102,41 +102,41 @@ double CvFuzzyCurve::calcValue(double param)
}
}
return 0;
};
}
double CvFuzzyCurve::getValue()
{
return value;
};
}
void CvFuzzyCurve::setValue(double _value)
{
value = _value;
};
}
CvFuzzyFunction::CvFuzzyFunction()
{
// nothing to do
};
}
CvFuzzyFunction::~CvFuzzyFunction()
{
curves.clear();
};
}
void CvFuzzyFunction::addCurve(CvFuzzyCurve *curve, double value)
{
curves.push_back(*curve);
curve->setValue(value);
};
}
void CvFuzzyFunction::resetValues()
{
int numCurves = (int)curves.size();
for (int i = 0; i < numCurves; i++)
curves[i].setValue(0);
};
}
double CvFuzzyFunction::calcValue()
{
@ -153,7 +153,7 @@ double CvFuzzyFunction::calcValue()
return s1/s2;
else
return 0;
};
}
CvFuzzyCurve *CvFuzzyFunction::newCurve()
{
@ -161,14 +161,14 @@ CvFuzzyCurve *CvFuzzyFunction::newCurve()
c = new CvFuzzyCurve();
addCurve(c);
return c;
};
}
CvFuzzyRule::CvFuzzyRule()
{
fuzzyInput1 = NULL;
fuzzyInput2 = NULL;
fuzzyOutput = NULL;
};
}
CvFuzzyRule::~CvFuzzyRule()
{
@ -180,14 +180,14 @@ CvFuzzyRule::~CvFuzzyRule()
if (fuzzyOutput != NULL)
delete fuzzyOutput;
};
}
void CvFuzzyRule::setRule(CvFuzzyCurve *c1, CvFuzzyCurve *c2, CvFuzzyCurve *o1)
{
fuzzyInput1 = c1;
fuzzyInput2 = c2;
fuzzyOutput = o1;
};
}
double CvFuzzyRule::calcValue(double param1, double param2)
{
@ -203,31 +203,31 @@ double CvFuzzyRule::calcValue(double param1, double param2)
}
else
return v1;
};
}
CvFuzzyCurve *CvFuzzyRule::getOutputCurve()
{
return fuzzyOutput;
};
}
CvFuzzyController::CvFuzzyController()
{
// nothing to do
};
}
CvFuzzyController::~CvFuzzyController()
{
int size = (int)rules.size();
for(int i = 0; i < size; i++)
delete rules[i];
};
}
void CvFuzzyController::addRule(CvFuzzyCurve *c1, CvFuzzyCurve *c2, CvFuzzyCurve *o1)
{
CvFuzzyRule *f = new CvFuzzyRule();
rules.push_back(f);
f->setRule(c1, c2, o1);
};
}
double CvFuzzyController::calcOutput(double param1, double param2)
{
@ -243,7 +243,7 @@ double CvFuzzyController::calcOutput(double param1, double param2)
}
v = list.calcValue();
return v;
};
}
CvFuzzyMeanShiftTracker::FuzzyResizer::FuzzyResizer()
{
@ -299,12 +299,12 @@ CvFuzzyMeanShiftTracker::FuzzyResizer::FuzzyResizer()
fuzzyController.addRule(i1L, NULL, oS);
fuzzyController.addRule(i1M, NULL, oZE);
fuzzyController.addRule(i1H, NULL, oE);
};
}
int CvFuzzyMeanShiftTracker::FuzzyResizer::calcOutput(double edgeDensity, double density)
{
return (int)fuzzyController.calcOutput(edgeDensity, density);
};
}
CvFuzzyMeanShiftTracker::SearchWindow::SearchWindow()
{
@ -329,7 +329,7 @@ CvFuzzyMeanShiftTracker::SearchWindow::SearchWindow()
depthLow = 0;
depthHigh = 0;
fuzzyResizer = NULL;
};
}
CvFuzzyMeanShiftTracker::SearchWindow::~SearchWindow()
{
@ -355,7 +355,7 @@ void CvFuzzyMeanShiftTracker::SearchWindow::setSize(int _x, int _y, int _width,
if (y + height > maxHeight)
height = maxHeight - y;
};
}
void CvFuzzyMeanShiftTracker::SearchWindow::initDepthValues(IplImage *maskImage, IplImage *depthMap)
{
@ -409,7 +409,7 @@ void CvFuzzyMeanShiftTracker::SearchWindow::initDepthValues(IplImage *maskImage,
depthHigh = 32000;
depthLow = 0;
}
};
}
bool CvFuzzyMeanShiftTracker::SearchWindow::shift()
{
@ -422,7 +422,7 @@ bool CvFuzzyMeanShiftTracker::SearchWindow::shift()
{
return false;
}
};
}
void CvFuzzyMeanShiftTracker::SearchWindow::extractInfo(IplImage *maskImage, IplImage *depthMap, bool initDepth)
{
@ -528,7 +528,7 @@ void CvFuzzyMeanShiftTracker::SearchWindow::extractInfo(IplImage *maskImage, Ipl
ellipseAngle = 0;
density = 0;
}
};
}
void CvFuzzyMeanShiftTracker::SearchWindow::getResizeAttribsEdgeDensityLinear(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh) {
int x1 = horizontalEdgeTop;
@ -572,7 +572,7 @@ void CvFuzzyMeanShiftTracker::SearchWindow::getResizeAttribsEdgeDensityLinear(in
} else {
resizeDw = - resizeDx;
}
};
}
void CvFuzzyMeanShiftTracker::SearchWindow::getResizeAttribsInnerDensity(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh)
{
@ -588,7 +588,7 @@ void CvFuzzyMeanShiftTracker::SearchWindow::getResizeAttribsInnerDensity(int &re
resizeDy = (int)(py*dy);
resizeDw = (int)((1-px)*dx);
resizeDh = (int)((1-py)*dy);
};
}
void CvFuzzyMeanShiftTracker::SearchWindow::getResizeAttribsEdgeDensityFuzzy(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh)
{
@ -627,7 +627,7 @@ void CvFuzzyMeanShiftTracker::SearchWindow::getResizeAttribsEdgeDensityFuzzy(int
resizeDy = int(-dy1);
resizeDh = int(dy1+dy2);
}
};
}
bool CvFuzzyMeanShiftTracker::SearchWindow::meanShift(IplImage *maskImage, IplImage *depthMap, int maxIteration, bool initDepth)
{
@ -640,7 +640,7 @@ bool CvFuzzyMeanShiftTracker::SearchWindow::meanShift(IplImage *maskImage, IplIm
} while (++numShifts < maxIteration);
return false;
};
}
void CvFuzzyMeanShiftTracker::findOptimumSearchWindow(SearchWindow &searchWindow, IplImage *maskImage, IplImage *depthMap, int maxIteration, int resizeMethod, bool initDepth)
{
@ -680,17 +680,17 @@ void CvFuzzyMeanShiftTracker::findOptimumSearchWindow(SearchWindow &searchWindow
searchWindow.setSize(searchWindow.x + resizeDx, searchWindow.y + resizeDy, searchWindow.width + resizeDw, searchWindow.height + resizeDh);
}
};
}
CvFuzzyMeanShiftTracker::CvFuzzyMeanShiftTracker()
{
searchMode = tsSetWindow;
};
}
CvFuzzyMeanShiftTracker::~CvFuzzyMeanShiftTracker()
{
// nothing to do
};
}
void CvFuzzyMeanShiftTracker::track(IplImage *maskImage, IplImage *depthMap, int resizeMethod, bool resetSearch, int minKernelMass)
{
@ -718,4 +718,4 @@ void CvFuzzyMeanShiftTracker::track(IplImage *maskImage, IplImage *depthMap, int
else
searchMode = tsTracking;
}
};
}

@ -709,7 +709,7 @@ void cv::SpinImageModel::defaultParams()
T_GeometriccConsistency = 0.25f;
T_GroupingCorespondances = 0.25f;
};
}
Mat cv::SpinImageModel::packRandomScaledSpins(bool separateScale, size_t xCount, size_t yCount) const
{

@ -127,6 +127,7 @@ public:
virtual int depth(int i=-1) const;
virtual int channels(int i=-1) const;
virtual bool isContinuous(int i=-1) const;
virtual bool isSubmatrix(int i=-1) const;
virtual bool empty() const;
virtual void copyTo(const _OutputArray& arr) const;
virtual size_t offset(int i=-1) const;

@ -186,6 +186,12 @@ inline _OutputArray::_OutputArray(const Mat& m)
inline _OutputArray::_OutputArray(const std::vector<Mat>& vec)
{ init(FIXED_SIZE + STD_VECTOR_MAT + ACCESS_WRITE, &vec); }
inline _OutputArray::_OutputArray(const UMat& m)
{ init(FIXED_TYPE + FIXED_SIZE + UMAT + ACCESS_WRITE, &m); }
inline _OutputArray::_OutputArray(const std::vector<UMat>& vec)
{ init(FIXED_SIZE + STD_VECTOR_UMAT + ACCESS_WRITE, &vec); }
inline _OutputArray::_OutputArray(const cuda::GpuMat& d_mat)
{ init(FIXED_TYPE + FIXED_SIZE + GPU_MAT + ACCESS_WRITE, &d_mat); }
@ -1912,7 +1918,7 @@ SparseMat_<_Tp>::SparseMat_(const SparseMat& m)
if( m.type() == DataType<_Tp>::type )
*this = (const SparseMat_<_Tp>&)m;
else
m.convertTo(this, DataType<_Tp>::type);
m.convertTo(*this, DataType<_Tp>::type);
}
template<typename _Tp> inline

@ -423,6 +423,12 @@ int print(const Mat& mtx, FILE* stream = stdout)
return print(Formatter::get()->format(mtx), stream);
}
static inline
int print(const UMat& mtx, FILE* stream = stdout)
{
return print(Formatter::get()->format(mtx.getMat(ACCESS_READ)), stream);
}
template<typename _Tp> static inline
int print(const std::vector<Point_<_Tp> >& vec, FILE* stream = stdout)
{

@ -628,7 +628,7 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|| argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR)
{
if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN
|| p->type == Param::UNSIGNED_INT || p->type == Param::UINT64 || p->type == Param::FLOAT || argType == Param::UCHAR) )
|| p->type == Param::UNSIGNED_INT || p->type == Param::UINT64 || p->type == Param::FLOAT || p->type == Param::UCHAR) )
{
String message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
CV_Error(CV_StsBadArg, message);

@ -1434,8 +1434,8 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
bool haveScalar = false, swapped12 = false;
if( dims1 != dims2 || sz1 != sz2 || cn != cn2 ||
((kind1 == _InputArray::MATX || kind2 == _InputArray::MATX) &&
(sz1 == Size(1,4) || sz2 == Size(1,4))) )
(kind1 == _InputArray::MATX && (sz1 == Size(1,4) || sz1 == Size(1,1))) ||
(kind2 == _InputArray::MATX && (sz2 == Size(1,4) || sz2 == Size(1,1))) )
{
if( checkScalar(*psrc1, type2, kind1, kind2) )
{

@ -1040,122 +1040,122 @@ stype* dst, size_t dstep, Size size, double*) \
}
DEF_CVT_SCALE_ABS_FUNC(8u, cvtScaleAbs_, uchar, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(8s8u, cvtScaleAbs_, schar, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(16u8u, cvtScaleAbs_, ushort, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(16s8u, cvtScaleAbs_, short, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(32s8u, cvtScaleAbs_, int, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(32f8u, cvtScaleAbs_, float, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(64f8u, cvtScaleAbs_, double, uchar, float);
DEF_CVT_SCALE_FUNC(8u, uchar, uchar, float);
DEF_CVT_SCALE_FUNC(8s8u, schar, uchar, float);
DEF_CVT_SCALE_FUNC(16u8u, ushort, uchar, float);
DEF_CVT_SCALE_FUNC(16s8u, short, uchar, float);
DEF_CVT_SCALE_FUNC(32s8u, int, uchar, float);
DEF_CVT_SCALE_FUNC(32f8u, float, uchar, float);
DEF_CVT_SCALE_FUNC(64f8u, double, uchar, float);
DEF_CVT_SCALE_FUNC(8u8s, uchar, schar, float);
DEF_CVT_SCALE_FUNC(8s, schar, schar, float);
DEF_CVT_SCALE_FUNC(16u8s, ushort, schar, float);
DEF_CVT_SCALE_FUNC(16s8s, short, schar, float);
DEF_CVT_SCALE_FUNC(32s8s, int, schar, float);
DEF_CVT_SCALE_FUNC(32f8s, float, schar, float);
DEF_CVT_SCALE_FUNC(64f8s, double, schar, float);
DEF_CVT_SCALE_FUNC(8u16u, uchar, ushort, float);
DEF_CVT_SCALE_FUNC(8s16u, schar, ushort, float);
DEF_CVT_SCALE_FUNC(16u, ushort, ushort, float);
DEF_CVT_SCALE_FUNC(16s16u, short, ushort, float);
DEF_CVT_SCALE_FUNC(32s16u, int, ushort, float);
DEF_CVT_SCALE_FUNC(32f16u, float, ushort, float);
DEF_CVT_SCALE_FUNC(64f16u, double, ushort, float);
DEF_CVT_SCALE_FUNC(8u16s, uchar, short, float);
DEF_CVT_SCALE_FUNC(8s16s, schar, short, float);
DEF_CVT_SCALE_FUNC(16u16s, ushort, short, float);
DEF_CVT_SCALE_FUNC(16s, short, short, float);
DEF_CVT_SCALE_FUNC(32s16s, int, short, float);
DEF_CVT_SCALE_FUNC(32f16s, float, short, float);
DEF_CVT_SCALE_FUNC(64f16s, double, short, float);
DEF_CVT_SCALE_FUNC(8u32s, uchar, int, float);
DEF_CVT_SCALE_FUNC(8s32s, schar, int, float);
DEF_CVT_SCALE_FUNC(16u32s, ushort, int, float);
DEF_CVT_SCALE_FUNC(16s32s, short, int, float);
DEF_CVT_SCALE_FUNC(32s, int, int, double);
DEF_CVT_SCALE_FUNC(32f32s, float, int, float);
DEF_CVT_SCALE_FUNC(64f32s, double, int, double);
DEF_CVT_SCALE_FUNC(8u32f, uchar, float, float);
DEF_CVT_SCALE_FUNC(8s32f, schar, float, float);
DEF_CVT_SCALE_FUNC(16u32f, ushort, float, float);
DEF_CVT_SCALE_FUNC(16s32f, short, float, float);
DEF_CVT_SCALE_FUNC(32s32f, int, float, double);
DEF_CVT_SCALE_FUNC(32f, float, float, float);
DEF_CVT_SCALE_FUNC(64f32f, double, float, double);
DEF_CVT_SCALE_FUNC(8u64f, uchar, double, double);
DEF_CVT_SCALE_FUNC(8s64f, schar, double, double);
DEF_CVT_SCALE_FUNC(16u64f, ushort, double, double);
DEF_CVT_SCALE_FUNC(16s64f, short, double, double);
DEF_CVT_SCALE_FUNC(32s64f, int, double, double);
DEF_CVT_SCALE_FUNC(32f64f, float, double, double);
DEF_CVT_SCALE_FUNC(64f, double, double, double);
DEF_CPY_FUNC(8u, uchar);
DEF_CVT_FUNC(8s8u, schar, uchar);
DEF_CVT_FUNC(16u8u, ushort, uchar);
DEF_CVT_FUNC(16s8u, short, uchar);
DEF_CVT_FUNC(32s8u, int, uchar);
DEF_CVT_FUNC(32f8u, float, uchar);
DEF_CVT_FUNC(64f8u, double, uchar);
DEF_CVT_FUNC(8u8s, uchar, schar);
DEF_CVT_FUNC(16u8s, ushort, schar);
DEF_CVT_FUNC(16s8s, short, schar);
DEF_CVT_FUNC(32s8s, int, schar);
DEF_CVT_FUNC(32f8s, float, schar);
DEF_CVT_FUNC(64f8s, double, schar);
DEF_CVT_FUNC(8u16u, uchar, ushort);
DEF_CVT_FUNC(8s16u, schar, ushort);
DEF_CPY_FUNC(16u, ushort);
DEF_CVT_FUNC(16s16u, short, ushort);
DEF_CVT_FUNC(32s16u, int, ushort);
DEF_CVT_FUNC(32f16u, float, ushort);
DEF_CVT_FUNC(64f16u, double, ushort);
DEF_CVT_FUNC(8u16s, uchar, short);
DEF_CVT_FUNC(8s16s, schar, short);
DEF_CVT_FUNC(16u16s, ushort, short);
DEF_CVT_FUNC(32s16s, int, short);
DEF_CVT_FUNC(32f16s, float, short);
DEF_CVT_FUNC(64f16s, double, short);
DEF_CVT_FUNC(8u32s, uchar, int);
DEF_CVT_FUNC(8s32s, schar, int);
DEF_CVT_FUNC(16u32s, ushort, int);
DEF_CVT_FUNC(16s32s, short, int);
DEF_CPY_FUNC(32s, int);
DEF_CVT_FUNC(32f32s, float, int);
DEF_CVT_FUNC(64f32s, double, int);
DEF_CVT_FUNC(8u32f, uchar, float);
DEF_CVT_FUNC(8s32f, schar, float);
DEF_CVT_FUNC(16u32f, ushort, float);
DEF_CVT_FUNC(16s32f, short, float);
DEF_CVT_FUNC(32s32f, int, float);
DEF_CVT_FUNC(64f32f, double, float);
DEF_CVT_FUNC(8u64f, uchar, double);
DEF_CVT_FUNC(8s64f, schar, double);
DEF_CVT_FUNC(16u64f, ushort, double);
DEF_CVT_FUNC(16s64f, short, double);
DEF_CVT_FUNC(32s64f, int, double);
DEF_CVT_FUNC(32f64f, float, double);
DEF_CPY_FUNC(64s, int64);
DEF_CVT_SCALE_ABS_FUNC(8u, cvtScaleAbs_, uchar, uchar, float)
DEF_CVT_SCALE_ABS_FUNC(8s8u, cvtScaleAbs_, schar, uchar, float)
DEF_CVT_SCALE_ABS_FUNC(16u8u, cvtScaleAbs_, ushort, uchar, float)
DEF_CVT_SCALE_ABS_FUNC(16s8u, cvtScaleAbs_, short, uchar, float)
DEF_CVT_SCALE_ABS_FUNC(32s8u, cvtScaleAbs_, int, uchar, float)
DEF_CVT_SCALE_ABS_FUNC(32f8u, cvtScaleAbs_, float, uchar, float)
DEF_CVT_SCALE_ABS_FUNC(64f8u, cvtScaleAbs_, double, uchar, float)
DEF_CVT_SCALE_FUNC(8u, uchar, uchar, float)
DEF_CVT_SCALE_FUNC(8s8u, schar, uchar, float)
DEF_CVT_SCALE_FUNC(16u8u, ushort, uchar, float)
DEF_CVT_SCALE_FUNC(16s8u, short, uchar, float)
DEF_CVT_SCALE_FUNC(32s8u, int, uchar, float)
DEF_CVT_SCALE_FUNC(32f8u, float, uchar, float)
DEF_CVT_SCALE_FUNC(64f8u, double, uchar, float)
DEF_CVT_SCALE_FUNC(8u8s, uchar, schar, float)
DEF_CVT_SCALE_FUNC(8s, schar, schar, float)
DEF_CVT_SCALE_FUNC(16u8s, ushort, schar, float)
DEF_CVT_SCALE_FUNC(16s8s, short, schar, float)
DEF_CVT_SCALE_FUNC(32s8s, int, schar, float)
DEF_CVT_SCALE_FUNC(32f8s, float, schar, float)
DEF_CVT_SCALE_FUNC(64f8s, double, schar, float)
DEF_CVT_SCALE_FUNC(8u16u, uchar, ushort, float)
DEF_CVT_SCALE_FUNC(8s16u, schar, ushort, float)
DEF_CVT_SCALE_FUNC(16u, ushort, ushort, float)
DEF_CVT_SCALE_FUNC(16s16u, short, ushort, float)
DEF_CVT_SCALE_FUNC(32s16u, int, ushort, float)
DEF_CVT_SCALE_FUNC(32f16u, float, ushort, float)
DEF_CVT_SCALE_FUNC(64f16u, double, ushort, float)
DEF_CVT_SCALE_FUNC(8u16s, uchar, short, float)
DEF_CVT_SCALE_FUNC(8s16s, schar, short, float)
DEF_CVT_SCALE_FUNC(16u16s, ushort, short, float)
DEF_CVT_SCALE_FUNC(16s, short, short, float)
DEF_CVT_SCALE_FUNC(32s16s, int, short, float)
DEF_CVT_SCALE_FUNC(32f16s, float, short, float)
DEF_CVT_SCALE_FUNC(64f16s, double, short, float)
DEF_CVT_SCALE_FUNC(8u32s, uchar, int, float)
DEF_CVT_SCALE_FUNC(8s32s, schar, int, float)
DEF_CVT_SCALE_FUNC(16u32s, ushort, int, float)
DEF_CVT_SCALE_FUNC(16s32s, short, int, float)
DEF_CVT_SCALE_FUNC(32s, int, int, double)
DEF_CVT_SCALE_FUNC(32f32s, float, int, float)
DEF_CVT_SCALE_FUNC(64f32s, double, int, double)
DEF_CVT_SCALE_FUNC(8u32f, uchar, float, float)
DEF_CVT_SCALE_FUNC(8s32f, schar, float, float)
DEF_CVT_SCALE_FUNC(16u32f, ushort, float, float)
DEF_CVT_SCALE_FUNC(16s32f, short, float, float)
DEF_CVT_SCALE_FUNC(32s32f, int, float, double)
DEF_CVT_SCALE_FUNC(32f, float, float, float)
DEF_CVT_SCALE_FUNC(64f32f, double, float, double)
DEF_CVT_SCALE_FUNC(8u64f, uchar, double, double)
DEF_CVT_SCALE_FUNC(8s64f, schar, double, double)
DEF_CVT_SCALE_FUNC(16u64f, ushort, double, double)
DEF_CVT_SCALE_FUNC(16s64f, short, double, double)
DEF_CVT_SCALE_FUNC(32s64f, int, double, double)
DEF_CVT_SCALE_FUNC(32f64f, float, double, double)
DEF_CVT_SCALE_FUNC(64f, double, double, double)
DEF_CPY_FUNC(8u, uchar)
DEF_CVT_FUNC(8s8u, schar, uchar)
DEF_CVT_FUNC(16u8u, ushort, uchar)
DEF_CVT_FUNC(16s8u, short, uchar)
DEF_CVT_FUNC(32s8u, int, uchar)
DEF_CVT_FUNC(32f8u, float, uchar)
DEF_CVT_FUNC(64f8u, double, uchar)
DEF_CVT_FUNC(8u8s, uchar, schar)
DEF_CVT_FUNC(16u8s, ushort, schar)
DEF_CVT_FUNC(16s8s, short, schar)
DEF_CVT_FUNC(32s8s, int, schar)
DEF_CVT_FUNC(32f8s, float, schar)
DEF_CVT_FUNC(64f8s, double, schar)
DEF_CVT_FUNC(8u16u, uchar, ushort)
DEF_CVT_FUNC(8s16u, schar, ushort)
DEF_CPY_FUNC(16u, ushort)
DEF_CVT_FUNC(16s16u, short, ushort)
DEF_CVT_FUNC(32s16u, int, ushort)
DEF_CVT_FUNC(32f16u, float, ushort)
DEF_CVT_FUNC(64f16u, double, ushort)
DEF_CVT_FUNC(8u16s, uchar, short)
DEF_CVT_FUNC(8s16s, schar, short)
DEF_CVT_FUNC(16u16s, ushort, short)
DEF_CVT_FUNC(32s16s, int, short)
DEF_CVT_FUNC(32f16s, float, short)
DEF_CVT_FUNC(64f16s, double, short)
DEF_CVT_FUNC(8u32s, uchar, int)
DEF_CVT_FUNC(8s32s, schar, int)
DEF_CVT_FUNC(16u32s, ushort, int)
DEF_CVT_FUNC(16s32s, short, int)
DEF_CPY_FUNC(32s, int)
DEF_CVT_FUNC(32f32s, float, int)
DEF_CVT_FUNC(64f32s, double, int)
DEF_CVT_FUNC(8u32f, uchar, float)
DEF_CVT_FUNC(8s32f, schar, float)
DEF_CVT_FUNC(16u32f, ushort, float)
DEF_CVT_FUNC(16s32f, short, float)
DEF_CVT_FUNC(32s32f, int, float)
DEF_CVT_FUNC(64f32f, double, float)
DEF_CVT_FUNC(8u64f, uchar, double)
DEF_CVT_FUNC(8s64f, schar, double)
DEF_CVT_FUNC(16u64f, ushort, double)
DEF_CVT_FUNC(16s64f, short, double)
DEF_CVT_FUNC(32s64f, int, double)
DEF_CVT_FUNC(32f64f, float, double)
DEF_CPY_FUNC(64s, int64)
static BinaryFunc getCvtScaleAbsFunc(int depth)
{

@ -166,16 +166,16 @@ static void copyMask##suffix(const uchar* src, size_t sstep, const uchar* mask,
}
DEF_COPY_MASK(8u, uchar);
DEF_COPY_MASK(16u, ushort);
DEF_COPY_MASK(8uC3, Vec3b);
DEF_COPY_MASK(32s, int);
DEF_COPY_MASK(16uC3, Vec3s);
DEF_COPY_MASK(32sC2, Vec2i);
DEF_COPY_MASK(32sC3, Vec3i);
DEF_COPY_MASK(32sC4, Vec4i);
DEF_COPY_MASK(32sC6, Vec6i);
DEF_COPY_MASK(32sC8, Vec8i);
DEF_COPY_MASK(8u, uchar)
DEF_COPY_MASK(16u, ushort)
DEF_COPY_MASK(8uC3, Vec3b)
DEF_COPY_MASK(32s, int)
DEF_COPY_MASK(16uC3, Vec3s)
DEF_COPY_MASK(32sC2, Vec2i)
DEF_COPY_MASK(32sC3, Vec3i)
DEF_COPY_MASK(32sC4, Vec4i)
DEF_COPY_MASK(32sC6, Vec6i)
DEF_COPY_MASK(32sC8, Vec8i)
BinaryFunc copyMaskTab[] =
{

@ -2057,10 +2057,15 @@ static bool ocl_pow(InputArray _src, double power, OutputArray _dst)
ocl::KernelArg srcarg = ocl::KernelArg::ReadOnlyNoSize(src),
dstarg = ocl::KernelArg::WriteOnly(dst, cn);
if (depth == CV_32F)
k.args(srcarg, dstarg, (float)power);
if (issqrt)
k.args(srcarg, dstarg);
else
k.args(srcarg, dstarg, power);
{
if (depth == CV_32F)
k.args(srcarg, dstarg, (float)power);
else
k.args(srcarg, dstarg, power);
}
size_t globalsize[2] = { dst.cols * cn, dst.rows };
return k.run(2, globalsize, NULL, false);

@ -1808,6 +1808,37 @@ bool _InputArray::isContinuous(int i) const
return false;
}
bool _InputArray::isSubmatrix(int i) const
{
int k = kind();
if( k == MAT )
return i < 0 ? ((const Mat*)obj)->isSubmatrix() : false;
if( k == UMAT )
return i < 0 ? ((const UMat*)obj)->isSubmatrix() : false;
if( k == EXPR || k == MATX || k == STD_VECTOR || k == NONE || k == STD_VECTOR_VECTOR)
return false;
if( k == STD_VECTOR_MAT )
{
const std::vector<Mat>& vv = *(const std::vector<Mat>*)obj;
CV_Assert((size_t)i < vv.size());
return vv[i].isSubmatrix();
}
if( k == STD_VECTOR_UMAT )
{
const std::vector<UMat>& vv = *(const std::vector<UMat>*)obj;
CV_Assert((size_t)i < vv.size());
return vv[i].isSubmatrix();
}
CV_Error(CV_StsNotImplemented, "");
return false;
}
size_t _InputArray::offset(int i) const
{
int k = kind();

@ -849,7 +849,9 @@ public:
};
#ifdef WIN32
#ifdef _MSC_VER
#pragma warning(disable:4505) // unreferenced local function has been removed
#endif
#ifdef HAVE_WINRT
// using C++11 thread attribute for local thread data

@ -729,11 +729,12 @@ void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) con
doubleSupport ? " -D DOUBLE_SUPPORT" : ""));
if (!k.empty())
{
UMat src = *this;
_dst.create( size(), _type );
UMat dst = _dst.getUMat();
float alphaf = (float)alpha, betaf = (float)beta;
k.args(ocl::KernelArg::ReadOnlyNoSize(*this), ocl::KernelArg::WriteOnly(dst, cn), alphaf, betaf);
k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::WriteOnly(dst, cn), alphaf, betaf);
size_t globalsize[2] = { dst.cols * cn, dst.rows };
if (k.run(2, globalsize, NULL, false))

@ -115,7 +115,7 @@ struct BaseAddOp : public BaseElemWiseOp
struct AddOp : public BaseAddOp
{
AddOp() : BaseAddOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA+SUPPORT_MASK, 1, 1, Scalar::all(0)) {};
AddOp() : BaseAddOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA+SUPPORT_MASK, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat& mask)
{
if( mask.empty() )
@ -128,7 +128,7 @@ struct AddOp : public BaseAddOp
struct SubOp : public BaseAddOp
{
SubOp() : BaseAddOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA+SUPPORT_MASK, 1, -1, Scalar::all(0)) {};
SubOp() : BaseAddOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA+SUPPORT_MASK, 1, -1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat& mask)
{
if( mask.empty() )
@ -141,7 +141,7 @@ struct SubOp : public BaseAddOp
struct AddSOp : public BaseAddOp
{
AddSOp() : BaseAddOp(1, FIX_ALPHA+FIX_BETA+SUPPORT_MASK, 1, 0, Scalar::all(0)) {};
AddSOp() : BaseAddOp(1, FIX_ALPHA+FIX_BETA+SUPPORT_MASK, 1, 0, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat& mask)
{
if( mask.empty() )
@ -154,7 +154,7 @@ struct AddSOp : public BaseAddOp
struct SubRSOp : public BaseAddOp
{
SubRSOp() : BaseAddOp(1, FIX_ALPHA+FIX_BETA+SUPPORT_MASK, -1, 0, Scalar::all(0)) {};
SubRSOp() : BaseAddOp(1, FIX_ALPHA+FIX_BETA+SUPPORT_MASK, -1, 0, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat& mask)
{
if( mask.empty() )
@ -167,7 +167,7 @@ struct SubRSOp : public BaseAddOp
struct ScaleAddOp : public BaseAddOp
{
ScaleAddOp() : BaseAddOp(2, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
ScaleAddOp() : BaseAddOp(2, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
scaleAdd(src[0], alpha, src[1], dst);
@ -181,7 +181,7 @@ struct ScaleAddOp : public BaseAddOp
struct AddWeightedOp : public BaseAddOp
{
AddWeightedOp() : BaseAddOp(2, REAL_GAMMA, 1, 1, Scalar::all(0)) {};
AddWeightedOp() : BaseAddOp(2, REAL_GAMMA, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
addWeighted(src[0], alpha, src[1], beta, gamma[0], dst);
@ -194,7 +194,7 @@ struct AddWeightedOp : public BaseAddOp
struct MulOp : public BaseElemWiseOp
{
MulOp() : BaseElemWiseOp(2, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
MulOp() : BaseElemWiseOp(2, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
void getValueRange(int depth, double& minval, double& maxval)
{
minval = depth < CV_32S ? cvtest::getMinVal(depth) : depth == CV_32S ? -1000000 : -1000.;
@ -218,7 +218,7 @@ struct MulOp : public BaseElemWiseOp
struct DivOp : public BaseElemWiseOp
{
DivOp() : BaseElemWiseOp(2, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
DivOp() : BaseElemWiseOp(2, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
cv::divide(src[0], src[1], dst, alpha);
@ -235,7 +235,7 @@ struct DivOp : public BaseElemWiseOp
struct RecipOp : public BaseElemWiseOp
{
RecipOp() : BaseElemWiseOp(1, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
RecipOp() : BaseElemWiseOp(1, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
cv::divide(alpha, src[0], dst);
@ -252,7 +252,7 @@ struct RecipOp : public BaseElemWiseOp
struct AbsDiffOp : public BaseAddOp
{
AbsDiffOp() : BaseAddOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, -1, Scalar::all(0)) {};
AbsDiffOp() : BaseAddOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, -1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
absdiff(src[0], src[1], dst);
@ -265,7 +265,7 @@ struct AbsDiffOp : public BaseAddOp
struct AbsDiffSOp : public BaseAddOp
{
AbsDiffSOp() : BaseAddOp(1, FIX_ALPHA+FIX_BETA, 1, 0, Scalar::all(0)) {};
AbsDiffSOp() : BaseAddOp(1, FIX_ALPHA+FIX_BETA, 1, 0, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
absdiff(src[0], gamma, dst);
@ -278,7 +278,7 @@ struct AbsDiffSOp : public BaseAddOp
struct LogicOp : public BaseElemWiseOp
{
LogicOp(char _opcode) : BaseElemWiseOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA+SUPPORT_MASK, 1, 1, Scalar::all(0)), opcode(_opcode) {};
LogicOp(char _opcode) : BaseElemWiseOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA+SUPPORT_MASK, 1, 1, Scalar::all(0)), opcode(_opcode) {}
void op(const vector<Mat>& src, Mat& dst, const Mat& mask)
{
if( opcode == '&' )
@ -309,7 +309,7 @@ struct LogicOp : public BaseElemWiseOp
struct LogicSOp : public BaseElemWiseOp
{
LogicSOp(char _opcode)
: BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+(_opcode != '~' ? SUPPORT_MASK : 0), 1, 1, Scalar::all(0)), opcode(_opcode) {};
: BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+(_opcode != '~' ? SUPPORT_MASK : 0), 1, 1, Scalar::all(0)), opcode(_opcode) {}
void op(const vector<Mat>& src, Mat& dst, const Mat& mask)
{
if( opcode == '&' )
@ -341,7 +341,7 @@ struct LogicSOp : public BaseElemWiseOp
struct MinOp : public BaseElemWiseOp
{
MinOp() : BaseElemWiseOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
MinOp() : BaseElemWiseOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
cv::min(src[0], src[1], dst);
@ -358,7 +358,7 @@ struct MinOp : public BaseElemWiseOp
struct MaxOp : public BaseElemWiseOp
{
MaxOp() : BaseElemWiseOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
MaxOp() : BaseElemWiseOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
cv::max(src[0], src[1], dst);
@ -375,7 +375,7 @@ struct MaxOp : public BaseElemWiseOp
struct MinSOp : public BaseElemWiseOp
{
MinSOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)) {};
MinSOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
cv::min(src[0], gamma[0], dst);
@ -392,7 +392,7 @@ struct MinSOp : public BaseElemWiseOp
struct MaxSOp : public BaseElemWiseOp
{
MaxSOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)) {};
MaxSOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
cv::max(src[0], gamma[0], dst);
@ -409,7 +409,7 @@ struct MaxSOp : public BaseElemWiseOp
struct CmpOp : public BaseElemWiseOp
{
CmpOp() : BaseElemWiseOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
CmpOp() : BaseElemWiseOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
void generateScalars(int depth, RNG& rng)
{
BaseElemWiseOp::generateScalars(depth, rng);
@ -437,7 +437,7 @@ struct CmpOp : public BaseElemWiseOp
struct CmpSOp : public BaseElemWiseOp
{
CmpSOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)) {};
CmpSOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)) {}
void generateScalars(int depth, RNG& rng)
{
BaseElemWiseOp::generateScalars(depth, rng);
@ -467,7 +467,7 @@ struct CmpSOp : public BaseElemWiseOp
struct CopyOp : public BaseElemWiseOp
{
CopyOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA+SUPPORT_MASK, 1, 1, Scalar::all(0)) {};
CopyOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA+SUPPORT_MASK, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat& mask)
{
src[0].copyTo(dst, mask);
@ -490,7 +490,7 @@ struct CopyOp : public BaseElemWiseOp
struct SetOp : public BaseElemWiseOp
{
SetOp() : BaseElemWiseOp(0, FIX_ALPHA+FIX_BETA+SUPPORT_MASK, 1, 1, Scalar::all(0)) {};
SetOp() : BaseElemWiseOp(0, FIX_ALPHA+FIX_BETA+SUPPORT_MASK, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>&, Mat& dst, const Mat& mask)
{
dst.setTo(gamma, mask);
@ -651,7 +651,7 @@ static void inRangeS(const Mat& src, const Scalar& lb, const Scalar& rb, Mat& ds
struct InRangeSOp : public BaseElemWiseOp
{
InRangeSOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA, 1, 1, Scalar::all(0)) {};
InRangeSOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
cv::inRange(src[0], gamma, gamma1, dst);
@ -681,7 +681,7 @@ struct InRangeSOp : public BaseElemWiseOp
struct InRangeOp : public BaseElemWiseOp
{
InRangeOp() : BaseElemWiseOp(3, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
InRangeOp() : BaseElemWiseOp(3, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
Mat lb, rb;
@ -707,7 +707,7 @@ struct InRangeOp : public BaseElemWiseOp
struct ConvertScaleOp : public BaseElemWiseOp
{
ConvertScaleOp() : BaseElemWiseOp(1, FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)), ddepth(0) { };
ConvertScaleOp() : BaseElemWiseOp(1, FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)), ddepth(0) { }
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
src[0].convertTo(dst, ddepth, alpha, gamma[0]);
@ -742,7 +742,7 @@ struct ConvertScaleOp : public BaseElemWiseOp
struct ConvertScaleAbsOp : public BaseElemWiseOp
{
ConvertScaleAbsOp() : BaseElemWiseOp(1, FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)) {};
ConvertScaleAbsOp() : BaseElemWiseOp(1, FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
cv::convertScaleAbs(src[0], dst, alpha, gamma[0]);
@ -810,7 +810,7 @@ static void setIdentity(Mat& dst, const Scalar& s)
struct FlipOp : public BaseElemWiseOp
{
FlipOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
FlipOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
void getRandomSize(RNG& rng, vector<int>& size)
{
cvtest::randomSize(rng, 2, 2, cvtest::ARITHM_MAX_SIZE_LOG, size);
@ -836,7 +836,7 @@ struct FlipOp : public BaseElemWiseOp
struct TransposeOp : public BaseElemWiseOp
{
TransposeOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
TransposeOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
void getRandomSize(RNG& rng, vector<int>& size)
{
cvtest::randomSize(rng, 2, 2, cvtest::ARITHM_MAX_SIZE_LOG, size);
@ -857,7 +857,7 @@ struct TransposeOp : public BaseElemWiseOp
struct SetIdentityOp : public BaseElemWiseOp
{
SetIdentityOp() : BaseElemWiseOp(0, FIX_ALPHA+FIX_BETA, 1, 1, Scalar::all(0)) {};
SetIdentityOp() : BaseElemWiseOp(0, FIX_ALPHA+FIX_BETA, 1, 1, Scalar::all(0)) {}
void getRandomSize(RNG& rng, vector<int>& size)
{
cvtest::randomSize(rng, 2, 2, cvtest::ARITHM_MAX_SIZE_LOG, size);
@ -878,7 +878,7 @@ struct SetIdentityOp : public BaseElemWiseOp
struct SetZeroOp : public BaseElemWiseOp
{
SetZeroOp() : BaseElemWiseOp(0, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
SetZeroOp() : BaseElemWiseOp(0, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
void op(const vector<Mat>&, Mat& dst, const Mat&)
{
dst = Scalar::all(0);
@ -954,7 +954,7 @@ static void log(const Mat& src, Mat& dst)
struct ExpOp : public BaseElemWiseOp
{
ExpOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
ExpOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
int getRandomType(RNG& rng)
{
return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_FLT, 1, ARITHM_MAX_CHANNELS);
@ -981,7 +981,7 @@ struct ExpOp : public BaseElemWiseOp
struct LogOp : public BaseElemWiseOp
{
LogOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
LogOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}
int getRandomType(RNG& rng)
{
return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_FLT, 1, ARITHM_MAX_CHANNELS);
@ -1564,3 +1564,19 @@ TEST(Core_round, CvRound)
ASSERT_EQ(-2, cvRound(-2.5));
ASSERT_EQ(-4, cvRound(-3.5));
}
typedef testing::TestWithParam<Size> Mul1;
TEST_P(Mul1, One)
{
Size size = GetParam();
cv::Mat src(size, CV_32FC1, cv::Scalar::all(2)), dst,
ref_dst(size, CV_32FC1, cv::Scalar::all(6));
cv::multiply(3, src, dst);
ASSERT_EQ(0, cv::norm(dst, ref_dst, cv::NORM_INF));
}
INSTANTIATE_TEST_CASE_P(Arithm, Mul1, testing::Values(Size(2, 2), Size(1, 1)));

@ -90,7 +90,7 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, MatchTemplate8U,
CPU_SANITY_CHECK(dst);
}
};
}
////////////////////////////////////////////////////////////////////////////////
// MatchTemplate32F

@ -58,19 +58,19 @@ Ptr<Feature2D> Feature2D::create( const String& feature2DType )
CV_INIT_ALGORITHM(BRISK, "Feature2D.BRISK",
obj.info()->addParam(obj, "thres", obj.threshold);
obj.info()->addParam(obj, "octaves", obj.octaves));
obj.info()->addParam(obj, "octaves", obj.octaves))
///////////////////////////////////////////////////////////////////////////////////////////////////////////
CV_INIT_ALGORITHM(BriefDescriptorExtractor, "Feature2D.BRIEF",
obj.info()->addParam(obj, "bytes", obj.bytes_));
obj.info()->addParam(obj, "bytes", obj.bytes_))
///////////////////////////////////////////////////////////////////////////////////////////////////////////
CV_INIT_ALGORITHM(FastFeatureDetector, "Feature2D.FAST",
obj.info()->addParam(obj, "threshold", obj.threshold);
obj.info()->addParam(obj, "nonmaxSuppression", obj.nonmaxSuppression);
obj.info()->addParam(obj, "type", obj.type));
obj.info()->addParam(obj, "type", obj.type))
///////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -79,7 +79,7 @@ CV_INIT_ALGORITHM(StarDetector, "Feature2D.STAR",
obj.info()->addParam(obj, "responseThreshold", obj.responseThreshold);
obj.info()->addParam(obj, "lineThresholdProjected", obj.lineThresholdProjected);
obj.info()->addParam(obj, "lineThresholdBinarized", obj.lineThresholdBinarized);
obj.info()->addParam(obj, "suppressNonmaxSize", obj.suppressNonmaxSize));
obj.info()->addParam(obj, "suppressNonmaxSize", obj.suppressNonmaxSize))
///////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -92,7 +92,7 @@ CV_INIT_ALGORITHM(MSER, "Feature2D.MSER",
obj.info()->addParam(obj, "maxEvolution", obj.maxEvolution);
obj.info()->addParam(obj, "areaThreshold", obj.areaThreshold);
obj.info()->addParam(obj, "minMargin", obj.minMargin);
obj.info()->addParam(obj, "edgeBlurSize", obj.edgeBlurSize));
obj.info()->addParam(obj, "edgeBlurSize", obj.edgeBlurSize))
///////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -104,7 +104,7 @@ CV_INIT_ALGORITHM(ORB, "Feature2D.ORB",
obj.info()->addParam(obj, "edgeThreshold", obj.edgeThreshold);
obj.info()->addParam(obj, "patchSize", obj.patchSize);
obj.info()->addParam(obj, "WTA_K", obj.WTA_K);
obj.info()->addParam(obj, "scoreType", obj.scoreType));
obj.info()->addParam(obj, "scoreType", obj.scoreType))
///////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -112,7 +112,7 @@ CV_INIT_ALGORITHM(FREAK, "Feature2D.FREAK",
obj.info()->addParam(obj, "orientationNormalized", obj.orientationNormalized);
obj.info()->addParam(obj, "scaleNormalized", obj.scaleNormalized);
obj.info()->addParam(obj, "patternScale", obj.patternScale);
obj.info()->addParam(obj, "nbOctave", obj.nOctaves));
obj.info()->addParam(obj, "nbOctave", obj.nOctaves))
///////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -121,7 +121,7 @@ CV_INIT_ALGORITHM(GFTTDetector, "Feature2D.GFTT",
obj.info()->addParam(obj, "qualityLevel", obj.qualityLevel);
obj.info()->addParam(obj, "minDistance", obj.minDistance);
obj.info()->addParam(obj, "useHarrisDetector", obj.useHarrisDetector);
obj.info()->addParam(obj, "k", obj.k));
obj.info()->addParam(obj, "k", obj.k))
///////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -141,7 +141,7 @@ CV_INIT_ALGORITHM(SimpleBlobDetector, "Feature2D.SimpleBlob",
obj.info()->addParam(obj, "maxInertiaRatio", obj.params.maxInertiaRatio);
obj.info()->addParam(obj, "filterByConvexity", obj.params.filterByConvexity);
obj.info()->addParam(obj, "maxConvexity", obj.params.maxConvexity);
);
)
///////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -162,7 +162,7 @@ CV_INIT_ALGORITHM(HarrisDetector, "Feature2D.HARRIS",
obj.info()->addParam(obj, "qualityLevel", obj.qualityLevel);
obj.info()->addParam(obj, "minDistance", obj.minDistance);
obj.info()->addParam(obj, "useHarrisDetector", obj.useHarrisDetector);
obj.info()->addParam(obj, "k", obj.k));
obj.info()->addParam(obj, "k", obj.k))
////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -173,21 +173,21 @@ CV_INIT_ALGORITHM(DenseFeatureDetector, "Feature2D.Dense",
obj.info()->addParam(obj, "initXyStep", obj.initXyStep);
obj.info()->addParam(obj, "initImgBound", obj.initImgBound);
obj.info()->addParam(obj, "varyXyStepWithScale", obj.varyXyStepWithScale);
obj.info()->addParam(obj, "varyImgBoundWithScale", obj.varyImgBoundWithScale));
obj.info()->addParam(obj, "varyImgBoundWithScale", obj.varyImgBoundWithScale))
CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid",
obj.info()->addParam<FeatureDetector>(obj, "detector", obj.detector, false, 0, 0); // Extra params added to avoid VS2013 fatal error in opencv2/core.hpp (decl. of addParam)
obj.info()->addParam(obj, "maxTotalKeypoints", obj.maxTotalKeypoints);
obj.info()->addParam(obj, "gridRows", obj.gridRows);
obj.info()->addParam(obj, "gridCols", obj.gridCols));
obj.info()->addParam(obj, "gridCols", obj.gridCols))
////////////////////////////////////////////////////////////////////////////////////////////////////////////
CV_INIT_ALGORITHM(BFMatcher, "DescriptorMatcher.BFMatcher",
obj.info()->addParam(obj, "normType", obj.normType);
obj.info()->addParam(obj, "crossCheck", obj.crossCheck));
obj.info()->addParam(obj, "crossCheck", obj.crossCheck))
CV_INIT_ALGORITHM(FlannBasedMatcher, "DescriptorMatcher.FlannBasedMatcher",);
CV_INIT_ALGORITHM(FlannBasedMatcher, "DescriptorMatcher.FlannBasedMatcher",)
///////////////////////////////////////////////////////////////////////////////////////////////////////////

@ -413,12 +413,6 @@ public:
void loadIndex(FILE* stream)
{
load_value(stream, branching_);
load_value(stream, trees_);
load_value(stream, centers_init_);
load_value(stream, leaf_size_);
load_value(stream, memoryCounter);
free_elements();
if (root!=NULL) {
@ -429,6 +423,12 @@ public:
delete[] indices;
}
load_value(stream, branching_);
load_value(stream, trees_);
load_value(stream, centers_init_);
load_value(stream, leaf_size_);
load_value(stream, memoryCounter);
indices = new int*[trees_];
root = new NodePtr[trees_];
for (int i=0; i<trees_; ++i) {

@ -208,6 +208,26 @@ Sets mouse handler for the specified window
:param userdata: The optional parameter passed to the callback.
getMouseWheelDelta
------------------
Gets the mouse-wheel motion delta, when handling mouse-wheel events EVENT_MOUSEWHEEL and EVENT_MOUSEHWHEEL.
.. ocv:function:: int getMouseWheelDelta(int flags)
:param flags: The mouse callback flags parameter.
For regular mice with a scroll-wheel, delta will be a multiple of 120. The value 120 corresponds to a one notch rotation of the wheel or the threshold for action to be taken and one such action should occur for each delta.
Some high-precision mice with higher-resolution freely-rotating wheels may generate smaller values.
For EVENT_MOUSEWHEEL positive and negative values mean forward and backward scrolling, respectively.
For EVENT_MOUSEHWHEEL, where available, positive and negative values mean right and left scrolling, respectively.
With the C API, the macro CV_GET_WHEEL_DELTA(flags) can be used alternatively.
.. note::
Mouse-wheel events are currently supported only on Windows.
setTrackbarPos
------------------
Sets the trackbar position.

@ -76,7 +76,9 @@ enum { EVENT_MOUSEMOVE = 0,
EVENT_MBUTTONUP = 6,
EVENT_LBUTTONDBLCLK = 7,
EVENT_RBUTTONDBLCLK = 8,
EVENT_MBUTTONDBLCLK = 9
EVENT_MBUTTONDBLCLK = 9,
EVENT_MOUSEWHEEL = 10,
EVENT_MOUSEHWHEEL = 11
};
enum { EVENT_FLAG_LBUTTON = 1,
@ -137,6 +139,8 @@ CV_EXPORTS_W double getWindowProperty(const String& winname, int prop_id);
//! assigns callback for mouse events
CV_EXPORTS void setMouseCallback(const String& winname, MouseCallback onMouse, void* userdata = 0);
CV_EXPORTS int getMouseWheelDelta(int flags);
CV_EXPORTS int createTrackbar(const String& trackbarname, const String& winname,
int* value, int count,
TrackbarCallback onChange = 0,

@ -170,7 +170,9 @@ enum
CV_EVENT_MBUTTONUP =6,
CV_EVENT_LBUTTONDBLCLK =7,
CV_EVENT_RBUTTONDBLCLK =8,
CV_EVENT_MBUTTONDBLCLK =9
CV_EVENT_MBUTTONDBLCLK =9,
CV_EVENT_MOUSEWHEEL =10,
CV_EVENT_MOUSEHWHEEL =11
};
enum
@ -183,6 +185,9 @@ enum
CV_EVENT_FLAG_ALTKEY =32
};
#define CV_GET_WHEEL_DELTA(flags) ((short)((flags >> 16) & 0xffff)) // upper 16 bits
typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param);
/* assign callback for mouse events */

@ -53,7 +53,7 @@ enum
RBS_THROW_EOS=-123, // <end of stream> exception code
RBS_THROW_FORB=-124, // <forrbidden huffman code> exception code
RBS_HUFF_FORB=2047, // forrbidden huffman code "value"
RBS_BAD_HEADER=-125, // invalid header
RBS_BAD_HEADER=-125 // invalid header
};
typedef unsigned long ulong;

@ -2096,7 +2096,7 @@ enum
VideoCodec_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')), // Y,V,U (4:2:0)
VideoCodec_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2')), // Y,UV (4:2:0)
VideoCodec_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')), // YUYV/YUY2 (4:2:2)
VideoCodec_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')), // UYVY (4:2:2)
VideoCodec_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')) // UYVY (4:2:2)
};
enum
@ -2104,7 +2104,7 @@ enum
VideoChromaFormat_Monochrome = 0,
VideoChromaFormat_YUV420,
VideoChromaFormat_YUV422,
VideoChromaFormat_YUV444,
VideoChromaFormat_YUV444
};
struct InputMediaStream_FFMPEG

@ -58,6 +58,14 @@
#include <assert.h>
#if defined WIN32 || defined WINCE
#if !defined _WIN32_WINNT
#ifdef HAVE_MSMF
#define _WIN32_WINNT 0x0600 // Windows Vista
#else
#define _WIN32_WINNT 0x0500 // Windows 2000
#endif
#endif
#include <windows.h>
#undef small
#undef min

@ -216,6 +216,11 @@ void cv::setMouseCallback( const String& windowName, MouseCallback onMouse, void
cvSetMouseCallback(windowName.c_str(), onMouse, param);
}
int cv::getMouseWheelDelta( int flags )
{
return CV_GET_WHEEL_DELTA(flags);
}
int cv::startWindowThread()
{
return cvStartWindowThread();

@ -40,30 +40,15 @@
//M*/
#include "precomp.hpp"
#include <windowsx.h> // required for GET_X_LPARAM() and GET_Y_LPARAM() macros
#if defined WIN32 || defined _WIN32
#define COMPILE_MULTIMON_STUBS // Required for multi-monitor support
#ifndef _MULTIMON_USE_SECURE_CRT
# define _MULTIMON_USE_SECURE_CRT 0 // some MinGW platforms have no strncpy_s
#endif
#if defined SM_CMONITORS && !defined MONITOR_DEFAULTTONEAREST
# define MONITOR_DEFAULTTONULL 0x00000000
# define MONITOR_DEFAULTTOPRIMARY 0x00000001
# define MONITOR_DEFAULTTONEAREST 0x00000002
# define MONITORINFOF_PRIMARY 0x00000001
#endif
#ifndef __inout
# define __inout
#endif
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
#endif
#include <commctrl.h>
#include <winuser.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@ -1377,6 +1362,39 @@ MainWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
SetFocus(window->hwnd);
break;
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
if( window->on_mouse )
{
int flags = (wParam & MK_LBUTTON ? CV_EVENT_FLAG_LBUTTON : 0)|
(wParam & MK_RBUTTON ? CV_EVENT_FLAG_RBUTTON : 0)|
(wParam & MK_MBUTTON ? CV_EVENT_FLAG_MBUTTON : 0)|
(wParam & MK_CONTROL ? CV_EVENT_FLAG_CTRLKEY : 0)|
(wParam & MK_SHIFT ? CV_EVENT_FLAG_SHIFTKEY : 0)|
(GetKeyState(VK_MENU) < 0 ? CV_EVENT_FLAG_ALTKEY : 0);
int event = (uMsg == WM_MOUSEWHEEL ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
// Set the wheel delta of mouse wheel to be in the upper word of 'event'
int delta = GET_WHEEL_DELTA_WPARAM(wParam);
flags |= (delta << 16);
POINT pt;
pt.x = GET_X_LPARAM( lParam );
pt.y = GET_Y_LPARAM( lParam );
::ScreenToClient(hwnd, &pt); // Convert screen coordinates to client coordinates.
RECT rect;
GetClientRect( window->hwnd, &rect );
SIZE size = {0,0};
icvGetBitmapData( window, &size, 0, 0 );
window->on_mouse( event, pt.x*size.cx/MAX(rect.right - rect.left,1),
pt.y*size.cy/MAX(rect.bottom - rect.top,1), flags,
window->on_mouse_param );
}
break;
case WM_ERASEBKGND:
{
RECT cr, tr, wrc;
@ -1474,8 +1492,8 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
if( uMsg == WM_LBUTTONUP || uMsg == WM_RBUTTONUP || uMsg == WM_MBUTTONUP )
ReleaseCapture();
pt.x = LOWORD( lParam );
pt.y = HIWORD( lParam );
pt.x = GET_X_LPARAM( lParam );
pt.y = GET_Y_LPARAM( lParam );
GetClientRect( window->hwnd, &rect );
icvGetBitmapData( window, &size, 0, 0 );

@ -0,0 +1,82 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
namespace cvtest {
namespace ocl {
///////////// BlendLinear ////////////////////////
typedef Size_MatType BlendLinearFixture;
OCL_PERF_TEST_P(BlendLinearFixture, BlendLinear, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
{
Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int srcType = get<1>(params);
const double eps = CV_MAT_DEPTH(srcType) <= CV_32S ? 1.0 : 0.2;
checkDeviceMaxMemoryAllocSize(srcSize, srcType);
UMat src1(srcSize, srcType), src2(srcSize, srcType), dst(srcSize, srcType);
UMat weights1(srcSize, CV_32FC1), weights2(srcSize, CV_32FC1);
declare.in(src1, src2, WARMUP_RNG).in(weights1, weights2, WARMUP_READ).out(dst);
randu(weights1, 0, 1);
randu(weights2, 0, 1);
OCL_TEST_CYCLE() cv::blendLinear(src1, src2, weights1, weights2, dst);
SANITY_CHECK(dst, eps);
}
} } // namespace cvtest::ocl
#endif // HAVE_OPENCL

@ -0,0 +1,104 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
namespace cvtest {
namespace ocl {
using std::tr1::make_tuple;
///////////// cvtColor////////////////////////
CV_ENUM(ConversionTypes, COLOR_RGB2GRAY, COLOR_RGB2BGR, COLOR_RGB2YUV, COLOR_YUV2RGB, COLOR_RGB2YCrCb,
COLOR_YCrCb2RGB, COLOR_RGB2XYZ, COLOR_XYZ2RGB, COLOR_RGB2HSV, COLOR_HSV2RGB, COLOR_RGB2HLS,
COLOR_HLS2RGB, COLOR_BGR5652BGR, COLOR_BGR2BGR565, COLOR_RGBA2mRGBA, COLOR_mRGBA2RGBA, COLOR_YUV2RGB_NV12)
typedef tuple<Size, tuple<ConversionTypes, int, int> > CvtColorParams;
typedef TestBaseWithParam<CvtColorParams> CvtColorFixture;
OCL_PERF_TEST_P(CvtColorFixture, CvtColor, testing::Combine(
OCL_TEST_SIZES,
testing::Values(
make_tuple(ConversionTypes(COLOR_RGB2GRAY), 3, 1),
make_tuple(ConversionTypes(COLOR_RGB2BGR), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2YUV), 3, 3),
make_tuple(ConversionTypes(COLOR_YUV2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2YCrCb), 3, 3),
make_tuple(ConversionTypes(COLOR_YCrCb2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2XYZ), 3, 3),
make_tuple(ConversionTypes(COLOR_XYZ2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2HSV), 3, 3),
make_tuple(ConversionTypes(COLOR_HSV2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2HLS), 3, 3),
make_tuple(ConversionTypes(COLOR_HLS2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_BGR5652BGR), 2, 3),
make_tuple(ConversionTypes(COLOR_BGR2BGR565), 3, 2),
make_tuple(ConversionTypes(COLOR_RGBA2mRGBA), 4, 4),
make_tuple(ConversionTypes(COLOR_mRGBA2RGBA), 4, 4),
make_tuple(ConversionTypes(COLOR_YUV2RGB_NV12), 1, 3)
)))
{
CvtColorParams params = GetParam();
const Size srcSize = get<0>(params);
const tuple<int, int, int> conversionParams = get<1>(params);
const int code = get<0>(conversionParams), scn = get<1>(conversionParams),
dcn = get<2>(conversionParams);
UMat src(srcSize, CV_8UC(scn)), dst(srcSize, CV_8UC(scn));
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::cvtColor(src, dst, code, dcn);
SANITY_CHECK(dst, 1);
}
} } // namespace cvtest::ocl
#endif // HAVE_OPENCL

@ -0,0 +1,302 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
namespace cvtest {
namespace ocl {
typedef tuple<Size, MatType, int> FilterParams;
typedef TestBaseWithParam<FilterParams> FilterFixture;
///////////// Blur ////////////////////////
typedef FilterFixture BlurFixture;
OCL_PERF_TEST_P(BlurFixture, Blur,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5)))
{
const FilterParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params), bordertype = BORDER_CONSTANT;
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::blur(src, dst, Size(ksize, ksize), Point(-1, -1), bordertype);
SANITY_CHECK(dst, eps);
}
///////////// Laplacian////////////////////////
typedef FilterFixture LaplacianFixture;
OCL_PERF_TEST_P(LaplacianFixture, Laplacian,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5)))
{
const FilterParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::Laplacian(src, dst, -1, ksize, 1);
SANITY_CHECK(dst, eps);
}
///////////// Erode ////////////////////
typedef FilterFixture ErodeFixture;
OCL_PERF_TEST_P(ErodeFixture, Erode,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5)))
{
const FilterParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params);
const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize));
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst).in(ker);
OCL_TEST_CYCLE() cv::erode(src, dst, ker);
SANITY_CHECK(dst);
}
///////////// Dilate ////////////////////
typedef FilterFixture DilateFixture;
OCL_PERF_TEST_P(DilateFixture, Dilate,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5)))
{
const FilterParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params);
const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize));
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst).in(ker);
OCL_TEST_CYCLE() cv::dilate(src, dst, ker);
SANITY_CHECK(dst);
}
///////////// MorphologyEx ////////////////////////
CV_ENUM(MorphOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT)
typedef tuple<Size, MatType, MorphOp, int> MorphologyExParams;
typedef TestBaseWithParam<MorphologyExParams> MorphologyExFixture;
OCL_PERF_TEST_P(MorphologyExFixture, MorphologyEx,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, MorphOp::all(), OCL_PERF_ENUM(3, 5)))
{
const MorphologyExParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), op = get<2>(params), ksize = get<3>(params);
const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize));
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst).in(ker);
OCL_TEST_CYCLE() cv::morphologyEx(src, dst, op, ker);
SANITY_CHECK(dst);
}
///////////// Sobel ////////////////////////
typedef Size_MatType SobelFixture;
OCL_PERF_TEST_P(SobelFixture, Sobel,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), dx = 1, dy = 1;
checkDeviceMaxMemoryAllocSize(srcSize, type, sizeof(float) * 2);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::Sobel(src, dst, -1, dx, dy);
SANITY_CHECK(dst);
}
///////////// Scharr ////////////////////////
typedef Size_MatType ScharrFixture;
OCL_PERF_TEST_P(ScharrFixture, Scharr,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), dx = 1, dy = 0;
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;
checkDeviceMaxMemoryAllocSize(srcSize, type, sizeof(float) * 2);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::Scharr(src, dst, -1, dx, dy);
SANITY_CHECK(dst, eps);
}
///////////// GaussianBlur ////////////////////////
typedef FilterFixture GaussianBlurFixture;
OCL_PERF_TEST_P(GaussianBlurFixture, GaussianBlur,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5, 7)))
{
const FilterParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 + DBL_EPSILON : 3e-4;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::GaussianBlur(src, dst, Size(ksize, ksize), 0);
SANITY_CHECK(dst, eps);
}
///////////// Filter2D ////////////////////////
typedef FilterFixture Filter2DFixture;
OCL_PERF_TEST_P(Filter2DFixture, Filter2D,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5)))
{
const FilterParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type), kernel(ksize, ksize, CV_32SC1);
declare.in(src, WARMUP_RNG).in(kernel).out(dst);
randu(kernel, -3.0, 3.0);
OCL_TEST_CYCLE() cv::filter2D(src, dst, -1, kernel);
SANITY_CHECK(dst, eps);
}
///////////// Bilateral ////////////////////////
typedef TestBaseWithParam<Size> BilateralFixture;
OCL_PERF_TEST_P(BilateralFixture, Bilateral, OCL_TEST_SIZES)
{
const Size srcSize = GetParam();
const int d = 7;
const double sigmacolor = 50.0, sigmaspace = 50.0;
checkDeviceMaxMemoryAllocSize(srcSize, CV_8UC1);
UMat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::bilateralFilter(src, dst, d, sigmacolor, sigmaspace);
SANITY_CHECK(dst);
}
///////////// MedianBlur ////////////////////////
typedef tuple<Size, int> MedianBlurParams;
typedef TestBaseWithParam<MedianBlurParams> MedianBlurFixture;
OCL_PERF_TEST_P(MedianBlurFixture, Bilateral, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(3, 5)))
{
MedianBlurParams params = GetParam();
const Size srcSize = get<0>(params);
const int ksize = get<1>(params);
checkDeviceMaxMemoryAllocSize(srcSize, CV_8UC1);
UMat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::medianBlur(src, dst, ksize);
SANITY_CHECK(dst);
}
} } // namespace cvtest::ocl
#endif // HAVE_OPENCL

@ -0,0 +1,246 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
namespace cvtest {
namespace ocl {
///////////// equalizeHist ////////////////////////
typedef TestBaseWithParam<Size> EqualizeHistFixture;
OCL_PERF_TEST_P(EqualizeHistFixture, EqualizeHist, OCL_TEST_SIZES)
{
const Size srcSize = GetParam();
const double eps = 1;
UMat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::equalizeHist(src, dst);
SANITY_CHECK(dst, eps);
}
/////////// CopyMakeBorder //////////////////////
CV_ENUM(Border, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, BORDER_WRAP, BORDER_REFLECT_101)
typedef tuple<Size, MatType, Border> CopyMakeBorderParamType;
typedef TestBaseWithParam<CopyMakeBorderParamType> CopyMakeBorderFixture;
OCL_PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, Border::all()))
{
const CopyMakeBorderParamType params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), borderType = get<2>(params);
UMat src(srcSize, type), dst;
const Size dstSize = srcSize + Size(12, 12);
dst.create(dstSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::copyMakeBorder(src, dst, 7, 5, 5, 7, borderType, cv::Scalar(1.0));
SANITY_CHECK(dst);
}
///////////// CornerMinEigenVal ////////////////////////
typedef Size_MatType CornerMinEigenValFixture;
OCL_PERF_TEST_P(CornerMinEigenValFixture, CornerMinEigenVal,
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), borderType = BORDER_REFLECT;
const int blockSize = 7, apertureSize = 1 + 2 * 3;
UMat src(srcSize, type), dst(srcSize, CV_32FC1);
declare.in(src, WARMUP_RNG).out(dst);
const int depth = CV_MAT_DEPTH(type);
const ERROR_TYPE errorType = depth == CV_8U ? ERROR_ABSOLUTE : ERROR_RELATIVE;
OCL_TEST_CYCLE() cv::cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType);
SANITY_CHECK(dst, 1e-6, errorType);
}
///////////// CornerHarris ////////////////////////
typedef Size_MatType CornerHarrisFixture;
OCL_PERF_TEST_P(CornerHarrisFixture, CornerHarris,
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), borderType = BORDER_REFLECT;
UMat src(srcSize, type), dst(srcSize, CV_32FC1);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::cornerHarris(src, dst, 5, 7, 0.1, borderType);
SANITY_CHECK(dst, 5e-5);
}
///////////// Integral ////////////////////////
typedef tuple<Size, MatDepth> IntegralParams;
typedef TestBaseWithParam<IntegralParams> IntegralFixture;
OCL_PERF_TEST_P(IntegralFixture, Integral1, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32S, CV_32F)))
{
const IntegralParams params = GetParam();
const Size srcSize = get<0>(params);
const int ddepth = get<1>(params);
UMat src(srcSize, CV_8UC1), dst(srcSize + Size(1, 1), ddepth);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::integral(src, dst, ddepth);
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
}
///////////// Threshold ////////////////////////
CV_ENUM(ThreshType, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO_INV)
typedef tuple<Size, MatType, ThreshType> ThreshParams;
typedef TestBaseWithParam<ThreshParams> ThreshFixture;
OCL_PERF_TEST_P(ThreshFixture, Threshold,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, ThreshType::all()))
{
const ThreshParams params = GetParam();
const Size srcSize = get<0>(params);
const int srcType = get<1>(params);
const int threshType = get<2>(params);
const double maxValue = 220.0, threshold = 50;
UMat src(srcSize, srcType), dst(srcSize, srcType);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::threshold(src, dst, threshold, maxValue, threshType);
SANITY_CHECK(dst);
}
///////////// CLAHE ////////////////////////
typedef TestBaseWithParam<Size> CLAHEFixture;
OCL_PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TEST_SIZES)
{
const Size srcSize = GetParam();
UMat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1);
const double clipLimit = 40.0;
declare.in(src, WARMUP_RNG).out(dst);
cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE(clipLimit);
OCL_TEST_CYCLE() clahe->apply(src, dst);
SANITY_CHECK(dst);
}
///////////// SqrBoxFilter ////////////////////////
typedef TestBaseWithParam<Size> SqrBoxFilterFixture;
OCL_PERF_TEST_P(SqrBoxFilterFixture, SqrBoxFilter, OCL_TEST_SIZES)
{
const Size srcSize = GetParam();
UMat src(srcSize, CV_8UC1), dst(srcSize, CV_32SC1);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::sqrBoxFilter(src, dst, CV_32S, Size(3, 3));
SANITY_CHECK(dst);
}
///////////// Canny ////////////////////////
typedef tuple<int, bool> CannyParams;
typedef TestBaseWithParam<CannyParams> CannyFixture;
OCL_PERF_TEST_P(CannyFixture, Canny, ::testing::Combine(OCL_PERF_ENUM(3, 5), Bool()))
{
const CannyParams params = GetParam();
int apertureSize = get<0>(params);
bool L2Grad = get<1>(params);
Mat _img = imread(getDataPath("gpu/stereobm/aloe-L.png"), cv::IMREAD_GRAYSCALE);
ASSERT_TRUE(!_img.empty()) << "can't open aloe-L.png";
UMat img;
_img.copyTo(img);
UMat edges(img.size(), CV_8UC1);
declare.in(img, WARMUP_RNG).out(edges);
OCL_TEST_CYCLE() cv::Canny(img, edges, 50.0, 100.0, apertureSize, L2Grad);
if (apertureSize == 3)
SANITY_CHECK(edges);
else
SANITY_CHECK_NOTHING();
}
} } // namespace cvtest::ocl
#endif // HAVE_OPENCL

@ -0,0 +1,210 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
namespace cvtest {
namespace ocl {
///////////// WarpAffine ////////////////////////
CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR)
typedef tuple<Size, MatType, InterType> WarpAffineParams;
typedef TestBaseWithParam<WarpAffineParams> WarpAffineFixture;
OCL_PERF_TEST_P(WarpAffineFixture, WarpAffine,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, InterType::all()))
{
static const double coeffs[2][3] =
{
{ cos(CV_PI / 6), -sin(CV_PI / 6), 100.0 },
{ sin(CV_PI / 6), cos(CV_PI / 6) , -100.0 }
};
Mat M(2, 3, CV_64F, (void *)coeffs);
const WarpAffineParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), interpolation = get<2>(params);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::warpAffine(src, dst, M, srcSize, interpolation);
SANITY_CHECK(dst, eps);
}
///////////// WarpPerspective ////////////////////////
typedef WarpAffineParams WarpPerspectiveParams;
typedef TestBaseWithParam<WarpPerspectiveParams> WarpPerspectiveFixture;
OCL_PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, InterType::all()))
{
static const double coeffs[3][3] =
{
{cos(CV_PI / 6), -sin(CV_PI / 6), 100.0},
{sin(CV_PI / 6), cos(CV_PI / 6), -100.0},
{0.0, 0.0, 1.0}
};
Mat M(3, 3, CV_64F, (void *)coeffs);
const WarpPerspectiveParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), interpolation = get<2>(params);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::warpPerspective(src, dst, M, srcSize, interpolation);
SANITY_CHECK(dst, eps);
}
///////////// Resize ////////////////////////
typedef tuple<Size, MatType, InterType, double> ResizeParams;
typedef TestBaseWithParam<ResizeParams> ResizeFixture;
OCL_PERF_TEST_P(ResizeFixture, Resize,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES,
InterType::all(), ::testing::Values(0.5, 2.0)))
{
const ResizeParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), interType = get<2>(params);
double scale = get<3>(params);
const Size dstSize(cvRound(srcSize.width * scale), cvRound(srcSize.height * scale));
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4;
checkDeviceMaxMemoryAllocSize(srcSize, type);
checkDeviceMaxMemoryAllocSize(dstSize, type);
UMat src(srcSize, type), dst(dstSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::resize(src, dst, Size(), scale, scale, interType);
SANITY_CHECK(dst, eps);
}
typedef tuple<Size, MatType, double> ResizeAreaParams;
typedef TestBaseWithParam<ResizeAreaParams> ResizeAreaFixture;
OCL_PERF_TEST_P(ResizeAreaFixture, Resize,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, ::testing::Values(0.3, 0.5, 0.6)))
{
const ResizeAreaParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
double scale = get<2>(params);
const Size dstSize(cvRound(srcSize.width * scale), cvRound(srcSize.height * scale));
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4;
checkDeviceMaxMemoryAllocSize(srcSize, type);
checkDeviceMaxMemoryAllocSize(dstSize, type);
UMat src(srcSize, type), dst(dstSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::resize(src, dst, Size(), scale, scale, cv::INTER_AREA);
SANITY_CHECK(dst, eps);
}
///////////// Remap ////////////////////////
typedef tuple<Size, MatType, InterType> RemapParams;
typedef TestBaseWithParam<RemapParams> RemapFixture;
OCL_PERF_TEST_P(RemapFixture, Remap,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, InterType::all()))
{
const RemapParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), interpolation = get<2>(params), borderMode = BORDER_CONSTANT;
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
UMat xmap(srcSize, CV_32FC1), ymap(srcSize, CV_32FC1);
{
Mat _xmap = xmap.getMat(ACCESS_WRITE), _ymap = ymap.getMat(ACCESS_WRITE);
for (int i = 0; i < srcSize.height; ++i)
{
float * const xmap_row = _xmap.ptr<float>(i);
float * const ymap_row = _ymap.ptr<float>(i);
for (int j = 0; j < srcSize.width; ++j)
{
xmap_row[j] = (j - srcSize.width * 0.5f) * 0.75f + srcSize.width * 0.5f;
ymap_row[j] = (i - srcSize.height * 0.5f) * 0.75f + srcSize.height * 0.5f;
}
}
}
declare.in(src, WARMUP_RNG).in(xmap, ymap, WARMUP_READ).out(dst);
OCL_TEST_CYCLE() cv::remap(src, dst, xmap, ymap, interpolation, borderMode);
SANITY_CHECK(dst, eps);
}
} } // namespace cvtest::ocl
#endif // HAVE_OPENCL

@ -0,0 +1,78 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other Materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
namespace cvtest {
namespace ocl {
///////////// Moments ////////////////////////
typedef tuple<Size, bool> MomentsParams;
typedef TestBaseWithParam<MomentsParams> MomentsFixture;
OCL_PERF_TEST_P(MomentsFixture, Moments,
::testing::Combine(OCL_TEST_SIZES, ::testing::Bool()))
{
const MomentsParams params = GetParam();
const Size srcSize = get<0>(params);
const bool binaryImage = get<1>(params);
cv::Moments m;
UMat src(srcSize, CV_8UC1);
declare.in(src, WARMUP_RNG);
OCL_TEST_CYCLE() m = cv::moments(src, binaryImage);
SANITY_CHECK_MOMENTS(m, 1e-6, ERROR_RELATIVE);
}
} } // namespace cvtest::ocl
#endif // HAVE_OPENCL

@ -0,0 +1,105 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
namespace cvtest {
namespace ocl {
///////////// PyrDown //////////////////////
typedef Size_MatType PyrDownFixture;
OCL_PERF_TEST_P(PyrDownFixture, PyrDown,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
const Size dstSize((srcSize.height + 1) >> 1, (srcSize.width + 1) >> 1);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;
checkDeviceMaxMemoryAllocSize(srcSize, type);
checkDeviceMaxMemoryAllocSize(dstSize, type);
UMat src(srcSize, type), dst(dstSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::pyrDown(src, dst);
SANITY_CHECK(dst, eps);
}
///////////// PyrUp ////////////////////////
typedef Size_MatType PyrUpFixture;
OCL_PERF_TEST_P(PyrUpFixture, PyrUp,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
const Size dstSize(srcSize.height << 1, srcSize.width << 1);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;
checkDeviceMaxMemoryAllocSize(srcSize, type);
checkDeviceMaxMemoryAllocSize(dstSize, type);
UMat src(srcSize, type), dst(dstSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::pyrDown(src, dst);
SANITY_CHECK(dst, eps);
}
} } // namespace cvtest::ocl
#endif // HAVE_OPENCL

@ -8,7 +8,7 @@ using std::tr1::make_tuple;
using std::tr1::get;
CV_ENUM(BorderMode, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT_101);
CV_ENUM(BorderMode, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT_101)
typedef TestBaseWithParam< tr1::tuple<Size, int, BorderMode> > TestFilter2d;
typedef TestBaseWithParam< tr1::tuple<string, int> > Image_KernelSize;

@ -40,6 +40,7 @@
//M*/
#include "precomp.hpp"
#include "opencl_kernels.hpp"
/*
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
@ -48,9 +49,11 @@
#undef USE_IPP_CANNY
#endif
*/
#ifdef USE_IPP_CANNY
namespace cv
{
#ifdef USE_IPP_CANNY
static bool ippCanny(const Mat& _src, Mat& _dst, float low, float high)
{
int size = 0, size1 = 0;
@ -83,22 +86,165 @@ static bool ippCanny(const Mat& _src, Mat& _dst, float low, float high)
return false;
return true;
}
}
#endif
static bool ocl_Canny(InputArray _src, OutputArray _dst, float low_thresh, float high_thresh,
int aperture_size, bool L2gradient, int cn, const Size & size)
{
UMat dx(size, CV_16SC(cn)), dy(size, CV_16SC(cn));
if (L2gradient)
{
low_thresh = std::min(32767.0f, low_thresh);
high_thresh = std::min(32767.0f, high_thresh);
if (low_thresh > 0) low_thresh *= low_thresh;
if (high_thresh > 0) high_thresh *= high_thresh;
}
int low = cvFloor(low_thresh), high = cvFloor(high_thresh);
Size esize(size.width + 2, size.height + 2);
UMat mag;
size_t globalsize[2] = { size.width * cn, size.height }, localsize[2] = { 16, 16 };
if (aperture_size == 3 && !_src.isSubmatrix())
{
// Sobel calculation
ocl::Kernel calcSobelRowPassKernel("calcSobelRowPass", ocl::imgproc::canny_oclsrc);
if (calcSobelRowPassKernel.empty())
return false;
UMat src = _src.getUMat(), dxBuf(size, CV_16SC(cn)), dyBuf(size, CV_16SC(cn));
calcSobelRowPassKernel.args(ocl::KernelArg::ReadOnly(src),
ocl::KernelArg::WriteOnlyNoSize(dxBuf),
ocl::KernelArg::WriteOnlyNoSize(dyBuf));
if (!calcSobelRowPassKernel.run(2, globalsize, localsize, false))
return false;
// magnitude calculation
ocl::Kernel magnitudeKernel("calcMagnitude_buf", ocl::imgproc::canny_oclsrc,
L2gradient ? " -D L2GRAD" : "");
if (magnitudeKernel.empty())
return false;
mag = UMat(esize, CV_32SC(cn), Scalar::all(0));
dx.create(size, CV_16SC(cn));
dy.create(size, CV_16SC(cn));
magnitudeKernel.args(ocl::KernelArg::ReadOnlyNoSize(dxBuf), ocl::KernelArg::ReadOnlyNoSize(dyBuf),
ocl::KernelArg::WriteOnlyNoSize(dx), ocl::KernelArg::WriteOnlyNoSize(dy),
ocl::KernelArg::WriteOnlyNoSize(mag, cn), size.height, size.width);
if (!magnitudeKernel.run(2, globalsize, localsize, false))
return false;
}
else
{
dx.create(size, CV_16SC(cn));
dy.create(size, CV_16SC(cn));
Sobel(_src, dx, CV_16SC1, 1, 0, aperture_size, 1, 0, BORDER_REPLICATE);
Sobel(_src, dy, CV_16SC1, 0, 1, aperture_size, 1, 0, BORDER_REPLICATE);
// magnitude calculation
ocl::Kernel magnitudeKernel("calcMagnitude", ocl::imgproc::canny_oclsrc,
L2gradient ? " -D L2GRAD" : "");
if (magnitudeKernel.empty())
return false;
mag = UMat(esize, CV_32SC(cn), Scalar::all(0));
magnitudeKernel.args(ocl::KernelArg::ReadOnlyNoSize(dx), ocl::KernelArg::ReadOnlyNoSize(dy),
ocl::KernelArg::WriteOnlyNoSize(mag, cn), size.height, size.width);
if (!magnitudeKernel.run(2, globalsize, NULL, false))
return false;
}
// map calculation
ocl::Kernel calcMapKernel("calcMap", ocl::imgproc::canny_oclsrc);
if (calcMapKernel.empty())
return false;
UMat map(esize, CV_32SC(cn));
calcMapKernel.args(ocl::KernelArg::ReadOnlyNoSize(dx), ocl::KernelArg::ReadOnlyNoSize(dy),
ocl::KernelArg::ReadOnlyNoSize(mag), ocl::KernelArg::WriteOnlyNoSize(map, cn),
size.height, size.width, low, high);
if (!calcMapKernel.run(2, globalsize, localsize, false))
return false;
// local hysteresis thresholding
ocl::Kernel edgesHysteresisLocalKernel("edgesHysteresisLocal", ocl::imgproc::canny_oclsrc);
if (edgesHysteresisLocalKernel.empty())
return false;
UMat stack(1, size.area(), CV_16UC2), counter(1, 1, CV_32SC1, Scalar::all(0));
edgesHysteresisLocalKernel.args(ocl::KernelArg::ReadOnlyNoSize(map), ocl::KernelArg::PtrReadWrite(stack),
ocl::KernelArg::PtrReadWrite(counter), size.height, size.width);
if (!edgesHysteresisLocalKernel.run(2, globalsize, localsize, false))
return false;
// global hysteresis thresholding
UMat stack2(1, size.area(), CV_16UC2);
int count;
for ( ; ; )
{
ocl::Kernel edgesHysteresisGlobalKernel("edgesHysteresisGlobal", ocl::imgproc::canny_oclsrc);
if (edgesHysteresisGlobalKernel.empty())
return false;
{
Mat _counter = counter.getMat(ACCESS_RW);
count = _counter.at<int>(0, 0);
if (count == 0)
break;
_counter.at<int>(0, 0) = 0;
}
edgesHysteresisGlobalKernel.args(ocl::KernelArg::ReadOnlyNoSize(map), ocl::KernelArg::PtrReadWrite(stack),
ocl::KernelArg::PtrReadWrite(stack2), ocl::KernelArg::PtrReadWrite(counter),
size.height, size.width, count);
#define divUp(total, grain) ((total + grain - 1) / grain)
size_t localsize2[2] = { 128, 1 }, globalsize2[2] = { std::min(count, 65535) * 128, divUp(count, 65535) };
#undef divUp
if (!edgesHysteresisGlobalKernel.run(2, globalsize2, localsize2, false))
return false;
std::swap(stack, stack2);
}
// get edges
ocl::Kernel getEdgesKernel("getEdges", ocl::imgproc::canny_oclsrc);
if (getEdgesKernel.empty())
return false;
_dst.create(size, CV_8UC(cn));
UMat dst = _dst.getUMat();
getEdgesKernel.args(ocl::KernelArg::ReadOnlyNoSize(map), ocl::KernelArg::WriteOnly(dst));
return getEdgesKernel.run(2, globalsize, NULL, false);
}
}
void cv::Canny( InputArray _src, OutputArray _dst,
double low_thresh, double high_thresh,
int aperture_size, bool L2gradient )
{
Mat src = _src.getMat();
CV_Assert( src.depth() == CV_8U );
const int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
const Size size = _src.size();
_dst.create(src.size(), CV_8U);
Mat dst = _dst.getMat();
CV_Assert( depth == CV_8U );
_dst.create(size, CV_8U);
if (!L2gradient && (aperture_size & CV_CANNY_L2_GRADIENT) == CV_CANNY_L2_GRADIENT)
{
//backward compatibility
// backward compatibility
aperture_size &= ~CV_CANNY_L2_GRADIENT;
L2gradient = true;
}
@ -109,6 +255,12 @@ void cv::Canny( InputArray _src, OutputArray _dst,
if (low_thresh > high_thresh)
std::swap(low_thresh, high_thresh);
if (ocl::useOpenCL() && _dst.isUMat() && cn == 1 &&
ocl_Canny(_src, _dst, (float)low_thresh, (float)high_thresh, aperture_size, L2gradient, cn, size))
return;
Mat src = _src.getMat(), dst = _dst.getMat();
#ifdef HAVE_TEGRA_OPTIMIZATION
if (tegra::canny(src, dst, low_thresh, high_thresh, aperture_size, L2gradient))
return;
@ -120,12 +272,11 @@ void cv::Canny( InputArray _src, OutputArray _dst,
return;
#endif
const int cn = src.channels();
Mat dx(src.rows, src.cols, CV_16SC(cn));
Mat dy(src.rows, src.cols, CV_16SC(cn));
Sobel(src, dx, CV_16S, 1, 0, aperture_size, 1, 0, cv::BORDER_REPLICATE);
Sobel(src, dy, CV_16S, 0, 1, aperture_size, 1, 0, cv::BORDER_REPLICATE);
Sobel(src, dx, CV_16S, 1, 0, aperture_size, 1, 0, BORDER_REPLICATE);
Sobel(src, dy, CV_16S, 0, 1, aperture_size, 1, 0, BORDER_REPLICATE);
if (L2gradient)
{

@ -2878,6 +2878,8 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
k.create("RGB2XYZ", ocl::imgproc::cvtcolor_oclsrc,
format("-D depth=%d -D scn=%d -D dcn=3 -D bidx=%d", depth, scn, bidx));
if (k.empty())
return false;
k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::WriteOnly(dst), ocl::KernelArg::PtrReadOnly(c));
return k.run(2, globalsize, 0, false);
}
@ -2927,6 +2929,8 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
k.create("XYZ2RGB", ocl::imgproc::cvtcolor_oclsrc,
format("-D depth=%d -D scn=3 -D dcn=%d -D bidx=%d", depth, dcn, bidx));
if (k.empty())
return false;
k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::WriteOnly(dst), ocl::KernelArg::PtrReadOnly(c));
return k.run(2, globalsize, 0, false);
}
@ -2981,6 +2985,8 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
k.create("RGB2HSV", ocl::imgproc::cvtcolor_oclsrc, format("-D depth=%d -D hrange=%d -D bidx=%d -D dcn=3 -D scn=%d",
depth, hrange, bidx, scn));
if (k.empty())
return false;
k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::WriteOnly(dst),
ocl::KernelArg::PtrReadOnly(sdiv_data), hrange == 256 ? ocl::KernelArg::PtrReadOnly(hdiv_data256) :

@ -380,6 +380,6 @@ bool GCGraph<TWeight>::inSourceSegment( int i )
{
CV_Assert( i>=0 && i<(int)vtcs.size() );
return vtcs[i].t == 0;
};
}
#endif

@ -2565,15 +2565,15 @@ struct RemapVec_8u
int operator()( const Mat& _src, void* _dst, const short* XY,
const ushort* FXY, const void* _wtab, int width ) const
{
int cn = _src.channels();
int cn = _src.channels(), x = 0, sstep = (int)_src.step;
if( (cn != 1 && cn != 3 && cn != 4) || !checkHardwareSupport(CV_CPU_SSE2) )
if( (cn != 1 && cn != 3 && cn != 4) || !checkHardwareSupport(CV_CPU_SSE2) ||
sstep > 0x8000 )
return 0;
const uchar *S0 = _src.data, *S1 = _src.data + _src.step;
const short* wtab = cn == 1 ? (const short*)_wtab : &BilinearTab_iC4[0][0][0];
uchar* D = (uchar*)_dst;
int x = 0, sstep = (int)_src.step;
__m128i delta = _mm_set1_epi32(INTER_REMAP_COEF_SCALE/2);
__m128i xy2ofs = _mm_set1_epi32(cn + (sstep << 16));
__m128i z = _mm_setzero_si128();

@ -0,0 +1,514 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Peng Xiao, pengxiao@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
// Smoothing perpendicular to the derivative direction with a triangle filter
// only support 3x3 Sobel kernel
// h (-1) = 1, h (0) = 2, h (1) = 1
// h'(-1) = -1, h'(0) = 0, h'(1) = 1
// thus sobel 2D operator can be calculated as:
// h'(x, y) = h'(x)h(y) for x direction
//
// src input 8bit single channel image data
// dx_buf output dx buffer
// dy_buf output dy buffer
__kernel void __attribute__((reqd_work_group_size(16, 16, 1)))
calcSobelRowPass
(__global const uchar * src, int src_step, int src_offset, int rows, int cols,
__global uchar * dx_buf, int dx_buf_step, int dx_buf_offset,
__global uchar * dy_buf, int dy_buf_step, int dy_buf_offset)
{
int gidx = get_global_id(0);
int gidy = get_global_id(1);
int lidx = get_local_id(0);
int lidy = get_local_id(1);
__local int smem[16][18];
smem[lidy][lidx + 1] = src[mad24(src_step, min(gidy, rows - 1), gidx + src_offset)];
if (lidx == 0)
{
smem[lidy][0] = src[mad24(src_step, min(gidy, rows - 1), max(gidx - 1, 0) + src_offset)];
smem[lidy][17] = src[mad24(src_step, min(gidy, rows - 1), min(gidx + 16, cols - 1) + src_offset)];
}
barrier(CLK_LOCAL_MEM_FENCE);
if (gidy < rows && gidx < cols)
{
*(__global short *)(dx_buf + mad24(gidy, dx_buf_step, gidx * (int)sizeof(short) + dx_buf_offset)) =
smem[lidy][lidx + 2] - smem[lidy][lidx];
*(__global short *)(dy_buf + mad24(gidy, dy_buf_step, gidx * (int)sizeof(short) + dy_buf_offset)) =
smem[lidy][lidx] + 2 * smem[lidy][lidx + 1] + smem[lidy][lidx + 2];
}
}
inline int calc(short x, short y)
{
#ifdef L2GRAD
return x * x + y * y;
#else
return (x >= 0 ? x : -x) + (y >= 0 ? y : -y);
#endif
}
// calculate the magnitude of the filter pass combining both x and y directions
// This is the non-buffered version(non-3x3 sobel)
//
// dx_buf dx buffer, calculated from calcSobelRowPass
// dy_buf dy buffer, calculated from calcSobelRowPass
// dx direvitive in x direction output
// dy direvitive in y direction output
// mag magnitude direvitive of xy output
__kernel void calcMagnitude(__global const uchar * dxptr, int dx_step, int dx_offset,
__global const uchar * dyptr, int dy_step, int dy_offset,
__global uchar * magptr, int mag_step, int mag_offset, int rows, int cols)
{
int x = get_global_id(0);
int y = get_global_id(1);
if (y < rows && x < cols)
{
int dx_index = mad24(dx_step, y, x * (int)sizeof(short) + dx_offset);
int dy_index = mad24(dy_step, y, x * (int)sizeof(short) + dy_offset);
int mag_index = mad24(mag_step, y + 1, (x + 1) * (int)sizeof(int) + mag_offset);
__global const short * dx = (__global const short *)(dxptr + dx_index);
__global const short * dy = (__global const short *)(dyptr + dy_index);
__global int * mag = (__global int *)(magptr + mag_index);
mag[0] = calc(dx[0], dy[0]);
}
}
// calculate the magnitude of the filter pass combining both x and y directions
// This is the buffered version(3x3 sobel)
//
// dx_buf dx buffer, calculated from calcSobelRowPass
// dy_buf dy buffer, calculated from calcSobelRowPass
// dx direvitive in x direction output
// dy direvitive in y direction output
// mag magnitude direvitive of xy output
__kernel void __attribute__((reqd_work_group_size(16, 16, 1)))
calcMagnitude_buf
(__global const short * dx_buf, int dx_buf_step, int dx_buf_offset,
__global const short * dy_buf, int dy_buf_step, int dy_buf_offset,
__global short * dx, int dx_step, int dx_offset,
__global short * dy, int dy_step, int dy_offset,
__global int * mag, int mag_step, int mag_offset,
int rows, int cols)
{
dx_buf_step /= sizeof(*dx_buf);
dx_buf_offset /= sizeof(*dx_buf);
dy_buf_step /= sizeof(*dy_buf);
dy_buf_offset /= sizeof(*dy_buf);
dx_step /= sizeof(*dx);
dx_offset /= sizeof(*dx);
dy_step /= sizeof(*dy);
dy_offset /= sizeof(*dy);
mag_step /= sizeof(*mag);
mag_offset /= sizeof(*mag);
int gidx = get_global_id(0);
int gidy = get_global_id(1);
int lidx = get_local_id(0);
int lidy = get_local_id(1);
__local short sdx[18][16];
__local short sdy[18][16];
sdx[lidy + 1][lidx] = dx_buf[gidx + min(gidy, rows - 1) * dx_buf_step + dx_buf_offset];
sdy[lidy + 1][lidx] = dy_buf[gidx + min(gidy, rows - 1) * dy_buf_step + dy_buf_offset];
if (lidy == 0)
{
sdx[0][lidx] = dx_buf[gidx + min(max(gidy - 1, 0), rows - 1) * dx_buf_step + dx_buf_offset];
sdx[17][lidx] = dx_buf[gidx + min(gidy + 16, rows - 1) * dx_buf_step + dx_buf_offset];
sdy[0][lidx] = dy_buf[gidx + min(max(gidy - 1, 0), rows - 1) * dy_buf_step + dy_buf_offset];
sdy[17][lidx] = dy_buf[gidx + min(gidy + 16, rows - 1) * dy_buf_step + dy_buf_offset];
}
barrier(CLK_LOCAL_MEM_FENCE);
if (gidx < cols && gidy < rows)
{
short x = sdx[lidy][lidx] + 2 * sdx[lidy + 1][lidx] + sdx[lidy + 2][lidx];
short y = -sdy[lidy][lidx] + sdy[lidy + 2][lidx];
dx[gidx + gidy * dx_step + dx_offset] = x;
dy[gidx + gidy * dy_step + dy_offset] = y;
mag[(gidx + 1) + (gidy + 1) * mag_step + mag_offset] = calc(x, y);
}
}
//////////////////////////////////////////////////////////////////////////////////////////
// 0.4142135623730950488016887242097 is tan(22.5)
#define CANNY_SHIFT 15
#define TG22 (int)(0.4142135623730950488016887242097f*(1<<CANNY_SHIFT) + 0.5f)
// First pass of edge detection and non-maximum suppression
// edgetype is set to for each pixel:
// 0 - below low thres, not an edge
// 1 - maybe an edge
// 2 - is an edge, either magnitude is greater than high thres, or
// Given estimates of the image gradients, a search is then carried out
// to determine if the gradient magnitude assumes a local maximum in the gradient direction.
// if the rounded gradient angle is zero degrees (i.e. the edge is in the north-south direction) the point will be considered to be on the edge if its gradient magnitude is greater than the magnitudes in the west and east directions,
// if the rounded gradient angle is 90 degrees (i.e. the edge is in the east-west direction) the point will be considered to be on the edge if its gradient magnitude is greater than the magnitudes in the north and south directions,
// if the rounded gradient angle is 135 degrees (i.e. the edge is in the north east-south west direction) the point will be considered to be on the edge if its gradient magnitude is greater than the magnitudes in the north west and south east directions,
// if the rounded gradient angle is 45 degrees (i.e. the edge is in the north west-south east direction)the point will be considered to be on the edge if its gradient magnitude is greater than the magnitudes in the north east and south west directions.
//
// dx, dy direvitives of x and y direction
// mag magnitudes calculated from calcMagnitude function
// map output containing raw edge types
__kernel void __attribute__((reqd_work_group_size(16,16,1)))
calcMap(
__global const uchar * dx, int dx_step, int dx_offset,
__global const uchar * dy, int dy_step, int dy_offset,
__global const uchar * mag, int mag_step, int mag_offset,
__global uchar * map, int map_step, int map_offset,
int rows, int cols, int low_thresh, int high_thresh)
{
__local int smem[18][18];
int gidx = get_global_id(0);
int gidy = get_global_id(1);
int lidx = get_local_id(0);
int lidy = get_local_id(1);
int grp_idx = get_global_id(0) & 0xFFFFF0;
int grp_idy = get_global_id(1) & 0xFFFFF0;
int tid = lidx + lidy * 16;
int lx = tid % 18;
int ly = tid / 18;
mag += mag_offset;
if (ly < 14)
smem[ly][lx] = *(__global const int *)(mag +
mad24(mag_step, min(grp_idy + ly, rows - 1), (int)sizeof(int) * (grp_idx + lx)));
if (ly < 4 && grp_idy + ly + 14 <= rows && grp_idx + lx <= cols)
smem[ly + 14][lx] = *(__global const int *)(mag +
mad24(mag_step, min(grp_idy + ly + 14, rows - 1), (int)sizeof(int) * (grp_idx + lx)));
barrier(CLK_LOCAL_MEM_FENCE);
if (gidy < rows && gidx < cols)
{
// 0 - the pixel can not belong to an edge
// 1 - the pixel might belong to an edge
// 2 - the pixel does belong to an edge
int edge_type = 0;
int m = smem[lidy + 1][lidx + 1];
if (m > low_thresh)
{
short xs = *(__global const short *)(dx + mad24(gidy, dx_step, dx_offset + (int)sizeof(short) * gidx));
short ys = *(__global const short *)(dy + mad24(gidy, dy_step, dy_offset + (int)sizeof(short) * gidx));
int x = abs(xs), y = abs(ys);
int tg22x = x * TG22;
y <<= CANNY_SHIFT;
if (y < tg22x)
{
if (m > smem[lidy + 1][lidx] && m >= smem[lidy + 1][lidx + 2])
edge_type = 1 + (int)(m > high_thresh);
}
else
{
int tg67x = tg22x + (x << (1 + CANNY_SHIFT));
if (y > tg67x)
{
if (m > smem[lidy][lidx + 1]&& m >= smem[lidy + 2][lidx + 1])
edge_type = 1 + (int)(m > high_thresh);
}
else
{
int s = (xs ^ ys) < 0 ? -1 : 1;
if (m > smem[lidy][lidx + 1 - s]&& m > smem[lidy + 2][lidx + 1 + s])
edge_type = 1 + (int)(m > high_thresh);
}
}
}
*(__global int *)(map + mad24(map_step, gidy + 1, (gidx + 1) * (int)sizeof(int) + map_offset)) = edge_type;
}
}
#undef CANNY_SHIFT
#undef TG22
struct PtrStepSz
{
__global uchar * ptr;
int step, rows, cols;
};
inline int get(struct PtrStepSz data, int y, int x)
{
return *(__global int *)(data.ptr + mad24(data.step, y + 1, (int)sizeof(int) * (x + 1)));
}
inline void set(struct PtrStepSz data, int y, int x, int value)
{
*(__global int *)(data.ptr + mad24(data.step, y + 1, (int)sizeof(int) * (x + 1))) = value;
}
// perform Hysteresis for pixel whose edge type is 1
//
// If candidate pixel (edge type is 1) has a neighbour pixel (in 3x3 area) with type 2, it is believed to be part of an edge and
// marked as edge. Each thread will iterate for 16 times to connect local edges.
// Candidate pixel being identified as edge will then be tested if there is nearby potiential edge points. If there is, counter will
// be incremented by 1 and the point location is stored. These potiential candidates will be processed further in next kernel.
//
// map raw edge type results calculated from calcMap.
// stack the potiential edge points found in this kernel call
// counter the number of potiential edge points
__kernel void __attribute__((reqd_work_group_size(16,16,1)))
edgesHysteresisLocal
(__global uchar * map_ptr, int map_step, int map_offset,
__global ushort2 * st, __global unsigned int * counter,
int rows, int cols)
{
struct PtrStepSz map = { map_ptr + map_offset, map_step, rows + 1, cols + 1 };
__local int smem[18][18];
int2 blockIdx = (int2)(get_group_id(0), get_group_id(1));
int2 blockDim = (int2)(get_local_size(0), get_local_size(1));
int2 threadIdx = (int2)(get_local_id(0), get_local_id(1));
const int x = blockIdx.x * blockDim.x + threadIdx.x;
const int y = blockIdx.y * blockDim.y + threadIdx.y;
smem[threadIdx.y + 1][threadIdx.x + 1] = x < map.cols && y < map.rows ? get(map, y, x) : 0;
if (threadIdx.y == 0)
smem[0][threadIdx.x + 1] = x < map.cols ? get(map, y - 1, x) : 0;
if (threadIdx.y == blockDim.y - 1)
smem[blockDim.y + 1][threadIdx.x + 1] = y + 1 < map.rows ? get(map, y + 1, x) : 0;
if (threadIdx.x == 0)
smem[threadIdx.y + 1][0] = y < map.rows ? get(map, y, x - 1) : 0;
if (threadIdx.x == blockDim.x - 1)
smem[threadIdx.y + 1][blockDim.x + 1] = x + 1 < map.cols && y < map.rows ? get(map, y, x + 1) : 0;
if (threadIdx.x == 0 && threadIdx.y == 0)
smem[0][0] = y > 0 && x > 0 ? get(map, y - 1, x - 1) : 0;
if (threadIdx.x == blockDim.x - 1 && threadIdx.y == 0)
smem[0][blockDim.x + 1] = y > 0 && x + 1 < map.cols ? get(map, y - 1, x + 1) : 0;
if (threadIdx.x == 0 && threadIdx.y == blockDim.y - 1)
smem[blockDim.y + 1][0] = y + 1 < map.rows && x > 0 ? get(map, y + 1, x - 1) : 0;
if (threadIdx.x == blockDim.x - 1 && threadIdx.y == blockDim.y - 1)
smem[blockDim.y + 1][blockDim.x + 1] = y + 1 < map.rows && x + 1 < map.cols ? get(map, y + 1, x + 1) : 0;
barrier(CLK_LOCAL_MEM_FENCE);
if (x >= cols || y >= rows)
return;
int n;
#pragma unroll
for (int k = 0; k < 16; ++k)
{
n = 0;
if (smem[threadIdx.y + 1][threadIdx.x + 1] == 1)
{
n += smem[threadIdx.y ][threadIdx.x ] == 2;
n += smem[threadIdx.y ][threadIdx.x + 1] == 2;
n += smem[threadIdx.y ][threadIdx.x + 2] == 2;
n += smem[threadIdx.y + 1][threadIdx.x ] == 2;
n += smem[threadIdx.y + 1][threadIdx.x + 2] == 2;
n += smem[threadIdx.y + 2][threadIdx.x ] == 2;
n += smem[threadIdx.y + 2][threadIdx.x + 1] == 2;
n += smem[threadIdx.y + 2][threadIdx.x + 2] == 2;
}
if (n > 0)
smem[threadIdx.y + 1][threadIdx.x + 1] = 2;
}
const int e = smem[threadIdx.y + 1][threadIdx.x + 1];
set(map, y, x, e);
n = 0;
if (e == 2)
{
n += smem[threadIdx.y ][threadIdx.x ] == 1;
n += smem[threadIdx.y ][threadIdx.x + 1] == 1;
n += smem[threadIdx.y ][threadIdx.x + 2] == 1;
n += smem[threadIdx.y + 1][threadIdx.x ] == 1;
n += smem[threadIdx.y + 1][threadIdx.x + 2] == 1;
n += smem[threadIdx.y + 2][threadIdx.x ] == 1;
n += smem[threadIdx.y + 2][threadIdx.x + 1] == 1;
n += smem[threadIdx.y + 2][threadIdx.x + 2] == 1;
}
if (n > 0)
{
const int ind = atomic_inc(counter);
st[ind] = (ushort2)(x + 1, y + 1);
}
}
__constant int c_dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
__constant int c_dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
#define stack_size 512
#define map_index mad24(map_step, pos.y, pos.x * (int)sizeof(int))
__kernel void __attribute__((reqd_work_group_size(128, 1, 1)))
edgesHysteresisGlobal(__global uchar * map, int map_step, int map_offset,
__global ushort2 * st1, __global ushort2 * st2, __global int * counter,
int rows, int cols, int count)
{
map += map_offset;
int lidx = get_local_id(0);
int grp_idx = get_group_id(0);
int grp_idy = get_group_id(1);
__local unsigned int s_counter, s_ind;
__local ushort2 s_st[stack_size];
if (lidx == 0)
s_counter = 0;
barrier(CLK_LOCAL_MEM_FENCE);
int ind = mad24(grp_idy, (int)get_local_size(0), grp_idx);
if (ind < count)
{
ushort2 pos = st1[ind];
if (lidx < 8)
{
pos.x += c_dx[lidx];
pos.y += c_dy[lidx];
if (pos.x > 0 && pos.x <= cols && pos.y > 0 && pos.y <= rows && *(__global int *)(map + map_index) == 1)
{
*(__global int *)(map + map_index) = 2;
ind = atomic_inc(&s_counter);
s_st[ind] = pos;
}
}
barrier(CLK_LOCAL_MEM_FENCE);
while (s_counter > 0 && s_counter <= stack_size - get_local_size(0))
{
const int subTaskIdx = lidx >> 3;
const int portion = min(s_counter, (uint)(get_local_size(0)>> 3));
if (subTaskIdx < portion)
pos = s_st[s_counter - 1 - subTaskIdx];
barrier(CLK_LOCAL_MEM_FENCE);
if (lidx == 0)
s_counter -= portion;
barrier(CLK_LOCAL_MEM_FENCE);
if (subTaskIdx < portion)
{
pos.x += c_dx[lidx & 7];
pos.y += c_dy[lidx & 7];
if (pos.x > 0 && pos.x <= cols && pos.y > 0 && pos.y <= rows && *(__global int *)(map + map_index) == 1)
{
*(__global int *)(map + map_index) = 2;
ind = atomic_inc(&s_counter);
s_st[ind] = pos;
}
}
barrier(CLK_LOCAL_MEM_FENCE);
}
if (s_counter > 0)
{
if (lidx == 0)
{
ind = atomic_add(counter, s_counter);
s_ind = ind - s_counter;
}
barrier(CLK_LOCAL_MEM_FENCE);
ind = s_ind;
for (int i = lidx; i < (int)s_counter; i += get_local_size(0))
st2[ind + i] = s_st[i];
}
}
}
#undef map_index
#undef stack_size
// Get the edge result. egde type of value 2 will be marked as an edge point and set to 255. Otherwise 0.
// map edge type mappings
// dst edge output
__kernel void getEdges(__global const uchar * mapptr, int map_step, int map_offset,
__global uchar * dst, int dst_step, int dst_offset, int rows, int cols)
{
int x = get_global_id(0);
int y = get_global_id(1);
if (y < rows && x < cols)
{
int map_index = mad24(map_step, y + 1, (x + 1) * (int)sizeof(int) + map_offset);
int dst_index = mad24(dst_step, y, x + dst_offset);
__global const int * map = (__global const int *)(mapptr + map_index);
dst[dst_index] = (uchar)(-(map[0] >> 1));
}
}

@ -50,7 +50,6 @@
#define INTER_RESIZE_COEF_BITS 11
#define INTER_RESIZE_COEF_SCALE (1 << INTER_RESIZE_COEF_BITS)
#define CAST_BITS (INTER_RESIZE_COEF_BITS << 1)
#define CAST_SCALE (1.0f/(1<<CAST_BITS))
#define INC(x,l) min(x+1,l-1)
#define PIXSIZE ((int)sizeof(PIXTYPE))

@ -0,0 +1,117 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Peng Xiao, pengxiao@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "test_precomp.hpp"
#include "opencv2/ts/ocl_test.hpp"
#ifdef HAVE_OPENCL
namespace cvtest {
namespace ocl {
////////////////////////////////////////////////////////
// Canny
IMPLEMENT_PARAM_CLASS(AppertureSize, int)
IMPLEMENT_PARAM_CLASS(L2gradient, bool)
IMPLEMENT_PARAM_CLASS(UseRoi, bool)
PARAM_TEST_CASE(Canny, AppertureSize, L2gradient, UseRoi)
{
int apperture_size;
bool useL2gradient, use_roi;
TEST_DECLARE_INPUT_PARAMETER(src)
TEST_DECLARE_OUTPUT_PARAMETER(dst)
virtual void SetUp()
{
apperture_size = GET_PARAM(0);
useL2gradient = GET_PARAM(1);
use_roi = GET_PARAM(2);
}
void generateTestData()
{
Mat img = readImage("shared/fruits.png", IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty()) << "cann't load shared/fruits.png";
Size roiSize = img.size();
int type = img.type();
ASSERT_EQ(CV_8UC1, type);
Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(src, src_roi, roiSize, srcBorder, type, 2, 100);
img.copyTo(src_roi);
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 5, 16);
UMAT_UPLOAD_INPUT_PARAMETER(src)
UMAT_UPLOAD_OUTPUT_PARAMETER(dst)
}
};
OCL_TEST_P(Canny, Accuracy)
{
generateTestData();
const double low_thresh = 50.0, high_thresh = 100.0;
OCL_OFF(cv::Canny(src_roi, dst_roi, low_thresh, high_thresh, apperture_size, useL2gradient));
OCL_ON(cv::Canny(usrc_roi, udst_roi, low_thresh, high_thresh, apperture_size, useL2gradient));
EXPECT_MAT_SIMILAR(dst_roi, udst_roi, 1e-2);
EXPECT_MAT_SIMILAR(dst, udst, 1e-2);
}
OCL_INSTANTIATE_TEST_CASE_P(ImgProc, Canny, testing::Combine(
testing::Values(AppertureSize(3), AppertureSize(5)),
testing::Values(L2gradient(false), L2gradient(true)),
testing::Values(UseRoi(false), UseRoi(true))));
} } // namespace cvtest::ocl
#endif // HAVE_OPENCL

@ -603,7 +603,7 @@ CV_ENUM(YUVCVTS, CV_YUV2RGB_NV12, CV_YUV2BGR_NV12, CV_YUV2RGB_NV21, CV_YUV2BGR_N
CV_YUV2RGBA_YUY2, CV_YUV2BGRA_YUY2, CV_YUV2RGBA_YVYU, CV_YUV2BGRA_YVYU,
CV_YUV2GRAY_420, CV_YUV2GRAY_UYVY, CV_YUV2GRAY_YUY2,
CV_YUV2BGR, CV_YUV2RGB, CV_RGB2YUV_YV12, CV_BGR2YUV_YV12, CV_RGBA2YUV_YV12,
CV_BGRA2YUV_YV12, CV_RGB2YUV_I420, CV_BGR2YUV_I420, CV_RGBA2YUV_I420, CV_BGRA2YUV_I420);
CV_BGRA2YUV_YV12, CV_RGB2YUV_I420, CV_BGR2YUV_I420, CV_RGBA2YUV_I420, CV_BGRA2YUV_I420)
typedef ::testing::TestWithParam<YUVCVTS> Imgproc_ColorYUV;

@ -205,7 +205,7 @@ double CvVSModule::GetParam(const char* name)
if(p->pInt) return p->pInt[0];
}
return 0;
};
}
const char* CvVSModule::GetParamStr(const char* name)
{

@ -209,7 +209,7 @@ public:
CvBlobDetectorSimple();
~CvBlobDetectorSimple();
int DetectNewBlob(IplImage* pImg, IplImage* pFGMask, CvBlobSeq* pNewBlobList, CvBlobSeq* pOldBlobList);
void Release(){delete this;};
void Release(){delete this;}
protected:
IplImage* m_pMaskBlobNew;
@ -219,7 +219,7 @@ protected:
};
/* Blob detector creator (sole interface function for this file) */
CvBlobDetector* cvCreateBlobDetectorSimple(){return new CvBlobDetectorSimple;};
CvBlobDetector* cvCreateBlobDetectorSimple(){return new CvBlobDetectorSimple;}
/* Constructor of BlobDetector: */
CvBlobDetectorSimple::CvBlobDetectorSimple()

@ -52,7 +52,7 @@ enum
{
MOUTH = 0,
LEYE = 1,
REYE = 2,
REYE = 2
};
#define MAX_LAYERS 64

@ -52,7 +52,7 @@ CV_INIT_ALGORITHM(EM, "StatModel.EM",
obj.info()->addParam(obj, "epsilon", obj.epsilon);
obj.info()->addParam(obj, "weights", obj.weights, true);
obj.info()->addParam(obj, "means", obj.means, true);
obj.info()->addParam(obj, "covs", obj.covs, true));
obj.info()->addParam(obj, "covs", obj.covs, true))
bool initModule_ml(void)
{

@ -52,7 +52,7 @@ CV_INIT_ALGORITHM(SURF, "Feature2D.SURF",
obj.info()->addParam(obj, "nOctaves", obj.nOctaves);
obj.info()->addParam(obj, "nOctaveLayers", obj.nOctaveLayers);
obj.info()->addParam(obj, "extended", obj.extended);
obj.info()->addParam(obj, "upright", obj.upright));
obj.info()->addParam(obj, "upright", obj.upright))
///////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -61,7 +61,7 @@ CV_INIT_ALGORITHM(SIFT, "Feature2D.SIFT",
obj.info()->addParam(obj, "nOctaveLayers", obj.nOctaveLayers);
obj.info()->addParam(obj, "contrastThreshold", obj.contrastThreshold);
obj.info()->addParam(obj, "edgeThreshold", obj.edgeThreshold);
obj.info()->addParam(obj, "sigma", obj.sigma));
obj.info()->addParam(obj, "sigma", obj.sigma))
///////////////////////////////////////////////////////////////////////////////////////////////////////////

@ -0,0 +1,61 @@
#include "perf_precomp.hpp"
#include <opencv2/imgproc.hpp>
#include "opencv2/ts/ocl_perf.hpp"
using namespace std;
using namespace cv;
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
typedef std::tr1::tuple<std::string, std::string, int> Cascade_Image_MinSize_t;
typedef perf::TestBaseWithParam<Cascade_Image_MinSize_t> Cascade_Image_MinSize;
#ifdef HAVE_OPENCL
OCL_PERF_TEST_P(Cascade_Image_MinSize, CascadeClassifier,
testing::Combine(
testing::Values( string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt.xml"),
string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt_old.xml"),
string("cv/cascadeandhog/cascades/lbpcascade_frontalface.xml") ),
testing::Values( string("cv/shared/lena.png"),
string("cv/cascadeandhog/images/bttf301.png"),
string("cv/cascadeandhog/images/class57.png") ),
testing::Values(30, 64, 90) ) )
{
const string cascasePath = get<0>(GetParam());
const string imagePath = get<1>(GetParam());
int min_size = get<2>(GetParam());
Size minSize(min_size, min_size);
CascadeClassifier cc( getDataPath(cascasePath) );
if (cc.empty())
FAIL() << "Can't load cascade file: " << getDataPath(cascasePath);
Mat img = imread(getDataPath(imagePath), IMREAD_GRAYSCALE);
if (img.empty())
FAIL() << "Can't load source image: " << getDataPath(imagePath);
vector<Rect> faces;
equalizeHist(img, img);
declare.in(img).time(60);
UMat uimg = img.getUMat(ACCESS_READ);
while(next())
{
faces.clear();
cvtest::ocl::perf::safeFinish();
startTimer();
cc.detectMultiScale(uimg, faces, 1.1, 3, 0, minSize);
stopTimer();
}
sort(faces.begin(), faces.end(), comparators::RectLess());
SANITY_CHECK(faces, min_size/5);
}
#endif //HAVE_OPENCL

@ -1,56 +0,0 @@
#include "perf_precomp.hpp"
#include <opencv2/imgproc.hpp>
using namespace std;
using namespace cv;
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
typedef std::tr1::tuple<std::string, int> ImageName_MinSize_t;
typedef perf::TestBaseWithParam<ImageName_MinSize_t> ImageName_MinSize;
PERF_TEST_P(ImageName_MinSize, CascadeClassifierLBPFrontalFace,
testing::Combine(testing::Values( std::string("cv/shared/lena.png"),
std::string("cv/shared/1_itseez-0000289.png"),
std::string("cv/shared/1_itseez-0000492.png"),
std::string("cv/shared/1_itseez-0000573.png")),
testing::Values(24, 30, 40, 50, 60, 70, 80, 90)
)
)
{
const string filename = get<0>(GetParam());
int min_size = get<1>(GetParam());
Size minSize(min_size, min_size);
CascadeClassifier cc(getDataPath("cv/cascadeandhog/cascades/lbpcascade_frontalface.xml"));
if (cc.empty())
FAIL() << "Can't load cascade file";
Mat img = imread(getDataPath(filename), 0);
if (img.empty())
FAIL() << "Can't load source image";
vector<Rect> faces;
equalizeHist(img, img);
declare.in(img);
while(next())
{
faces.clear();
startTimer();
cc.detectMultiScale(img, faces, 1.1, 3, 0, minSize);
stopTimer();
}
// for some reason OpenCL version detects the face, which CPU version does not detect, we just remove it
// TODO better solution: implement smart way of comparing two set of rectangles
if( filename == "cv/shared/1_itseez-0000492.png" && faces.size() == (size_t)3 )
{
faces.erase(faces.begin());
}
std::sort(faces.begin(), faces.end(), comparators::RectLess());
SANITY_CHECK(faces, 3.001 * faces.size());
}

@ -167,7 +167,7 @@ namespace cv
CACHE_NONE = 0, // do not cache OpenCL binary
CACHE_DEBUG = 0x1 << 0, // cache OpenCL binary when built in debug mode
CACHE_RELEASE = 0x1 << 1, // default behavior, only cache when built in release mode
CACHE_ALL = CACHE_DEBUG | CACHE_RELEASE, // cache opencl binary
CACHE_ALL = CACHE_DEBUG | CACHE_RELEASE // cache opencl binary
};
//! Enable or disable OpenCL program binary caching onto local disk
// After a program (*.cl files in opencl/ folder) is built at runtime, we allow the

@ -108,7 +108,7 @@ inline cl_int getStringInfo(Functor f, ObjectType obj, cl_uint name, std::string
}
return CL_SUCCESS;
};
}
} // namespace cl_utils

@ -48,8 +48,8 @@
////////////////////////////////////////////////////////
// Canny
IMPLEMENT_PARAM_CLASS(AppertureSize, int);
IMPLEMENT_PARAM_CLASS(L2gradient, bool);
IMPLEMENT_PARAM_CLASS(AppertureSize, int)
IMPLEMENT_PARAM_CLASS(L2gradient, bool)
PARAM_TEST_CASE(Canny, AppertureSize, L2gradient)
{

@ -50,7 +50,7 @@
// MatchTemplate
#define ALL_TEMPLATE_METHODS testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR), TemplateMethod(cv::TM_CCOEFF), TemplateMethod(cv::TM_SQDIFF_NORMED), TemplateMethod(cv::TM_CCORR_NORMED), TemplateMethod(cv::TM_CCOEFF_NORMED))
IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size);
IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size)
#define MTEMP_SIZES testing::Values(cv::Size(128, 256), cv::Size(1024, 768))

@ -180,7 +180,7 @@ INSTANTIATE_TEST_CASE_P(OCL_ObjDetect, HOG, testing::Combine(
///////////////////////////// Haar //////////////////////////////
IMPLEMENT_PARAM_CLASS(CascadeName, std::string);
IMPLEMENT_PARAM_CLASS(CascadeName, std::string)
CascadeName cascade_frontalface_alt(std::string("haarcascade_frontalface_alt.xml"));
CascadeName cascade_frontalface_alt2(std::string("haarcascade_frontalface_alt2.xml"));

@ -273,7 +273,7 @@ CV_ENUM(Interpolation, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_AREA)
CV_ENUM(Border, BORDER_REFLECT101, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_WRAP)
CV_ENUM(TemplateMethod, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
CV_FLAGS(GemmFlags, GEMM_1_T, GEMM_2_T, GEMM_3_T);
CV_FLAGS(GemmFlags, GEMM_1_T, GEMM_2_T, GEMM_3_T)
CV_FLAGS(WarpFlags, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, WARP_INVERSE_MAP)
CV_FLAGS(DftFlags, DFT_INVERSE, DFT_SCALE, DFT_ROWS, DFT_COMPLEX_OUTPUT, DFT_REAL_OUTPUT)

@ -487,7 +487,7 @@ namespace
obj.info()->addParam(obj, "blurKernelSize", obj.blurKernelSize_, false, 0, 0, "Gaussian blur kernel size.");
obj.info()->addParam(obj, "blurSigma", obj.blurSigma_, false, 0, 0, "Gaussian blur sigma.");
obj.info()->addParam(obj, "temporalAreaRadius", obj.temporalAreaRadius_, false, 0, 0, "Radius of the temporal search area.");
obj.info()->addParam<DenseOpticalFlowExt>(obj, "opticalFlow", obj.opticalFlow_, false, 0, 0, "Dense optical flow algorithm."));
obj.info()->addParam<DenseOpticalFlowExt>(obj, "opticalFlow", obj.opticalFlow_, false, 0, 0, "Dense optical flow algorithm."))
BTVL1::BTVL1()
{

@ -582,7 +582,7 @@ namespace
obj.info()->addParam(obj, "blurKernelSize", obj.blurKernelSize_, false, 0, 0, "Gaussian blur kernel size.");
obj.info()->addParam(obj, "blurSigma", obj.blurSigma_, false, 0, 0, "Gaussian blur sigma.");
obj.info()->addParam(obj, "temporalAreaRadius", obj.temporalAreaRadius_, false, 0, 0, "Radius of the temporal search area.");
obj.info()->addParam<DenseOpticalFlowExt>(obj, "opticalFlow", obj.opticalFlow_, false, 0, 0, "Dense optical flow algorithm."));
obj.info()->addParam<DenseOpticalFlowExt>(obj, "opticalFlow", obj.opticalFlow_, false, 0, 0, "Dense optical flow algorithm."))
BTVL1_OCL::BTVL1_OCL()
{

@ -148,7 +148,7 @@ namespace
obj.info()->addParam(obj, "numIters", obj.numIters_);
obj.info()->addParam(obj, "polyN", obj.polyN_);
obj.info()->addParam(obj, "polySigma", obj.polySigma_);
obj.info()->addParam(obj, "flags", obj.flags_));
obj.info()->addParam(obj, "flags", obj.flags_))
Farneback::Farneback() : CpuOpticalFlow(CV_8UC1)
{
@ -218,7 +218,7 @@ namespace
obj.info()->addParam(obj, "upscaleAveragingRadius", obj.upscaleAveragingRadius_);
obj.info()->addParam(obj, "upscaleSigmaDist", obj.upscaleSigmaDist_);
obj.info()->addParam(obj, "upscaleSigmaColor", obj.upscaleSigmaColor_);
obj.info()->addParam(obj, "speedUpThr", obj.speedUpThr_));
obj.info()->addParam(obj, "speedUpThr", obj.speedUpThr_))
Simple::Simple() : CpuOpticalFlow(CV_8UC3)
{
@ -301,7 +301,7 @@ namespace
obj.info()->addParam(obj, "warps", obj.warps_);
obj.info()->addParam(obj, "epsilon", obj.epsilon_);
obj.info()->addParam(obj, "iterations", obj.iterations_);
obj.info()->addParam(obj, "useInitialFlow", obj.useInitialFlow_));
obj.info()->addParam(obj, "useInitialFlow", obj.useInitialFlow_))
DualTVL1::DualTVL1() : CpuOpticalFlow(CV_8UC1)
{
@ -472,7 +472,7 @@ namespace
obj.info()->addParam(obj, "scaleFactor", obj.scaleFactor_, false, 0, 0, "Pyramid scale factor");
obj.info()->addParam(obj, "innerIterations", obj.innerIterations_, false, 0, 0, "Number of lagged non-linearity iterations (inner loop)");
obj.info()->addParam(obj, "outerIterations", obj.outerIterations_, false, 0, 0, "Number of warping iterations (number of pyramid levels)");
obj.info()->addParam(obj, "solverIterations", obj.solverIterations_, false, 0, 0, "Number of linear system solver iterations"));
obj.info()->addParam(obj, "solverIterations", obj.solverIterations_, false, 0, 0, "Number of linear system solver iterations"))
Brox_CUDA::Brox_CUDA() : GpuOpticalFlow(CV_32FC1), alg_(0.197f, 50.0f, 0.8f, 10, 77, 10)
{
@ -536,7 +536,7 @@ namespace
CV_INIT_ALGORITHM(PyrLK_CUDA, "DenseOpticalFlowExt.PyrLK_CUDA",
obj.info()->addParam(obj, "winSize", obj.winSize_);
obj.info()->addParam(obj, "maxLevel", obj.maxLevel_);
obj.info()->addParam(obj, "iterations", obj.iterations_));
obj.info()->addParam(obj, "iterations", obj.iterations_))
PyrLK_CUDA::PyrLK_CUDA() : GpuOpticalFlow(CV_8UC1)
{
@ -603,7 +603,7 @@ namespace
obj.info()->addParam(obj, "numIters", obj.numIters_);
obj.info()->addParam(obj, "polyN", obj.polyN_);
obj.info()->addParam(obj, "polySigma", obj.polySigma_);
obj.info()->addParam(obj, "flags", obj.flags_));
obj.info()->addParam(obj, "flags", obj.flags_))
Farneback_CUDA::Farneback_CUDA() : GpuOpticalFlow(CV_8UC1)
{
@ -679,7 +679,7 @@ namespace
obj.info()->addParam(obj, "warps", obj.warps_);
obj.info()->addParam(obj, "epsilon", obj.epsilon_);
obj.info()->addParam(obj, "iterations", obj.iterations_);
obj.info()->addParam(obj, "useInitialFlow", obj.useInitialFlow_));
obj.info()->addParam(obj, "useInitialFlow", obj.useInitialFlow_))
DualTVL1_CUDA::DualTVL1_CUDA() : GpuOpticalFlow(CV_8UC1)
{
@ -801,7 +801,7 @@ namespace
CV_INIT_ALGORITHM(PyrLK_OCL, "DenseOpticalFlowExt.PyrLK_OCL",
obj.info()->addParam(obj, "winSize", obj.winSize_);
obj.info()->addParam(obj, "maxLevel", obj.maxLevel_);
obj.info()->addParam(obj, "iterations", obj.iterations_));
obj.info()->addParam(obj, "iterations", obj.iterations_))
PyrLK_OCL::PyrLK_OCL() : oclOpticalFlow(CV_8UC1)
{
@ -870,7 +870,7 @@ namespace
obj.info()->addParam(obj, "warps", obj.warps_);
obj.info()->addParam(obj, "epsilon", obj.epsilon_);
obj.info()->addParam(obj, "iterations", obj.iterations_);
obj.info()->addParam(obj, "useInitialFlow", obj.useInitialFlow_));
obj.info()->addParam(obj, "useInitialFlow", obj.useInitialFlow_))
DualTVL1_OCL::DualTVL1_OCL() : oclOpticalFlow(CV_8UC1)
{
@ -947,7 +947,7 @@ namespace
obj.info()->addParam(obj, "numIters", obj.numIters_);
obj.info()->addParam(obj, "polyN", obj.polyN_);
obj.info()->addParam(obj, "polySigma", obj.polySigma_);
obj.info()->addParam(obj, "flags", obj.flags_));
obj.info()->addParam(obj, "flags", obj.flags_))
FarneBack_OCL::FarneBack_OCL() : oclOpticalFlow(CV_8UC1)
{

@ -57,19 +57,33 @@ using std::tr1::tuple;
#define OCL_PERF_STRATEGY PERF_STRATEGY_SIMPLE
#define OCL_PERF_TEST(fixture, name) SIMPLE_PERF_TEST(fixture, name)
#define OCL_PERF_TEST_P(fixture, name, params) SIMPLE_PERF_TEST_P(fixture, name, params)
#define SIMPLE_PERF_TEST_P(fixture, name, params)\
class OCL##_##fixture##_##name : public fixture {\
public:\
OCL##_##fixture##_##name() {}\
protected:\
virtual void PerfTestBody();\
};\
TEST_P(OCL##_##fixture##_##name, name){ declare.strategy(OCL_PERF_STRATEGY); RunPerfTestBody(); }\
INSTANTIATE_TEST_CASE_P(/*none*/, OCL##_##fixture##_##name, params);\
#define SIMPLE_PERF_TEST(fixture, name) \
class OCL##_##fixture##_##name : \
public ::perf::TestBase \
{ \
public: \
OCL##_##fixture##_##name() { } \
protected: \
virtual void PerfTestBody(); \
}; \
TEST_F(OCL##_##fixture##_##name, name) { declare.strategy(OCL_PERF_STRATEGY); RunPerfTestBody(); } \
void OCL##_##fixture##_##name::PerfTestBody()
#define SIMPLE_PERF_TEST_P(fixture, name, params) \
class OCL##_##fixture##_##name : \
public fixture \
{ \
public: \
OCL##_##fixture##_##name() { } \
protected: \
virtual void PerfTestBody(); \
}; \
TEST_P(OCL##_##fixture##_##name, name) { declare.strategy(OCL_PERF_STRATEGY); RunPerfTestBody(); } \
INSTANTIATE_TEST_CASE_P(/*none*/, OCL##_##fixture##_##name, params); \
void OCL##_##fixture##_##name::PerfTestBody()
#define OCL_SIZE_1 szVGA
#define OCL_SIZE_2 sz720p

@ -96,18 +96,18 @@ extern int test_loop_times;
#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
{ \
ASSERT_EQ(mat1.type(), mat2.type()); \
ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(checkNorm(mat1, mat2), eps) \
<< cv::format("Size: %d x %d", mat1.size().width, mat1.size().height) << std::endl; \
ASSERT_EQ(mat1.type(), mat2.type()); \
ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(checkNorm(mat1, mat2), eps) \
<< "Size: " << mat1.size() << std::endl; \
}
#define EXPECT_MAT_NEAR_RELATIVE(mat1, mat2, eps) \
{ \
ASSERT_EQ(mat1.type(), mat2.type()); \
ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(checkNormRelative(mat1, mat2), eps) \
<< cv::format("Size: %d x %d", mat1.size().width, mat1.size().height) << std::endl; \
ASSERT_EQ(mat1.type(), mat2.type()); \
ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(checkNormRelative(mat1, mat2), eps) \
<< "Size: " << mat1.size() << std::endl; \
}
#define OCL_EXPECT_MATS_NEAR(name, eps) \
@ -134,8 +134,8 @@ extern int test_loop_times;
{ \
ASSERT_EQ(mat1.type(), mat2.type()); \
ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(checkSimilarity(mat1, mat2), eps); \
<< cv::format("Size: %d x %d", mat1.size().width, mat1.size().height) << std::endl; \
EXPECT_LE(checkSimilarity(mat1, mat2), eps) \
<< "Size: " << mat1.size() << std::endl; \
}
using perf::MatDepth;

@ -164,6 +164,7 @@ class CV_EXPORTS Regression
{
public:
static Regression& add(TestBase* test, const std::string& name, cv::InputArray array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE);
static Regression& addMoments(TestBase* test, const std::string& name, const cv::Moments & array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE);
static Regression& addKeypoints(TestBase* test, const std::string& name, const std::vector<cv::KeyPoint>& array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE);
static Regression& addMatches(TestBase* test, const std::string& name, const std::vector<cv::DMatch>& array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE);
static void Init(const std::string& testSuitName, const std::string& ext = ".xml");
@ -201,6 +202,7 @@ private:
};
#define SANITY_CHECK(array, ...) ::perf::Regression::add(this, #array, array , ## __VA_ARGS__)
#define SANITY_CHECK_MOMENTS(array, ...) ::perf::Regression::addMoments(this, #array, array , ## __VA_ARGS__)
#define SANITY_CHECK_KEYPOINTS(array, ...) ::perf::Regression::addKeypoints(this, #array, array , ## __VA_ARGS__)
#define SANITY_CHECK_MATCHES(array, ...) ::perf::Regression::addMatches(this, #array, array , ## __VA_ARGS__)
#define SANITY_CHECK_NOTHING() this->setVerified();
@ -253,7 +255,7 @@ enum PERF_STRATEGY
{
PERF_STRATEGY_DEFAULT = -1,
PERF_STRATEGY_BASE = 0,
PERF_STRATEGY_SIMPLE = 1,
PERF_STRATEGY_SIMPLE = 1
};

@ -115,6 +115,14 @@ Regression& Regression::add(TestBase* test, const std::string& name, cv::InputAr
return instance()(name, array, eps, err);
}
Regression& Regression::addMoments(TestBase* test, const std::string& name, const cv::Moments& array, double eps, ERROR_TYPE err)
{
int len = (int)sizeof(cv::Moments) / sizeof(double);
cv::Mat m(1, len, CV_64F, (void*)&array);
return Regression::add(test, name, m, eps, err);
}
Regression& Regression::addKeypoints(TestBase* test, const std::string& name, const std::vector<cv::KeyPoint>& array, double eps, ERROR_TYPE err)
{
int len = (int)array.size();

@ -178,7 +178,7 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize_Deriv, OpticalFlowPyrLK_self, testing::Com
SANITY_CHECK(err, 2);
}
CV_ENUM(PyrBorderMode, BORDER_DEFAULT, BORDER_TRANSPARENT);
CV_ENUM(PyrBorderMode, BORDER_DEFAULT, BORDER_TRANSPARENT)
typedef tr1::tuple<std::string, int, bool, PyrBorderMode, bool> Path_Win_Deriv_Border_Reuse_t;
typedef TestBaseWithParam<Path_Win_Deriv_Border_Reuse_t> Path_Win_Deriv_Border_Reuse;

@ -127,4 +127,4 @@ const Mat& KalmanFilter::correct(const Mat& measurement)
return statePost;
}
};
}

@ -947,7 +947,7 @@ CV_INIT_ALGORITHM(OpticalFlowDual_TVL1, "DenseOpticalFlow.DualTVL1",
"inner iterations (between outlier filtering) used in the numerical scheme");
obj.info()->addParam(obj, "outerIterations", obj.outerIterations, false, 0, 0,
"outer iterations (number of inner loops) used in the numerical scheme");
obj.info()->addParam(obj, "useInitialFlow", obj.useInitialFlow));
obj.info()->addParam(obj, "useInitialFlow", obj.useInitialFlow))
} // namespace

@ -126,12 +126,12 @@ ASDFrameHolder::ASDFrameHolder( )
{
image = NULL;
timeStamp = 0;
};
}
ASDFrameHolder::~ASDFrameHolder( )
{
cvReleaseImage(&image);
};
}
void ASDFrameHolder::assignFrame(IplImage *sourceImage, double frameTime)
{
@ -143,22 +143,22 @@ void ASDFrameHolder::assignFrame(IplImage *sourceImage, double frameTime)
image = cvCloneImage(sourceImage);
timeStamp = frameTime;
};
}
IplImage *ASDFrameHolder::getImage()
{
return image;
};
}
double ASDFrameHolder::getTimeStamp()
{
return timeStamp;
};
}
void ASDFrameHolder::setImage(IplImage *sourceImage)
{
image = sourceImage;
};
}
//-------------------- ASDFrameSequencer -----------------------//
@ -166,26 +166,26 @@ void ASDFrameHolder::setImage(IplImage *sourceImage)
ASDFrameSequencer::~ASDFrameSequencer()
{
close();
};
}
IplImage *ASDFrameSequencer::getNextImage()
{
return NULL;
};
}
void ASDFrameSequencer::close()
{
};
}
bool ASDFrameSequencer::isOpen()
{
return false;
};
}
void ASDFrameSequencer::getFrameCaption(char* /*caption*/) {
return;
};
}
IplImage* ASDCVFrameSequencer::getNextImage()
{
@ -201,7 +201,7 @@ IplImage* ASDCVFrameSequencer::getNextImage()
{
return NULL;
}
};
}
void ASDCVFrameSequencer::close()
{
@ -209,12 +209,12 @@ void ASDCVFrameSequencer::close()
{
cvReleaseCapture(&capture);
}
};
}
bool ASDCVFrameSequencer::isOpen()
{
return (capture != NULL);
};
}
//-------------------- ASDFrameSequencerWebCam -----------------------//
@ -233,7 +233,7 @@ bool ASDFrameSequencerWebCam::open(int cameraIndex)
{
return true;
}
};
}
//-------------------- ASDFrameSequencerVideoFile -----------------------//
@ -251,7 +251,7 @@ bool ASDFrameSequencerVideoFile::open(const char *fileName)
{
return true;
}
};
}
//-------------------- ASDFrameSequencerImageFile -----------------------//
@ -263,11 +263,11 @@ void ASDFrameSequencerImageFile::open(const char *fileNameMask, int startIndex,
nEndIndex = endIndex;
std::sprintf(sFileNameMask, "%s", fileNameMask);
};
}
void ASDFrameSequencerImageFile::getFrameCaption(char *caption) {
std::sprintf(caption, sFileNameMask, nCurrentIndex);
};
}
IplImage* ASDFrameSequencerImageFile::getNextImage()
{
@ -283,23 +283,23 @@ IplImage* ASDFrameSequencerImageFile::getNextImage()
IplImage* img = cvLoadImage(fileName);
return img;
};
}
void ASDFrameSequencerImageFile::close()
{
nCurrentIndex = nEndIndex+1;
};
}
bool ASDFrameSequencerImageFile::isOpen()
{
return (nCurrentIndex <= nEndIndex);
};
}
static void putTextWithShadow(IplImage *img, const char *str, CvPoint point, CvFont *font, CvScalar color = CV_RGB(255, 255, 128))
{
cvPutText(img, str, cvPoint(point.x-1,point.y-1), font, CV_RGB(0, 0, 0));
cvPutText(img, str, point, font, color);
};
}
#define ASD_RGB_SET_PIXEL(pointer, r, g, b) { (*pointer) = (unsigned char)b; (*(pointer+1)) = (unsigned char)g; (*(pointer+2)) = (unsigned char)r; }
@ -336,7 +336,7 @@ static void displayBuffer(IplImage *rgbDestImage, IplImage *buffer, int rValue,
destY = 0;
destX += dx;
}
};
}
int main(int argc, char** argv )
{

@ -46,7 +46,7 @@ private:
Point3f generateChessBoardCenter(const Mat& camMat, const Size& imgSize) const;
Mat rvec, tvec;
};
};
}

@ -33,10 +33,10 @@ int main( int /*argc*/, char** /*argv*/ )
{
int k, clusterCount = rng.uniform(2, MAX_CLUSTERS+1);
int i, sampleCount = rng.uniform(1, 1001);
Mat points(sampleCount, 1, CV_32FC2), labels;
Mat points(sampleCount, 2, CV_32F), labels;
clusterCount = MIN(clusterCount, sampleCount);
Mat centers(clusterCount, 1, points.type());
Mat centers;
/* generate random sample from multigaussian distribution */
for( k = 0; k < clusterCount; k++ )

@ -14,7 +14,7 @@ using namespace cv;
/// Global variables
int threshold_value = 0;
int threshold_type = 3;;
int threshold_type = 3;
int const max_value = 255;
int const max_type = 4;
int const max_BINARY_value = 255;

Loading…
Cancel
Save