2

I have 2 photos of chessboard from camera. I need to find angle between planes on 2 images. For example we have normal "chessboard" image, after some transformations we got a new image in perspective "chessboard2". Is it possible to find angle between those planes?

Normal chessboard: Normal

Perspective chessboard: Perspective

For understanding: i try to find angle φ between planes.image φ

I've tried to solve this by python(opencv) program. I used cv2.getPerspectiveTransform() function to find transformation matrix, but i can't pull out the angles I need :(

Thank you!

Jack Aron
  • 41
  • 1
  • 8
  • You need to detect some pivot points in both the images, and then comparing those values you can calculate yaw, pitch and roll as answered [here](https://stackoverflow.com/a/36591123/3051961) I have took 6 points, and would also suggest to choose any 6 prominent points like 4 corners, 2 intersection points of middle white and black piece, etc. – ZdaR Jan 30 '18 at 09:14
  • @ZdaR thanks for the answer! How can I find 3D points? – Jack Aron Jan 30 '18 at 09:45

2 Answers2

3

Francesco gave a very sensible answer. However, if you don't have the camera intrinsics (focal length, principal point etc.) for the 'perspective view', you need to estimate them.

Because your images are of a regular checkerboard, you can do this using OpenCV's camera calibration methods with automatic checkerboard detection. See opencv_source_code/samples/cpp/calibration.cpp for a nice demonstration.

In the calibration example, you can use the -o flag to specify that you want to output the camera extrinsic matrices (i.e. the rotation R and translation t that transforms the planar target to the perspective view). The angle between the two planes in the Normal and Perspective view is simply acos(R22), where R22 is the bottom right element in R.

One important point about calibration. If you have more than one perspective view from different angles, and you are sure that the camera intrinsics are constant for all views, then you can do a normal calibration of the complete intrinsic matrix, as is done in the calibration example.

However, if you only have one perspective view, this is not possible, and you have to use a simplified camera intrinsic matrix. Normally you would do this by only calibrating the camera's focal length. To do this you need to pass calibrateCamera a cameraMatrix K with K = [0,0,px;0,0,py;0,0,1] where px is half the image width, and py is half the image height (of the perspective view). You also pass calibrateCamera a distortion matrix of size 3x1 with all elements zero. Finally, you need to ensure only the focal length is estimated in the call to calibrateCamera by setting the following flags: CALIB_FIX_ASPECT_RATIO, CALIB_FIX_PRINCIPAL_POINT, CALIB_ZERO_TANGENT_DIST, CALIB_FIX_K1,CALIB_FIX_K2,CALIB_FIX_K3.

Toby Collins
  • 823
  • 5
  • 8
0

Simplest approach is to estimate the vanishing points of the horizontal and vertical directions of the checkerboard - and note that they are both points at infinity in your "Normal" image.

For each image, you write them in homogeneous coordinates, and normalize them to unit Euclidean norm. Then their cross product is the unit vector normal to the checkerboard plane, decomposed in camera coordinates.

Do that for both images, then compute the angle between the found normal vectors: that's the angle between the planes you want.

Francesco Callari
  • 11,300
  • 2
  • 25
  • 40