|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "precomp.hpp"
|
|
|
|
|
|
namespace cv
|
|
|
{
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
|
Feature2D::~Feature2D() {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Feature2D::detect( InputArray image,
|
|
|
std::vector<KeyPoint>& keypoints,
|
|
|
InputArray mask )
|
|
|
{
|
|
|
CV_INSTRUMENT_REGION();
|
|
|
|
|
|
if( image.empty() )
|
|
|
{
|
|
|
keypoints.clear();
|
|
|
return;
|
|
|
}
|
|
|
detectAndCompute(image, mask, keypoints, noArray(), false);
|
|
|
}
|
|
|
|
|
|
|
|
|
void Feature2D::detect( InputArrayOfArrays images,
|
|
|
std::vector<std::vector<KeyPoint> >& keypoints,
|
|
|
InputArrayOfArrays masks )
|
|
|
{
|
|
|
CV_INSTRUMENT_REGION();
|
|
|
|
|
|
int nimages = (int)images.total();
|
|
|
|
|
|
if (!masks.empty())
|
|
|
{
|
|
|
CV_Assert(masks.total() == (size_t)nimages);
|
|
|
}
|
|
|
|
|
|
keypoints.resize(nimages);
|
|
|
|
|
|
if (images.isMatVector())
|
|
|
{
|
|
|
for (int i = 0; i < nimages; i++)
|
|
|
{
|
|
|
detect(images.getMat(i), keypoints[i], masks.empty() ? noArray() : masks.getMat(i));
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < nimages; i++)
|
|
|
{
|
|
|
detect(images.getUMat(i), keypoints[i], masks.empty() ? noArray() : masks.getUMat(i));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Feature2D::compute( InputArray image,
|
|
|
std::vector<KeyPoint>& keypoints,
|
|
|
OutputArray descriptors )
|
|
|
{
|
|
|
CV_INSTRUMENT_REGION();
|
|
|
|
|
|
if( image.empty() )
|
|
|
{
|
|
|
descriptors.release();
|
|
|
return;
|
|
|
}
|
|
|
detectAndCompute(image, noArray(), keypoints, descriptors, true);
|
|
|
}
|
|
|
|
|
|
void Feature2D::compute( InputArrayOfArrays images,
|
|
|
std::vector<std::vector<KeyPoint> >& keypoints,
|
|
|
OutputArrayOfArrays descriptors )
|
|
|
{
|
|
|
CV_INSTRUMENT_REGION();
|
|
|
|
|
|
if( !descriptors.needed() )
|
|
|
return;
|
|
|
|
|
|
int nimages = (int)images.total();
|
|
|
|
|
|
CV_Assert( keypoints.size() == (size_t)nimages );
|
|
|
|
|
|
if (descriptors.isMatVector())
|
|
|
{
|
|
|
vector<Mat>& vec = *(vector<Mat>*)descriptors.getObj();
|
|
|
vec.resize(nimages);
|
|
|
for (int i = 0; i < nimages; i++)
|
|
|
{
|
|
|
compute(images.getMat(i), keypoints[i], vec[i]);
|
|
|
}
|
|
|
}
|
|
|
else if (descriptors.isUMatVector())
|
|
|
{
|
|
|
vector<UMat>& vec = *(vector<UMat>*)descriptors.getObj();
|
|
|
vec.resize(nimages);
|
|
|
for (int i = 0; i < nimages; i++)
|
|
|
{
|
|
|
compute(images.getUMat(i), keypoints[i], vec[i]);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CV_Error(Error::StsBadArg, "descriptors must be vector<Mat> or vector<UMat>");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Feature2D::detectAndCompute( InputArray, InputArray,
|
|
|
std::vector<KeyPoint>&,
|
|
|
OutputArray,
|
|
|
bool )
|
|
|
{
|
|
|
CV_INSTRUMENT_REGION();
|
|
|
|
|
|
CV_Error(Error::StsNotImplemented, "");
|
|
|
}
|
|
|
|
|
|
void Feature2D::write( const String& fileName ) const
|
|
|
{
|
|
|
FileStorage fs(fileName, FileStorage::WRITE);
|
|
|
write(fs);
|
|
|
}
|
|
|
|
|
|
void Feature2D::read( const String& fileName )
|
|
|
{
|
|
|
FileStorage fs(fileName, FileStorage::READ);
|
|
|
read(fs.root());
|
|
|
}
|
|
|
|
|
|
void Feature2D::write( FileStorage&) const
|
|
|
{
|
|
|
}
|
|
|
|
|
|
void Feature2D::read( const FileNode&)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
int Feature2D::descriptorSize() const
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
int Feature2D::descriptorType() const
|
|
|
{
|
|
|
return CV_32F;
|
|
|
}
|
|
|
|
|
|
int Feature2D::defaultNorm() const
|
|
|
{
|
|
|
int tp = descriptorType();
|
|
|
return tp == CV_8U ? NORM_HAMMING : NORM_L2;
|
|
|
}
|
|
|
|
|
|
|
|
|
bool Feature2D::empty() const
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
String Feature2D::getDefaultName() const
|
|
|
{
|
|
|
return "Feature2D";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|