hybridgroup / gocv

Go package for computer vision using OpenCV 4 and beyond. Includes support for DNN, CUDA, OpenCV Contrib, and OpenVINO.
https://gocv.io
Other
6.7k stars 866 forks source link

Error converting `*gocv.NativeByteBuffer` to `string` #1193

Open tlalarus opened 3 months ago

tlalarus commented 3 months ago

Description

I am encountering the following error:

cannot convert buf (variable of type *gocv.NativeByteBuffer) to type string

In Go, converting []byte to string is typically straightforward with type casting, but I am running into this error. My specific question is about how to convert a *gocv.NativeByteBuffer to string

Steps to Reproduce

func somefunc(img cv.Mat) {
  clone := img.Clone()
  buf, _ := gocv.IMEncode(".png", clone)

  strBytes := string(buf) // <- error occured
}

Your Environment

diegohce commented 2 months ago

Hi @tlalarus , gocv.NativeByteBuffer has a function GetBytes() []byte which is probably what you're looking for.

here's the doc

Cheers!