Guest User

Untitled

a guest
Jan 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.29 KB | None | 0 0
  1. func findCircle(window *Window, frame int) Circle {
  2.         filtered := make(chan *image.Point, 1000)
  3.         edge := make(chan image.Point, 100)
  4.         transformed := make(chan Circle, 400)
  5.         var c Circle
  6.         var ok bool
  7.  
  8.         img,_ := getImage(window.Frames[frame].Path)
  9.  
  10.         fmt.Printf("Finding circle of %s\n", window.Frames[frame].Path)
  11.  
  12.         SetState(window, WORKING)
  13.         redraw(*window, window.Frames[frame])
  14.  
  15.         start := time.Seconds()
  16.  
  17.         r := findBounds(&img)
  18.  
  19.         go filter(&img,filtered)
  20.         go Sobel(&img,filtered,edge)
  21.         go Transform(&img, edge, transformed, r)
  22. //      var index int
  23.  
  24. //      bx,by := img.Bounds().Max.X,img.Bounds().Max.Y
  25. //      votes := make([]int, bx*by*bx)
  26. //      max := 0
  27.  
  28.         for {
  29.                 c,ok = <-transformed
  30.  
  31.                 if ok != true {
  32.                         break
  33.                 }
  34.  
  35. /*              index = c.Radius+bx*c.Centre.Y+bx*by*c.Centre.X
  36.                 votes[index] += 1
  37.                 if votes[index] > max {
  38.                         max = votes[index]
  39.                         centre = c
  40.                 }*/
  41.         }
  42.  
  43.         end := time.Seconds()
  44.         fmt.Printf("Done in %d seconds\n", end-start)
  45.  
  46.         SetState(window, IDLE)
  47.  
  48.         return c
  49. }
Add Comment
Please, Sign In to add comment