Permalink
5b3f3df Feb 25, 2018
3 contributors

Users who have contributed to this file

@deadprogram @ogrian @berak
41 lines (35 sloc) 670 Bytes
// What it does:
//
// This example uses the Window class to open an image file, and then display
// the image in a Window class.
//
// How to run:
//
// go run ./cmd/showimage/main.go /home/ron/Pictures/mcp23017.jpg
//
// +build example
package main
import (
"fmt"
"os"
"gocv.io/x/gocv"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("How to run:\n\tshowimage [imgfile]")
return
}
filename := os.Args[1]
window := gocv.NewWindow("Hello")
img := gocv.IMRead(filename, gocv.IMReadColor)
if img.Empty() {
fmt.Println("Error reading image from: %v", filename)
return
}
for {
window.IMShow(img)
if window.WaitKey(1) >= 0 {
break
}
}
}