Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error converting *gocv.NativeByteBuffer to string #1193

Open
tlalarus opened this issue Aug 12, 2024 · 1 comment
Open

Error converting *gocv.NativeByteBuffer to string #1193

tlalarus opened this issue Aug 12, 2024 · 1 comment

Comments

@tlalarus
Copy link

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

  • Operating System and version: ubuntu 18.04 (docker)
  • OpenCV version used: 4.10.0
  • How did you install OpenCV? build from source of opencv github
  • GoCV version used: 0.37.0
  • Go version: 1.22.4
  • Did you run the env.sh or env.cmd script before trying to go run or go build? no
@diegohce
Copy link
Contributor

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

here's the doc

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants