gocv icon indicating copy to clipboard operation
gocv copied to clipboard

gocv.NewPointVectorFromMat(img) throwing Exception

Open zaargham opened this issue 1 year ago • 1 comments

While converting a gocv.Mat into point vector using NewPointVectorFromMat func panic/exception is occuring

exception: what(): OpenCV(4.6.0) /tmp/opencv/opencv-4.6.0/modules/core/src/copy.cpp:320: error: (-215:Assertion failed) channels() == CV_MAT_CN(dtype) in function 'copyTo' Screenshot from 2022-12-07 16-27-54

Steps to Reproduce

  1. load a image from dir img:=gocv.IMRead("dir",color)
  2. pv := gocv.NewPointVectorFromMat(img)

Your Environment

  • Operating System and version: ubuntu 20.4 focal
  • OpenCV version used: 4.0 and above
  • How did you install OpenCV? sudo apt instal libopencv-dev and make install for gocv
  • GoCV version used: 0.30.0
  • Go version: go1.18.4 linux/amd64
  • Did you run the env.sh or env.cmd script before trying to go run or go build? No

zaargham avatar Dec 08 '22 09:12 zaargham

I encounter this too, when I call FitLine and try to convert line the *Mat to a PointVector line:=gocv.NewMat() gocv.FitLine(contour,&line,gocv.DistL2,0,0.01,0.01) l:=gocv.NewPointVectorFromMat(line) vx,vy,x1,y1:=l.At(0).X,l.At(0).Y,l.At(1).X,l.At(1).Y; // vx,vy,x1,y1:= line.GetUCharAt(1,0),line.GetUCharAt(1,1),line.GetUCharAt(1,2),line.GetUCharAt(1,3)

yg7001 avatar May 31 '23 07:05 yg7001