gocv
gocv copied to clipboard
gocv.NewPointVectorFromMat(img) throwing Exception
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'
Steps to Reproduce
- load a image from dir img:=gocv.IMRead("dir",color)
- 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
orenv.cmd
script before trying togo run
orgo build
? No
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)