introlab / find-object

Find-Object project
http://introlab.github.io/find-object/
BSD 3-Clause "New" or "Revised" License
448 stars 189 forks source link

Coordinates of the detected object. #86

Open ArjunSikhwal opened 5 years ago

ArjunSikhwal commented 5 years ago

Hello , I'm building a pick and place robotic arm and I'm using kinect for object detection can anyone tell me how to get the coordinates of the detected object ? I'm very new to ROS and can't figure it out, really appreciate your help. Thanks in advance

matlabbe commented 5 years ago

Did you try http://wiki.ros.org/find_object_2d#A3D_position_of_the_objects ?

npd26 commented 5 years ago

@ArjunSikhwal how you using this package with pick and place?

Sammysedo commented 4 years ago

Maybe a bit old, but here's how I did it (note that I did not need object orientation):

import rospy
import tf

def get_pose_coord():

  listener = tf.TransformListener()

  listener.waitForTransform("/camera_rgb_optical_frame", "object_id", rospy.Time(), rospy.Duration(4.0))
  (trans, rot) = listener.lookupTransform('camera_rgb_optical_frame', 'object_id', rospy.Time())

  goal_coord = [trans[0], trans[1], trans[2]] # x, y, z
  return goal_coord

Feel free to replace object_id with whatever object prefix you are using. Please also note that you need to do a static transform publication to get camera frame in correct position and orientation in reference to the robot base frame.

AnukritiSinghh commented 3 years ago

Hey, were you able to get the image co-ordinates using the find_object package?

matlabbe commented 3 years ago

Using the homography and size of the object, you can derive the corners like in this example: https://github.com/introlab/find-object/blob/fd9270a5617f31087bc61c3fae919961a2240b78/src/ros/print_objects_detected_node.cpp#L60-L75

AnukritiSinghh commented 3 years ago

Hi @matlabbe, but these corner values aren't in pixels, right? How to get the values in pixels? I want to use it for image based visual serving. Thanks

matlabbe commented 3 years ago

Yeah, they should be in pixels. When launching the node print_objects_detected, here is an example of output of the code above, the corners are in pixels:

$ rosrun find_object_2d print_objects_detected
---
No objects detected.
---
Object 1 detected, Qt corners at (245.456680,97.388290) (396.141483,97.715099) (239.838840,384.329650) (394.736687,362.925157)
---
Object 1 detected, Qt corners at (239.857468,97.219025) (391.417286,97.380249) (229.270036,385.406300) (389.819694,367.935798)
AnukritiSinghh commented 3 years ago

thanks @matlabbe but aren't pixel values integer?

matlabbe commented 3 years ago

When doing the homography, we play in subpixel accuracy, thus float. You can round the values if you need intergers.

AnukritiSinghh commented 3 years ago

Okay, thank you very much for helping me out.