find-object icon indicating copy to clipboard operation
find-object copied to clipboard

Can I use webcam for detecting an object in rviz ?

Open Abduoit opened this issue 6 years ago • 9 comments

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.

Abduoit avatar Oct 09 '17 21:10 Abduoit

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

matlabbe avatar Oct 09 '17 23:10 matlabbe

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

Abduoit avatar Oct 10 '17 01:10 Abduoit

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

matlabbe avatar Oct 10 '17 23:10 matlabbe

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

Abduoit avatar Oct 11 '17 14:10 Abduoit

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.

matlabbe avatar Oct 11 '17 17:10 matlabbe

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.

Abduoit avatar Oct 12 '17 15:10 Abduoit

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

matlabbe avatar Oct 12 '17 18:10 matlabbe

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

AnukritiSinghh avatar Nov 17 '21 09:11 AnukritiSinghh

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.

matlabbe avatar Nov 20 '21 18:11 matlabbe