0

I have a task to find the object in an image.

object1

and translate the 2d coordinate(x,y) from my camera to 3d coordinate for my robotic arm. Now I can find the 2d coordinate with my opencv python code, and 3d coordinate by my teaching method from my robotic program but in different origin point. However, the method that I use to convert 2d to 3d coordinate is still wrong. Since the origin of the robotic arm and camera is not the same point. So I would like to ask that what formula/code should I use to convert 2d coordinate(x,y) to 3d coordinate(x,y,z) if the origin is not the same.

2 Answers2

0

Assuming that:

  • You are able to find 3D coordinates centered on the camera
  • You know the coordinates of the camera "origin" in relation to the arm
  • You know how many degree, the camera's coordinate system is rotated in respect to a given axis in the arm's coordinate system.
  • You need to obtain arm-centered coordinates.

You just need to apply a rigid transformation known as roto-translation. To simplify the following example code we'll also assume that the Z axes of both coordinate systems are parallel to each other, perpendicular to the "table", and have the same direction. So, the only rotation possible is around the Z axis.

x, y, z = get_3d(x, y)

x -= camera_origin_x_in_arm_coord_system
y -= camera_origin_y_in_arm_coord_system
z -= camera_origin_z_in_arm_coord_system

arm_x = x*cos(theta) - y*sin(theta)
arm_y = x*sin(theta) + y*cos(theta)
arm_z = z

For more complex rotations please refer to the answers to this question.

smeso
  • 3,918
  • 16
  • 25
  • Thank you for your answer. However, I understand all the method but I don't know how to find the theta to subtitute in the equation. Do I need to measure it by hand or there is anyway to calculate it? – Sarun Chanchaipattana Jul 09 '18 at 07:00
  • You can measure it by hand or, if you are able to recognize the arm with your cam, you should be able to infer the theta by confronting the coordinates measured by your cam with those you "entered" in your arm. – smeso Jul 09 '18 at 09:16
0

You need to transform your points into another coordinate system.

If you somehow calculate transformation matrix you may use cv.transform() method.

Also you can calculate youself:

point3d` = RotationMatrix * (point3d - TranslationVector)

TranslationVector and RotationMatrix it is extrinsic parameters of you arm

tenta4
  • 236
  • 1
  • 12