introlab / find-object

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

Can I use webcam for detecting an object in rviz ? #48

Open Abduoit opened 7 years ago

Abduoit commented 7 years ago

I cloned find-object and I run the following codes properly by using webcam I detected the object and I published the detected object with (position, rotation, scale and shear)

roscore
rosrun uvc_camera uvc_camera_node &
rosrun find_object_2d find_object_2d image:=image_raw
rosrun find_object_2d print_objects_detected

Can I use normal webcam for detecting an object in rviz ? I mean, can we display object position (x, y) in rviz.

matlabbe commented 7 years ago

You would have to do it yourself, by creating a node subscribing to image and objects topics, draw object position in the image and republish the image to RVIZ.

cheers

Abduoit commented 7 years ago

do you mean that I have to subscribe to the object printed topic, and draw the detected object in the image, then republish the image to the rviz

matlabbe commented 7 years ago

I added a new example for image+objects synchronization, then republishing the image with rectangles drawn around the objects detected.

$ roscore
$ rosrun uvc_camera uvc_camera_node 
$ rosrun find_object_2d find_object_2d image:=image_raw
$ rosrun find_object_2d print_objects_detected image:=image_raw
$ rqt_image_view

In rviz you could subscribe to image published by print_objects_detected node (/image_with_objects).

screenshot from 2017-10-10 19 10 06

cheers, Mathieu

Abduoit commented 7 years ago

After running these

$ roscore
$ rosrun uvc_camera uvc_camera_node 
$ rosrun find_object_2d find_object_2d image:=image_raw
$ rosrun find_object_2d print_objects_detected image:=image_raw
$ rqt_image_view
$ rosrun rviz rviz

I selected my object and print_objects_detected node, BUT there's no object detected in rqt_image_view only normal image.

And there is NO topic /image_with_objects in rviz, only image_raw

matlabbe commented 7 years ago

Make sure to rebuild find_object_2d from source to get the update. Did you add objects in Find-Object like in the right of the screenshot above? /image_with_objects is published only when objects are detected in Find-Object.

Abduoit commented 7 years ago

Thx @matlabbe

I detect the object in rviz as u can see in the following pic

detect-object-rviz

Do you think that I need to see the TF frames in rviz link this link, I mean, representing the detected object in TF space. Since I need to subscribe to the publish msg. later, cuz my last target is controlling the Dynamixel ax-12a servo by moving the detected object that shown above.

matlabbe commented 7 years ago

Maybe just tell the camera to move right when the object is on the right of the image, so you don't really need TF. The TF example is using an RGB-D camera to get the 3D pose of the object.

cheers, Mathieu

AnukritiSinghh commented 2 years ago

Hi @Abduoit how were you able to do it? I run roslaunch usb_cam usb_cam-test.launch rosrun find_object_2d find_object_2d image:=/usb_cam/image_raw rosrun find_object_2d print_objects_detected And my object is detected in find_object, but then when I open rqt_image_view I see a blank screen with image_with_objects. Can you please help me? image

matlabbe commented 2 years ago

Hi, you should make sure to remap the input image topic of print_objects_detected:

rosrun find_object_2d print_objects_detected image:=/usb_cam/image_raw

However, I also found a sync issue with that node, the stamp of the published objectsStamped topic was not exactly the same than the one in the input image. I fixed this issue in the commit above.