diff --git a/doc/py_tutorials/py_calib3d/py_calibration/py_calibration.markdown b/doc/py_tutorials/py_calib3d/py_calibration/py_calibration.markdown index 401fc45dfb..423f46a262 100644 --- a/doc/py_tutorials/py_calib3d/py_calibration/py_calibration.markdown +++ b/doc/py_tutorials/py_calib3d/py_calibration/py_calibration.markdown @@ -81,7 +81,7 @@ pass in terms of square size). So to find pattern in chess board, we can use the function, **cv.findChessboardCorners()**. We also need to pass what kind of pattern we are looking for, like 8x8 grid, 5x5 grid etc. In this example, we -use 7x6 grid. (Normally a chess board has 8x8 squares and 7x7 internal corners). It returns the +use 6x7 grid. (Normally a chess board has 8x8 squares and 7x7 internal corners). It returns the corner points and retval which will be True if pattern is obtained. These corners will be placed in an order (from left-to-right, top-to-bottom) @@ -107,9 +107,11 @@ import glob # termination criteria criteria = (cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_MAX_ITER, 30, 0.001) -# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0) -objp = np.zeros((6*7,3), np.float32) -objp[:,:2] = np.mgrid[0:7,0:6].T.reshape(-1,2) +# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(5,6,0) +cols = 6 +rows = 7 +objp = np.zeros((cols*rows,3), np.float32) +objp[:,:2] = np.mgrid[0:cols,0:rows].T.reshape(-1,2) # Arrays to store object points and image points from all the images. objpoints = [] # 3d point in real world space @@ -122,7 +124,7 @@ for fname in images: gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) # Find the chess board corners - ret, corners = cv.findChessboardCorners(gray, (7,6), None) + ret, corners = cv.findChessboardCorners(gray, (cols, rows), None) # If found, add object points, image points (after refining them) if ret == True: @@ -132,7 +134,7 @@ for fname in images: imgpoints.append(corners2) # Draw and display the corners - cv.drawChessboardCorners(img, (7,6), corners2, ret) + cv.drawChessboardCorners(img, (cols, rows), corners2, ret) cv.imshow('img', img) cv.waitKey(500) diff --git a/doc/py_tutorials/py_calib3d/py_pose/py_pose.markdown b/doc/py_tutorials/py_calib3d/py_pose/py_pose.markdown index e4d93d2717..40f13a2ac5 100644 --- a/doc/py_tutorials/py_calib3d/py_pose/py_pose.markdown +++ b/doc/py_tutorials/py_calib3d/py_pose/py_pose.markdown @@ -50,12 +50,14 @@ our X axis is drawn from (0,0,0) to (3,0,0), so for Y axis. For Z axis, it is dr (0,0,-3). Negative denotes it is drawn towards the camera. @code{.py} criteria = (cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_MAX_ITER, 30, 0.001) -objp = np.zeros((6*7,3), np.float32) -objp[:,:2] = np.mgrid[0:7,0:6].T.reshape(-1,2) +cols = 6 +rows = 7 +objp = np.zeros((cols*rows,3), np.float32) +objp[:,:2] = np.mgrid[0:cols,0:rows].T.reshape(-1,2) axis = np.float32([[3,0,0], [0,3,0], [0,0,-3]]).reshape(-1,3) @endcode -Now, as usual, we load each image. Search for 7x6 grid. If found, we refine it with subcorner +Now, as usual, we load each image. Search for 6x7 grid. If found, we refine it with subcorner pixels. Then to calculate the rotation and translation, we use the function, **cv.solvePnPRansac()**. Once we those transformation matrices, we use them to project our **axis points** to the image plane. In simple words, we find the points on image plane corresponding to @@ -65,7 +67,7 @@ to each of these points using our generateImage() function. Done !!! for fname in glob.glob('left*.jpg'): img = cv.imread(fname) gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY) - ret, corners = cv.findChessboardCorners(gray, (7,6),None) + ret, corners = cv.findChessboardCorners(gray, (cols, rows), None) if ret == True: corners2 = cv.cornerSubPix(gray,corners,(11,11),(-1,-1),criteria) diff --git a/modules/calib3d/include/opencv2/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d.hpp index 54403f7e6d..c1dca33c39 100644 --- a/modules/calib3d/include/opencv2/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d.hpp @@ -881,7 +881,8 @@ CV_EXPORTS_W Vec3d RQDecomp3x3( InputArray src, OutputArray mtxR, OutputArray mt @param projMatrix 3x4 input projection matrix P. @param cameraMatrix Output 3x3 camera intrinsic matrix \f$\cameramatrix{A}\f$. @param rotMatrix Output 3x3 external rotation matrix R. -@param transVect Output 4x1 translation vector T. +@param transVect Output 4x1 vector representing the camera position in homogeneous coordinates. +To obtain the translation vector, use t = -rotMatrix * transVect[:3]. @param rotMatrixX Optional 3x3 rotation matrix around x-axis. @param rotMatrixY Optional 3x3 rotation matrix around y-axis. @param rotMatrixZ Optional 3x3 rotation matrix around z-axis. diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 72d1ae4d1e..943d4f0bd6 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -2529,9 +2529,11 @@ with the WARP_RELATIVE_MAP flag : where values of pixels with non-integer coordinates are computed using one of available interpolation methods. \f$map_x\f$ and \f$map_y\f$ can be encoded as separate floating-point maps in \f$map_1\f$ and \f$map_2\f$ respectively, or interleaved floating-point maps of \f$(x,y)\f$ in -\f$map_1\f$, or fixed-point maps created by using #convertMaps. The reason you might want to -convert from floating to fixed-point representations of a map is that they can yield much faster -(\~2x) remapping operations. In the converted case, \f$map_1\f$ contains pairs (cvFloor(x), +\f$map_1\f$, or fixed-point maps created by using #convertMaps. Fixed-point maps +use a more compact representation, which can reduce memory bandwidth and benefit +repeated remap calls that reuse the same map. Performance gains vary by hardware +and are typically modest; measure before converting. In the converted case, +\f$map_1\f$ contains pairs (cvFloor(x), cvFloor(y)) and \f$map_2\f$ contains indices in a table of interpolation coefficients. This function cannot operate in-place. @@ -2540,7 +2542,7 @@ This function cannot operate in-place. @param dst Destination image. It has the same size as map1 and the same type as src . @param map1 The first map of either (x,y) points or just x values having the type CV_16SC2 , CV_32FC1, or CV_32FC2. See #convertMaps for details on converting a floating point -representation to fixed-point for speed. +representation to fixed-point. @param map2 The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map if map1 is (x,y) points), respectively. @param interpolation Interpolation method (see #InterpolationFlags). The methods #INTER_AREA