diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d23a6414..9f6d33379 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,7 +155,7 @@ SET(snark_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) IF( NOT BUILD_SHARED_LIBS ) SET( Boost_USE_STATIC_LIBS ON ) ENDIF( NOT BUILD_SHARED_LIBS ) -FIND_PACKAGE( Boost COMPONENTS thread filesystem system serialization date_time program_options ) +FIND_PACKAGE( Boost COMPONENTS thread filesystem system serialization date_time program_options regex chrono ) INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} ) LINK_DIRECTORIES( ${Boost_LIBRARY_DIRS} ) diff --git a/imaging/applications/cv-calc.cpp b/imaging/applications/cv-calc.cpp index 5fa25e5db..7ff490f5f 100644 --- a/imaging/applications/cv-calc.cpp +++ b/imaging/applications/cv-calc.cpp @@ -624,8 +624,8 @@ class shapes bool draw( cv::Mat m ) const { if( !comma::math::less( 0, radius ) ) { return false; } - if( properties.normalized ) { cv::circle( m, cv::Point2i( centre.x * m.cols, centre.y * m.rows ), radius * m.cols, properties.color, properties.weight, CV_AA ); } - else { cv::circle( m, centre, radius, properties.color, properties.weight, CV_AA ); } + if( properties.normalized ) { cv::circle( m, cv::Point2i( centre.x * m.cols, centre.y * m.rows ), radius * m.cols, properties.color, properties.weight, cv::LINE_AA ); } + else { cv::circle( m, centre, radius, properties.color, properties.weight, cv::LINE_AA ); } return true; } }; @@ -638,7 +638,7 @@ class shapes bool draw( cv::Mat m ) const { if( text.empty() ) { return false; } - cv::putText( m, text, properties.normalized ? cv::Point2f( position.x * m.cols, position.y * m.rows ) : position, cv::FONT_HERSHEY_SIMPLEX, 1.0, properties.color, properties.weight, CV_AA ); + cv::putText( m, text, properties.normalized ? cv::Point2f( position.x * m.cols, position.y * m.rows ) : position, cv::FONT_HERSHEY_SIMPLEX, 1.0, properties.color, properties.weight, cv::LINE_AA ); return true; } }; diff --git a/imaging/applications/image-accumulate.cpp b/imaging/applications/image-accumulate.cpp index 7b47961b0..58e880a40 100644 --- a/imaging/applications/image-accumulate.cpp +++ b/imaging/applications/image-accumulate.cpp @@ -350,7 +350,7 @@ static void output_once_( const boost::posix_time::ptime& t ) static void output_() { - static const boost::posix_time::time_duration period = boost::posix_time::milliseconds( 1000.0 / *fps ); + static const boost::posix_time::time_duration period = boost::posix_time::milliseconds( (long)(1000.0 / *fps) ); static const boost::posix_time::time_duration timeout = boost::posix_time::milliseconds( 10 ); boost::posix_time::ptime time_to_output = boost::posix_time::microsec_clock::universal_time() + period; while( !is_shutdown && !done && std::cout.good() ) diff --git a/imaging/applications/image-pinhole-calibrate.cpp b/imaging/applications/image-pinhole-calibrate.cpp index 48ca43cdd..3190172b6 100644 --- a/imaging/applications/image-pinhole-calibrate.cpp +++ b/imaging/applications/image-pinhole-calibrate.cpp @@ -175,7 +175,7 @@ static double reprojection_error( const std::vector< std::vector< cv::Point3f > for( unsigned int i = 0; i < object_points.size(); ++i ) { cv::projectPoints( cv::Mat( object_points[i] ), rvecs[i], tvecs[i], camera_matrix, distortion_coefficients, image_points_2 ); - double err = cv::norm( cv::Mat( image_points[i] ), cv::Mat( image_points_2 ), CV_L2 ); + double err = cv::norm( cv::Mat( image_points[i] ), cv::Mat( image_points_2 ), cv::NORM_L2 ); unsigned int n = object_points[i].size(); per_view_errors[i] = std::sqrt( err * err / n ); total_error += err * err; @@ -196,7 +196,7 @@ static bool calibrate( const std::vector< cv::Point3f >& pattern_corners { std::vector< float > reprojection_errors; std::vector< std::vector< cv::Point3f > > object_points( image_points.size(), pattern_corners ); - cv::calibrateCamera( object_points, image_points, image_size, camera_matrix, distortion_coefficients, rvecs, tvecs, flags | CV_CALIB_FIX_K4 | CV_CALIB_FIX_K5 ); + cv::calibrateCamera( object_points, image_points, image_size, camera_matrix, distortion_coefficients, rvecs, tvecs, flags | cv::CALIB_FIX_K4 | cv::CALIB_FIX_K5 ); bool ok = cv::checkRange( camera_matrix ) && cv::checkRange( distortion_coefficients ); total_average_error = reprojection_error( object_points, image_points, rvecs, tvecs, camera_matrix, distortion_coefficients, reprojection_errors ); return ok; @@ -284,9 +284,9 @@ int main( int ac, char** av ) if( pattern == patterns::invalid ) { std::cerr << "image-pinhole-calibration: expected calibration pattern, got: \"" << pattern_string << "\"" << std::endl; } float square_size = options.value< float >( "--pattern-square-size,--square-size", 1 ); int flags = 0; - if( options.exists( "--no-principal-point" ) ) { flags |= CV_CALIB_FIX_PRINCIPAL_POINT; } - if( options.exists( "--no-tangential-distortion" ) ) { flags |= CV_CALIB_ZERO_TANGENT_DIST; } - if( options.exists( "--no-aspect-ratio" ) ) { flags |= CV_CALIB_FIX_ASPECT_RATIO; } + if( options.exists( "--no-principal-point" ) ) { flags |= cv::CALIB_FIX_PRINCIPAL_POINT; } + if( options.exists( "--no-tangential-distortion" ) ) { flags |= cv::CALIB_ZERO_TANGENT_DIST; } + if( options.exists( "--no-aspect-ratio" ) ) { flags |= cv::CALIB_FIX_ASPECT_RATIO; } bool view = options.exists( "--view" ); bool verbose = options.exists( "--verbose,-v" ); std::vector< std::vector< cv::Point2f > > image_points; @@ -307,7 +307,7 @@ int main( int ac, char** av ) //if( view ) { images.push_back( pair.second.clone() ); } image_size = pair.second.size(); std::vector< cv::Point2f > points; - bool found = pattern == patterns::chessboard ? cv::findChessboardCorners( pair.second, pattern_size, points, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE ) + bool found = pattern == patterns::chessboard ? cv::findChessboardCorners( pair.second, pattern_size, points, cv::CALIB_CB_ADAPTIVE_THRESH | cv::CALIB_CB_FAST_CHECK | cv::CALIB_CB_NORMALIZE_IMAGE ) : pattern == patterns::circles_grid ? findCirclesGrid( view, pattern_size, points ) : pattern == patterns::asymmetric_circles_grid ? findCirclesGrid( view, pattern_size, points, cv::CALIB_CB_ASYMMETRIC_GRID ) : false; @@ -324,7 +324,7 @@ int main( int ac, char** av ) { cv::Mat grey; cv::cvtColor( pair.second, grey, cv::COLOR_BGR2GRAY ); - cv::cornerSubPix( grey, points, cv::Size( 11, 11 ), cv::Size( -1, -1 ), cv::TermCriteria( CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1 ) ); + cv::cornerSubPix( grey, points, cv::Size( 11, 11 ), cv::Size( -1, -1 ), cv::TermCriteria( cv::TermCriteria::EPS + cv::TermCriteria::MAX_ITER, 30, 0.1 ) ); } image_points.push_back( points ); timestamps.push_back( pair.first ); @@ -368,7 +368,7 @@ int main( int ac, char** av ) else { // set flag to use values from config - if (options.exists("--config")) { flags |= CV_CALIB_USE_INTRINSIC_GUESS; } + if (options.exists("--config")) { flags |= cv::CALIB_USE_INTRINSIC_GUESS; } if( !calibrate( pattern_corners, *image_size, image_points, flags, camera_matrix, distortion_coefficients, rvecs, tvecs, output.total_average_error ) ) { std::cerr << "image-pinhole-calibrate: calibration failed" << std::endl; return 1; } } for( unsigned int i = 0; i < images.size(); ++i ) @@ -381,7 +381,7 @@ int main( int ac, char** av ) if( verbose ) { std::cerr << "image-pinhole-calibrate: outputting..." << std::endl; } output.pinhole.image_size = Eigen::Vector2i( image_size->width, image_size->height ); output.pinhole.principal_point = Eigen::Vector2d( camera_matrix.at< double >( 0, 2 ), camera_matrix.at< double >( 1, 2 ) ); - if( flags & CV_CALIB_FIX_ASPECT_RATIO ) + if( flags & cv::CALIB_FIX_ASPECT_RATIO ) { output.pinhole.focal_length = camera_matrix.at< double >( 0, 0 ); } diff --git a/imaging/camera/pinhole.cpp b/imaging/camera/pinhole.cpp index d45772820..e978b275b 100644 --- a/imaging/camera/pinhole.cpp +++ b/imaging/camera/pinhole.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/imaging/cv_mat/detail/utils.cpp b/imaging/cv_mat/detail/utils.cpp index b4fae8d9b..87663fd82 100644 --- a/imaging/cv_mat/detail/utils.cpp +++ b/imaging/cv_mat/detail/utils.cpp @@ -171,7 +171,7 @@ std::string make_filename( const boost::posix_time::ptime& t, const std::string& std::vector< int > imwrite_params( const std::string& type, const int quality ) { std::vector< int > params; - if ( type == "jpg" ) { params.push_back( CV_IMWRITE_JPEG_QUALITY ); } + if ( type == "jpg" ) { params.push_back( cv::IMWRITE_JPEG_QUALITY ); } else { COMMA_THROW( comma::exception, "quality only supported for jpg images, not for \"" << type << "\" yet" ); } params.push_back( quality ); return params; diff --git a/imaging/cv_mat/filters.cpp b/imaging/cv_mat/filters.cpp index 0b6831839..86b7596a0 100644 --- a/imaging/cv_mat/filters.cpp +++ b/imaging/cv_mat/filters.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #if CV_MAJOR_VERSION <= 2 #include #endif // #if CV_MAJOR_VERSION <= 2 diff --git a/imaging/examples/regionprops-demo.cpp b/imaging/examples/regionprops-demo.cpp index 9d5885d3d..c501456c5 100644 --- a/imaging/examples/regionprops-demo.cpp +++ b/imaging/examples/regionprops-demo.cpp @@ -44,7 +44,7 @@ int main( int ac, char** av ) } cv::Mat image = cv::imread( av[1], 1 ); cv::Mat binary; - cv::threshold( image, binary, 128, 255, CV_THRESH_BINARY_INV ); + cv::threshold( image, binary, 128, 255, cv::THRESH_BINARY_INV ); snark::imaging::region_properties properties( binary ); properties.show( image ); cv::imshow( "image", image ); diff --git a/imaging/frequency_domain.cpp b/imaging/frequency_domain.cpp index b261845f0..3d170c107 100644 --- a/imaging/frequency_domain.cpp +++ b/imaging/frequency_domain.cpp @@ -78,7 +78,7 @@ cv::Mat frequency_domain::filter( const cv::Mat& image, const cv::Mat& mask ) cv::multiply( abs, paddedMaskF, abs ); } cv::Mat result; - cv::normalize( abs, abs, 0, maxValue, CV_MINMAX ); // scale to get the same max value as the original TODO better scaling ? + cv::normalize( abs, abs, 0, maxValue, cv::NORM_MINMAX ); // scale to get the same max value as the original TODO better scaling ? abs.convertTo( result, CV_8U ); return result; } @@ -101,7 +101,7 @@ cv::Mat frequency_domain::magnitude() const shift( magnitudeImage ); // transform the matrix with float values into a viewable image form (float between values 0 and 1). - cv::normalize( magnitudeImage, magnitudeImage, 0, 1, CV_MINMAX ); + cv::normalize( magnitudeImage, magnitudeImage, 0, 1, cv::NORM_MINMAX ); return magnitudeImage; } diff --git a/imaging/region_properties.cpp b/imaging/region_properties.cpp index 8db4773ac..eff0f7091 100644 --- a/imaging/region_properties.cpp +++ b/imaging/region_properties.cpp @@ -73,7 +73,7 @@ region_properties::region_properties ( const cv::Mat& image, double minArea ): cv::Mat binary; if( image.channels() == 3 ) { - cv::cvtColor( image, binary, CV_RGB2GRAY ); + cv::cvtColor( image, binary, cv::COLOR_RGB2GRAY ); } else if( image.channels() == 1 ) { @@ -86,12 +86,12 @@ region_properties::region_properties ( const cv::Mat& image, double minArea ): // cv::Mat closed; // cv::morphologyEx( binary, closed, cv::MORPH_CLOSE, cv::Mat::ones( 3, 3, CV_8U) ); std::vector< std::vector > contours; - cv::findContours( binary, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE ); + cv::findContours( binary, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE ); for( unsigned int i = 0; i < contours.size(); i++ ) { binary = cv::Scalar(0); - cv::drawContours( binary, contours, i, cv::Scalar(0xFF), CV_FILLED ); + cv::drawContours( binary, contours, i, cv::Scalar(0xFF), cv::FILLED ); cv::Rect rect = cv::boundingRect( cv::Mat( contours[i]) ); cv::Moments moments = cv::moments( binary( rect ), true ); double x = moments.m10/moments.m00; diff --git a/sensors/lidars/hokuyo/detail/ust.h b/sensors/lidars/hokuyo/detail/ust.h index b01c16792..650235a6e 100644 --- a/sensors/lidars/hokuyo/detail/ust.h +++ b/sensors/lidars/hokuyo/detail/ust.h @@ -5,6 +5,8 @@ #include "../output.h" #include #include "../sensors.h" +#include +#include namespace hok = snark::hokuyo; namespace ip = boost::asio::ip; @@ -136,12 +138,12 @@ static bool tcp_connect( const std::string& conn_str, ip::tcp::resolver::query query( v[0] == "localhost" ? "127.0.0.1" : v[0], v[1] ); ip::tcp::resolver::iterator it = resolver.resolve( query ); - io.expires_from_now( timeout ); + io.expires_from_now( std::chrono::microseconds(timeout.total_microseconds()) ); io.connect( it->endpoint() ); - io.expires_at( boost::posix_time::pos_infin ); + io.expires_at( boost::asio::steady_timer::time_point::max() ); - return io.error() == 0; + return io.error().value() == boost::system::errc::success; } template < int STEPS >