Move border type constants and Moments class to core module

This commit is contained in:
Andrey Kamaev
2013-04-10 15:54:14 +04:00
parent f4ae0cf19c
commit c98c246fc2
83 changed files with 541 additions and 639 deletions

View File

@@ -169,7 +169,7 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm
std::vector < std::vector<Point> > contours;
Mat tmpBinaryImage = binaryImage.clone();
findContours(tmpBinaryImage, contours, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
findContours(tmpBinaryImage, contours, RETR_LIST, CHAIN_APPROX_NONE);
#ifdef DEBUG_BLOB_DETECTOR
// Mat keypointsImage;
@@ -239,7 +239,7 @@ void SimpleBlobDetector::findBlobs(const cv::Mat &image, const cv::Mat &binaryIm
if (ratio < params.minConvexity || ratio >= params.maxConvexity)
continue;
}
center.location = Point2d(moms.m10 / moms.m00, moms.m01 / moms.m00);
if (params.filterByColor)
@@ -281,7 +281,7 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector<cv::KeyPoi
keypoints.clear();
Mat grayscaleImage;
if (image.channels() == 3)
cvtColor(image, grayscaleImage, CV_BGR2GRAY);
cvtColor(image, grayscaleImage, COLOR_BGR2GRAY);
else
grayscaleImage = image;

View File

@@ -111,7 +111,7 @@ BriefDescriptorExtractor::BriefDescriptorExtractor(int bytes) :
test_fn_ = pixelTests64;
break;
default:
CV_Error(CV_StsBadArg, "bytes must be 16, 32, or 64");
CV_Error(Error::StsBadArg, "bytes must be 16, 32, or 64");
}
}
@@ -140,7 +140,7 @@ void BriefDescriptorExtractor::read( const FileNode& fn)
test_fn_ = pixelTests64;
break;
default:
CV_Error(CV_StsBadArg, "descriptorSize must be 16, 32, or 64");
CV_Error(Error::StsBadArg, "descriptorSize must be 16, 32, or 64");
}
bytes_ = dSize;
}
@@ -156,7 +156,7 @@ void BriefDescriptorExtractor::computeImpl(const Mat& image, std::vector<KeyPoin
Mat sum;
Mat grayImage = image;
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
if( image.type() != CV_8U ) cvtColor( image, grayImage, COLOR_BGR2GRAY );
///TODO allow the user to pass in a precomputed integral image
//if(image.type() == CV_32S)

View File

@@ -236,7 +236,7 @@ BRISK::generateKernel(std::vector<float> &radiusList, std::vector<int> &numberLi
// get the total number of points
const int rings = (int)radiusList.size();
assert(radiusList.size()!=0&&radiusList.size()==numberList.size());
CV_Assert(radiusList.size() != 0 && radiusList.size() == numberList.size());
points_ = 0; // remember the total number of points
for (int ring = 0; ring < rings; ring++)
{
@@ -336,7 +336,7 @@ BRISK::generateKernel(std::vector<float> &radiusList, std::vector<int> &numberLi
else if (norm_sq < dMax_sq)
{
// save to short pairs
assert(noShortPairs_<indSize);
CV_Assert(noShortPairs_ < indSize);
// make sure the user passes something sensible
BriskShortPair& shortPair = shortPairs_[indexChange[noShortPairs_]];
shortPair.j = j;
@@ -536,7 +536,7 @@ BRISK::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _mask, s
{
Mat image = _image.getMat(), mask = _mask.getMat();
if( image.type() != CV_8UC1 )
cvtColor(image, image, CV_BGR2GRAY);
cvtColor(image, image, COLOR_BGR2GRAY);
if (!useProvidedKeypoints)
{
@@ -729,7 +729,7 @@ BRISK::computeKeypointsNoOrientation(InputArray _image, InputArray _mask, std::v
{
Mat image = _image.getMat(), mask = _mask.getMat();
if( image.type() != CV_8UC1 )
cvtColor(_image, image, CV_BGR2GRAY);
cvtColor(_image, image, COLOR_BGR2GRAY);
BriskScaleSpace briskScaleSpace(octaves);
briskScaleSpace.constructPyramid(image);
@@ -912,7 +912,7 @@ BriskScaleSpace::getKeypoints(const int threshold_, std::vector<cv::KeyPoint>& k
inline int
BriskScaleSpace::getScoreAbove(const int layer, const int x_layer, const int y_layer) const
{
assert(layer<layers_-1);
CV_Assert(layer < layers_-1);
const BriskLayer& l = pyramid_[layer + 1];
if (layer % 2 == 0)
{ // octave
@@ -955,7 +955,7 @@ BriskScaleSpace::getScoreAbove(const int layer, const int x_layer, const int y_l
inline int
BriskScaleSpace::getScoreBelow(const int layer, const int x_layer, const int y_layer) const
{
assert(layer);
CV_Assert(layer);
const BriskLayer& l = pyramid_[layer - 1];
int sixth_x;
int quarter_x;
@@ -1343,7 +1343,7 @@ BriskScaleSpace::getScoreMaxAbove(const int layer, const int x_layer, const int
float y1;
// the layer above
assert(layer+1<layers_);
CV_Assert(layer + 1 < layers_);
const BriskLayer& layerAbove = pyramid_[layer + 1];
if (layer % 2 == 0)
@@ -1539,7 +1539,7 @@ BriskScaleSpace::getScoreMaxBelow(const int layer, const int x_layer, const int
}
// the layer below
assert(layer>0);
CV_Assert(layer > 0);
const BriskLayer& layerBelow = pyramid_[layer - 1];
// check the first row
@@ -2109,7 +2109,7 @@ BriskLayer::getAgastScore(float xf, float yf, int threshold_in, float scale_in)
inline int
BriskLayer::value(const cv::Mat& mat, float xf, float yf, float scale_in) const
{
assert(!mat.empty());
CV_Assert(!mat.empty());
// get the position
const int x = cvFloor(xf);
const int y = cvFloor(yf);
@@ -2216,8 +2216,8 @@ inline void
BriskLayer::halfsample(const cv::Mat& srcimg, cv::Mat& dstimg)
{
// make sure the destination image is of the right size:
assert(srcimg.cols/2==dstimg.cols);
assert(srcimg.rows/2==dstimg.rows);
CV_Assert(srcimg.cols / 2 == dstimg.cols);
CV_Assert(srcimg.rows / 2 == dstimg.rows);
// handle non-SSE case
resize(srcimg, dstimg, dstimg.size(), 0, 0, INTER_AREA);
@@ -2227,8 +2227,8 @@ inline void
BriskLayer::twothirdsample(const cv::Mat& srcimg, cv::Mat& dstimg)
{
// make sure the destination image is of the right size:
assert((srcimg.cols/3)*2==dstimg.cols);
assert((srcimg.rows/3)*2==dstimg.rows);
CV_Assert((srcimg.cols / 3) * 2 == dstimg.cols);
CV_Assert((srcimg.rows / 3) * 2 == dstimg.rows);
resize(srcimg, dstimg, dstimg.size(), 0, 0, INTER_AREA);
}

View File

@@ -118,7 +118,7 @@ OpponentColorDescriptorExtractor::OpponentColorDescriptorExtractor( const Ptr<De
static void convertBGRImageToOpponentColorSpace( const Mat& bgrImage, std::vector<Mat>& opponentChannels )
{
if( bgrImage.type() != CV_8UC3 )
CV_Error( CV_StsBadArg, "input image must be an BGR image of type CV_8UC3" );
CV_Error( Error::StsBadArg, "input image must be an BGR image of type CV_8UC3" );
// Prepare opponent color space storage matrices.
opponentChannels.resize( 3 );

View File

@@ -128,7 +128,7 @@ GFTTDetector::GFTTDetector( int _nfeatures, double _qualityLevel,
void GFTTDetector::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask) const
{
Mat grayImage = image;
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
if( image.type() != CV_8U ) cvtColor( image, grayImage, COLOR_BGR2GRAY );
std::vector<Point2f> corners;
goodFeaturesToTrack( grayImage, corners, nfeatures, qualityLevel, minDistance, mask,
@@ -346,7 +346,7 @@ void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, std::vector<Ke
src = dst;
if( !mask.empty() )
resize( dilated_mask, src_mask, src.size(), 0, 0, CV_INTER_AREA );
resize( dilated_mask, src_mask, src.size(), 0, 0, INTER_AREA );
}
}

View File

@@ -60,7 +60,7 @@ static inline void _drawKeypoint( Mat& img, const KeyPoint& p, const Scalar& col
int radius = cvRound(p.size/2 * draw_multiplier); // KeyPoint::size is a diameter
// draw the circles around keypoints with the keypoints size
circle( img, center, radius, color, 1, CV_AA, draw_shift_bits );
circle( img, center, radius, color, 1, LINE_AA, draw_shift_bits );
// draw orientation of the keypoint, if it is applicable
if( p.angle != -1 )
@@ -69,14 +69,14 @@ static inline void _drawKeypoint( Mat& img, const KeyPoint& p, const Scalar& col
Point orient( cvRound(cos(srcAngleRad)*radius ),
cvRound(sin(srcAngleRad)*radius )
);
line( img, center, center+orient, color, 1, CV_AA, draw_shift_bits );
line( img, center, center+orient, color, 1, LINE_AA, draw_shift_bits );
}
#if 0
else
{
// draw center with R=1
int radius = 1 * draw_multiplier;
circle( img, center, radius, color, 1, CV_AA, draw_shift_bits );
circle( img, center, radius, color, 1, LINE_AA, draw_shift_bits );
}
#endif
}
@@ -84,7 +84,7 @@ static inline void _drawKeypoint( Mat& img, const KeyPoint& p, const Scalar& col
{
// draw center with R=3
int radius = 3 * draw_multiplier;
circle( img, center, radius, color, 1, CV_AA, draw_shift_bits );
circle( img, center, radius, color, 1, LINE_AA, draw_shift_bits );
}
}
@@ -99,11 +99,11 @@ void drawKeypoints( const Mat& image, const std::vector<KeyPoint>& keypoints, Ma
}
else if( image.type() == CV_8UC1 )
{
cvtColor( image, outImage, CV_GRAY2BGR );
cvtColor( image, outImage, COLOR_GRAY2BGR );
}
else
{
CV_Error( CV_StsBadArg, "Incorrect type of input image.\n" );
CV_Error( Error::StsBadArg, "Incorrect type of input image.\n" );
}
}
@@ -129,7 +129,7 @@ static void _prepareImgAndDrawKeypoints( const Mat& img1, const std::vector<KeyP
if( flags & DrawMatchesFlags::DRAW_OVER_OUTIMG )
{
if( size.width > outImg.cols || size.height > outImg.rows )
CV_Error( CV_StsBadSize, "outImg has size less than need to draw img1 and img2 together" );
CV_Error( Error::StsBadSize, "outImg has size less than need to draw img1 and img2 together" );
outImg1 = outImg( Rect(0, 0, img1.cols, img1.rows) );
outImg2 = outImg( Rect(img1.cols, 0, img2.cols, img2.rows) );
}
@@ -141,12 +141,12 @@ static void _prepareImgAndDrawKeypoints( const Mat& img1, const std::vector<KeyP
outImg2 = outImg( Rect(img1.cols, 0, img2.cols, img2.rows) );
if( img1.type() == CV_8U )
cvtColor( img1, outImg1, CV_GRAY2BGR );
cvtColor( img1, outImg1, COLOR_GRAY2BGR );
else
img1.copyTo( outImg1 );
if( img2.type() == CV_8U )
cvtColor( img2, outImg2, CV_GRAY2BGR );
cvtColor( img2, outImg2, COLOR_GRAY2BGR );
else
img2.copyTo( outImg2 );
}
@@ -179,7 +179,7 @@ static inline void _drawMatch( Mat& outImg, Mat& outImg1, Mat& outImg2 ,
line( outImg,
Point(cvRound(pt1.x*draw_multiplier), cvRound(pt1.y*draw_multiplier)),
Point(cvRound(dpt2.x*draw_multiplier), cvRound(dpt2.y*draw_multiplier)),
color, 1, CV_AA, draw_shift_bits );
color, 1, LINE_AA, draw_shift_bits );
}
void drawMatches( const Mat& img1, const std::vector<KeyPoint>& keypoints1,
@@ -189,7 +189,7 @@ void drawMatches( const Mat& img1, const std::vector<KeyPoint>& keypoints1,
const std::vector<char>& matchesMask, int flags )
{
if( !matchesMask.empty() && matchesMask.size() != matches1to2.size() )
CV_Error( CV_StsBadSize, "matchesMask must have the same size as matches1to2" );
CV_Error( Error::StsBadSize, "matchesMask must have the same size as matches1to2" );
Mat outImg1, outImg2;
_prepareImgAndDrawKeypoints( img1, keypoints1, img2, keypoints2,
@@ -218,7 +218,7 @@ void drawMatches( const Mat& img1, const std::vector<KeyPoint>& keypoints1,
const std::vector<std::vector<char> >& matchesMask, int flags )
{
if( !matchesMask.empty() && matchesMask.size() != matches1to2.size() )
CV_Error( CV_StsBadSize, "matchesMask must have the same size as matches1to2" );
CV_Error( Error::StsBadSize, "matchesMask must have the same size as matches1to2" );
Mat outImg1, outImg2;
_prepareImgAndDrawKeypoints( img1, keypoints1, img2, keypoints2,

View File

@@ -185,7 +185,7 @@ void EllipticKeyPoint::convert( const std::vector<KeyPoint>& src, std::vector<El
for( size_t i = 0; i < src.size(); i++ )
{
float rad = src[i].size/2;
assert( rad );
CV_Assert( rad );
float fac = 1.f/(rad*rad);
dst[i] = EllipticKeyPoint( src[i].pt, Scalar(fac, 0, fac) );
}
@@ -210,7 +210,7 @@ void EllipticKeyPoint::calcProjection( const std::vector<EllipticKeyPoint>& src,
{
if( !src.empty() )
{
assert( !H.empty() && H.cols == 3 && H.rows == 3);
CV_Assert( !H.empty() && H.cols == 3 && H.rows == 3);
dst.resize(src.size());
std::vector<EllipticKeyPoint>::const_iterator srcIt = src.begin();
std::vector<EllipticKeyPoint>::iterator dstIt = dst.begin();
@@ -462,7 +462,7 @@ void cv::evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H
keypoints2 = _keypoints2 != 0 ? _keypoints2 : &buf2;
if( (keypoints1->empty() || keypoints2->empty()) && fdetector.empty() )
CV_Error( CV_StsBadArg, "fdetector must not be empty when keypoints1 or keypoints2 is empty" );
CV_Error( Error::StsBadArg, "fdetector must not be empty when keypoints1 or keypoints2 is empty" );
if( keypoints1->empty() )
fdetector->detect( img1, *keypoints1 );
@@ -573,15 +573,15 @@ void cv::evaluateGenericDescriptorMatcher( const Mat& img1, const Mat& img2, con
correctMatches1to2Mask = _correctMatches1to2Mask != 0 ? _correctMatches1to2Mask : &buf2;
if( keypoints1.empty() )
CV_Error( CV_StsBadArg, "keypoints1 must not be empty" );
CV_Error( Error::StsBadArg, "keypoints1 must not be empty" );
if( matches1to2->empty() && dmatcher.empty() )
CV_Error( CV_StsBadArg, "dmatch must not be empty when matches1to2 is empty" );
CV_Error( Error::StsBadArg, "dmatch must not be empty when matches1to2 is empty" );
bool computeKeypoints2ByPrj = keypoints2.empty();
if( computeKeypoints2ByPrj )
{
assert(0);
CV_Error(Error::StsNotImplemented, "");
// TODO: add computing keypoints2 from keypoints1 using H1to2
}

View File

@@ -286,7 +286,7 @@ FastFeatureDetector::FastFeatureDetector( int _threshold, bool _nonmaxSuppressio
void FastFeatureDetector::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask ) const
{
Mat grayImage = image;
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
if( image.type() != CV_8U ) cvtColor( image, grayImage, COLOR_BGR2GRAY );
FAST( grayImage, keypoints, threshold, nonmaxSuppression, type );
KeyPointsFilter::runByPixelsMask( keypoints, mask );
}

View File

@@ -206,7 +206,7 @@ void FREAK::buildPattern()
descriptionPairs[i] = allPairs[selectedPairs0.at(i)];
}
else {
CV_Error(CV_StsVecLengthErr, "Input vector does not match the required size");
CV_Error(Error::StsVecLengthErr, "Input vector does not match the required size");
}
}
else { // default selected pairs
@@ -548,7 +548,7 @@ std::vector<int> FREAK::selectPairs(const std::vector<Mat>& images
int idxB = pairStat[m].idx;
double corr(0);
// compute correlation between 2 pairs
corr = fabs(compareHist(descriptorsFloat.col(idxA), descriptorsFloat.col(idxB), CV_COMP_CORREL));
corr = fabs(compareHist(descriptorsFloat.col(idxA), descriptorsFloat.col(idxB), HISTCMP_CORREL));
if( corr > corrMax ) {
corrMax = corr;
@@ -575,7 +575,7 @@ std::vector<int> FREAK::selectPairs(const std::vector<Mat>& images
else {
if( verbose )
std::cout << "correlation threshold too small (restrictive)" << std::endl;
CV_Error(CV_StsError, "correlation threshold too small (restrictive)");
CV_Error(Error::StsError, "correlation threshold too small (restrictive)");
}
extAll = false;
return idxBestPairs;

View File

@@ -112,7 +112,7 @@ void DescriptorMatcher::DescriptorCollection::set( const std::vector<Mat>& descr
dim = descriptors[0].cols;
type = descriptors[0].type();
}
assert( dim > 0 );
CV_Assert( dim > 0 );
int count = startIdxs[imageCount-1] + descriptors[imageCount-1].rows;
@@ -484,7 +484,7 @@ Ptr<DescriptorMatcher> DescriptorMatcher::create( const String& descriptorMatche
dm = new BFMatcher(NORM_HAMMING2);
}
else
CV_Error( CV_StsBadArg, "Unknown matcher name" );
CV_Error( Error::StsBadArg, "Unknown matcher name" );
return dm;
}
@@ -727,7 +727,7 @@ Ptr<DescriptorMatcher> FlannBasedMatcher::clone( bool emptyTrainData ) const
FlannBasedMatcher* matcher = new FlannBasedMatcher(indexParams, searchParams);
if( !emptyTrainData )
{
CV_Error( CV_StsNotImplemented, "deep clone functionality is not implemented, because "
CV_Error( Error::StsNotImplemented, "deep clone functionality is not implemented, because "
"Flann::Index has not copy constructor or clone method ");
//matcher->flannIndex;
matcher->addedDescCount = addedDescCount;

View File

@@ -40,6 +40,7 @@
*/
#include "precomp.hpp"
#include "opencv2/imgproc/imgproc_c.h"
namespace cv
{

View File

@@ -240,7 +240,7 @@ static void computeOrbDescriptor(const KeyPoint& kpt,
}
}
else
CV_Error( CV_StsBadSize, "Wrong WTA_K. It can be only 2, 3 or 4." );
CV_Error( Error::StsBadSize, "Wrong WTA_K. It can be only 2, 3 or 4." );
#undef GET_VALUE
}
@@ -738,7 +738,7 @@ void ORB::operator()( InputArray _image, InputArray _mask, std::vector<KeyPoint>
Mat image = _image.getMat(), mask = _mask.getMat();
if( image.type() != CV_8UC1 )
cvtColor(_image, image, CV_BGR2GRAY);
cvtColor(_image, image, COLOR_BGR2GRAY);
int levelsNum = this->nlevels;

View File

@@ -45,7 +45,6 @@
#include "opencv2/features2d.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp"

View File

@@ -114,7 +114,7 @@ StarDetectorComputeResponses( const Mat& img, Mat& responses, Mat& sizes, int ma
#if CV_SSE2
__m128 invSizes4[MAX_PATTERN][2];
__m128 sizes1_4[MAX_PATTERN];
Cv32suf absmask;
union { int i; float f; } absmask;
absmask.i = 0x7fffffff;
volatile bool useSIMD = cv::checkHardwareSupport(CV_CPU_SSE2);
#endif
@@ -429,7 +429,7 @@ StarDetector::StarDetector(int _maxSize, int _responseThreshold,
void StarDetector::detectImpl( const Mat& image, std::vector<KeyPoint>& keypoints, const Mat& mask ) const
{
Mat grayImage = image;
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
if( image.type() != CV_8U ) cvtColor( image, grayImage, COLOR_BGR2GRAY );
(*this)(grayImage, keypoints);
KeyPointsFilter::runByPixelsMask( keypoints, mask );