You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Install GCC or MinGW (download here) at first,
and then run these commands:
go get -d github.com/chai2010/opencv
go generate and go install
go run hello.go
Notes
If use TDM-GCC, and build error like this:
c:\tdm-gcc-64\x86_64-w64-mingw32\include\aviriff.h:3:25: error: 'refer' does not
name a type
* No warranty is given; refer to the file DISCLAIMER within this package.
...
You need fix the C:\TDM-GCC-64\x86_64-w64-mingw32\include\aviriff.h header first:
** // fixit: ** -> /**
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
*/
Example
// Copyright 2014 <chaishushan{AT}gmail.com>. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package main
import (
"fmt""log""os""github.com/chai2010/opencv"
)
funcmain() {
filename:="./testdata/lena.jpg"iflen(os.Args) ==2 {
filename=os.Args[1]
}
image:=opencv.LoadImage(filename)
ifimage==nil {
log.Fatalf("LoadImage %s failed!", filename)
}
deferimage.Release()
win:=opencv.NewWindow("Go-OpenCV")
deferwin.Destroy()
win.SetMouseCallback(func(event, x, y, flagsint) {
fmt.Printf("event = %d, x = %d, y = %d, flags = %d\n",
event, x, y, flags,
)
})
win.CreateTrackbar("Thresh", 1, 100, func(posint) {
fmt.Printf("pos = %d\n", pos)
})
win.ShowImage(image)
opencv.WaitKey(0)
}