Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencv cv2.0:错误:(-215:断言失败)src.size==dst.size&&;函数'中的src.channels()==dst.channels();CVX标准';_Opencv - Fatal编程技术网

Opencv cv2.0:错误:(-215:断言失败)src.size==dst.size&&;函数'中的src.channels()==dst.channels();CVX标准';

Opencv cv2.0:错误:(-215:断言失败)src.size==dst.size&&;函数'中的src.channels()==dst.channels();CVX标准';,opencv,Opencv,我正在尝试使用OpenCV 4.1.1中的立体视觉。代码如下 points1 = np.array([[2566, 542], [2567, 848], [2569, 947], [3154, 452], [3158, 934], [4061, 332], [4069, 576]]) points2 = np.array([[277, 471], [290, 774], [296, 868], [79

我正在尝试使用OpenCV 4.1.1中的立体视觉。代码如下

points1 = np.array([[2566, 542], [2567, 848], [2569, 947],
               [3154, 452], [3158, 934], 
               [4061, 332], [4069, 576]])

points2 = np.array([[277, 471], [290, 774], [296, 868],
                [794, 393], [816, 830], 
                [1472, 310], [1480, 510]
])

F, mask = cv2.findFundamentalMat(points1, points2)
ret, H1, H2 = cv2.stereoRectifyUncalibrated(points1, points2, F, imgSize=(4112, 1200))
error                                     Traceback (most recent call last)
---> 11 ret, H1, H2 = cv2.stereoRectifyUncalibrated(points1, points2, F, imgSize=(4112, 1200))
error: OpenCV(4.1.1) /home/hao/workspace/opencv/modules/core/src/convert_c.cpp:112: error: (-215:Assertion failed) src.size == dst.size && src.channels() == dst.channels() in function 'cvConvertScale'
它生成一个错误,如下所示

points1 = np.array([[2566, 542], [2567, 848], [2569, 947],
               [3154, 452], [3158, 934], 
               [4061, 332], [4069, 576]])

points2 = np.array([[277, 471], [290, 774], [296, 868],
                [794, 393], [816, 830], 
                [1472, 310], [1480, 510]
])

F, mask = cv2.findFundamentalMat(points1, points2)
ret, H1, H2 = cv2.stereoRectifyUncalibrated(points1, points2, F, imgSize=(4112, 1200))
error                                     Traceback (most recent call last)
---> 11 ret, H1, H2 = cv2.stereoRectifyUncalibrated(points1, points2, F, imgSize=(4112, 1200))
error: OpenCV(4.1.1) /home/hao/workspace/opencv/modules/core/src/convert_c.cpp:112: error: (-215:Assertion failed) src.size == dst.size && src.channels() == dst.channels() in function 'cvConvertScale'
正如文档所说,“点2是第二个图像中的对应点。支持与findFundamentalMat中相同的格式。”()。我不知道发生了什么事。提前谢谢

简短回答:

你只是没有足够的分数

长答覆:

由于只有7个点,函数findFundamentalMat不会返回单个3x3矩阵,而是返回3个3x3矩阵

当函数尝试将F转换为3x3矩阵时,异常实际上会抛出,但由于src.size==dst.size不为true而失败

为什么findFundamentalMat返回了3个矩阵

在文件中,点数应为:

CV_FM_7点用于7点算法。N=7
8点算法的CV_FM_8点。N≥8
用于RANSAC算法的CV_FM_RANSAC。N≥8
用于LMEDS算法的CV_FM_LMEDS。N≥八,

默认值是CV_FM_RANSAC,我猜代码会自动切换到CV_FM_7POINT方法(只有7点的情况)

关于此方法,findFundamentalMat的文档说明:

该函数使用上面列出的四种方法之一计算基本矩阵,并返回找到的基本矩阵。通常只找到一个矩阵。但在7点算法的情况下,该函数最多可返回3个解(9×3矩阵,顺序存储所有3个矩阵)

希望这有帮助

简短回答:

你只是没有足够的分数

长答覆:

由于只有7个点,函数findFundamentalMat不会返回单个3x3矩阵,而是返回3个3x3矩阵

当函数尝试将F转换为3x3矩阵时,异常实际上会抛出,但由于src.size==dst.size不为true而失败

为什么findFundamentalMat返回了3个矩阵

在文件中,点数应为:

CV_FM_7点用于7点算法。N=7
8点算法的CV_FM_8点。N≥8
用于RANSAC算法的CV_FM_RANSAC。N≥8
用于LMEDS算法的CV_FM_LMEDS。N≥八,

默认值是CV_FM_RANSAC,我猜代码会自动切换到CV_FM_7POINT方法(只有7点的情况)

关于此方法,findFundamentalMat的文档说明:

该函数使用上面列出的四种方法之一计算基本矩阵,并返回找到的基本矩阵。通常只找到一个矩阵。但在7点算法的情况下,该函数最多可返回3个解(9×3矩阵,顺序存储所有3个矩阵)


希望这有帮助

您使用哪种编程语言?您使用哪种编程语言?谢谢您的详细回答。这很有帮助。谢谢你详细的回答。这很有帮助。