diff --git a/modules/calib3d/include/opencv2/calib3d/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d/calib3d.hpp index b416759270..d15b849227 100644 --- a/modules/calib3d/include/opencv2/calib3d/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d/calib3d.hpp @@ -104,31 +104,6 @@ CVAPI(void) cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2, CVAPI(void) cvCorrectMatches(CvMat* F, CvMat* points1, CvMat* points2, CvMat* new_points1, CvMat* new_points2); -/* Transforms the input image to compensate lens distortion */ -CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst, - const CvMat* camera_matrix, - const CvMat* distortion_coeffs, - const CvMat* new_camera_matrix CV_DEFAULT(0) ); - -/* Computes transformation map from intrinsic camera parameters - that can used by cvRemap */ -CVAPI(void) cvInitUndistortMap( const CvMat* camera_matrix, - const CvMat* distortion_coeffs, - CvArr* mapx, CvArr* mapy ); - -/* Computes undistortion+rectification map for a head of stereo camera */ -CVAPI(void) cvInitUndistortRectifyMap( const CvMat* camera_matrix, - const CvMat* dist_coeffs, - const CvMat *R, const CvMat* new_camera_matrix, - CvArr* mapx, CvArr* mapy ); - -/* Computes the original (undistorted) feature coordinates - from the observed (distorted) coordinates */ -CVAPI(void) cvUndistortPoints( const CvMat* src, CvMat* dst, - const CvMat* camera_matrix, - const CvMat* dist_coeffs, - const CvMat* R CV_DEFAULT(0), - const CvMat* P CV_DEFAULT(0)); /* Computes the optimal new camera matrix according to the free scaling parameter alpha: alpha=0 - only valid pixels will be retained in the undistorted image @@ -450,13 +425,6 @@ public: namespace cv { - CV_EXPORTS void undistortPoints( const Mat& src, vector& dst, - const Mat& cameraMatrix, const Mat& distCoeffs, - const Mat& R=Mat(), const Mat& P=Mat()); -CV_EXPORTS void undistortPoints( const Mat& src, Mat& dst, - const Mat& cameraMatrix, const Mat& distCoeffs, - const Mat& R=Mat(), const Mat& P=Mat()); - CV_EXPORTS void Rodrigues(const Mat& src, Mat& dst); CV_EXPORTS void Rodrigues(const Mat& src, Mat& dst, Mat& jacobian); @@ -573,7 +541,7 @@ CV_EXPORTS void calibrationMatrixValues( const Mat& cameraMatrix, double& focalLength, Point2d& principalPoint, double& aspectRatio ); - + CV_EXPORTS double stereoCalibrate( const vector >& objectPoints, const vector >& imagePoints1, const vector >& imagePoints2, @@ -605,6 +573,10 @@ CV_EXPORTS bool stereoRectifyUncalibrated( const Mat& points1, Mat& H1, Mat& H2, double threshold=5 ); +CV_EXPORTS Mat getOptimalNewCameraMatrix( const Mat& cameraMatrix, const Mat& distCoeffs, + Size imageSize, double alpha, Size newImgSize=Size(), + Rect* validPixROI=0); + CV_EXPORTS void convertPointsHomogeneous( const Mat& src, vector& dst ); CV_EXPORTS void convertPointsHomogeneous( const Mat& src, vector& dst ); diff --git a/modules/calib3d/include/opencv2/calib3d/compat_c.h b/modules/calib3d/include/opencv2/calib3d/compat_c.h index e3a2db376e..2b2b66aa3d 100644 --- a/modules/calib3d/include/opencv2/calib3d/compat_c.h +++ b/modules/calib3d/include/opencv2/calib3d/compat_c.h @@ -263,49 +263,6 @@ CV_INLINE void cvProjectPointsSimple( int point_count, CvPoint3D64f* _object_po } -CV_INLINE void cvUnDistortOnce( const CvArr* src, CvArr* dst, - const float* intrinsic_matrix, - const float* distortion_coeffs, - int CV_UNREFERENCED(interpolate) ) -{ - CvMat _a = cvMat( 3, 3, CV_32F, (void*)intrinsic_matrix ); - CvMat _k = cvMat( 4, 1, CV_32F, (void*)distortion_coeffs ); - cvUndistort2( src, dst, &_a, &_k, 0 ); -} - - -/* the two functions below have quite hackerish implementations, use with care - (or, which is better, switch to cvUndistortInitMap and cvRemap instead */ -CV_INLINE void cvUnDistortInit( const CvArr* CV_UNREFERENCED(src), - CvArr* undistortion_map, - const float* A, const float* k, - int CV_UNREFERENCED(interpolate) ) -{ - union { uchar* ptr; float* fl; } data; - CvSize sz; - cvGetRawData( undistortion_map, &data.ptr, 0, &sz ); - assert( sz.width >= 8 ); - /* just save the intrinsic parameters to the map */ - data.fl[0] = A[0]; data.fl[1] = A[4]; - data.fl[2] = A[2]; data.fl[3] = A[5]; - data.fl[4] = k[0]; data.fl[5] = k[1]; - data.fl[6] = k[2]; data.fl[7] = k[3]; -} - -CV_INLINE void cvUnDistort( const CvArr* src, CvArr* dst, - const CvArr* undistortion_map, - int CV_UNREFERENCED(interpolate) ) -{ - union { uchar* ptr; float* fl; } data; - float a[] = {0,0,0,0,0,0,0,0,1}; - CvSize sz; - cvGetRawData( undistortion_map, &data.ptr, 0, &sz ); - assert( sz.width >= 8 ); - a[0] = data.fl[0]; a[4] = data.fl[1]; - a[2] = data.fl[2]; a[5] = data.fl[3]; - cvUnDistortOnce( src, dst, a, data.fl + 4, 1 ); -} - #define cvMake2DPoints cvConvertPointsHomogeneous #define cvMake3DPoints cvConvertPointsHomogeneous diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index 4d2852e577..a530621adb 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -46,6 +46,8 @@ #include "opencv2/core/core.hpp" #ifdef __cplusplus +#include + extern "C" { #endif diff --git a/modules/features2d/src/oneway.cpp b/modules/features2d/src/oneway.cpp index a9df95771a..e0b3d5c56e 100644 --- a/modules/features2d/src/oneway.cpp +++ b/modules/features2d/src/oneway.cpp @@ -9,6 +9,7 @@ #include "precomp.hpp" #include "opencv2/highgui/highgui.hpp" +#include namespace cv{ diff --git a/modules/highgui/src/cap_dc1394_v2.cpp b/modules/highgui/src/cap_dc1394_v2.cpp index c3d972f5d3..12986b7a37 100644 --- a/modules/highgui/src/cap_dc1394_v2.cpp +++ b/modules/highgui/src/cap_dc1394_v2.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include diff --git a/modules/highgui/src/cap_xine.cpp b/modules/highgui/src/cap_xine.cpp index e06ea267fb..cdaf004550 100644 --- a/modules/highgui/src/cap_xine.cpp +++ b/modules/highgui/src/cap_xine.cpp @@ -51,7 +51,6 @@ // required to enable some functions used here... #define XINE_ENABLE_EXPERIMENTAL_FEATURES -#include #include extern "C" diff --git a/modules/imgproc/include/opencv2/imgproc/compat_c.h b/modules/imgproc/include/opencv2/imgproc/compat_c.h index 5ad9e3a544..2a1f8e6f8f 100644 --- a/modules/imgproc/include/opencv2/imgproc/compat_c.h +++ b/modules/imgproc/include/opencv2/imgproc/compat_c.h @@ -425,8 +425,6 @@ CV_INLINE void cvMinAreaRect( CvPoint* points, int n, vect1->y = pt[1].y - pt[0].y; vect2->x = pt[3].x - pt[0].x; vect2->y = pt[3].y - pt[0].y; - - CV_UNREFERENCED( (left, bottom, right, top) ); } typedef int CvDisType; @@ -828,6 +826,50 @@ typedef struct CvMatrix3 } CvMatrix3; + +CV_INLINE void cvUnDistortOnce( const CvArr* src, CvArr* dst, + const float* intrinsic_matrix, + const float* distortion_coeffs, + int CV_UNREFERENCED(interpolate) ) +{ + CvMat _a = cvMat( 3, 3, CV_32F, (void*)intrinsic_matrix ); + CvMat _k = cvMat( 4, 1, CV_32F, (void*)distortion_coeffs ); + cvUndistort2( src, dst, &_a, &_k, 0 ); +} + + +/* the two functions below have quite hackerish implementations, use with care + (or, which is better, switch to cvUndistortInitMap and cvRemap instead */ +CV_INLINE void cvUnDistortInit( const CvArr* CV_UNREFERENCED(src), + CvArr* undistortion_map, + const float* A, const float* k, + int CV_UNREFERENCED(interpolate) ) +{ + union { uchar* ptr; float* fl; } data; + CvSize sz; + cvGetRawData( undistortion_map, &data.ptr, 0, &sz ); + assert( sz.width >= 8 ); + /* just save the intrinsic parameters to the map */ + data.fl[0] = A[0]; data.fl[1] = A[4]; + data.fl[2] = A[2]; data.fl[3] = A[5]; + data.fl[4] = k[0]; data.fl[5] = k[1]; + data.fl[6] = k[2]; data.fl[7] = k[3]; +} + +CV_INLINE void cvUnDistort( const CvArr* src, CvArr* dst, + const CvArr* undistortion_map, + int CV_UNREFERENCED(interpolate) ) +{ + union { uchar* ptr; float* fl; } data; + float a[] = {0,0,0,0,0,0,0,0,1}; + CvSize sz; + cvGetRawData( undistortion_map, &data.ptr, 0, &sz ); + assert( sz.width >= 8 ); + a[0] = data.fl[0]; a[4] = data.fl[1]; + a[2] = data.fl[2]; a[5] = data.fl[3]; + cvUnDistortOnce( src, dst, a, data.fl + 4, 1 ); +} + #ifdef __cplusplus } #endif diff --git a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp index dd5a2c6406..b1fcc29154 100644 --- a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp @@ -347,7 +347,7 @@ CV_EXPORTS void remap( const Mat& src, Mat& dst, const Mat& map1, const Mat& map CV_EXPORTS void convertMaps( const Mat& map1, const Mat& map2, Mat& dstmap1, Mat& dstmap2, int dstmap1type, bool nninterpolation=false ); - + CV_EXPORTS Mat getRotationMatrix2D( Point2f center, double angle, double scale ); CV_EXPORTS Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] ); CV_EXPORTS Mat getAffineTransform( const Point2f src[], const Point2f dst[] ); @@ -388,12 +388,15 @@ CV_EXPORTS void undistort( const Mat& src, Mat& dst, const Mat& cameraMatrix, CV_EXPORTS void initUndistortRectifyMap( const Mat& cameraMatrix, const Mat& distCoeffs, const Mat& R, const Mat& newCameraMatrix, Size size, int m1type, Mat& map1, Mat& map2 ); -CV_EXPORTS Mat getOptimalNewCameraMatrix( const Mat& cameraMatrix, const Mat& distCoeffs, - Size imageSize, double alpha, Size newImgSize=Size(), - Rect* validPixROI=0); CV_EXPORTS Mat getDefaultNewCameraMatrix( const Mat& cameraMatrix, Size imgsize=Size(), bool centerPrincipalPoint=false ); +CV_EXPORTS void undistortPoints( const Mat& src, vector& dst, + const Mat& cameraMatrix, const Mat& distCoeffs, + const Mat& R=Mat(), const Mat& P=Mat()); +CV_EXPORTS void undistortPoints( const Mat& src, Mat& dst, + const Mat& cameraMatrix, const Mat& distCoeffs, + const Mat& R=Mat(), const Mat& P=Mat()); template<> CV_EXPORTS void Ptr::delete_obj(); diff --git a/modules/imgproc/include/opencv2/imgproc/imgproc_c.h b/modules/imgproc/include/opencv2/imgproc/imgproc_c.h index e7c3cd0797..fadcf2028a 100644 --- a/modules/imgproc/include/opencv2/imgproc/imgproc_c.h +++ b/modules/imgproc/include/opencv2/imgproc/imgproc_c.h @@ -205,6 +205,32 @@ CVAPI(void) cvLinearPolar( const CvArr* src, CvArr* dst, CvPoint2D32f center, double maxRadius, int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS)); +/* Transforms the input image to compensate lens distortion */ +CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst, + const CvMat* camera_matrix, + const CvMat* distortion_coeffs, + const CvMat* new_camera_matrix CV_DEFAULT(0) ); + +/* Computes transformation map from intrinsic camera parameters + that can used by cvRemap */ +CVAPI(void) cvInitUndistortMap( const CvMat* camera_matrix, + const CvMat* distortion_coeffs, + CvArr* mapx, CvArr* mapy ); + +/* Computes undistortion+rectification map for a head of stereo camera */ +CVAPI(void) cvInitUndistortRectifyMap( const CvMat* camera_matrix, + const CvMat* dist_coeffs, + const CvMat *R, const CvMat* new_camera_matrix, + CvArr* mapx, CvArr* mapy ); + +/* Computes the original (undistorted) feature coordinates + from the observed (distorted) coordinates */ +CVAPI(void) cvUndistortPoints( const CvMat* src, CvMat* dst, + const CvMat* camera_matrix, + const CvMat* dist_coeffs, + const CvMat* R CV_DEFAULT(0), + const CvMat* P CV_DEFAULT(0)); + /* creates structuring element used for morphological operations */ CVAPI(IplConvKernel*) cvCreateStructuringElementEx( int cols, int rows, int anchor_x, int anchor_y, diff --git a/modules/calib3d/src/undistort.cpp b/modules/imgproc/src/undistort.cpp similarity index 100% rename from modules/calib3d/src/undistort.cpp rename to modules/imgproc/src/undistort.cpp