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