Ask Your Question

tomcat81's profile - activity

2020-11-09 07:30:36 -0600 received badge  Popular Question (source)
2014-05-18 12:17:00 -0600 asked a question OpenCV Python StereoCalibrate error

I am still using the old python CV interface as there is other code I do not want to migrate to the new python CV2 interface. When using the stereocalibrate function, I already have all my intrinsic camera parameters ready when I did a separate calibration of both my cameras using the cameraCalibrate function. I only want to find the R, T, E, and F matrices.

I am getting the error:

SystemError: new style getargs format but argument is not a tuple

The following code is posted here:

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)

The only argument that StereoCalibrate that is a tuple is imageSize, but I have already created it as a tuple. Every other argument is a CV array.

Which argument is causing the problem for me? The error does not give me any hints on which one.

2013-04-10 07:10:25 -0600 commented answer Large number of chessboard corners and camera calibration

I just tried with the 6x9 pattern and corner detection becomes unreliable with decreasing pixel size of the square. Is there an actual limit to the square pixel size in which corner detection is still reliable?

2013-04-09 10:00:10 -0600 received badge  Editor (source)
2013-04-09 09:59:41 -0600 asked a question Large number of chessboard corners and camera calibration

I am implementing camera calibration using a chessboard pattern as the test image. However, I am having problems identifying corners when I use a large number of corners (18x27 inner corners). Identifying corners works fine when I use a smaller test pattern (6x9 inner corners). I've tried adding a white border to the image but to no avail.

Is there a limit as to how many corners can be detected using the OpenCV "FindChessboardCorners" function? Is there anyway I can find the corners for a large test pattern such as 18x27 for camera calibration?

My Python script is below but I don't think there should be any problems with it:

    img = cv.LoadImage(filename,cv.CV_8UC1)
    img2 = cv.LoadImage(filename,cv.CV_LOAD_IMAGE_COLOR)
    found,corners = cv.FindChessboardCorners(img,(17,26),0)
    corners2 = cv.FindCornerSubPix(img,corners,(5,5),(-1,-1),(cv.CV_TERMCRIT_EPS,0,0.001))
    cv.DrawChessboardCorners(img2,(17,26),corners2,found)
    cv.SaveImage(filename_corner,img2)