[OpenCV] Chapter01-01 Read image from file
Read image from file
Source Code
package main import ( "log" "gocv.io/x/gocv" ) func main() { imageFilePath := "../../data/Lena.png" mat := gocv.IMRead(imageFilePath, gocv.IMReadAnyColor) if mat.Empty() { log.Panic("Can not read Image file : ", imageFilePath) return } log.Println("read", imageFilePath) log.Println("size:", mat.Size()) log.Println("type:", mat.Type()) mat = gocv.IMRead(imageFilePath, gocv.IMReadGrayScale) if &mat == nil { log.Panic("Can not read Image file : ", imageFilePath) return } log.Println("read", imageFilePath) log.Println("size:", mat.Size()) log.Println("type:", mat.Type()) }
Execute Result
$ go run chapter01-01_read_image_from_file.go
2019/03/06 23:19:05 read ../../data/Lena.png
2019/03/06 23:19:05 size: [512 512]
2019/03/06 23:19:05 type: 16
2019/03/06 23:19:05 read ../../data/Lena.png
2019/03/06 23:19:05 size: [512 512]
2019/03/06 23:19:05 type: 0
Comments
Post a Comment