Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/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-Python校准错误_Python_Opencv - Fatal编程技术网

OpenCV-Python校准错误

OpenCV-Python校准错误,python,opencv,Python,Opencv,我仍然在使用旧的python CV接口,因为还有其他代码我不想迁移到新的python CV2接口。当使用stereocalibrate功能时,当我使用cameraCalibrate功能对两台相机进行单独校准时,我已经准备好了所有固有的相机参数。我只想找到R,T,E和F矩阵 我得到一个错误: SystemError: new style getargs format but argument is not a tuple 以下代码发布在此处: import cv import numpy as

我仍然在使用旧的python CV接口,因为还有其他代码我不想迁移到新的python CV2接口。当使用stereocalibrate功能时,当我使用cameraCalibrate功能对两台相机进行单独校准时,我已经准备好了所有固有的相机参数。我只想找到R,T,E和F矩阵

我得到一个错误:

SystemError: new style getargs format but argument is not a tuple
以下代码发布在此处:

import cv
import numpy as np
import os
import shutil
from sys import getsizeof
import time

imagePoints = []
objectPoints = []
pointCounts = []

positions = 10

K1 = np.asarray([(  2303.88696,   0.00000000,   315.330859),
            (  0.00000000,   2303.75915,   234.229586),
            (  0.00000000,   0.00000000,   1.00000000)])

K2 = np.asarray([(  2294.70130,   0.00000000,   320.751796),
            (  0.00000000,   2293.85357,   240.760682),
            (  0.00000000,   0.00000000,   1.00000000)])

distcoeffs1 = np.asarray([( -7.42497976e-03,   3.74099082e+00,  -1.81154814e-03,  3.65969196e-04)])

distcoeffs2 = np.asarray([(  4.05620881e-03,   3.27334706e+00,  -5.00835868e-04,  1.56068477e-03)])

imageSize = (640,480)

R = np.asarray([(0., 0., 0.), (0., 0., 0.), (0., 0., 0.)])
T = np.asarray([(0., 0., 0.), (0., 0., 0.), (0., 0., 0.)])
E = np.asarray([(0., 0., 0.), (0., 0., 0.), (0., 0., 0.)])
F = np.asarray([(0., 0., 0.), (0., 0., 0.), (0., 0., 0.)])

images = range(0,positions)
for numberofimages in images:
    print numberofimages
    temp_output = []
    temp_coord = []

    f_output = file('/home/Desktop/output_stereo/output_cam1_%d.txt' %numberofimages, 'r')
    f_coord = file('/home/Desktop/output_stereo/coord.txt', 'r')    

    for line_output in f_output:
        row_output = line_output.split()
        temp_output = temp_output + [row_output]

    for line_coord in f_coord:
        row_coord = line_coord.split()
        temp_coord = temp_coord + [row_coord]

    count_output = range(0,len(temp_output))
    count_coord = range(0,len(temp_coord))

    for index_output in count_output:
        row_output = temp_output[index_output]      
        imagePoints = imagePoints + [(float(row_output[0]),float(row_output[1]))]

    for index_coord in count_coord:
        row_coord = temp_coord[index_coord] 
        objectPoints = objectPoints + [(float(row_coord[0]),float(row_coord[1]),0)]

    #pointCounts = pointCounts + [len(temp_output)]

imagePoints1 = cv.fromarray(np.asarray(imagePoints))
objectPoints = cv.fromarray(np.asarray(objectPoints))

imagePoints = []
for numberofimages in images:
    print numberofimages
    temp_output = []
    temp_coord = []

    f_output = file('/home/Desktop/output_stereo/output_cam2_%d.txt' %numberofimages, 'r')
    f_coord = file('/home/Desktop/output_stereo/coord.txt', 'r')    

    for line_output in f_output:
        row_output = line_output.split()
        temp_output = temp_output + [row_output]

    for line_coord in f_coord:
        row_coord = line_coord.split()
        temp_coord = temp_coord + [row_coord]

    count_output = range(0,len(temp_output))
    count_coord = range(0,len(temp_coord))

    for index_output in count_output:
        row_output = temp_output[index_output]      
        imagePoints = imagePoints + [(float(row_output[0]),float(row_output[1]))]

    pointCounts = pointCounts + [len(temp_output)]

imagePoints2 = cv.fromarray(np.asarray(imagePoints))
pointCounts = cv.fromarray(np.asarray(np.int32([pointCounts])))

cv.StereoCalibrate(objectPoints, imagePoints1, imagePoints2, pointCounts, cv.fromarray(K1), cv.fromarray(distcoeffs1), cv.fromarray(K2), cv.fromarray(distcoeffs2), imageSize, cv.fromarray(R), cv.fromarray(T), cv.fromarray(E), cv.fromarray(F), cv.CV_CALIB_FIX_INTRINSIC)
作为元组的唯一参数是imageSize,但我已经将其创建为元组。其他每个参数都是CV数组


哪一个论点导致了我的问题?这个错误没有给我任何关于哪一个的提示。

如果有人遇到这个问题,你必须在最后一个参数中设置标志。这个错误并不能很好地说明什么是错的

应该是:

cv.StereoCalibrate(objectPoints, imagePoints1, imagePoints2, pointCounts, cv.fromarray(K1), cv.fromarray(distcoeffs1), cv.fromarray(K2), cv.fromarray(distcoeffs2), imageSize, cv.fromarray(R), cv.fromarray(T), cv.fromarray(E), cv.fromarray(F), flags = cv.CV_CALIB_FIX_INTRINSIC)
不是:


请注意,他们正在废除旧的cv api,下一个opencv版本将不再使用它。是的,我知道,目前我要做的事情太多,无法将所有内容切换到新界面:(
cv.StereoCalibrate(objectPoints, imagePoints1, imagePoints2, pointCounts, cv.fromarray(K1), cv.fromarray(distcoeffs1), cv.fromarray(K2), cv.fromarray(distcoeffs2), imageSize, cv.fromarray(R), cv.fromarray(T), cv.fromarray(E), cv.fromarray(F), cv.CV_CALIB_FIX_INTRINSIC)