opencv for Go
github.com/malcolmston/opencv
Image processing & computer vision, zero dependencies.
GitHubports opencv/opencv
A standard-library-only port of a useful subset of Python's OpenCV (cv2). The core type is Mat, a dense row-major uint8 matrix; convert to/from image.Image, read and write PNG/JPEG, and run classic pipelines — colour conversion, blurring, thresholding, morphology, edges and geometric transforms — with no cgo.
Install
shell
$ go get github.com/malcolmston/opencvQuick start
main.go
img, _ := cv.ImRead("in.png")
gray := cv.CvtColor(img, cv.ColorRGB2Gray)
blur := cv.GaussianBlur(gray, 5, 1.4)
edges := cv.Canny(blur, 50, 150)
cv.ImWrite("edges.png", edges)Features
Mat: dense row-major 8-bit matrix (1- or 3-channel)- I/O:
ImRead/ImWrite(PNG & JPEG),FromImage/ToImage - Colour:
CvtColor(e.g.ColorRGB2Gray) - Filtering:
GaussianBlur,Blur,Threshold, morphology - Edges & more:
Canny,Sobel, geometric transforms, drawing - Package name is
cv— no cgo, standard library only