Matlab双目相机标定参数--python

为了以后便于查看和学习,在此记录一下。我使用的是单USB双目摄像头,分辨率2560*720。在Matlab中标定好的参数写入Pycharm中,以进行后续处理。

 

注意事项:在填写相机内参时要将矩阵转置,代码如下:

 

#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
author: jianbin 
time:2022/9/26
"""

import numpy as np


# 双目相机参数
class stereoCamera(object):
    def __init__(self):
        # 左相机内参
        self.cam_matrix_left = np.array([[996.203302939305, -0.623047033252807, 588.670199625865],
                                           [0, 996.317135079095, 373.780685618595],
                                           [0, 0, 1]])
        # 右相机内参
        self.cam_matrix_right = np.array([[991.718946669437, -0.0907540625530892, 624.408161711083],
                                            [0, 991.720854573884, 370.420436667102],
                                            [0, 0, 1]])

        # 左右相机畸变系数:[k1, k2, p1, p2, k3]
        self.distortion_l = np.array([[-0.451000919444727, 0.233773017190369, -0.000235517122247992, -0.00107206555811668, 0]])
        self.distortion_r = np.array([[-0.449248394437632, 0.247393036690202, -0.0000349078939884892, -0.0000547393740792125, 0]])

        # 旋转矩阵
        self.R = np.matrix([[1, 0.00161382047916743, 0.00530724206543221],
                             [-0.00156777683550538, 1, -0.00866837204274770],
                             [-0.00532102534048900, 0.00865991810229502, 0.999948344919770]])
        # 平移矩阵
        self.T = np.array([[63.4813645248768], [0.300383582551749], [-0.343160895064395]])

        # 主点列坐标的差
        # cx1-cx0,
        self.doffs = 35.738

        # 指示上述内外参是否为经过立体校正后的结果
        self.isRectified = False

 

posted @ 2022-10-06 15:17  路人加  阅读(487)  评论(0编辑  收藏  举报