Fix indentions.

This commit is contained in:
Bert Chang 2014-01-16 11:46:19 +08:00
parent 41ec01563c
commit d511e25516
5 changed files with 57 additions and 57 deletions

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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)
}
}
}

View file

@ -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
}