top of page

Project:

Center Detection

​

Skills Involved:

ROS2

C++

Python

OpenCv

​

Code

Description

Objectives:

This project was aimed at finding the centers of the circles that were different in color i.e. red, blue, magenta and green.

​

Methodology:

For the robot and the block to spawn, the following lines were needed to run:

  1. ros2 launch rrbot_gazebo rrbot_world.launch.py : This is a ros launch file. The executable python file - rrbot_world.launch.py contains the files and packages that this launch file makes run. This launch file when run, spawns a 2R joint robot, thus called R_R bot.

  2. ros2 launch rrbot_description object_spawn.launch.py : Similar to above, this as well is a launch file. However, this executable python launch file - object_spawn.launch.py spawns a plate that contains our circles of a different color.

  3. ros2 rviz 2 rviz2 : Rviz is a tool that is used to view the camera captures in a gazebo environment. Here it captures the circles and helps detect their centers.

  4. ros2 run image_view image_view -r image:=camera1/image_raw : This command runs the image view executable. This executable subscribes to a topic. Here, it subscribes to the remapped topic, camera1/output_image.

  5. ros2 run opencv_test opencv_test1 : This is the node where the entire thresholding exists. Thus, this file is responsible for the detection of circle centers. Also, the thresholded image is published to another topic - /output_image.

  6. ros2 run image_view image_view -r image:=output_image - Again using the image_view executable but this time remapping the topic to which it subscribes to to output_image.

​

What happens in the code :

  • First, an image is received from the camera1/image_view topic.

  • Initially, the image gets converted to a ros2-type message.

  • New matrices are created for storing the thresholded values of the respective colors. This is done by using the inRange function in the hsv domain instead of rgb domain.

  • After tuning the inRange function parameters, we average out the points in the circle and find the center of the circles. Then, this image with marked circle centers (centers being the circle which a very small radius) is published to the ouput_image topic.

​

The output after thresholding:

​

 

 

 

 

 

 

 

​

 

 

 

 

 

​


Thresholded image

bottom of page