From 0ca3e31d0b61bbce8f30fbc06c1d5c7831387993 Mon Sep 17 00:00:00 2001 From: biagio montesano Date: Sat, 2 Aug 2014 17:03:28 +0200 Subject: [PATCH] Removed some asserts --- .../opencv2/line_descriptor/descriptor.hpp | 4 +-- .../line_descriptor/src/binary_descriptor.cpp | 36 ++++++------------- modules/line_descriptor/src/precomp.hpp | 1 + 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/modules/line_descriptor/include/opencv2/line_descriptor/descriptor.hpp b/modules/line_descriptor/include/opencv2/line_descriptor/descriptor.hpp index 8ee5825b0..a28f876ac 100644 --- a/modules/line_descriptor/include/opencv2/line_descriptor/descriptor.hpp +++ b/modules/line_descriptor/include/opencv2/line_descriptor/descriptor.hpp @@ -236,10 +236,10 @@ class CV_EXPORTS_W BinaryDescriptor : public Algorithm int OctaveKeyLines( cv::Mat& image, ScaleLines &keyLines ); /* the local gaussian coefficient applied to the orthogonal line direction within each band */ - std::vector gaussCoefL_; + std::vector gaussCoefL_; /* the global gaussian coefficient applied to each row within line support region */ - std::vector gaussCoefG_; + std::vector gaussCoefG_; /* descriptor parameters */ Params params; diff --git a/modules/line_descriptor/src/binary_descriptor.cpp b/modules/line_descriptor/src/binary_descriptor.cpp index 5f640d714..e62711299 100644 --- a/modules/line_descriptor/src/binary_descriptor.cpp +++ b/modules/line_descriptor/src/binary_descriptor.cpp @@ -209,7 +209,7 @@ void BinaryDescriptor::operator()( InputArray image, InputArray mask, CV_OUT std maskMat = mask.getMat(); /* initialize output matrix */ - descriptors.create( Size( 32, keylines.size() ), CV_8UC1 ); + descriptors.create( Size( 32, (int) keylines.size() ), CV_8UC1 ); /* store reference to output matrix */ descrMat = descriptors.getMat(); @@ -260,12 +260,11 @@ int BinaryDescriptor::descriptorSize() const static inline int get2Pow( int i ) { if( i >= 0 && i <= 7 ) - return pow( 2, (double) i ); + return (int) pow( 2, (double) i ); else { - CV_Assert( false ); - return -1; + throw std::runtime_error( "Invalid power argument" ); } } @@ -276,7 +275,7 @@ unsigned char BinaryDescriptor::binaryConversion( float* f1, float* f2 ) for ( int i = 0; i < 8; i++ ) { if( f1[i] > f2[i] ) - result += get2Pow( i ); + result += (uchar) get2Pow( i ); } return result; @@ -287,12 +286,7 @@ unsigned char BinaryDescriptor::binaryConversion( float* f1, float* f2 ) void BinaryDescriptor::detect( const Mat& image, CV_OUT std::vector& keylines, const Mat& mask ) { if( mask.data != NULL && ( mask.size() != image.size() || mask.type() != CV_8UC1 ) ) - { - - std::cout << "Mask error while detecting lines: " << "please check its dimensions and that data type is CV_8UC1" << std::endl; - - CV_Assert( false ); - } + throw std::runtime_error( "Mask error while detecting lines: please check its dimensions and that data type is CV_8UC1" ); else detectImpl( image, keylines, mask ); @@ -305,14 +299,10 @@ void BinaryDescriptor::detect( const std::vector& images, std::vector& ke /*check whether image depth is different from 0 */ if( image.depth() != 0 ) - { - std::cout << "Warning, depth image!= 0" << std::endl; - CV_Assert( false ); - } + throw std::runtime_error( "Warning, depth image!= 0" ); /* create a pointer to self */ BinaryDescriptor *bn = const_cast( this ); @@ -415,10 +402,7 @@ void BinaryDescriptor::computeImpl( const Mat& imageSrc, std::vector& k /*check whether image's depth is different from 0 */ if( image.depth() != 0 ) - { - std::cout << "Error, depth of image != 0" << std::endl; - CV_Assert( false ); - } + throw std::runtime_error( "Error, depth of image != 0" ); /* keypoints list can't be empty */ if( keylines.size() == 0 ) diff --git a/modules/line_descriptor/src/precomp.hpp b/modules/line_descriptor/src/precomp.hpp index 9662d41b8..42e84dfb3 100644 --- a/modules/line_descriptor/src/precomp.hpp +++ b/modules/line_descriptor/src/precomp.hpp @@ -60,6 +60,7 @@ #include #include #include +#include #include "opencv2/line_descriptor.hpp"