CvException: Mat data type is not compatible: 28 OpenCVForUnity.CoreModule.Mat.get

137 Views Asked by At

opencv for unity

Class PerspectiveTransformComponent

private Mat linesMat = new Mat();

Imgproc.HoughLinesP(outputMat, linesMat, 1, Mathf.PI / 180, 60, 50, 10);
outputMat = new Mat(outputTexture.height, outputTexture.width, CvType.CV_32S);

private void GetCrossCorners()
{   
        linesMat.convertTo(linesMat, CvType.CV_32S);
        int[] linesArray = new int[linesMat.cols() * linesMat.rows() * linesMat.channels()];
        //byte[] linesArray = new byte[linesMat.cols() * linesMat.rows() * linesMat.channels()];
        //double[] linesArray = new double[linesMat.cols() * linesMat.rows() * linesMat.channels()];
        
        linesMat.get(0, 0, linesArray);

ClassMat:

         public int get(int row, int col, int[] data)
        {
            ThrowIfDisposed();

            int t = type();
            if (data == null || data.Length % CvType.channels(t) != 0)
                throw new CvException(
                    "Provided data element number (" +
                    (data == null ? 0 : data.Length) +
                    ") should be multiple of the Mat channels count (" +
                    CvType.channels(t) + ")");
            if (CvType.depth(t) == CvType.CV_32S)
            {
                return core_Mat_nGetI(nativeObj, row, col, data.Length, data);
            }
            throw new CvException("Mat data type is not compatible: " + t);

        }

log:

CvException: Mat data type is not compatible: 28
OpenCVForUnity.CoreModule.Mat.get (System.Int32 row, System.Int32 col, System.Byte[] data) (at Assets/OpenCVForUnity/org/opencv/core/Mat.cs:3021)
UIPerspectiveTransform.GetCrossCorners () (at Assets/Scripts/UI/UICarpet/UIPerspectiveTransform.cs:83)
UIPerspectiveTransform.GetPerspectiveTransMat (OpenCVForUnity.CoreModule.Mat srcMat) (at Assets/Scripts/UI/UICarpet/UIPerspectiveTransform.cs:36)
Golf.UICarpet.DetectTarget () (at Assets/Scripts/UI/UICarpet/UICarpet.cs:109)
Golf.UICameraToMat.Update () (at Assets/Scripts/UI/UICarpet/UICameraToMat.cs:112)
0

There are 0 best solutions below