Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes snark builds with recent versions of boost and opencv #130

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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} )

Expand Down
6 changes: 3 additions & 3 deletions imaging/applications/cv-calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand All @@ -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;
}
};
Expand Down
2 changes: 1 addition & 1 deletion imaging/applications/image-accumulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
Expand Down
18 changes: 9 additions & 9 deletions imaging/applications/image-pinhole-calibrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 );
Expand Down Expand Up @@ -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 )
Expand All @@ -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 );
}
Expand Down
1 change: 1 addition & 0 deletions imaging/camera/pinhole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <sstream>
#include <boost/bind.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d.hpp>
#include <comma/application/verbose.h>
#include <comma/base/exception.h>
#include <comma/base/types.h>
Expand Down
2 changes: 1 addition & 1 deletion imaging/cv_mat/detail/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions imaging/cv_mat/filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include <opencv2/imgproc/imgproc_c.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/calib3d.hpp>
#if CV_MAJOR_VERSION <= 2
#include <opencv2/contrib/contrib.hpp>
#endif // #if CV_MAJOR_VERSION <= 2
Expand Down
2 changes: 1 addition & 1 deletion imaging/examples/regionprops-demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions imaging/frequency_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions imaging/region_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand All @@ -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<cv::Point> > 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;
Expand Down
8 changes: 5 additions & 3 deletions sensors/lidars/hokuyo/detail/ust.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "../output.h"
#include <comma/base/exception.h>
#include "../sensors.h"
#include <chrono>
#include <boost/asio/steady_timer.hpp>

namespace hok = snark::hokuyo;
namespace ip = boost::asio::ip;
Expand Down Expand Up @@ -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 >
Expand Down