1,得出摄像头距离目标的距离
GetDistance
range: distance = 303 mm
2,得出按键的位置信息
FindKey:Fn
Find the color_key is green:Fn, value is {"x":60, "y":215, "w":24, "h":28, "pixels":598, "cx":72, "cy":228, "rotation":1.483038, "code":1, "count":1, "perimeter":111, "roundness":0.697987},
3,得出AprilTag位置的信息
FindPC:0
find tag id is 0
{"x":389, "y":301, "w":100, "h":91, "id":0, "family":16, "cx":439, "cy":348, "rotation":3.098659, "decision_margin":0.224468, "hamming":0, "goodness":0.000000, "x_translation":2.496496, "y_translation":-2.235201, "z_translation":-10.204804, "x_rotation":2.967950, "y_rotation":6.077061, "z_rotation":3.098659}
4,算的实际距离的比例K
double K = Math.Round(double.Parse(distance) / Math.Sqrt(2.507362 * 2.507362 + 2.210557 * 2.210557 + -10.253651 * -10.253651));
double x_distance = K * 2.50;
double y_distance = K * 2.210557;
double z_dinstance = K * -10.253651;5,计算每个像素占比的实际距离
double c_x = 640 * 0.5; //# 默认值(image.w * 0.5)
double c_y = 480 * 0.5; //# 默认值(image.h * 0.5)
double x_xiangsu = x_distance / (c_x - 439); //439 为 步骤3获取的AprilTag cx
double y_xiangsu = y_distance / (c_y - 348); //348为 步骤3获取的AprilTag cy6, 算得Fn 的实际距离
double fn_x = 60 * x_xiangsu; //60为 步骤2获取的Fn x
double fn_y = 215 * y_xiangsu; //215为 步骤2获取的Fn y7,OpenMV获取到的图片

8,实际上的位置信息
请问 这样算有问题吗
提醒你一下,先做一下畸变矫正:https://book.openmv.cc/example/04-Image-Filters/lens-correction.html
@kidswong999 在 [这样可以得出实际的坐标吗](/post/29660) 中说:
> 提醒你一下,先做一下畸变矫正:https://book.openmv.cc/example/04-Image-Filters/lens-correction.html
好的 谢谢
请问根据 勾股定理算出的K 值,用K乘上x_translation 是摄像头距离AprilTag x 方向的 实际距离吗?
K = Math.Round(double.Parse(distance) / Math.Sqrt(x_translation * x_translation + y_translation * y_translation + z_translation * z_translation));
double xDistance = K * x_translation;@sqph 是的。
@kidswong999 在 [这样可以得出实际的坐标吗](/post/29671) 中说:
> @sqph 是的。
根据摄像头距离AprilTag x 方向的 实际距离xDistance
计算出每个像素的 实际大小 根据 x 方向的图片中像素的差值
cx 是摄像头的中心位置,c_x 是AprilTag 的中心位置
像素距离 = xDistance/(cx-c_x)
这样对吗
@kidswong999 麻烦帮忙看一下呗 这样对吗 根据像素比例 然后 计算x y 实际坐标 移动到坐标点
@kidswong999 在 [这样可以得出实际的坐标吗](/post/29671) 中说:
> @sqph 是的。
但是和实际测量的不一样啊,哪里出问题了吗