Close

Finding edges

A project log for Anna The Multibot!

Multifunctional robot to help bring the dream of a personal robot into reality.

dennisDennis 07/05/2016 at 18:240 Comments

With the image from the camera now in the program, we need to look for object edges. This is one of the easiest ways to locate threats to the robot’s movements. An easy way to do this is to take the bitmap image that we have from the camera and invoke the canny function from the OpenCV library to implement the Canny Edge Detector. Below is the function I use to accomplish this. It returns a black and white image. The background is black and the edges show up white.

Public Function edges() As Bitmap
Dim cannyFrame As New Mat()
Dim cannyFrame2 As New Mat()
Dim ColordImage As Image(Of Bgr, [Byte]) = New Image(Of Bgr, Byte)(picture)
Dim grayImage As Image(Of Gray, [Byte]) = ColordImage.Convert(Of Gray, [Byte])()
Dim pyrDown As New UMat()
CvInvoke.Canny(grayImage, cannyFrame, 100, 60)
Dim img As Image(Of Bgr, [Byte]) = cannyFrame.ToImage(Of Bgr, [Byte])()
Dim MyImage As Image = img.ToBitmap()
Return img.ToBitmap()
End Function

Here's the image with the bitmap:

Here's the image after invoking the Canny Edge Detector:

Discussions