top of page

Project:

Canny Edge Detection

​

Skills Involved:

ROS2

C++

Python

OpenCv

​

Code

Description

Objectives:

This project was aimed towards finding the Edges of the block which is kept in Gazebo environment.

​

Methodology:

For the robot and the block to spawn, 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 contain our circles of different colour.

  3. ros2 rviz 2 rviz2 : Rviz is a tool which is used to view the camera captures in a gazebo environment. Here it captures the image of the simulation and detect the corners.

  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 canny_edge : This node generates edges to the plate and other components if the mask finds any. The final image is published to the /output_image topic.

  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.

  • A new image is created with a single channel.

  • Also, the RGB image is converted to HSV image.

  • Using the canny edge detection function, we get the edges in a different image which we then publish to the /output_image topic.

​

The output after detecting edges:

​

 

 

 

 

 

 

 

 

 

 

 

 

 

​

​

​

Detected Edges

bottom of page