diff --git a/samples/edge.go b/samples/edge.go index 19fa1eb..ac9d416 100644 --- a/samples/edge.go +++ b/samples/edge.go @@ -7,15 +7,15 @@ package main import ( "fmt" "os" - "path" - "runtime" + "path" + "runtime" - //"github.com/lazywei/go-opencv/opencv" + //"github.com/lazywei/go-opencv/opencv" "../opencv" // can be used in forks, comment in real application ) func main() { - _, currentfile, _, _ := runtime.Caller(0) + _, currentfile, _, _ := runtime.Caller(0) filename := path.Join(path.Dir(currentfile), "../images/lena.jpg") if len(os.Args) == 2 { filename = os.Args[1] @@ -79,5 +79,3 @@ func main() { os.Exit(0) } - - diff --git a/samples/hellocv.go b/samples/hellocv.go index 6ddceb0..185caac 100644 --- a/samples/hellocv.go +++ b/samples/hellocv.go @@ -7,15 +7,15 @@ package main import ( "fmt" "os" - "path" - "runtime" + "path" + "runtime" - //"github.com/lazywei/go-opencv/opencv" + //"github.com/lazywei/go-opencv/opencv" "../opencv" // can be used in forks, comment in real application ) func main() { - _, currentfile, _, _ := runtime.Caller(0) + _, currentfile, _, _ := runtime.Caller(0) filename := path.Join(path.Dir(currentfile), "../images/lena.jpg") if len(os.Args) == 2 { filename = os.Args[1] @@ -43,5 +43,3 @@ func main() { opencv.WaitKey(0) } - - diff --git a/samples/inpaint.go b/samples/inpaint.go index 60b0e59..000948d 100644 --- a/samples/inpaint.go +++ b/samples/inpaint.go @@ -7,15 +7,15 @@ package main import ( "fmt" "os" - "path" - "runtime" + "path" + "runtime" - //"github.com/lazywei/go-opencv/opencv" + //"github.com/lazywei/go-opencv/opencv" "../opencv" // can be used in forks, comment in real application ) func main() { - _, currentfile, _, _ := runtime.Caller(0) + _, currentfile, _, _ := runtime.Caller(0) filename := path.Join(path.Dir(currentfile), "../images/fruits.jpg") if len(os.Args) == 2 { filename = os.Args[1] @@ -94,5 +94,3 @@ func main() { } os.Exit(0) } - - diff --git a/samples/player.go b/samples/player.go index 3113c8c..9637609 100644 --- a/samples/player.go +++ b/samples/player.go @@ -7,10 +7,8 @@ package main import ( "fmt" "os" - "path" - "runtime" - //"github.com/lazywei/go-opencv/opencv" + //"github.com/lazywei/go-opencv/opencv" "../opencv" // can be used in forks, comment in real application ) @@ -58,18 +56,26 @@ func main() { for { if !stop { img := cap.QueryFrame() - if img == nil { break } + if img == nil { + break + } frame_pos := int(cap.GetProperty(opencv.CV_CAP_PROP_POS_FRAMES)) - if frame_pos >= frames { break } + if frame_pos >= frames { + break + } win.SetTrackbarPos("Seek", frame_pos) win.ShowImage(img) - key := opencv.WaitKey(1000/fps) - if key == 27 { os.Exit(0) } + key := opencv.WaitKey(1000 / fps) + if key == 27 { + os.Exit(0) + } } else { key := opencv.WaitKey(20) - if key == 27 { os.Exit(0) } + if key == 27 { + os.Exit(0) + } } } diff --git a/samples/webcam.go b/samples/webcam.go index f404412..53d5117 100644 --- a/samples/webcam.go +++ b/samples/webcam.go @@ -1,12 +1,12 @@ package main import ( - "fmt" + "fmt" "os" - //"path" - //"runtime" + //"path" + //"runtime" - //"github.com/lazywei/go-opencv/opencv" + //"github.com/lazywei/go-opencv/opencv" "../opencv" // can be used in forks, comment in real application ) @@ -14,29 +14,29 @@ func main() { win := opencv.NewWindow("Go-OpenCV Webcam") defer win.Destroy() - cap := opencv.NewCameraCapture(0) + cap := opencv.NewCameraCapture(0) if cap == nil { panic("can not open camera") } - defer cap.Release() + defer cap.Release() - win.CreateTrackbar("Thresh", 1, 100, func(pos int, param ...interface{}) { - for { - if cap.GrabFrame() { - img := cap.RetrieveFrame(1) - if img != nil { - ProcessImage(img, win, pos) - } else { - fmt.Println("Image ins nil") - } - } + win.CreateTrackbar("Thresh", 1, 100, func(pos int, param ...interface{}) { + for { + if cap.GrabFrame() { + img := cap.RetrieveFrame(1) + if img != nil { + ProcessImage(img, win, pos) + } else { + fmt.Println("Image ins nil") + } + } - if key := opencv.WaitKey(10); key == 27 { - os.Exit(0) - } - } - }) - opencv.WaitKey(0) + if key := opencv.WaitKey(10); key == 27 { + os.Exit(0) + } + } + }) + opencv.WaitKey(0) } func ProcessImage(img *opencv.IplImage, win *opencv.Window, pos int) error { @@ -55,16 +55,16 @@ func ProcessImage(img *opencv.IplImage, win *opencv.Window, pos int) error { opencv.CvtColor(img, gray, opencv.CV_BGR2GRAY) - opencv.Smooth(gray, edge, opencv.CV_BLUR, 3, 3, 0, 0) - opencv.Not(gray, edge) + opencv.Smooth(gray, edge, opencv.CV_BLUR, 3, 3, 0, 0) + opencv.Not(gray, edge) - // Run the edge detector on grayscale - opencv.Canny(gray, edge, float64(pos), float64(pos*3), 3) + // Run the edge detector on grayscale + opencv.Canny(gray, edge, float64(pos), float64(pos*3), 3) - opencv.Zero(cedge) - // copy edge points - opencv.Copy(img, cedge, edge) + opencv.Zero(cedge) + // copy edge points + opencv.Copy(img, cedge, edge) - win.ShowImage(cedge) - return nil + win.ShowImage(cedge) + return nil }