# about the RTK circular projection geometric calibration

**URL:** <https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195>\
**Category:** Algorithms\
**Tags:** rtk\
**Created:** [August 29, 2024, 2:31am UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195 "2024-08-29T02:31:34Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [August 29, 2024, 2:31am UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/1 "2024-08-29T02:31:34Z")

</div>

I have a set of images of a phantom with steel balls, and I have extracted the coordinates of the steel balls. In total, there are 845 images, and I have tracked the coordinates of each steel ball. Currently, the known quantities are the coordinates of each steel ball in the 845 images, as well as the three-dimensional coordinates of the steel balls in the phantom. Now, to perform geometric calibration, what should I do? My confusion lies in whether the gantry angle is considered a known quantity or an unknown quantity. I have been unable to obtain results using LM optimization and least squares methods.

---

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [August 29, 2024, 2:39am UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/2 "2024-08-29T02:39:29Z")

</div>

![image](https://discourse.itk.org/uploads/default/original/2X/b/bcff0f2458b06b7fedd7d494885ed4daacb4b314.jpeg)  
I ensure that the coordinates of the steel balls are correctly matched.

---

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [August 29, 2024, 2:49am UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/3 "2024-08-29T02:49:10Z")

</div>

```auto
> def likelihood(params, A, b):
> inPlaneAngle = params[0]
> outOfPlaneAngle = params[1]
> SourceToDetectorDistance = params[2]
> SourceToIsocenterDistance = params[3]
> sourceOffsetX = params[4]
> sourceOffsetY = params[5]
> projOffsetX = params[6]
> projOffsetY = params[7]
> c = params[8] # 从params中提取c值
> # squared_residuals_sum = 0.0
> 
>    
>  
> # c = c* math.pi / 180.0
> gantryAngle = c # 获取当前点对应的gantryAngle
>         
> Rz = np.array([[np.cos(-inPlaneAngle), -np.sin(-inPlaneAngle), 0],
> [np.sin(-inPlaneAngle), np.cos(-inPlaneAngle), 0],
> [0, 0, 1]])
> 
> # 绕X轴旋转矩阵
> Rx = np.array([[1, 0, 0],
> [0, np.cos(-outOfPlaneAngle), -np.sin(-outOfPlaneAngle)],
> [0, np.sin(-outOfPlaneAngle), np.cos(-outOfPlaneAngle)]])
> 
> # 绕Y轴旋转矩阵
> Ry = np.array([[np.cos(-gantryAngle), 0, np.sin(-gantryAngle)],
> [0, 1, 0],
> [-np.sin(-gantryAngle), 0, np.cos(-gantryAngle)]])
> 
> rotation_matrix = np.dot(Rz, np.dot(Rx, Ry))
> 
> # 平移向量
> translation_vector = np.zeros((3, 1)) # 这里默认平移向量为 [0, 0, 0]
> 
> # 创建齐次矩阵
> homogeneous_matrix = np.eye(4)
> homogeneous_matrix[:3, :3] = rotation_matrix
> homogeneous_matrix[:3, 3] = np.squeeze(translation_vector)
> 
> Mp1 = np.array([[1, 0, sourceOffsetX - projOffsetX],
> [0, 1, sourceOffsetY - projOffsetY],
> [0, 0, 1]])
> 
> Mp2 = np.array([[-SourceToDetectorDistance, 0, 0, 0],
> [0, -SourceToDetectorDistance, 0, 0],
> [0, 0, 1, -SourceToIsocenterDistance]])
> 
> Mp3 = np.array([[1, 0, 0, -sourceOffsetX],
> [0, 1, 0, -sourceOffsetY],
> [0, 0, 1, 0],
> [0, 0, 0, 1]])
> 
> Mp = np.dot(Mp1, np.dot(Mp2, np.dot(Mp3, homogeneous_matrix)))
>       
> 
> projected_points = np.dot(Mp, A.T)
> projected_points /= np.divide(projected_points[2], projected_points[2])
> residuals = projected_points[:2].T - b
> squared_residuals = np.sum(residuals**2)
> # squared_residuals_sum += squared_residuals
> #print(A.shape[0])
> return squared_residuals

```

This is my modeling of the RTK circular projection geometry, used as an estimation function. However, I have been unable to obtain results using maximum likelihood estimation and least squares methods. I anticipated two outcomes: one is to solve for each parameter, and the other is to obtain a projection matrix corresponding to each angular position. However, I cannot achieve either. Can you help me?

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [August 29, 2024, 4:48pm UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/4 "2024-08-29T16:48:16Z")

</div>

What you might want is OpenCV’s [calibrateCamera()](https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html#ga3207604e4b1a1758aa66acb6ed5aa65d), as it provides rotation and translation vectors for each calibration image ([tutorial](https://docs.opencv.org/4.x/dc/dbb/tutorial_py_calibration.html)).

---

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [August 30, 2024, 6:10am UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/5 "2024-08-30T06:10:15Z")

</div>

thank you very much

---

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [August 30, 2024, 6:12am UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/6 "2024-08-30T06:12:40Z")

</div>

However, the modeling approach for the camera is different from the circular geometric modeling approach of RTK. Can these methods be used interchangeably, or do I only need to compute the projection matrix without concerning specific SID and SAD parameters?

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [August 30, 2024, 1:53pm UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/7 "2024-08-30T13:53:39Z")

</div>

Calibrate camera should give your camera positions on a circular path around the phantom. I have not used RTK myself, so I don’t know how to further treat that. Perhaps @simon.rit has some advice?

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [August 31, 2024, 6:42pm UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/8 "2024-08-31T18:42:35Z")

</div>

If you know the position of the source + position and orientation of the detector at each position, you can use [AddProjection](http://www.openrtk.org/Doxygen/classrtk_1_1ThreeDCircularProjectionGeometry.html#a0fb1475ed76a28cde24fac85eae18e1e) to create your RTK geometry object.

---

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [September 18, 2024, 10:04am UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/9 "2024-09-18T10:04:38Z")

</div>

This won’t work, OpenCV only supports planar calibration

---

<div class="post-metadata">

**Author:** ![ma1282029525](https://discourse.itk.org/user_avatar/discourse.itk.org/ma1282029525/32/3084_2.png) [@ma1282029525](https://discourse.itk.org/u/ma1282029525)\
**Post date:** [September 18, 2024, 10:05am UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/10 "2024-09-18T10:05:43Z")

</div>

I only know the approximate parameters, so I need to calibrate to determine more accurate results.

---

<div class="post-metadata">

**Author:** ![zhangxiang](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/c77e96/32.png) [@zhangxiang](https://discourse.itk.org/u/zhangxiang)\
**Post date:** [October 14, 2024, 2:12am UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/11 "2024-10-14T02:12:58Z")

</div>

I have the same question. In 2d image of ITK, u→,v↓, in a pinhole model and DLT, u→ v↓. But in 3D circular geometry in RTK wiki, [RTK: RTK 3D circular projection geometry](http://www.openrtk.org/Doxygen/DocGeo3D.html) , u→,v↑ ,the direction of v axis is opposite to 2D image and pinhole model.  
I wonder whether I can directly input the projection matrice obtained by DLT and optimization.

---

<div class="post-metadata">

**Author:** ![langzhizhen](https://discourse.itk.org/user_avatar/discourse.itk.org/langzhizhen/32/4468_2.png) [@langzhizhen](https://discourse.itk.org/u/langzhizhen)\
**Post date:** [February 15, 2025, 2:20am UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/12 "2025-02-15T02:20:45Z")

</div>

Hello, I have the same problem. How should I construct a system of DLT equations to solve the projection matrix. I have now got the 2D image coordinates (x,y) and the 3D world coordinates (x,y,z).

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [February 18, 2025, 9:12pm UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/13 "2025-02-18T21:12:06Z")

</div>

I guess that if you set the out of plane angle to pi, you will obtain the sought effect. The best would be to express your source position, detector position, u and v in a reference frame and to use [this AddProjection](http://www.openrtk.org/Doxygen/classrtk_1_1ThreeDCircularProjectionGeometry.html#a0fb1475ed76a28cde24fac85eae18e1e).

---

<div class="post-metadata">

**Author:** ![zhangxiang](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/c77e96/32.png) [@zhangxiang](https://discourse.itk.org/u/zhangxiang)\
**Post date:** [February 19, 2025, 5:23am UTC](https://discourse.itk.org/t/about-the-rtk-circular-projection-geometric-calibration/7195/14 "2025-02-19T05:23:37Z")

</div>

see this paper.  
New Calibrator with Points Distributed Conical Helically for Online Calibration of C-Arm.
