From 44d0885de871fdbbfdb1817274ef4882099036a7 Mon Sep 17 00:00:00 2001 From: Kirillov Alexander Date: Tue, 14 Jan 2014 17:21:26 +0400 Subject: [PATCH 1/2] Add package file --- go-opencv.go | 1 + 1 file changed, 1 insertion(+) create mode 100644 go-opencv.go diff --git a/go-opencv.go b/go-opencv.go new file mode 100644 index 0000000..0113b8a --- /dev/null +++ b/go-opencv.go @@ -0,0 +1 @@ +package opencv From 745f3e095552deaad39d6819449d3541ccbdb9da Mon Sep 17 00:00:00 2001 From: Kirillov Alexander Date: Tue, 14 Jan 2014 17:47:04 +0400 Subject: [PATCH 2/2] Modify samples to run in changed forks --- samples/edge.go | 8 ++++++-- samples/hellocv.go | 8 ++++++-- samples/inpaint.go | 8 ++++++-- samples/player.go | 12 ++++++------ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/samples/edge.go b/samples/edge.go index f7a157e..19fa1eb 100644 --- a/samples/edge.go +++ b/samples/edge.go @@ -7,12 +7,16 @@ 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 ) func main() { - filename := "../images/lena.jpg" + _, currentfile, _, _ := runtime.Caller(0) + filename := path.Join(path.Dir(currentfile), "../images/lena.jpg") if len(os.Args) == 2 { filename = os.Args[1] } diff --git a/samples/hellocv.go b/samples/hellocv.go index cccbf28..6ddceb0 100644 --- a/samples/hellocv.go +++ b/samples/hellocv.go @@ -7,12 +7,16 @@ 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 ) func main() { - filename := "../images/lena.jpg" + _, currentfile, _, _ := runtime.Caller(0) + filename := path.Join(path.Dir(currentfile), "../images/lena.jpg") if len(os.Args) == 2 { filename = os.Args[1] } diff --git a/samples/inpaint.go b/samples/inpaint.go index af34496..60b0e59 100644 --- a/samples/inpaint.go +++ b/samples/inpaint.go @@ -7,12 +7,16 @@ 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 ) func main() { - filename := "../images/fruits.jpg" + _, currentfile, _, _ := runtime.Caller(0) + filename := path.Join(path.Dir(currentfile), "../images/fruits.jpg") if len(os.Args) == 2 { filename = os.Args[1] } diff --git a/samples/player.go b/samples/player.go index 25761b5..3113c8c 100644 --- a/samples/player.go +++ b/samples/player.go @@ -7,8 +7,11 @@ 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 ) func main() { @@ -22,7 +25,7 @@ func main() { cap := opencv.NewFileCapture(filename) if cap == nil { - panic("can not open video") + panic("can not open video") } defer cap.Release() @@ -60,7 +63,7 @@ func main() { frame_pos := int(cap.GetProperty(opencv.CV_CAP_PROP_POS_FRAMES)) if frame_pos >= frames { break } win.SetTrackbarPos("Seek", frame_pos) - + win.ShowImage(img) key := opencv.WaitKey(1000/fps) if key == 27 { os.Exit(0) } @@ -70,8 +73,5 @@ func main() { } } - opencv.WaitKey(0) } - -