Modify samples to run in changed forks

This commit is contained in:
Kirillov Alexander 2014-01-14 17:47:04 +04:00
parent 44d0885de8
commit 745f3e0955
4 changed files with 24 additions and 12 deletions

View file

@ -7,12 +7,16 @@ package main
import ( import (
"fmt" "fmt"
"os" "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() { func main() {
filename := "../images/lena.jpg" _, currentfile, _, _ := runtime.Caller(0)
filename := path.Join(path.Dir(currentfile), "../images/lena.jpg")
if len(os.Args) == 2 { if len(os.Args) == 2 {
filename = os.Args[1] filename = os.Args[1]
} }

View file

@ -7,12 +7,16 @@ package main
import ( import (
"fmt" "fmt"
"os" "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() { func main() {
filename := "../images/lena.jpg" _, currentfile, _, _ := runtime.Caller(0)
filename := path.Join(path.Dir(currentfile), "../images/lena.jpg")
if len(os.Args) == 2 { if len(os.Args) == 2 {
filename = os.Args[1] filename = os.Args[1]
} }

View file

@ -7,12 +7,16 @@ package main
import ( import (
"fmt" "fmt"
"os" "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() { func main() {
filename := "../images/fruits.jpg" _, currentfile, _, _ := runtime.Caller(0)
filename := path.Join(path.Dir(currentfile), "../images/fruits.jpg")
if len(os.Args) == 2 { if len(os.Args) == 2 {
filename = os.Args[1] filename = os.Args[1]
} }

View file

@ -7,8 +7,11 @@ package main
import ( import (
"fmt" "fmt"
"os" "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() { func main() {
@ -22,7 +25,7 @@ func main() {
cap := opencv.NewFileCapture(filename) cap := opencv.NewFileCapture(filename)
if cap == nil { if cap == nil {
panic("can not open video") panic("can not open video")
} }
defer cap.Release() defer cap.Release()
@ -60,7 +63,7 @@ func main() {
frame_pos := int(cap.GetProperty(opencv.CV_CAP_PROP_POS_FRAMES)) 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.SetTrackbarPos("Seek", frame_pos)
win.ShowImage(img) win.ShowImage(img)
key := opencv.WaitKey(1000/fps) key := opencv.WaitKey(1000/fps)
if key == 27 { os.Exit(0) } if key == 27 { os.Exit(0) }
@ -70,8 +73,5 @@ func main() {
} }
} }
opencv.WaitKey(0) opencv.WaitKey(0)
} }