Run processing in main thread instead of widget.
This commit is contained in:
parent
f5cf2f6e3b
commit
1f51a1601e
1 changed files with 18 additions and 13 deletions
|
|
@ -11,6 +11,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var edge_threshold int
|
||||||
|
|
||||||
win := opencv.NewWindow("Go-OpenCV Webcam")
|
win := opencv.NewWindow("Go-OpenCV Webcam")
|
||||||
defer win.Destroy()
|
defer win.Destroy()
|
||||||
|
|
||||||
|
|
@ -21,22 +23,25 @@ func main() {
|
||||||
defer cap.Release()
|
defer cap.Release()
|
||||||
|
|
||||||
win.CreateTrackbar("Thresh", 1, 100, func(pos int, param ...interface{}) {
|
win.CreateTrackbar("Thresh", 1, 100, func(pos int, param ...interface{}) {
|
||||||
for {
|
edge_threshold = pos
|
||||||
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 {
|
fmt.Println("Press ESC to quit")
|
||||||
os.Exit(0)
|
for {
|
||||||
|
if cap.GrabFrame() {
|
||||||
|
img := cap.RetrieveFrame(1)
|
||||||
|
if img != nil {
|
||||||
|
ProcessImage(img, win, edge_threshold)
|
||||||
|
} else {
|
||||||
|
fmt.Println("Image ins nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
key := opencv.WaitKey(10)
|
||||||
opencv.WaitKey(0)
|
|
||||||
|
if key == 27 {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProcessImage(img *opencv.IplImage, win *opencv.Window, pos int) error {
|
func ProcessImage(img *opencv.IplImage, win *opencv.Window, pos int) error {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue