I'm trying to convert this python interface to tensorflow serving into golang:
image = cv2.imread("1.jpg")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = cv2.resize(image, (256, 256))
image = np.expand_dims(image, axis=0)
image = np.true_divide(image, 255)
np.shape(image)
What I'm came up with is:
package main
import (
"log"
"image"
"gocv.io/x/gocv"
)
func main() {
imageFilePath := "./a.jpg"
mat := gocv.IMRead(imageFilePath, gocv.IMReadAnyColor)
if mat.Empty() {
log.Panic("Can not read Image file : ", imageFilePath)
return
}
resizeImage := gocv.NewMat()
gocv.Resize(mat, &resizeImage, image.Point{X: 256, Y: 256}, 0, 0, gocv.InterpolationNearestNeighbor)
img := resizeImage.Clone()
gocv.CvtColor(resizeImage, &img, gocv.ColorBGRToRGB)
// equivalent to np.expand_dims(image, axis=0) ?
}
I've tried to get help from gonum but had no luck plugging it to gocv, so I'm left clueless and appreciate your help about this.