go_away

Author Topic: Canny Edge Detector  (Read 5159 times)

0 Members and 1 Guest are viewing this topic.

Offline SomchayaTopic starter

  • Robot Overlord
  • ****
  • Posts: 180
  • Helpful? 0
  • You know it's cute!
Canny Edge Detector
« on: March 21, 2007, 01:01:57 PM »
Hey, is anyone familiar with the Canny Edge Detector? I found some tutorials online, but when I coded it, the results didn't look "right". I have some pictures below:



This is the original size image. The image from the webcam is 160x120, but I resize it to 32x24 before running the Canny edge detection. The smaller images from right to left are:

1) 32x24 version of the original
2) A gaussian smoothed version (with a 5x5 filter)
3) After running the Sobel edge detector (both horizontally and vertically)
4) After running the edge thresholding

An enlarged version of the picture is below:



For some reason, the edges I'm finding are really big. Is it because of the small size of the picture I'm using? Also, I haven't coded up the part where it suppresses edges to get a thin line, because I'm not entirely sure how that works.

I tried playing around with the thresholds, but it either breaks apart the line, or gets a lot of noise.

If anyone has a working copy of the Canny edge detector program where I can just load the image to test, it'll be great! The online ones I've found only load from a set of pre-determined pictures, so I couldn't test my own picture on it.


Somchaya - Back after a year of misc things
http://whisker.scribblewiki.com

Offline hgordon

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 373
  • Helpful? 7
Re: Canny Edge Detector
« Reply #1 on: March 21, 2007, 01:07:59 PM »
Give RoboRealm a try - it's free and it has Canny edge detector support -
    http://www.roborealm.com/help/Canny.php

You can process images live from your webcam. 
Surveyor Corporation
  www.surveyor.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,665
  • Helpful? 169
    • Society of Robots
Re: Canny Edge Detector
« Reply #2 on: April 02, 2007, 03:58:38 AM »
Im assuming you are already using roborealm . . .

When I did mobot with a camera years ago, all I did was a simple middle mass algorithm. Ignore the color red (too much of it from the sun), and concentrate on just the brightest green and blue pixels.

But of course, you could probably write a better control algorithm if you can calculate the curvature of the white line by using edge detection . . .

Offline SomchayaTopic starter

  • Robot Overlord
  • ****
  • Posts: 180
  • Helpful? 0
  • You know it's cute!
Re: Canny Edge Detector
« Reply #3 on: April 02, 2007, 08:04:50 AM »
Oh actually I'm not running with Roborealm, partly cos my little laptop probably can't run it at real-time.. It's a measly 700 mhz transmeta crusoe with 112mb ram, so couple that with win xp sp2 and you get an idea how slow it runs  ;D

Right now, my algorithm runs by edge detection and thresholding, which kind of works, but strong sunlight and noise still kills the algo really badly. I'm still thinking of ways to go around that. Does the middle mass work well in sunlight and noise too?
Somchaya - Back after a year of misc things
http://whisker.scribblewiki.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,665
  • Helpful? 169
    • Society of Robots
Re: Canny Edge Detector
« Reply #4 on: April 02, 2007, 03:13:08 PM »
middle mass is effectively an average, so noise has no effect on it. but when the line splits into two different lines at the decision points, you will have to apply another special trick - when the line splits, the middle mass location wont have the line in it, thereby detecting the split.

for the sunlight problem, put a shaded lens (and maybe even an IR filter) on the cam.

Offline SomchayaTopic starter

  • Robot Overlord
  • ****
  • Posts: 180
  • Helpful? 0
  • You know it's cute!
Re: Canny Edge Detector
« Reply #5 on: April 02, 2007, 04:35:17 PM »
Hmm so the problem I'm having with sunlight isn't so much the sun itself, but the shadows it casts. On particular sunny days (a somewhat rare occurance, yet happens on spring carnival usually), the difference between an area under shadow and under direct sunlight is huge. So what happens is that my line following algo starts chasing the bright areas, cos it looks like a white line relatively.

I'm thinking of a way to fix this, but the only thing I've come up with is to build a big box around the camera's field of view.

Do you have any ideas/suggestions that might work better?
Somchaya - Back after a year of misc things
http://whisker.scribblewiki.com

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
Re: Canny Edge Detector
« Reply #6 on: April 02, 2007, 05:06:40 PM »
what about using the same technique as a barcode scanner?
get one of those DIY laser level things that gives you a straight line of red light. (i couldn't find a very good picture of one:http://www.tlc-direct.co.uk/Images/Products/size_3/FXLLGC.JPG)
point the laser thing a set distance ahead of the bot, drawing it's line across the robot's direction of travel.
the laser will be far brighter than any other light source so ignore all colours other than red and first look for the red laser line in your image.
once you have isolated the laser line look along it's length for variations caused by the line panted on the road.
you are using the laser to illuminate the view to such an extent as to make background light insignificant.

so i can see some disadvantages with doing things this way, notably reducing the depth of the cameras image to a single line illuminated by the laser.
maybe use multiple laser thingies.
or move the laser line in the same way supermarket checkout scanners do.

meh. maybe i'm over complicating things again.

dunk.
(with frickin' laser beams)

Offline SomchayaTopic starter

  • Robot Overlord
  • ****
  • Posts: 180
  • Helpful? 0
  • You know it's cute!
Re: Canny Edge Detector
« Reply #7 on: April 02, 2007, 10:29:04 PM »
Hehe laser beams look really cool actually. Unfortunately, there's only 2-3 weeks left before the competition so I'll probably not have the time to experiment with that.

I think I'll try out just shading the whole field of view from the sun and see how well that works. With luck, that will be sufficient  :)
Somchaya - Back after a year of misc things
http://whisker.scribblewiki.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,665
  • Helpful? 169
    • Society of Robots
Re: Canny Edge Detector
« Reply #8 on: April 03, 2007, 01:22:51 AM »
Quote
I'm thinking of a way to fix this, but the only thing I've come up with is to build a big box around the camera's field of view.

Do you have any ideas/suggestions that might work better?
haha nope, thats the method I used :P

if you angle the camera just right, and mount it on a pole, the camera will not see any shadows cast from the robot. during carnival the competition is at 12-ish, so the sun will be sorta directly above.

Quote
what about using the same technique as a barcode scanner?
an interesting idea, but i dont think it will work (not entirely sure). barcodes do black on white, but the mobot course is a white paint on light grey cement. the terrain is also unlevel with cracks in the sidewalk . . .

 


Get Your Ad Here