Commit ca0f70b2 authored by biagio montesano's avatar biagio montesano

Corrected errors on matching

parent 53fc0861
......@@ -190,12 +190,14 @@ class CV_EXPORTS_W BinaryDescriptor : public Algorithm
/* requires descriptors computation (only one image) */
CV_WRAP
void compute( const Mat& image, CV_OUT CV_IN_OUT std::vector<KeyLine>& keylines, CV_OUT Mat& descriptors, bool returnFloatDescr = false ) const;
void compute( const Mat& image, CV_OUT CV_IN_OUT std::vector<KeyLine>& keylines, CV_OUT Mat& descriptors, bool returnFloatDescr = false,
bool useDetectionData = false ) const;
/* requires descriptors computation (more than one image) */
CV_WRAP
void compute( const std::vector<Mat>& images, std::vector<std::vector<KeyLine> >& keylines, std::vector<Mat>& descriptors, bool returnFloatDescr =
false ) const;
false,
bool useDetectionData = false ) const;
/* returns descriptor size */
CV_WRAP
......@@ -219,17 +221,24 @@ class CV_EXPORTS_W BinaryDescriptor : public Algorithm
virtual void detectImpl( const Mat& imageSrc, std::vector<KeyLine>& keylines, const Mat& mask = Mat() ) const;
/* implementation of descriptors' computation */
virtual void computeImpl( const Mat& imageSrc, std::vector<KeyLine>& keylines, Mat& descriptors, bool returnFloatDescr ) const;
virtual void computeImpl( const Mat& imageSrc, std::vector<KeyLine>& keylines, Mat& descriptors, bool returnFloatDescr,
bool useDetectionData ) const;
/* function inherited from Algorithm */
AlgorithmInfo* info() const;
private:
/* compute Gaussian pyramids */
void computeGaussianPyramid( const Mat& image );
/* compute Sobel's derivatives */
void computeSobel( const Mat& image );
/* conversion of an LBD descriptor to its binary representation */
unsigned char binaryConversion( float* f1, float* f2 );
/* compute LBD descriptors using EDLine extractor */
int computeLBD( ScaleLines &keyLines );
int computeLBD( ScaleLines &keyLines, bool useDetectionData = false );
/* gathers lines in groups using EDLine extractor.
Each group contains the same line, detected in different octaves */
......@@ -251,7 +260,13 @@ class CV_EXPORTS_W BinaryDescriptor : public Algorithm
*from the EDLineDetector class without extra computation cost. Another reason is that, if we use
*a single EDLineDetector to detect lines in different octave of images, then we need to allocate and release
*memory for gradient images (dxImg, dyImg, gImg) repeatedly for their varying size*/
std::vector<EDLineDetector*> edLineVec_;
std::vector<Ptr<EDLineDetector> > edLineVec_;
/* Sobel's derivatives */
std::vector<cv::Mat> dxImg_vector, dyImg_vector;
/* Gaussian pyramid */
std::vector<cv::Mat> octaveImages;
};
......
......@@ -104,17 +104,17 @@ int main( int argc, char** argv )
bd->detect( imageMat, keylines, mask );
/* select only lines from first octave */
std::vector<KeyLine> octave0;
/*std::vector<KeyLine> octave0;
for ( size_t i = 0; i < keylines.size(); i++ )
{
if( keylines[i].octave == 0 )
octave0.push_back( keylines[i] );
}
}*/
/* compute descriptors */
cv::Mat descriptors;
bd->compute( imageMat, octave0, descriptors, 1);
writeMat( descriptors, "bd_descriptors", 0 );
bd->compute( imageMat, keylines, descriptors);
writeMat( descriptors, "bd_descriptors", 1 );
}
......@@ -63,6 +63,222 @@ static void help()
}
inline void writeMat( cv::Mat m, std::string name, int n )
{
std::stringstream ss;
std::string s;
ss << n;
ss >> s;
std::string fileNameConf = name + s;
cv::FileStorage fsConf( fileNameConf, cv::FileStorage::WRITE );
fsConf << "m" << m;
fsConf.release();
}
inline void loadMat( cv::Mat& m, std::string name )
{
cv::FileStorage fsConf( name, cv::FileStorage::READ );
fsConf["m"] >> m;
fsConf.release();
}
int binaryDist( const uchar * p_descriptor, const uchar * p_trained )
{
int count = 0;
for ( int i = 0; i < 32; i++ )
{
uchar a = p_descriptor[i];
uchar a1 = a & 1;
uchar a2 = a & 2;
uchar a4 = a & 4;
uchar a8 = a & 8;
uchar a16 = a & 16;
uchar a32 = a & 32;
uchar a64 = a & 64;
uchar a128 = a & 128;
uchar b = p_trained[i];
uchar b1 = b & 1;
uchar b2 = b & 2;
uchar b4 = b & 4;
uchar b8 = b & 8;
uchar b16 = b & 16;
uchar b32 = b & 32;
uchar b64 = b & 64;
uchar b128 = b & 128;
if( a1 == b1 )
count++;
if( a2 == b2 )
count++;
if( a4 == b4 )
count++;
if( a8 == b8 )
count++;
if( a16 == b16 )
count++;
if( a32 == b32 )
count++;
if( a64 == b64 )
count++;
if( a128 == b128 )
count++;
}
return count;
}
std::vector<DMatch> computeBruteForceSingleImages( Mat descriptor_query, Mat descriptor_db )
{
//BRUTE FORCE//
std::vector<DMatch> matches;
for ( int i = 0; i < descriptor_query.rows; i++ )
{
const uchar * p_descriptor = ( descriptor_query.ptr() ) + i * 32;
const uchar * p_trained = descriptor_db.ptr();
int min_dist = 0;
int min_index = -1;
for ( int k = 0; k < descriptor_db.rows; k++ )
{
int dist = binaryDist( p_descriptor, p_trained + ( k * 32 ) );
if( dist > min_dist )
{
min_dist = dist;
min_index = k;
}
}
DMatch m( i, min_index, (float) min_dist );
matches.push_back( m );
}
return matches;
}
void computeDescr( Mat sm_image, Mat img )
{
Mat query = sm_image.clone();
Mat db = img.clone();
Ptr<BinaryDescriptor> bd = BinaryDescriptor::createBinaryDescriptor();
/* compute lines */
std::vector<KeyLine> keylines1, keylines2;
bd->detect( query, keylines1 );
bd->detect( db, keylines2 );
/* compute descriptors */
cv::Mat descr1, descr2;
bd->compute( query, keylines1, descr1 );
bd->compute( db, keylines2, descr2 );
std::vector<cv::KeyPoint> keypoints_1;
std::vector<cv::KeyPoint> keypoints_2;
std::vector<std::pair<cv::KeyPoint, int> > v_pair_k1;
std::vector<std::pair<cv::KeyPoint, int> > v_pair_k2;
for ( int i = 0; i < keylines1.size(); i++ )
{
KeyLine l = keylines1[i];
keypoints_1.push_back( cv::KeyPoint( l.startPointX, l.startPointY, 8, l.angle ) );
v_pair_k1.push_back( std::make_pair( cv::KeyPoint( l.startPointX, l.startPointY, 8, l.angle ), i ) );
}
for ( int i = 0; i < keylines2.size(); i++ )
{
KeyLine l = keylines2[i];
keypoints_2.push_back( cv::KeyPoint( l.startPointX, l.startPointY, 8, l.angle ) );
v_pair_k2.push_back( std::make_pair( cv::KeyPoint( l.startPointX, l.startPointY, 8, l.angle ), i ) );
}
// vector<DMatch> matches = ImageFinderFLANN::computeBruteForceSingleImages(purged_descriptor_query, purged_descriptor_db );
std::vector<DMatch> matches = computeBruteForceSingleImages( descr1, descr2 );
Mat img_draw_matches, img_draw_matches_debug;
std::vector<DMatch> good_matches;
int thresh_good = 200;
for ( int i = 0; i < matches.size(); i++ )
{
if( matches[i].distance > thresh_good )
{
good_matches.push_back( matches[i] );
}
}
srand( (unsigned) time( 0 ) );
int lowest = 100, highest = 255;
int range = ( highest - lowest ) + 1;
unsigned int r, g, b;
//DISEGNO MATCHES
std::vector<cv::KeyPoint> fake_k1;
std::vector<cv::KeyPoint> fake_k2;
std::vector<cv::DMatch> fake_match;
drawMatches( sm_image, fake_k1, img, fake_k2, fake_match, img_draw_matches, Scalar::all( -1 ), Scalar::all( -1 ), Mat(),
DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
for ( int i = 0; i < keylines1.size(); i++ )
{
KeyLine line = keylines1[i];
cv::Point startP( line.sPointInOctaveX, line.sPointInOctaveY );
cv::Point endP( line.ePointInOctaveX, line.ePointInOctaveY );
cv::Point midP( ( startP.x + endP.x ) / 2, ( startP.y + endP.y ) / 2 );
//cv::putText(img_draw_matches, std::to_string(i), midP, 1, 1, Scalar(255,0,0), 1 );
cv::line( img_draw_matches, startP, endP, Scalar( 0, 0, 255 ) );
}
for ( int i = 0; i < keylines2.size(); i++ )
{
KeyLine line = keylines2[i];
cv::Point startP( line.sPointInOctaveX + sm_image.cols, line.sPointInOctaveY );
cv::Point endP( line.ePointInOctaveX + sm_image.cols, line.ePointInOctaveY );
cv::Point midP( ( startP.x + endP.x ) / 2, ( startP.y + endP.y ) / 2 );
//cv::putText(img_draw_matches, std::to_string(i), midP, 1, 1, Scalar(255,0,0), 1 );
cv::line( img_draw_matches, startP, endP, Scalar( 0, 0, 255 ) );
}
for ( int i = 0; i < good_matches.size(); i++ )
{
r = lowest + int( rand() % range );
g = lowest + int( rand() % range );
b = lowest + int( rand() % range );
std::pair<cv::KeyPoint, int> tmp_pair_1 = v_pair_k1[good_matches[i].queryIdx];
std::pair<cv::KeyPoint, int> tmp_pair_2 = v_pair_k2[good_matches[i].trainIdx];
cv::KeyPoint tmp_key_1 = tmp_pair_1.first;
cv::KeyPoint tmp_key_2 = tmp_pair_2.first;
KeyLine line1 = keylines1[tmp_pair_1.second];
cv::Point startP1( line1.sPointInOctaveX, line1.sPointInOctaveY );
cv::Point endP1( line1.ePointInOctaveX, line1.ePointInOctaveY );
cv::line( img_draw_matches, startP1, endP1, Scalar( r, g, b ), 2 );
KeyLine line2 = keylines2[tmp_pair_2.second];
cv::Point startP2( line2.sPointInOctaveX + sm_image.cols, line2.sPointInOctaveY );
cv::Point endP2( line2.ePointInOctaveX + sm_image.cols, line2.ePointInOctaveY );
cv::line( img_draw_matches, startP2, endP2, Scalar( r, g, b ), 2 );
cv::Point startP_connect( tmp_key_1.pt.x, tmp_key_1.pt.y );
cv::Point endP_connect( tmp_key_2.pt.x + sm_image.cols, tmp_key_2.pt.y );
cv::line( img_draw_matches, startP_connect, endP_connect, Scalar( r, g, b ), 2 );
}
imshow( "Imshow", img_draw_matches );
waitKey();
}
int main( int argc, char** argv )
{
/* get parameters from comand line */
......@@ -80,7 +296,6 @@ int main( int argc, char** argv )
cv::Mat imageMat1 = imread( image_path1, 1 );
cv::Mat imageMat2 = imread( image_path2, 1 );
waitKey();
if( imageMat1.data == NULL || imageMat2.data == NULL )
{
std::cout << "Error, images could not be loaded. Please, check their path" << std::endl;
......@@ -95,13 +310,21 @@ int main( int argc, char** argv )
/* compute lines */
std::vector<KeyLine> keylines1, keylines2;
bd->detect( imageMat1, keylines1, mask1 );
bd->detect( imageMat2, keylines2, mask2 );
/* compute descriptors */
cv::Mat descr1, descr2;
bd->compute( imageMat1, keylines1, descr1 );
bd->compute( imageMat2, keylines2, descr2 );
bd->detect( imageMat2, keylines2, mask2 );
bd->detect( imageMat1, keylines1, mask1 );
//compute descriptors
/* cv::Mat descr1, descr2;*/
cv::Mat descr1, descr2;
bd->compute( imageMat1, keylines1, descr1 );
bd->compute( imageMat2, keylines2, descr2 );
//cv::Mat descr1, descr2;
//( *bd )( imageMat1, mask1, keylines1, descr1, true, false );
//( *bd )( imageMat2, mask2, keylines2, descr2, true, false );
/* create a BinaryDescriptorMatcher object */
Ptr<BinaryDescriptorMatcher> bdm = BinaryDescriptorMatcher::createBinaryDescriptorMatcher();
......@@ -109,14 +332,59 @@ int main( int argc, char** argv )
/* require match */
std::vector<DMatch> matches;
bdm->match( descr1, descr2, matches );
/* Mat newd1, newd2;
loadMat(newd1, "bd_descriptors0");
loadMat(newd2, "bd_descriptors1");*/
//matches = computeBruteForceSingleImages(newd1, newd2);
//matches = computeBruteForceSingleImages( descr1, descr2 );
std::vector<DMatch> good_matches;
int thresh_good = 25;
for(int i = 0; i<matches.size(); i++)
{
if(matches[i].distance < thresh_good)
{
good_matches.push_back(matches[i]);
}
}
/* plot matches */
cv::Mat outImg;
std::vector<char> mask( matches.size(), 1 );
drawLineMatches( imageMat1, keylines1, imageMat2, keylines2, matches, outImg, Scalar::all( -1 ), Scalar::all( -1 ), mask,
drawLineMatches( imageMat1, keylines1, imageMat2, keylines2, good_matches , outImg, Scalar::all( -1 ), Scalar::all( -1 ), mask,
DrawLinesMatchesFlags::DEFAULT );
imshow( "Matches", outImg );
waitKey();
Ptr<LSDDetector> lsd = LSDDetector::createLSDDetector();
std::vector<KeyLine> klsd1, klsd2;
Mat lsd_descr1, lsd_descr2;
lsd->detect(imageMat1, klsd1, 2, 2, mask1);
lsd->detect(imageMat2, klsd2, 2, 2, mask2);
bd->compute( imageMat1, klsd1, lsd_descr1 );
bd->compute( imageMat2, klsd2, lsd_descr2 );
std::vector<DMatch> lsd_matches;
bdm->match( lsd_descr1, lsd_descr2, lsd_matches);
good_matches.clear();
for(int i = 0; i<lsd_matches.size(); i++)
{
if(lsd_matches[i].distance < thresh_good)
{
good_matches.push_back(lsd_matches[i]);
}
}
cv::Mat lsd_outImg;
std::vector<char> lsd_mask( matches.size(), 1 );
drawLineMatches( imageMat1, klsd1, imageMat2, klsd2, good_matches , lsd_outImg, Scalar::all( -1 ), Scalar::all( -1 ), lsd_mask,
DrawLinesMatchesFlags::DEFAULT );
imshow("LSD matches", lsd_outImg);
waitKey();
}
......@@ -156,6 +156,7 @@ void LSDDetector::detectImpl( const Mat& imageSrc, std::vector<KeyLine>& keyline
}
/* create keylines */
int class_counter = -1;
for ( int j = 0; j < (int) lines_lsd.size(); j++ )
{
for ( int k = 0; k < (int) lines_lsd[j].size(); k++ )
......@@ -182,7 +183,7 @@ void LSDDetector::detectImpl( const Mat& imageSrc, std::vector<KeyLine>& keyline
kl.numOfPixels = li.count;
kl.angle = atan2( ( kl.endPointY - kl.startPointY ), ( kl.endPointX - kl.startPointX ) );
kl.class_id = k;
kl.class_id = ++class_counter;
kl.octave = j;
kl.size = ( kl.endPointX - kl.startPointX ) * ( kl.endPointY - kl.startPointY );
kl.response = kl.lineLength / max( gaussianPyrs[j].cols, gaussianPyrs[j].rows );
......
......@@ -154,13 +154,12 @@ Ptr<BinaryDescriptor> BinaryDescriptor::createBinaryDescriptor( Params parameter
BinaryDescriptor::BinaryDescriptor( const BinaryDescriptor::Params &parameters ) :
params( parameters )
{
/* reserve enough space for EDLine objects and images in Gaussian pyramid */
edLineVec_.resize( params.numOfOctave_ );
images_sizes.resize( params.numOfOctave_ );
for ( int i = 0; i < params.numOfOctave_; i++ )
edLineVec_[i] = new EDLineDetector;
edLineVec_[i] = Ptr<EDLineDetector>( new EDLineDetector() );
/* prepare a vector to host local weights F_l*/
gaussCoefL_.resize( params.widthOfBand_ * 3 );
......@@ -208,22 +207,40 @@ void BinaryDescriptor::operator()( InputArray image, InputArray mask, CV_OUT std
imageMat = image.getMat();
maskMat = mask.getMat();
/* require drawing KeyLines detection if demanded */
if( !useProvidedKeyLines )
{
keylines.clear();
BinaryDescriptor *bn = const_cast<BinaryDescriptor*>( this );
bn->edLineVec_.clear();
bn->edLineVec_.resize( params.numOfOctave_ );
for ( int i = 0; i < params.numOfOctave_; i++ )
bn->edLineVec_[i] = Ptr<EDLineDetector>( new EDLineDetector() );
detectImpl( imageMat, keylines, maskMat );
}
/* initialize output matrix */
descriptors.create( Size( 32, (int) keylines.size() ), CV_8UC1 );
//descriptors.create( Size( 32, (int) keylines.size() ), CV_8UC1 );
/* store reference to output matrix */
descrMat = descriptors.getMat();
//descrMat = descriptors.getMat();
/* require drawing KeyLines detection if demanded */
/* compute descriptors */
if( !useProvidedKeyLines )
detectImpl( imageMat, keylines, maskMat );
computeImpl( imageMat, keylines, descrMat, returnFloatDescr, true );
/* compute descriptors */
computeImpl( imageMat, keylines, descrMat, returnFloatDescr );
else
computeImpl( imageMat, keylines, descrMat, returnFloatDescr, false );
descrMat.copyTo(descriptors);
}
BinaryDescriptor::~BinaryDescriptor()
{
}
/* read parameters from a FileNode object and store them (class function ) */
......@@ -268,6 +285,57 @@ static inline int get2Pow( int i )
}
}
/* compute Gaussian pyramids */
void BinaryDescriptor::computeGaussianPyramid( const Mat& image )
{
/* clear class fields */
images_sizes.clear();
octaveImages.clear();
/* insert input image into pyramid */
cv::Mat currentMat = image.clone();
cv::GaussianBlur( currentMat, currentMat, cv::Size( 5, 5 ), 1 );
octaveImages.push_back( currentMat );
images_sizes.push_back( currentMat.size() );
/* fill Gaussian pyramid */
for ( int pyrCounter = 1; pyrCounter < params.numOfOctave_; pyrCounter++ )
{
/* compute and store next image in pyramid and its size */
pyrDown( currentMat, currentMat, Size( currentMat.cols / params.reductionRatio, currentMat.rows / params.reductionRatio ) );
octaveImages.push_back( currentMat );
images_sizes.push_back( currentMat.size() );
}
}
/* compute Sobel's derivatives */
void BinaryDescriptor::computeSobel( const cv::Mat& image )
{
std::cout << "SOBEL" << std::endl;
/* compute Gaussian pyramids */
computeGaussianPyramid( image );
/* reinitialize class structures */
dxImg_vector.clear();
dyImg_vector.clear();
dxImg_vector.resize( params.numOfOctave_ );
dyImg_vector.resize( params.numOfOctave_ );
std::cout<<"octaveImages.size(): "<<octaveImages.size()<<std::endl;
/* compute derivatives */
for ( size_t sobelCnt = 0; sobelCnt < octaveImages.size(); sobelCnt++ )
{
dxImg_vector[sobelCnt].create( images_sizes[sobelCnt].height, images_sizes[sobelCnt].width, CV_16SC1 );
dyImg_vector[sobelCnt].create( images_sizes[sobelCnt].height, images_sizes[sobelCnt].width, CV_16SC1 );
cv::Sobel( octaveImages[sobelCnt], dxImg_vector[sobelCnt], CV_16SC1, 1, 0, 3 );
cv::Sobel( octaveImages[sobelCnt], dyImg_vector[sobelCnt], CV_16SC1, 0, 1, 3 );
}
}
/* utility function for conversion of an LBD descriptor to its binary representation */
unsigned char BinaryDescriptor::binaryConversion( float* f1, float* f2 )
{
......@@ -309,11 +377,19 @@ void BinaryDescriptor::detect( const std::vector<Mat>& images, std::vector<std::
void BinaryDescriptor::detectImpl( const Mat& imageSrc, std::vector<KeyLine>& keylines, const Mat& mask ) const
{
std::cout<<"n channels imageSRC: "<<imageSrc.channels()<<std::endl;
cv::Mat image;
if( imageSrc.channels() != 1 )
{
std::cout<<"entra1"<<std::endl;
cvtColor( imageSrc, image, COLOR_BGR2GRAY );
}
else
{
std::cout<<"entra2"<<std::endl;
image = imageSrc.clone();
//imageSrc.copyTo(image);
}
/*check whether image depth is different from 0 */
if( image.depth() != 0 )
......@@ -376,22 +452,23 @@ void BinaryDescriptor::detectImpl( const Mat& imageSrc, std::vector<KeyLine>& ke
}
/* requires descriptors computation (only one image) */
void BinaryDescriptor::compute( const Mat& image, CV_OUT CV_IN_OUT std::vector<KeyLine>& keylines, CV_OUT Mat& descriptors,
bool returnFloatDescr ) const
void BinaryDescriptor::compute( const Mat& image, CV_OUT CV_IN_OUT std::vector<KeyLine>& keylines, CV_OUT Mat& descriptors, bool returnFloatDescr,
bool useDetectionData ) const
{
computeImpl( image, keylines, descriptors, returnFloatDescr );
computeImpl( image, keylines, descriptors, returnFloatDescr, useDetectionData );
}
/* requires descriptors computation (more than one image) */
void BinaryDescriptor::compute( const std::vector<Mat>& images, std::vector<std::vector<KeyLine> >& keylines, std::vector<Mat>& descriptors,
bool returnFloatDescr ) const
bool returnFloatDescr, bool useDetectionData ) const
{
for ( size_t i = 0; i < images.size(); i++ )
computeImpl( images[i], keylines[i], descriptors[i], returnFloatDescr );
computeImpl( images[i], keylines[i], descriptors[i], returnFloatDescr, useDetectionData );
}
/* implementation of descriptors computation */
void BinaryDescriptor::computeImpl( const Mat& imageSrc, std::vector<KeyLine>& keylines, Mat& descriptors, bool returnFloatDescr ) const
void BinaryDescriptor::computeImpl( const Mat& imageSrc, std::vector<KeyLine>& keylines, Mat& descriptors, bool returnFloatDescr,
bool useDetectionData ) const
{
/* convert input image to gray scale */
cv::Mat image;
......@@ -411,6 +488,11 @@ void BinaryDescriptor::computeImpl( const Mat& imageSrc, std::vector<KeyLine>& k
return;
}
BinaryDescriptor* bd = const_cast<BinaryDescriptor*>( this );
if( !useDetectionData )
bd->computeSobel( image );
/* get maximum class_id */
int numLines = 0;
for ( size_t l = 0; l < keylines.size(); l++ )
......@@ -472,8 +554,7 @@ void BinaryDescriptor::computeImpl( const Mat& imageSrc, std::vector<KeyLine>& k
}
/* compute LBD descriptors */
BinaryDescriptor* bd = const_cast<BinaryDescriptor*>( this );
bd->computeLBD( sl );
bd->computeLBD( sl, useDetectionData );
/* resize output matrix */
if( !returnFloatDescr )
......@@ -509,7 +590,6 @@ void BinaryDescriptor::computeImpl( const Mat& imageSrc, std::vector<KeyLine>& k
else
{
std::cout << "Descrittori float" << std::endl;
/* get a pointer to correspondent row in output matrix */
float* pointerToRow = descriptors.ptr<float>( originalIndex );
......@@ -866,7 +946,7 @@ int BinaryDescriptor::OctaveKeyLines( cv::Mat& image, ScaleLines &keyLines )
return 1;
}
int BinaryDescriptor::computeLBD( ScaleLines &keyLines )
int BinaryDescriptor::computeLBD( ScaleLines &keyLines, bool useDetectionData )
{
//the default length of the band is the line length.
short numOfFinalLine = (short) keyLines.size();
......@@ -922,14 +1002,29 @@ int BinaryDescriptor::computeLBD( ScaleLines &keyLines )
pSingleLine = & ( keyLines[lineIDInScaleVec][lineIDInSameLine] );
octaveCount = (short) pSingleLine->octaveCount;
/* retrieve associated dxImg and dyImg */
pdxImg = edLineVec_[octaveCount]->dxImg_.ptr<short>();
pdyImg = edLineVec_[octaveCount]->dyImg_.ptr<short>();
if( useDetectionData )
{
/* retrieve associated dxImg and dyImg */
pdxImg = edLineVec_[octaveCount]->dxImg_.ptr<short>();
pdyImg = edLineVec_[octaveCount]->dyImg_.ptr<short>();
/* get image size to work on from real one */
realWidth = (short) edLineVec_[octaveCount]->imageWidth;
imageWidth = realWidth - 1;
imageHeight = (short) ( edLineVec_[octaveCount]->imageHeight - 1 );
}
/* get image size to work on from real one */
realWidth = (short) edLineVec_[octaveCount]->imageWidth;
imageWidth = realWidth - 1;
imageHeight = (short) ( edLineVec_[octaveCount]->imageHeight - 1 );
else
{
/* retrieve associated dxImg and dyImg */
pdxImg = dxImg_vector[octaveCount].ptr<short>();
pdyImg = dyImg_vector[octaveCount].ptr<short>();
/* get image size to work on from real one */
realWidth = (short) images_sizes[octaveCount].width;
imageWidth = realWidth - 1;
imageHeight = (short) ( images_sizes[octaveCount].height - 1 );
}
/* initialize memory areas */
memset( pgdLBandSum, 0, numOfBitsBand );
......
......@@ -49,6 +49,12 @@ void drawLineMatches( const Mat& img1, const std::vector<KeyLine>& keylines1, co
const std::vector<char>& matchesMask, int flags )
{
if(img1.type() != img2.type())
{
std::cout << "Input images have different types" << std::endl;
CV_Assert(img1.type() == img2.type());
}
/* initialize output matrix (if necessary) */
if( flags == DrawLinesMatchesFlags::DEFAULT )
{
......
......@@ -123,11 +123,11 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
imageHeight = image.rows;
unsigned int pixelNum = imageWidth * imageHeight;
if( !smoothed )
/*if( !smoothed )
{ //input image hasn't been smoothed.
cv::Mat InImage = image.clone();
cv::GaussianBlur( InImage, image, cv::Size( ksize_, ksize_ ), sigma_ );
}
}*/
unsigned int edgePixelArraySize = pixelNum / 5;
unsigned int maxNumOfEdge = edgePixelArraySize / 20;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment