1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #12310 from cv3d:chunks/enum_interface

* Cleanup macros and enable expansion of `__VA_ARGS__` for Visual Studio

* Macros for enum-arguments backwards compatibility

* Convert struct Param to enum struct

* Enabled ParamType.type for enum types

* Enabled `cv.read` and `cv.write` for enum types

* Rename unnamed enum to AAKAZE.DescriptorType

* Rename unnamed enum to AccessFlag

* Rename unnamed enum to AgastFeatureDetector.DetectorType

* Convert struct DrawMatchesFlags to enum struct

* Rename unnamed enum to FastFeatureDetector.DetectorType

* Rename unnamed enum to Formatter.FormatType

* Rename unnamed enum to HOGDescriptor.HistogramNormType

* Rename unnamed enum to DescriptorMatcher.MatcherType

* Rename unnamed enum to KAZE.DiffusivityType

* Rename unnamed enum to ORB.ScoreType

* Rename unnamed enum to UMatData.MemoryFlag

* Rename unnamed enum to _InputArray.KindFlag

* Rename unnamed enum to _OutputArray.DepthMask

* Convert normType enums to static const NormTypes

* Avoid conflicts with ElemType

* Rename unnamed enum to DescriptorStorageFormat
This commit is contained in:
Hamdi Sahloul
2018-09-22 00:12:35 +09:00
committed by Alexander Alekhin
parent 84ae8097b1
commit ef5579dc86
51 changed files with 567 additions and 333 deletions
@@ -372,10 +372,12 @@ http://www.learnopencv.com/handwritten-digits-classification-an-opencv-c-python-
struct CV_EXPORTS_W HOGDescriptor
{
public:
enum { L2Hys = 0 //!< Default histogramNormType
enum HistogramNormType { L2Hys = 0 //!< Default histogramNormType
};
enum { DEFAULT_NLEVELS = 64 //!< Default nlevels value.
};
enum DescriptorStorageFormat { DESCR_FORMAT_COL_BY_COL, DESCR_FORMAT_ROW_BY_ROW };
/**@brief Creates the HOG descriptor and detector with default params.
aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9, 1 )
@@ -402,7 +404,7 @@ public:
*/
CV_WRAP HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride,
Size _cellSize, int _nbins, int _derivAperture=1, double _winSigma=-1,
int _histogramNormType=HOGDescriptor::L2Hys,
HOGDescriptor::HistogramNormType _histogramNormType=HOGDescriptor::L2Hys,
double _L2HysThreshold=0.2, bool _gammaCorrection=false,
int _nlevels=HOGDescriptor::DEFAULT_NLEVELS, bool _signedGradient=false)
: winSize(_winSize), blockSize(_blockSize), blockStride(_blockStride), cellSize(_cellSize),
@@ -603,7 +605,7 @@ public:
CV_PROP double winSigma;
//! histogramNormType
CV_PROP int histogramNormType;
CV_PROP HOGDescriptor::HistogramNormType histogramNormType;
//! L2-Hys normalization method shrinkage.
CV_PROP double L2HysThreshold;
@@ -0,0 +1,13 @@
#ifdef HAVE_OPENCV_OBJDETECT
#include "opencv2/objdetect.hpp"
typedef HOGDescriptor::HistogramNormType HOGDescriptor_HistogramNormType;
typedef HOGDescriptor::DescriptorStorageFormat HOGDescriptor_DescriptorStorageFormat;
CV_PY_FROM_ENUM(HOGDescriptor::HistogramNormType);
CV_PY_TO_ENUM(HOGDescriptor::HistogramNormType);
CV_PY_FROM_ENUM(HOGDescriptor::DescriptorStorageFormat);
CV_PY_TO_ENUM(HOGDescriptor::DescriptorStorageFormat);
#endif
+4 -6
View File
@@ -63,8 +63,6 @@ namespace cv
#define NTHREADS 256
enum {DESCR_FORMAT_COL_BY_COL, DESCR_FORMAT_ROW_BY_ROW};
static int numPartsWithin(int size, int part_size, int stride)
{
return (size - part_size + stride) / stride;
@@ -1515,7 +1513,7 @@ static bool ocl_extract_descrs_by_cols(int win_height, int win_width, int block_
return k.run(2, globalThreads, localThreads, false);
}
static bool ocl_compute(InputArray _img, Size win_stride, std::vector<float>& _descriptors, int descr_format, Size blockSize,
static bool ocl_compute(InputArray _img, Size win_stride, std::vector<float>& _descriptors, HOGDescriptor::DescriptorStorageFormat descr_format, Size blockSize,
Size cellSize, int nbins, Size blockStride, Size winSize, float sigma, bool gammaCorrection, double L2HysThreshold, bool signedGradient)
{
Size imgSize = _img.size();
@@ -1564,13 +1562,13 @@ static bool ocl_compute(InputArray _img, Size win_stride, std::vector<float>& _d
UMat descriptors(wins_per_img.area(), static_cast<int>(blocks_per_win.area() * block_hist_size), CV_32F);
switch (descr_format)
{
case DESCR_FORMAT_ROW_BY_ROW:
case HOGDescriptor::DESCR_FORMAT_ROW_BY_ROW:
if(!ocl_extract_descrs_by_rows(winSize.height, winSize.width,
blockStride.height, blockStride.width, win_stride.height, win_stride.width, effect_size.height,
effect_size.width, block_hists, descriptors, (int)block_hist_size, descr_size, descr_width))
return false;
break;
case DESCR_FORMAT_COL_BY_COL:
case HOGDescriptor::DESCR_FORMAT_COL_BY_COL:
if(!ocl_extract_descrs_by_cols(winSize.height, winSize.width,
blockStride.height, blockStride.width, win_stride.height, win_stride.width, effect_size.height, effect_size.width,
block_hists, descriptors, (int)block_hist_size, descr_size, blocks_per_win.width, blocks_per_win.height))
@@ -1602,7 +1600,7 @@ void HOGDescriptor::compute(InputArray _img, std::vector<float>& descriptors,
Size paddedImgSize(imgSize.width + padding.width*2, imgSize.height + padding.height*2);
CV_OCL_RUN(_img.dims() <= 2 && _img.type() == CV_8UC1 && _img.isUMat(),
ocl_compute(_img, winStride, descriptors, DESCR_FORMAT_COL_BY_COL, blockSize,
ocl_compute(_img, winStride, descriptors, HOGDescriptor::DESCR_FORMAT_COL_BY_COL, blockSize,
cellSize, nbins, blockStride, winSize, (float)getWinSigma(), gammaCorrection, L2HysThreshold, signedGradient))
Mat img = _img.getMat();