added read/write methods for SimpleBlobDetector and DenseFeatureDetector; added their creation to FeatureDetector::create method (#1290)
This commit is contained in:
parent
7f32e8131d
commit
81cb7b2c5e
@ -1583,10 +1583,16 @@ public:
|
|||||||
|
|
||||||
bool filterByConvexity;
|
bool filterByConvexity;
|
||||||
float minConvexity, maxConvexity;
|
float minConvexity, maxConvexity;
|
||||||
|
|
||||||
|
void read( const FileNode& fn );
|
||||||
|
void write( FileStorage& fs ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
SimpleBlobDetector(const SimpleBlobDetector::Params ¶meters = SimpleBlobDetector::Params());
|
SimpleBlobDetector(const SimpleBlobDetector::Params ¶meters = SimpleBlobDetector::Params());
|
||||||
|
|
||||||
|
virtual void read( const FileNode& fn );
|
||||||
|
virtual void write( FileStorage& fs ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct CV_EXPORTS Center
|
struct CV_EXPORTS Center
|
||||||
{
|
{
|
||||||
@ -1618,11 +1624,15 @@ public:
|
|||||||
|
|
||||||
bool varyXyStepWithScale;
|
bool varyXyStepWithScale;
|
||||||
bool varyImgBoundWithScale;
|
bool varyImgBoundWithScale;
|
||||||
|
|
||||||
|
void read( const FileNode& fn );
|
||||||
|
void write( FileStorage& fs ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
DenseFeatureDetector( const DenseFeatureDetector::Params& params=DenseFeatureDetector::Params() );
|
DenseFeatureDetector( const DenseFeatureDetector::Params& params=DenseFeatureDetector::Params() );
|
||||||
|
|
||||||
// TODO implement read/write
|
virtual void read( const FileNode& fn );
|
||||||
|
virtual void write( FileStorage& fs ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
@ -84,11 +84,79 @@ SimpleBlobDetector::Params::Params()
|
|||||||
maxConvexity = std::numeric_limits<float>::max();
|
maxConvexity = std::numeric_limits<float>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleBlobDetector::Params::read(const cv::FileNode& fn )
|
||||||
|
{
|
||||||
|
thresholdStep = fn["thresholdStep"];
|
||||||
|
minThreshold = fn["minThreshold"];
|
||||||
|
maxThreshold = fn["maxThreshold"];
|
||||||
|
|
||||||
|
minRepeatability = (size_t)(int)fn["minRepeatability"];
|
||||||
|
minDistBetweenBlobs = fn["minDistBetweenBlobs"];
|
||||||
|
|
||||||
|
filterByColor = (int)fn["filterByColor"] != 0 ? true : false;
|
||||||
|
blobColor = (uchar)(int)fn["blobColor"];
|
||||||
|
|
||||||
|
filterByArea = (int)fn["filterByArea"] != 0 ? true : false;
|
||||||
|
minArea = fn["minArea"];
|
||||||
|
maxArea = fn["maxArea"];
|
||||||
|
|
||||||
|
filterByCircularity = (int)fn["filterByCircularity"] != 0 ? true : false;
|
||||||
|
minCircularity = fn["minCircularity"];
|
||||||
|
maxCircularity = fn["maxCircularity"];
|
||||||
|
|
||||||
|
filterByInertia = (int)fn["filterByInertia"] != 0 ? true : false;
|
||||||
|
minInertiaRatio = fn["minInertiaRatio"];
|
||||||
|
maxInertiaRatio = fn["maxInertiaRatio"];
|
||||||
|
|
||||||
|
filterByConvexity = (int)fn["filterByConvexity"] != 0 ? true : false;
|
||||||
|
minConvexity = fn["minConvexity"];
|
||||||
|
maxConvexity = fn["maxConvexity"];
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimpleBlobDetector::Params::write(cv::FileStorage& fs) const
|
||||||
|
{
|
||||||
|
fs << "thresholdStep" << thresholdStep;
|
||||||
|
fs << "minThreshold" << minThreshold;
|
||||||
|
fs << "maxThreshold" << maxThreshold;
|
||||||
|
|
||||||
|
fs << "minRepeatability" << (int)minRepeatability;
|
||||||
|
fs << "minDistBetweenBlobs" << minDistBetweenBlobs;
|
||||||
|
|
||||||
|
fs << "filterByColor" << (int)filterByColor;
|
||||||
|
fs << "blobColor" << (int)blobColor;
|
||||||
|
|
||||||
|
fs << "filterByArea" << (int)filterByArea;
|
||||||
|
fs << "minArea" << minArea;
|
||||||
|
fs << "maxArea" << maxArea;
|
||||||
|
|
||||||
|
fs << "filterByCircularity" << (int)filterByCircularity;
|
||||||
|
fs << "minCircularity" << minCircularity;
|
||||||
|
fs << "maxCircularity" << maxCircularity;
|
||||||
|
|
||||||
|
fs << "filterByInertia" << (int)filterByInertia;
|
||||||
|
fs << "minInertiaRatio" << minInertiaRatio;
|
||||||
|
fs << "maxInertiaRatio" << maxInertiaRatio;
|
||||||
|
|
||||||
|
fs << "filterByConvexity" << (int)filterByConvexity;
|
||||||
|
fs << "minConvexity" << minConvexity;
|
||||||
|
fs << "maxConvexity" << maxConvexity;
|
||||||
|
}
|
||||||
|
|
||||||
SimpleBlobDetector::SimpleBlobDetector(const SimpleBlobDetector::Params ¶meters) :
|
SimpleBlobDetector::SimpleBlobDetector(const SimpleBlobDetector::Params ¶meters) :
|
||||||
params(parameters)
|
params(parameters)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleBlobDetector::read( const cv::FileNode& fn )
|
||||||
|
{
|
||||||
|
params.read(fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimpleBlobDetector::write( cv::FileStorage& fs ) const
|
||||||
|
{
|
||||||
|
params.write(fs);
|
||||||
|
}
|
||||||
|
|
||||||
void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryImage, vector<Center> ¢ers) const
|
void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryImage, vector<Center> ¢ers) const
|
||||||
{
|
{
|
||||||
(void)image;
|
(void)image;
|
||||||
|
@ -126,6 +126,14 @@ Ptr<FeatureDetector> FeatureDetector::create( const string& detectorType )
|
|||||||
params.useHarrisDetector = true;
|
params.useHarrisDetector = true;
|
||||||
fd = new GoodFeaturesToTrackDetector(params);
|
fd = new GoodFeaturesToTrackDetector(params);
|
||||||
}
|
}
|
||||||
|
else if( !detectorType.compare( "Dense" ) )
|
||||||
|
{
|
||||||
|
fd = new DenseFeatureDetector();
|
||||||
|
}
|
||||||
|
else if( !detectorType.compare( "SimpleBlob" ) )
|
||||||
|
{
|
||||||
|
fd = new SimpleBlobDetector();
|
||||||
|
}
|
||||||
else if( (pos=detectorType.find("Grid")) == 0 )
|
else if( (pos=detectorType.find("Grid")) == 0 )
|
||||||
{
|
{
|
||||||
pos += string("Grid").size();
|
pos += string("Grid").size();
|
||||||
@ -499,9 +507,45 @@ DenseFeatureDetector::Params::Params( float _initFeatureScale, int _featureScale
|
|||||||
varyXyStepWithScale(_varyXyStepWithScale), varyImgBoundWithScale(_varyImgBoundWithScale)
|
varyXyStepWithScale(_varyXyStepWithScale), varyImgBoundWithScale(_varyImgBoundWithScale)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void DenseFeatureDetector::Params::read( const FileNode& fn )
|
||||||
|
{
|
||||||
|
initFeatureScale = fn["initFeatureScale"];
|
||||||
|
featureScaleLevels = fn["featureScaleLevels"];
|
||||||
|
featureScaleMul = fn["featureScaleMul"];
|
||||||
|
|
||||||
|
initXyStep = fn["initXyStep"];
|
||||||
|
initImgBound = fn["initImgBound"];
|
||||||
|
|
||||||
|
varyXyStepWithScale = (int)fn["varyXyStepWithScale"] != 0 ? true : false;
|
||||||
|
varyImgBoundWithScale = (int)fn["varyImgBoundWithScale"] != 0 ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DenseFeatureDetector::Params::write( FileStorage& fs ) const
|
||||||
|
{
|
||||||
|
fs << "initFeatureScale" << initFeatureScale;
|
||||||
|
fs << "featureScaleLevels" << featureScaleLevels;
|
||||||
|
fs << "featureScaleMul" << featureScaleMul;
|
||||||
|
|
||||||
|
fs << "initXyStep" << initXyStep;
|
||||||
|
fs << "initImgBound" << initImgBound;
|
||||||
|
|
||||||
|
fs << "varyXyStepWithScale" << (int)varyXyStepWithScale;
|
||||||
|
fs << "varyImgBoundWithScale" << (int)varyImgBoundWithScale;
|
||||||
|
}
|
||||||
|
|
||||||
DenseFeatureDetector::DenseFeatureDetector(const DenseFeatureDetector::Params &_params) : params(_params)
|
DenseFeatureDetector::DenseFeatureDetector(const DenseFeatureDetector::Params &_params) : params(_params)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void DenseFeatureDetector::read( const FileNode &fn )
|
||||||
|
{
|
||||||
|
params.read(fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DenseFeatureDetector::write( FileStorage &fs ) const
|
||||||
|
{
|
||||||
|
params.write(fs);
|
||||||
|
}
|
||||||
|
|
||||||
void DenseFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
void DenseFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
||||||
{
|
{
|
||||||
float curScale = params.initFeatureScale;
|
float curScale = params.initFeatureScale;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user