Commit 1f33b20b authored by biagio montesano's avatar biagio montesano

Removed some other warnings

parent e0da9f93
...@@ -107,8 +107,8 @@ int main( int argc, char** argv ) ...@@ -107,8 +107,8 @@ int main( int argc, char** argv )
int B = ( rand() % (int) ( 255 + 1 ) ); int B = ( rand() % (int) ( 255 + 1 ) );
/* get extremes of line */ /* get extremes of line */
Point pt1 = Point( kl.startPointX, kl.startPointY ); Point pt1 = Point2f( kl.startPointX, kl.startPointY );
Point pt2 = Point( kl.endPointX, kl.endPointY ); Point pt2 = Point2f( kl.endPointX, kl.endPointY );
/* draw line */ /* draw line */
line( output, pt1, pt2, Scalar( B, G, R ), 3 ); line( output, pt1, pt2, Scalar( B, G, R ), 3 );
......
...@@ -610,7 +610,7 @@ int BinaryDescriptor::OctaveKeyLines( cv::Mat& image, ScaleLines &keyLines ) ...@@ -610,7 +610,7 @@ int BinaryDescriptor::OctaveKeyLines( cv::Mat& image, ScaleLines &keyLines )
scale[0] = 1; scale[0] = 1;
for ( int octaveCount = 1; octaveCount < params.numOfOctave_; octaveCount++ ) for ( int octaveCount = 1; octaveCount < params.numOfOctave_; octaveCount++ )
{ {
scale[octaveCount] = factor * scale[octaveCount - 1]; scale[octaveCount] = (float) ( factor * scale[octaveCount - 1] );
} }
/* some variables' declarations */ /* some variables' declarations */
...@@ -1114,7 +1114,7 @@ int BinaryDescriptor::computeLBD( ScaleLines &keyLines ) ...@@ -1114,7 +1114,7 @@ int BinaryDescriptor::computeLBD( ScaleLines &keyLines )
desVec = pSingleLine->descriptor.data(); desVec = pSingleLine->descriptor.data();
int base = 0; int base = 0;
for ( short i = 0; i < (short) ( NUM_OF_BANDS * 8 ); ++base, i = base * 8 ) for ( short i = 0; i < (short) ( NUM_OF_BANDS * 8 ); ++base, i = (short) ( base * 8 ) )
{ {
tempM += * ( desVec + i ) * * ( desVec + i ); //desVec[8*i+0] * desVec[8*i+0]; tempM += * ( desVec + i ) * * ( desVec + i ); //desVec[8*i+0] * desVec[8*i+0];
tempM += * ( desVec + i + 1 ) * * ( desVec + i + 1 ); //desVec[8*i+1] * desVec[8*i+1]; tempM += * ( desVec + i + 1 ) * * ( desVec + i + 1 ); //desVec[8*i+1] * desVec[8*i+1];
...@@ -1130,7 +1130,7 @@ int BinaryDescriptor::computeLBD( ScaleLines &keyLines ) ...@@ -1130,7 +1130,7 @@ int BinaryDescriptor::computeLBD( ScaleLines &keyLines )
tempS = 1 / sqrt( tempS ); tempS = 1 / sqrt( tempS );
desVec = pSingleLine->descriptor.data(); desVec = pSingleLine->descriptor.data();
base = 0; base = 0;
for ( short i = 0; i < (short) ( NUM_OF_BANDS * 8 ); ++base, i = base * 8 ) for ( short i = 0; i < (short) ( NUM_OF_BANDS * 8 ); ++base, i = (short) ( base * 8 ) )
{ {
* ( desVec + i ) = * ( desVec + i ) * tempM; //desVec[8*i] = desVec[8*i] * tempM; * ( desVec + i ) = * ( desVec + i ) * tempM; //desVec[8*i] = desVec[8*i] * tempM;
* ( desVec + 1 + i ) = * ( desVec + 1 + i ) * tempM; //desVec[8*i+1] = desVec[8*i+1] * tempM; * ( desVec + 1 + i ) = * ( desVec + 1 + i ) * tempM; //desVec[8*i+1] = desVec[8*i+1] * tempM;
...@@ -1151,7 +1151,7 @@ int BinaryDescriptor::computeLBD( ScaleLines &keyLines ) ...@@ -1151,7 +1151,7 @@ int BinaryDescriptor::computeLBD( ScaleLines &keyLines )
{ {
if( desVec[i] > 0.4 ) if( desVec[i] > 0.4 )
{ {
desVec[i] = (float)0.4; desVec[i] = (float) 0.4;
} }
} }
......
...@@ -105,7 +105,7 @@ void BinaryDescriptorMatcher::checkKDistances( UINT32 * numres, int k, std::vect ...@@ -105,7 +105,7 @@ void BinaryDescriptorMatcher::checkKDistances( UINT32 * numres, int k, std::vect
{ {
if( ( * ( numres_tmp + j ) ) > 0 ) if( ( * ( numres_tmp + j ) ) > 0 )
{ {
for ( int i = 0; i < (int)( * ( numres_tmp + j ) ) && k_to_found > 0; i++ ) for ( int i = 0; i < (int) ( * ( numres_tmp + j ) ) && k_to_found > 0; i++ )
{ {
k_distances.push_back( j ); k_distances.push_back( j );
k_to_found--; k_to_found--;
...@@ -153,10 +153,10 @@ void BinaryDescriptorMatcher::match( const Mat& queryDescriptors, std::vector<DM ...@@ -153,10 +153,10 @@ void BinaryDescriptorMatcher::match( const Mat& queryDescriptors, std::vector<DM
/* data validity check */ /* data validity check */
if( !masks.empty() && ( masks[itup->second].rows != queryDescriptors.rows || masks[itup->second].cols != 1 ) ) if( !masks.empty() && ( masks[itup->second].rows != queryDescriptors.rows || masks[itup->second].cols != 1 ) )
{ {
std::cout << "Error: mask " << itup->second << " in knnMatch function " << "should have " << queryDescriptors.rows << " and " std::stringstream ss;
<< "1 column. Program will be terminated" << std::endl; ss << "Error: mask " << itup->second << " in knnMatch function " << "should have " << queryDescriptors.rows << " and "
<< "1 column. Program will be terminated";
CV_Assert( false ); throw std::runtime_error( ss.str() );
} }
/* create a DMatch object if required by mask or if there is /* create a DMatch object if required by mask or if there is
...@@ -170,7 +170,7 @@ void BinaryDescriptorMatcher::match( const Mat& queryDescriptors, std::vector<DM ...@@ -170,7 +170,7 @@ void BinaryDescriptorMatcher::match( const Mat& queryDescriptors, std::vector<DM
dm.queryIdx = counter; dm.queryIdx = counter;
dm.trainIdx = results[counter] - 1; dm.trainIdx = results[counter] - 1;
dm.imgIdx = itup->second; dm.imgIdx = itup->second;
dm.distance = k_distances[0]; dm.distance = (float) k_distances[0];
matches.push_back( dm ); matches.push_back( dm );
} }
...@@ -223,7 +223,7 @@ void BinaryDescriptorMatcher::match( const Mat& queryDescriptors, const Mat& tra ...@@ -223,7 +223,7 @@ void BinaryDescriptorMatcher::match( const Mat& queryDescriptors, const Mat& tra
dm.queryIdx = counter; dm.queryIdx = counter;
dm.trainIdx = results[counter] - 1; dm.trainIdx = results[counter] - 1;
dm.imgIdx = 0; dm.imgIdx = 0;
dm.distance = k_distances[0]; dm.distance = (float) k_distances[0];
matches.push_back( dm ); matches.push_back( dm );
} }
...@@ -293,7 +293,7 @@ void BinaryDescriptorMatcher::knnMatch( const Mat& queryDescriptors, const Mat& ...@@ -293,7 +293,7 @@ void BinaryDescriptorMatcher::knnMatch( const Mat& queryDescriptors, const Mat&
dm.queryIdx = counter; dm.queryIdx = counter;
dm.trainIdx = results[j] - 1; dm.trainIdx = results[j] - 1;
dm.imgIdx = 0; dm.imgIdx = 0;
dm.distance = k_distances[j - index]; dm.distance = (float) k_distances[j - index];
tempVec.push_back( dm ); tempVec.push_back( dm );
} }
...@@ -375,7 +375,7 @@ void BinaryDescriptorMatcher::knnMatch( const Mat& queryDescriptors, std::vector ...@@ -375,7 +375,7 @@ void BinaryDescriptorMatcher::knnMatch( const Mat& queryDescriptors, std::vector
dm.queryIdx = counter; dm.queryIdx = counter;
dm.trainIdx = results[j] - 1; dm.trainIdx = results[j] - 1;
dm.imgIdx = itup->second; dm.imgIdx = itup->second;
dm.distance = k_distances[j - index]; dm.distance = (float) k_distances[j - index];
tempVector.push_back( dm ); tempVector.push_back( dm );
} }
...@@ -444,7 +444,7 @@ void BinaryDescriptorMatcher::radiusMatch( const Mat& queryDescriptors, const Ma ...@@ -444,7 +444,7 @@ void BinaryDescriptorMatcher::radiusMatch( const Mat& queryDescriptors, const Ma
dm.queryIdx = i; dm.queryIdx = i;
dm.trainIdx = results[j] - 1; dm.trainIdx = results[j] - 1;
dm.imgIdx = 0; dm.imgIdx = 0;
dm.distance = k_distances[j - index]; dm.distance = (float) k_distances[j - index];
tempVector.push_back( dm ); tempVector.push_back( dm );
} }
...@@ -528,7 +528,7 @@ void BinaryDescriptorMatcher::radiusMatch( const Mat& queryDescriptors, std::vec ...@@ -528,7 +528,7 @@ void BinaryDescriptorMatcher::radiusMatch( const Mat& queryDescriptors, std::vec
dm.queryIdx = counter; dm.queryIdx = counter;
dm.trainIdx = results[j] - 1; dm.trainIdx = results[j] - 1;
dm.imgIdx = itup->second; dm.imgIdx = itup->second;
dm.distance = k_distances[j - index]; dm.distance = (float)k_distances[j - index];
tempVector.push_back( dm ); tempVector.push_back( dm );
} }
......
...@@ -61,7 +61,7 @@ void drawLineMatches( const Mat& img1, const std::vector<KeyLine>& keylines1, co ...@@ -61,7 +61,7 @@ void drawLineMatches( const Mat& img1, const std::vector<KeyLine>& keylines1, co
} }
/* initialize random seed: */ /* initialize random seed: */
srand( time( NULL ) ); srand( (unsigned int) time( NULL ) );
Scalar singleLineColorRGB; Scalar singleLineColorRGB;
if( singleLineColor == Scalar::all( -1 ) ) if( singleLineColor == Scalar::all( -1 ) )
...@@ -91,13 +91,13 @@ void drawLineMatches( const Mat& img1, const std::vector<KeyLine>& keylines1, co ...@@ -91,13 +91,13 @@ void drawLineMatches( const Mat& img1, const std::vector<KeyLine>& keylines1, co
for ( size_t i = 0; i < keylines1.size(); i++ ) for ( size_t i = 0; i < keylines1.size(); i++ )
{ {
KeyLine k1 = keylines1[i]; KeyLine k1 = keylines1[i];
line( outImg, Point( k1.startPointX, k1.startPointY ), Point( k1.endPointX, k1.endPointY ), singleLineColorRGB, 2 ); line( outImg, Point2f( k1.startPointX, k1.startPointY ), Point2f( k1.endPointX, k1.endPointY ), singleLineColorRGB, 2 );
} }
for ( size_t j = 0; j < keylines2.size(); j++ ) for ( size_t j = 0; j < keylines2.size(); j++ )
{ {
KeyLine k2 = keylines2[j]; KeyLine k2 = keylines2[j];
line( outImg, Point( k2.startPointX + offset, k2.startPointY ), Point( k2.endPointX + offset, k2.endPointY ), singleLineColorRGB, 2 ); line( outImg, Point2f( k2.startPointX + offset, k2.startPointY ), Point2f( k2.endPointX + offset, k2.endPointY ), singleLineColorRGB, 2 );
} }
} }
...@@ -127,13 +127,13 @@ void drawLineMatches( const Mat& img1, const std::vector<KeyLine>& keylines1, co ...@@ -127,13 +127,13 @@ void drawLineMatches( const Mat& img1, const std::vector<KeyLine>& keylines1, co
matchColorRGB = matchColor; matchColorRGB = matchColor;
/* draw lines if necessary */ /* draw lines if necessary */
line( outImg, Point( left.startPointX, left.startPointY ), Point( left.endPointX, left.endPointY ), singleLineColorRGB, 2 ); line( outImg, Point2f( left.startPointX, left.startPointY ), Point2f( left.endPointX, left.endPointY ), singleLineColorRGB, 2 );
line( outImg, Point( right.startPointX + offset, right.startPointY ), Point( right.endPointX + offset, right.endPointY ), singleLineColorRGB, line( outImg, Point2f( right.startPointX + offset, right.startPointY ), Point2f( right.endPointX + offset, right.endPointY ), singleLineColorRGB,
2 ); 2 );
/* link correspondent lines */ /* link correspondent lines */
line( outImg, Point( left.startPointX, left.startPointY ), Point( right.startPointX + offset, right.startPointY ), matchColorRGB, 1 ); line( outImg, Point2f( left.startPointX, left.startPointY ), Point2f( right.startPointX + offset, right.startPointY ), matchColorRGB, 1 );
} }
} }
} }
...@@ -164,7 +164,7 @@ void drawKeylines( const Mat& image, const std::vector<KeyLine>& keylines, Mat& ...@@ -164,7 +164,7 @@ void drawKeylines( const Mat& image, const std::vector<KeyLine>& keylines, Mat&
KeyLine k = keylines[i]; KeyLine k = keylines[i];
/* draw line */ /* draw line */
line( outImage, Point( k.startPointX, k.startPointY ), Point( k.endPointX, k.endPointY ), lineColor, 1 ); line( outImage, Point2f( k.startPointX, k.startPointY ), Point2f( k.endPointX, k.endPointY ), lineColor, 1 );
} }
} }
......
...@@ -66,8 +66,8 @@ EDLineDetector::EDLineDetector( EDLineParam param ) ...@@ -66,8 +66,8 @@ EDLineDetector::EDLineDetector( EDLineParam param )
//set parameters for line segment detection //set parameters for line segment detection
ksize_ = param.ksize; ksize_ = param.ksize;
sigma_ = param.sigma; sigma_ = param.sigma;
gradienThreshold_ = param.gradientThreshold; gradienThreshold_ = (short) param.gradientThreshold;
anchorThreshold_ = param.anchorThreshold; anchorThreshold_ = (unsigned char) param.anchorThreshold;
scanIntervals_ = param.scanIntervals; scanIntervals_ = param.scanIntervals;
minLineLen_ = param.minLineLen; minLineLen_ = param.minLineLen;
lineFitErrThreshold_ = param.lineFitErrThreshold; lineFitErrThreshold_ = param.lineFitErrThreshold;
...@@ -132,17 +132,18 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -132,17 +132,18 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
unsigned int edgePixelArraySize = pixelNum / 5; unsigned int edgePixelArraySize = pixelNum / 5;
unsigned int maxNumOfEdge = edgePixelArraySize / 20; unsigned int maxNumOfEdge = edgePixelArraySize / 20;
//compute dx, dy images //compute dx, dy images
if( gImg_.cols != (int)imageWidth || gImg_.rows != (int)imageHeight ) if( gImg_.cols != (int) imageWidth || gImg_.rows != (int) imageHeight )
{ {
if(pFirstPartEdgeX_!= NULL){ if( pFirstPartEdgeX_ != NULL )
delete [] pFirstPartEdgeX_; {
delete [] pFirstPartEdgeY_; delete[] pFirstPartEdgeX_;
delete [] pSecondPartEdgeX_; delete[] pFirstPartEdgeY_;
delete [] pSecondPartEdgeY_; delete[] pSecondPartEdgeX_;
delete [] pFirstPartEdgeS_; delete[] pSecondPartEdgeY_;
delete [] pSecondPartEdgeS_; delete[] pFirstPartEdgeS_;
delete [] pAnchorX_; delete[] pSecondPartEdgeS_;
delete [] pAnchorY_; delete[] pAnchorX_;
delete[] pAnchorY_;
} }
dxImg_.create( imageHeight, imageWidth, CV_16SC1 ); dxImg_.create( imageHeight, imageWidth, CV_16SC1 );
...@@ -285,9 +286,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -285,9 +286,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the right and pick the one with the max. gradient value // Look at 3 neighbors to the right and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray - imageWidth + 1]; gValue1 = (unsigned char) pgImg[indexInArray - imageWidth + 1];
gValue2 = pgImg[indexInArray + 1]; gValue2 = (unsigned char) pgImg[indexInArray + 1];
gValue3 = pgImg[indexInArray + imageWidth + 1]; gValue3 = (unsigned char) pgImg[indexInArray + imageWidth + 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //up-right { //up-right
x = x + 1; x = x + 1;
...@@ -311,9 +312,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -311,9 +312,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the left and pick the one with the max. gradient value // Look at 3 neighbors to the left and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray - imageWidth - 1]; gValue1 = (unsigned char) pgImg[indexInArray - imageWidth - 1];
gValue2 = pgImg[indexInArray - 1]; gValue2 = (unsigned char) pgImg[indexInArray - 1];
gValue3 = pgImg[indexInArray + imageWidth - 1]; gValue3 = (unsigned char) pgImg[indexInArray + imageWidth - 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //up-left { //up-left
x = x - 1; x = x - 1;
...@@ -353,9 +354,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -353,9 +354,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the down and pick the one with the max. gradient value // Look at 3 neighbors to the down and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray + imageWidth + 1]; gValue1 = (unsigned char) pgImg[indexInArray + imageWidth + 1];
gValue2 = pgImg[indexInArray + imageWidth]; gValue2 = (unsigned char) pgImg[indexInArray + imageWidth];
gValue3 = pgImg[indexInArray + imageWidth - 1]; gValue3 = (unsigned char) pgImg[indexInArray + imageWidth - 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //down-right { //down-right
x = x + 1; x = x + 1;
...@@ -379,9 +380,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -379,9 +380,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the up and pick the one with the max. gradient value // Look at 3 neighbors to the up and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray - imageWidth + 1]; gValue1 = (unsigned char) pgImg[indexInArray - imageWidth + 1];
gValue2 = pgImg[indexInArray - imageWidth]; gValue2 = (unsigned char) pgImg[indexInArray - imageWidth];
gValue3 = pgImg[indexInArray - imageWidth - 1]; gValue3 = (unsigned char) pgImg[indexInArray - imageWidth - 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //up-right { //up-right
x = x + 1; x = x + 1;
...@@ -436,9 +437,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -436,9 +437,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the right and pick the one with the max. gradient value // Look at 3 neighbors to the right and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray - imageWidth + 1]; gValue1 = (unsigned char) pgImg[indexInArray - imageWidth + 1];
gValue2 = pgImg[indexInArray + 1]; gValue2 = (unsigned char) pgImg[indexInArray + 1];
gValue3 = pgImg[indexInArray + imageWidth + 1]; gValue3 = (unsigned char) pgImg[indexInArray + imageWidth + 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //up-right { //up-right
x = x + 1; x = x + 1;
...@@ -462,9 +463,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -462,9 +463,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the left and pick the one with the max. gradient value // Look at 3 neighbors to the left and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray - imageWidth - 1]; gValue1 = (unsigned char) pgImg[indexInArray - imageWidth - 1];
gValue2 = pgImg[indexInArray - 1]; gValue2 = (unsigned char) pgImg[indexInArray - 1];
gValue3 = pgImg[indexInArray + imageWidth - 1]; gValue3 = (unsigned char) pgImg[indexInArray + imageWidth - 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //up-left { //up-left
x = x - 1; x = x - 1;
...@@ -504,9 +505,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -504,9 +505,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the down and pick the one with the max. gradient value // Look at 3 neighbors to the down and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray + imageWidth + 1]; gValue1 = (unsigned char) pgImg[indexInArray + imageWidth + 1];
gValue2 = pgImg[indexInArray + imageWidth]; gValue2 = (unsigned char) pgImg[indexInArray + imageWidth];
gValue3 = pgImg[indexInArray + imageWidth - 1]; gValue3 = (unsigned char) pgImg[indexInArray + imageWidth - 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //down-right { //down-right
x = x + 1; x = x + 1;
...@@ -530,9 +531,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -530,9 +531,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the up and pick the one with the max. gradient value // Look at 3 neighbors to the up and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray - imageWidth + 1]; gValue1 = (unsigned char) pgImg[indexInArray - imageWidth + 1];
gValue2 = pgImg[indexInArray - imageWidth]; gValue2 = (unsigned char) pgImg[indexInArray - imageWidth];
gValue3 = pgImg[indexInArray - imageWidth - 1]; gValue3 = (unsigned char) pgImg[indexInArray - imageWidth - 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //up-right { //up-right
x = x + 1; x = x + 1;
...@@ -586,9 +587,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -586,9 +587,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the right and pick the one with the max. gradient value // Look at 3 neighbors to the right and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray - imageWidth + 1]; gValue1 = (unsigned char) pgImg[indexInArray - imageWidth + 1];
gValue2 = pgImg[indexInArray + 1]; gValue2 = (unsigned char) pgImg[indexInArray + 1];
gValue3 = pgImg[indexInArray + imageWidth + 1]; gValue3 = (unsigned char) pgImg[indexInArray + imageWidth + 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //up-right { //up-right
x = x + 1; x = x + 1;
...@@ -612,9 +613,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -612,9 +613,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the left and pick the one with the max. gradient value // Look at 3 neighbors to the left and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray - imageWidth - 1]; gValue1 = (unsigned char) pgImg[indexInArray - imageWidth - 1];
gValue2 = pgImg[indexInArray - 1]; gValue2 = (unsigned char) pgImg[indexInArray - 1];
gValue3 = pgImg[indexInArray + imageWidth - 1]; gValue3 = (unsigned char) pgImg[indexInArray + imageWidth - 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //up-left { //up-left
x = x - 1; x = x - 1;
...@@ -654,9 +655,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -654,9 +655,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the down and pick the one with the max. gradient value // Look at 3 neighbors to the down and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray + imageWidth + 1]; gValue1 = (unsigned char) pgImg[indexInArray + imageWidth + 1];
gValue2 = pgImg[indexInArray + imageWidth]; gValue2 = (unsigned char) pgImg[indexInArray + imageWidth];
gValue3 = pgImg[indexInArray + imageWidth - 1]; gValue3 = (unsigned char) pgImg[indexInArray + imageWidth - 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //down-right { //down-right
x = x + 1; x = x + 1;
...@@ -680,9 +681,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -680,9 +681,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the up and pick the one with the max. gradient value // Look at 3 neighbors to the up and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray - imageWidth + 1]; gValue1 = (unsigned char) pgImg[indexInArray - imageWidth + 1];
gValue2 = pgImg[indexInArray - imageWidth]; gValue2 = (unsigned char) pgImg[indexInArray - imageWidth];
gValue3 = pgImg[indexInArray - imageWidth - 1]; gValue3 = (unsigned char) pgImg[indexInArray - imageWidth - 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //up-right { //up-right
x = x + 1; x = x + 1;
...@@ -737,9 +738,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -737,9 +738,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the right and pick the one with the max. gradient value // Look at 3 neighbors to the right and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray - imageWidth + 1]; gValue1 = (unsigned char) pgImg[indexInArray - imageWidth + 1];
gValue2 = pgImg[indexInArray + 1]; gValue2 = (unsigned char) pgImg[indexInArray + 1];
gValue3 = pgImg[indexInArray + imageWidth + 1]; gValue3 = (unsigned char) pgImg[indexInArray + imageWidth + 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //up-right { //up-right
x = x + 1; x = x + 1;
...@@ -763,9 +764,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -763,9 +764,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the left and pick the one with the max. gradient value // Look at 3 neighbors to the left and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray - imageWidth - 1]; gValue1 = (unsigned char) pgImg[indexInArray - imageWidth - 1];
gValue2 = pgImg[indexInArray - 1]; gValue2 = (unsigned char) pgImg[indexInArray - 1];
gValue3 = pgImg[indexInArray + imageWidth - 1]; gValue3 = (unsigned char) pgImg[indexInArray + imageWidth - 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //up-left { //up-left
x = x - 1; x = x - 1;
...@@ -805,9 +806,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -805,9 +806,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the down and pick the one with the max. gradient value // Look at 3 neighbors to the down and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray + imageWidth + 1]; gValue1 = (unsigned char) pgImg[indexInArray + imageWidth + 1];
gValue2 = pgImg[indexInArray + imageWidth]; gValue2 = (unsigned char) pgImg[indexInArray + imageWidth];
gValue3 = pgImg[indexInArray + imageWidth - 1]; gValue3 = (unsigned char) pgImg[indexInArray + imageWidth - 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //down-right { //down-right
x = x + 1; x = x + 1;
...@@ -831,9 +832,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -831,9 +832,9 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
break; break;
} }
// Look at 3 neighbors to the up and pick the one with the max. gradient value // Look at 3 neighbors to the up and pick the one with the max. gradient value
gValue1 = pgImg[indexInArray - imageWidth + 1]; gValue1 = (unsigned char) pgImg[indexInArray - imageWidth + 1];
gValue2 = pgImg[indexInArray - imageWidth]; gValue2 = (unsigned char) pgImg[indexInArray - imageWidth];
gValue3 = pgImg[indexInArray - imageWidth - 1]; gValue3 = (unsigned char) pgImg[indexInArray - imageWidth - 1];
if( gValue1 >= gValue2 && gValue1 >= gValue3 ) if( gValue1 >= gValue2 && gValue1 >= gValue3 )
{ //up-right { //up-right
x = x + 1; x = x + 1;
...@@ -912,7 +913,7 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm ...@@ -912,7 +913,7 @@ int EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &edgeChains, bool sm
} }
indexInArray = pSecondPartEdgeS_[edgeId]; indexInArray = pSecondPartEdgeS_[edgeId];
offsetPSecond = pSecondPartEdgeS_[edgeId + 1]; offsetPSecond = pSecondPartEdgeS_[edgeId + 1];
for ( tempID = indexInArray + 1; tempID < (int)offsetPSecond; tempID++ ) for ( tempID = indexInArray + 1; tempID < (int) offsetPSecond; tempID++ )
{ //add second part edge { //add second part edge
pxCors[indexInCors] = pSecondPartEdgeX_[tempID]; pxCors[indexInCors] = pSecondPartEdgeX_[tempID];
pyCors[indexInCors++] = pSecondPartEdgeY_[tempID]; pyCors[indexInCors++] = pSecondPartEdgeY_[tempID];
...@@ -929,7 +930,7 @@ int EDLineDetector::EDline( cv::Mat &image, LineChains &lines, bool smoothed ) ...@@ -929,7 +930,7 @@ int EDLineDetector::EDline( cv::Mat &image, LineChains &lines, bool smoothed )
//first, call EdgeDrawing function to extract edges //first, call EdgeDrawing function to extract edges
EdgeChains edges; EdgeChains edges;
if( ( EdgeDrawing( image, edges, smoothed ) ) != true ) if( ( EdgeDrawing( image, edges, smoothed ) ) != 1 )
{ {
cout << "Line Detection not finished" << endl; cout << "Line Detection not finished" << endl;
return -1; return -1;
...@@ -1053,12 +1054,12 @@ int EDLineDetector::EDline( cv::Mat &image, LineChains &lines, bool smoothed ) ...@@ -1053,12 +1054,12 @@ int EDLineDetector::EDline( cv::Mat &image, LineChains &lines, bool smoothed )
double a5 = lineEqu[2] * lineEqu[1]; double a5 = lineEqu[2] * lineEqu[1];
unsigned int Px = pLineXCors[pLineSID[numOfLines]]; //first pixel unsigned int Px = pLineXCors[pLineSID[numOfLines]]; //first pixel
unsigned int Py = pLineYCors[pLineSID[numOfLines]]; unsigned int Py = pLineYCors[pLineSID[numOfLines]];
lineEndP[0] = a1 * Px - a3 * Py - a4; //x lineEndP[0] = (float) ( a1 * Px - a3 * Py - a4 ); //x
lineEndP[1] = a2 * Py - a3 * Px - a5; //y lineEndP[1] = (float) ( a2 * Py - a3 * Px - a5 ); //y
Px = pLineXCors[offsetInLineArray - 1]; //last pixel Px = pLineXCors[offsetInLineArray - 1]; //last pixel
Py = pLineYCors[offsetInLineArray - 1]; Py = pLineYCors[offsetInLineArray - 1];
lineEndP[2] = a1 * Px - a3 * Py - a4; //x lineEndP[2] = (float) ( a1 * Px - a3 * Py - a4 ); //x
lineEndP[3] = a2 * Py - a3 * Px - a5; //y lineEndP[3] = (float) ( a2 * Py - a3 * Px - a5 ); //y
lineEndpoints_.push_back( lineEndP ); lineEndpoints_.push_back( lineEndP );
lineDirection_.push_back( direction ); lineDirection_.push_back( direction );
numOfLines++; numOfLines++;
...@@ -1140,12 +1141,12 @@ int EDLineDetector::EDline( cv::Mat &image, LineChains &lines, bool smoothed ) ...@@ -1140,12 +1141,12 @@ int EDLineDetector::EDline( cv::Mat &image, LineChains &lines, bool smoothed )
double a5 = lineEqu[2] * lineEqu[1]; double a5 = lineEqu[2] * lineEqu[1];
unsigned int Px = pLineXCors[pLineSID[numOfLines]]; //first pixel unsigned int Px = pLineXCors[pLineSID[numOfLines]]; //first pixel
unsigned int Py = pLineYCors[pLineSID[numOfLines]]; unsigned int Py = pLineYCors[pLineSID[numOfLines]];
lineEndP[0] = a1 * Px - a3 * Py - a4; //x lineEndP[0] = (float) ( a1 * Px - a3 * Py - a4 ); //x
lineEndP[1] = a2 * Py - a3 * Px - a5; //y lineEndP[1] = (float) ( a2 * Py - a3 * Px - a5 ); //y
Px = pLineXCors[offsetInLineArray - 1]; //last pixel Px = pLineXCors[offsetInLineArray - 1]; //last pixel
Py = pLineYCors[offsetInLineArray - 1]; Py = pLineYCors[offsetInLineArray - 1];
lineEndP[2] = a1 * Px - a3 * Py - a4; //x lineEndP[2] = (float) ( a1 * Px - a3 * Py - a4 ); //x
lineEndP[3] = a2 * Py - a3 * Px - a5; //y lineEndP[3] = (float) ( a2 * Py - a3 * Px - a5 ); //y
lineEndpoints_.push_back( lineEndP ); lineEndpoints_.push_back( lineEndP );
lineDirection_.push_back( direction ); lineDirection_.push_back( direction );
numOfLines++; numOfLines++;
...@@ -1187,8 +1188,8 @@ double EDLineDetector::LeastSquaresLineFit_( unsigned int *xCors, unsigned int * ...@@ -1187,8 +1188,8 @@ double EDLineDetector::LeastSquaresLineFit_( unsigned int *xCors, unsigned int *
for ( int i = 0; i < minLineLen_; i++ ) for ( int i = 0; i < minLineLen_; i++ )
{ {
//*(pMatT+minLineLen_) = 1; //the value are not changed; //*(pMatT+minLineLen_) = 1; //the value are not changed;
* ( pMatT++ ) = xCors[offsetS]; * ( pMatT++ ) = (float) xCors[offsetS];
fitVec[0][i] = yCors[offsetS++]; fitVec[0][i] = (float) yCors[offsetS++];
} }
ATA = fitMatT * fitMatT.t(); ATA = fitMatT * fitMatT.t();
ATV = fitMatT * fitVec.t(); ATV = fitMatT * fitVec.t();
...@@ -1221,8 +1222,8 @@ double EDLineDetector::LeastSquaresLineFit_( unsigned int *xCors, unsigned int * ...@@ -1221,8 +1222,8 @@ double EDLineDetector::LeastSquaresLineFit_( unsigned int *xCors, unsigned int *
for ( int i = 0; i < minLineLen_; i++ ) for ( int i = 0; i < minLineLen_; i++ )
{ {
//*(pMatT+minLineLen_) = 1;//the value are not changed; //*(pMatT+minLineLen_) = 1;//the value are not changed;
* ( pMatT++ ) = yCors[offsetS]; * ( pMatT++ ) = (float) yCors[offsetS];
fitVec[0][i] = xCors[offsetS++]; fitVec[0][i] = (float) xCors[offsetS++];
} }
ATA = fitMatT * ( fitMatT.t() ); ATA = fitMatT * ( fitMatT.t() );
ATV = fitMatT * fitVec.t(); ATV = fitMatT * fitVec.t();
...@@ -1279,8 +1280,8 @@ double EDLineDetector::LeastSquaresLineFit_( unsigned int *xCors, unsigned int * ...@@ -1279,8 +1280,8 @@ double EDLineDetector::LeastSquaresLineFit_( unsigned int *xCors, unsigned int *
for ( int i = 0; i < newLength; i++ ) for ( int i = 0; i < newLength; i++ )
{ {
* ( pMatT + newLength ) = 1; * ( pMatT + newLength ) = 1;
* ( pMatT++ ) = xCors[newOffsetS]; * ( pMatT++ ) = (float) xCors[newOffsetS];
vec[0][i] = yCors[newOffsetS++]; vec[0][i] = (float) yCors[newOffsetS++];
} }
/* [a,b]^T = Inv(ATA + mat^T * mat) * (ATV + mat^T * vec) */ /* [a,b]^T = Inv(ATA + mat^T * mat) * (ATV + mat^T * vec) */
tempMatLineFit = matT * matT.t(); tempMatLineFit = matT * matT.t();
...@@ -1307,8 +1308,8 @@ double EDLineDetector::LeastSquaresLineFit_( unsigned int *xCors, unsigned int * ...@@ -1307,8 +1308,8 @@ double EDLineDetector::LeastSquaresLineFit_( unsigned int *xCors, unsigned int *
for ( int i = 0; i < newLength; i++ ) for ( int i = 0; i < newLength; i++ )
{ {
* ( pMatT + newLength ) = 1; * ( pMatT + newLength ) = 1;
* ( pMatT++ ) = yCors[newOffsetS]; * ( pMatT++ ) = (float) yCors[newOffsetS];
vec[0][i] = xCors[newOffsetS++]; vec[0][i] = (float) xCors[newOffsetS++];
} }
/* [a,b]^T = Inv(ATA + mat^T * mat) * (ATV + mat^T * vec) */ /* [a,b]^T = Inv(ATA + mat^T * mat) * (ATV + mat^T * vec) */
// matT.MultiplyWithTransposeOf(matT, tempMatLineFit); // matT.MultiplyWithTransposeOf(matT, tempMatLineFit);
...@@ -1358,19 +1359,19 @@ bool EDLineDetector::LineValidation_( unsigned int *xCors, unsigned int *yCors, ...@@ -1358,19 +1359,19 @@ bool EDLineDetector::LineValidation_( unsigned int *xCors, unsigned int *yCors,
} }
if( meanGradientX > 0 && meanGradientY >= 0 ) if( meanGradientX > 0 && meanGradientY >= 0 )
{ //first quadrant, and positive direction of X axis. { //first quadrant, and positive direction of X axis.
direction = atan2( -dy, dx ); //line direction is in fourth quadrant direction = (float) atan2( -dy, dx ); //line direction is in fourth quadrant
} }
if( meanGradientX <= 0 && meanGradientY > 0 ) if( meanGradientX <= 0 && meanGradientY > 0 )
{ //second quadrant, and positive direction of Y axis. { //second quadrant, and positive direction of Y axis.
direction = atan2( dy, dx ); //line direction is in first quadrant direction = (float) atan2( dy, dx ); //line direction is in first quadrant
} }
if( meanGradientX < 0 && meanGradientY <= 0 ) if( meanGradientX < 0 && meanGradientY <= 0 )
{ //third quadrant, and negative direction of X axis. { //third quadrant, and negative direction of X axis.
direction = atan2( dy, -dx ); //line direction is in second quadrant direction = (float) atan2( dy, -dx ); //line direction is in second quadrant
} }
if( meanGradientX >= 0 && meanGradientY < 0 ) if( meanGradientX >= 0 && meanGradientY < 0 )
{ //fourth quadrant, and negative direction of Y axis. { //fourth quadrant, and negative direction of Y axis.
direction = atan2( -dy, -dx ); //line direction is in third quadrant direction = (float) atan2( -dy, -dx ); //line direction is in third quadrant
} }
/*then check whether the line is on the border of the image. We don't keep the border line.*/ /*then check whether the line is on the border of the image. We don't keep the border line.*/
if( fabs( direction ) < 0.15 || M_PI - fabs( direction ) < 0.15 ) if( fabs( direction ) < 0.15 || M_PI - fabs( direction ) < 0.15 )
...@@ -1411,7 +1412,7 @@ bool EDLineDetector::LineValidation_( unsigned int *xCors, unsigned int *yCors, ...@@ -1411,7 +1412,7 @@ bool EDLineDetector::LineValidation_( unsigned int *xCors, unsigned int *yCors,
int EDLineDetector::EDline( cv::Mat &image, bool smoothed ) int EDLineDetector::EDline( cv::Mat &image, bool smoothed )
{ {
if( ( EDline( image, lines_, smoothed ) ) != true ) if( ( EDline( image, lines_, smoothed ) ) != 1 )
{ {
return -1; return -1;
} }
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include <bitset> #include <bitset>
#include <time.h> #include <time.h>
#include <stdexcept> #include <stdexcept>
#include <sstream>
#include "opencv2/line_descriptor.hpp" #include "opencv2/line_descriptor.hpp"
......
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