简体   繁体   中英

CV2 Distance with projectPoints

is it possible to calculate the distance between points which i created with cv2.projectPoints?

I have two aruco markers and from both markers i have created (with cv2.projectPoints) points which are in a specific distance to the marker. Now i want to know how far these points are away from each other?

I know you cant give a specific code without an MVP and it is not necessary i only need an idea how this is possible to calculate. I would be awesome if someone knows maybe a cv2 function or a way to calculate these?

Thank you very much <3

在此处输入图像描述

Assuming you're asking about 3D , ie you want a 3D distance between those points...

You just need to define the poses of those points, relative to their markers. That is T_marker1_point1 and T_marker2_point2 . Make those be pure translation, probably with Z=0 if these points are in each respective marker's plane. Literally make a 4x4 identity matrix, then stick your nominal (constructed) dimensions into the last column.

Then you need the marker poses relative to the camera, T_cam_marker1 and T_cam_marker2 .

Finally you calculate

T_point1_point2 = T_point1_marker1 @ T_marker1_cam @ T_cam_marker2 @ T_marker2_point2
# where
# T_marker1_cam = np.linalg.inv(T_cam_marker1)
# and so on

The translation part of that pose matrix gives you the distance between those points. You can ignore the rotation component. That'd only give you the rotation between those markers, because your points were defined as poses of the same orientation as their respective markers. Yes, orientation is silly for points but eh...

All of that is 4x4 matrices. Compose from tvec , put in third column, and rvec , turned into a 3x3 rotation matrix using cv.Rodrigues .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM