opencvsharp icon indicating copy to clipboard operation
opencvsharp copied to clipboard

how fix to erorr in DecodeMulti

Open AbdalaMask opened this issue 1 year ago • 1 comments

image code

 if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                using var obj = new QRCodeDetector();

                using var withQr = new Mat(openFileDialog1.FileName, ImreadModes.Color);

                bool detected = obj.DetectMulti(withQr, out var points);
                bool decoded = obj.DecodeMulti(withQr, points, out var decodedStrings, out var straightQrCode);
                List<List<Point>> listOfListOfPoint2D = new List<List<Point>>();
                List<Point> listOfPoint2D = new List<Point>();

                int m = 0;

                for (int x = 0; x < straightQrCode.Length; x++)
                {
                     
                    for (int i = 0; i <= 3; i++)
                    {
                        listOfPoint2D.Add(new Point(points[m].X, points[m].Y));
                        m++;
                    }
                    listOfListOfPoint2D.Add(listOfPoint2D);
                   
                }

                if (straightQrCode.Length > 0)
                {

                    

                    openFileTextBox.Invoke(new MethodInvoker(delegate ()
                    {
                        openFileTextBox.Text = decodedStrings[0];
                    }));
                    var s = new Scalar(255, 0, 0);

                    withQr.Polylines(  listOfListOfPoint2D, true, s, 3);

                    var bs = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(withQr);
                    openFileBox.Image = bs;
                }

            }

AbdalaMask avatar Sep 16 '22 17:09 AbdalaMask

qr_multi

AbdalaMask avatar Sep 16 '22 17:09 AbdalaMask