some more changes

This commit is contained in:
Ilya Lavrenov
2014-02-17 03:00:20 +04:00
parent f74ef644bc
commit 6ad7b64912
8 changed files with 74 additions and 67 deletions

View File

@@ -791,15 +791,18 @@ void DescriptorMatcher::radiusMatch( InputArray queryDescriptors, InputArray tra
tempMatcher->radiusMatch( queryDescriptors, matches, maxDistance, std::vector<Mat>(1, mask.getMat()), compactResult );
}
void DescriptorMatcher::match( InputArray queryDescriptors, std::vector<DMatch>& matches, const std::vector<Mat>& masks )
void DescriptorMatcher::match( InputArray queryDescriptors, std::vector<DMatch>& matches, InputArrayOfArrays masks )
{
std::vector<std::vector<DMatch> > knnMatches;
knnMatch( queryDescriptors, knnMatches, 1, masks, true /*compactResult*/ );
convertMatches( knnMatches, matches );
}
void DescriptorMatcher::checkMasks( const std::vector<Mat>& masks, int queryDescriptorsCount ) const
void DescriptorMatcher::checkMasks( InputArrayOfArrays _masks, int queryDescriptorsCount ) const
{
std::vector<Mat> masks;
_masks.getMatVector(masks);
if( isMaskSupported() && !masks.empty() )
{
// Check masks
@@ -819,7 +822,7 @@ void DescriptorMatcher::checkMasks( const std::vector<Mat>& masks, int queryDesc
}
void DescriptorMatcher::knnMatch( InputArray queryDescriptors, std::vector<std::vector<DMatch> >& matches, int knn,
const std::vector<Mat>& masks, bool compactResult )
InputArrayOfArrays masks, bool compactResult )
{
if( empty() || queryDescriptors.empty() )
return;
@@ -833,7 +836,7 @@ void DescriptorMatcher::knnMatch( InputArray queryDescriptors, std::vector<std::
}
void DescriptorMatcher::radiusMatch( InputArray queryDescriptors, std::vector<std::vector<DMatch> >& matches, float maxDistance,
const std::vector<Mat>& masks, bool compactResult )
InputArrayOfArrays masks, bool compactResult )
{
matches.clear();
if( empty() || queryDescriptors.empty() )
@@ -853,13 +856,17 @@ void DescriptorMatcher::read( const FileNode& )
void DescriptorMatcher::write( FileStorage& ) const
{}
bool DescriptorMatcher::isPossibleMatch( const Mat& mask, int queryIdx, int trainIdx )
bool DescriptorMatcher::isPossibleMatch( InputArray _mask, int queryIdx, int trainIdx )
{
Mat mask = _mask.getMat();
return mask.empty() || mask.at<uchar>(queryIdx, trainIdx);
}
bool DescriptorMatcher::isMaskedOut( const std::vector<Mat>& masks, int queryIdx )
bool DescriptorMatcher::isMaskedOut( InputArrayOfArrays _masks, int queryIdx )
{
std::vector<Mat> masks;
_masks.getMatVector(masks);
size_t outCount = 0;
for( size_t i = 0; i < masks.size(); i++ )
{
@@ -1679,43 +1686,43 @@ void GenericDescriptorMatcher::classify( InputArray queryImage, std::vector<KeyP
void GenericDescriptorMatcher::match( InputArray queryImage, std::vector<KeyPoint>& queryKeypoints,
InputArray _trainImage, std::vector<KeyPoint>& trainKeypoints,
std::vector<DMatch>& matches, const Mat& mask ) const
std::vector<DMatch>& matches, InputArray mask ) const
{
Mat trainImage = _trainImage.getMat();
Ptr<GenericDescriptorMatcher> tempMatcher = clone( true );
std::vector<std::vector<KeyPoint> > vecTrainPoints(1, trainKeypoints);
tempMatcher->add( std::vector<Mat>(1, trainImage), vecTrainPoints );
tempMatcher->match( queryImage, queryKeypoints, matches, std::vector<Mat>(1, mask) );
tempMatcher->match( queryImage, queryKeypoints, matches, std::vector<Mat>(1, mask.getMat()) );
vecTrainPoints[0].swap( trainKeypoints );
}
void GenericDescriptorMatcher::knnMatch( InputArray queryImage, std::vector<KeyPoint>& queryKeypoints,
InputArray _trainImage, std::vector<KeyPoint>& trainKeypoints,
std::vector<std::vector<DMatch> >& matches, int knn, const Mat& mask, bool compactResult ) const
std::vector<std::vector<DMatch> >& matches, int knn, InputArray mask, bool compactResult ) const
{
Mat trainImage = _trainImage.getMat();
Ptr<GenericDescriptorMatcher> tempMatcher = clone( true );
std::vector<std::vector<KeyPoint> > vecTrainPoints(1, trainKeypoints);
tempMatcher->add( std::vector<Mat>(1, trainImage), vecTrainPoints );
tempMatcher->knnMatch( queryImage, queryKeypoints, matches, knn, std::vector<Mat>(1, mask), compactResult );
tempMatcher->knnMatch( queryImage, queryKeypoints, matches, knn, std::vector<Mat>(1, mask.getMat()), compactResult );
vecTrainPoints[0].swap( trainKeypoints );
}
void GenericDescriptorMatcher::radiusMatch( InputArray queryImage, std::vector<KeyPoint>& queryKeypoints,
InputArray _trainImage, std::vector<KeyPoint>& trainKeypoints,
std::vector<std::vector<DMatch> >& matches, float maxDistance,
const Mat& mask, bool compactResult ) const
InputArray mask, bool compactResult ) const
{
Mat trainImage = _trainImage.getMat();
Ptr<GenericDescriptorMatcher> tempMatcher = clone( true );
std::vector<std::vector<KeyPoint> > vecTrainPoints(1, trainKeypoints);
tempMatcher->add( std::vector<Mat>(1, trainImage), vecTrainPoints );
tempMatcher->radiusMatch( queryImage, queryKeypoints, matches, maxDistance, std::vector<Mat>(1, mask), compactResult );
tempMatcher->radiusMatch( queryImage, queryKeypoints, matches, maxDistance, std::vector<Mat>(1, mask.getMat()), compactResult );
vecTrainPoints[0].swap( trainKeypoints );
}
void GenericDescriptorMatcher::match( InputArray queryImage, std::vector<KeyPoint>& queryKeypoints,
std::vector<DMatch>& matches, const std::vector<Mat>& masks )
std::vector<DMatch>& matches, InputArrayOfArrays masks )
{
std::vector<std::vector<DMatch> > knnMatches;
knnMatch( queryImage, queryKeypoints, knnMatches, 1, masks, false );
@@ -1724,7 +1731,7 @@ void GenericDescriptorMatcher::match( InputArray queryImage, std::vector<KeyPoin
void GenericDescriptorMatcher::knnMatch( InputArray queryImage, std::vector<KeyPoint>& queryKeypoints,
std::vector<std::vector<DMatch> >& matches, int knn,
const std::vector<Mat>& masks, bool compactResult )
InputArrayOfArrays masks, bool compactResult )
{
matches.clear();
@@ -1740,7 +1747,7 @@ void GenericDescriptorMatcher::knnMatch( InputArray queryImage, std::vector<KeyP
void GenericDescriptorMatcher::radiusMatch( InputArray queryImage, std::vector<KeyPoint>& queryKeypoints,
std::vector<std::vector<DMatch> >& matches, float maxDistance,
const std::vector<Mat>& masks, bool compactResult )
InputArrayOfArrays masks, bool compactResult )
{
matches.clear();
@@ -1831,7 +1838,7 @@ bool VectorDescriptorMatcher::isMaskSupported()
void VectorDescriptorMatcher::knnMatchImpl( InputArray queryImage, std::vector<KeyPoint>& queryKeypoints,
std::vector<std::vector<DMatch> >& matches, int knn,
const std::vector<Mat>& masks, bool compactResult )
InputArrayOfArrays masks, bool compactResult )
{
Mat queryDescriptors;
extractor->compute( queryImage, queryKeypoints, queryDescriptors );
@@ -1840,7 +1847,7 @@ void VectorDescriptorMatcher::knnMatchImpl( InputArray queryImage, std::vector<K
void VectorDescriptorMatcher::radiusMatchImpl( InputArray queryImage, std::vector<KeyPoint>& queryKeypoints,
std::vector<std::vector<DMatch> >& matches, float maxDistance,
const std::vector<Mat>& masks, bool compactResult )
InputArrayOfArrays masks, bool compactResult )
{
Mat queryDescriptors;
extractor->compute( queryImage, queryKeypoints, queryDescriptors );

View File

@@ -1266,11 +1266,11 @@ MSER::MSER( int _delta, int _min_area, int _max_area,
{
}
void MSER::operator()( const Mat& image, std::vector<std::vector<Point> >& dstcontours, const Mat& mask ) const
void MSER::operator()( InputArray image, std::vector<std::vector<Point> >& dstcontours, InputArray mask ) const
{
CvMat _image = image, _mask, *pmask = 0;
if( mask.data )
pmask = &(_mask = mask);
CvMat _image = image.getMat(), _mask, *pmask = 0;
if( !mask.empty() )
pmask = &(_mask = mask.getMat());
MemStorage storage(cvCreateMemStorage(0));
Seq<CvSeq*> contours;
extractMSER( &_image, pmask, &contours.seq, storage,