Cv2.DecomposeHomographyMat throws OpenCVException [closed]

asked 2020-08-09 07:07:17 -0500

updated 2020-08-09 20:42:24 -0500

supra56 gravatar image

Hello. I'm trying to use the DecomposeHomographyMat method but it always throws an OpenCVException with the message:

OpenCvSharp.OpenCVException: 'K.cols == 3 && K.rows == 3


                Mat homo = Cv2.FindHomography(InputArray.Create(pts1), InputArray.Create(pts2), HomographyMethods.None);
                Mat K = new Mat(3, 3, MatType.CV_8UC3, Scalar.All(0));

                IEnumerable<Mat> rot = Enumerable.Empty<Mat>();
                IEnumerable<Mat> trans = Enumerable.Empty<Mat>();
                IEnumerable<Mat> normal = Enumerable.Empty<Mat>();

                try
                {
                    Cv2.DecomposeHomographyMat(homo, K, rot, trans, normal);

                }
                catch (OpenCVException e)
                {
                    Console.WriteLine(e.ErrMsg);
                }

What is wrong with my method call?

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2020-08-10 04:07:16.173522

Comments

sorry but we cannot help with 3rdparty api wrappers.

however, the K Mat should be the camera Matrix from calibration (not an empty Mat), and CV_8UC3 is for sure the wrong type (and the reason for your error) it must be CV_32F instead

berak gravatar imageberak ( 2020-08-10 04:09:21 -0500 )edit