LensDistortion.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:imgProcessor 作者: radjkarl 项目源码 文件源码
def coeffs(self):
        if not self._coeffs:
            if not self.findCount:
                raise NothingFound(
                    'can create camera calibration because no corners have been found')

            # http://en.wikipedia.org/wiki/Reprojection_error
            try:
                (reprojectionError, cameraMatrix, distortionCoeffs,
                 rotationVecs, translationVecs) = cv2.calibrateCamera(
                    self.objpoints,
                    self.opts['imgPoints'],
                    self.img.shape[::-1], None, None)
                print('reprojectionError=%s' % reprojectionError)
            except Exception as err:
                raise NothingFound(err)

            self._coeffs = OrderedDict([
                ('reprojectionError', reprojectionError),
                ('apertureSize', self.apertureSize),
                ('cameraMatrix', cameraMatrix),
                ('distortionCoeffs', distortionCoeffs),
                ('shape', self.img.shape),
                #('rotationVecs',rotationVecs),
                #('translationVecs',translationVecs),
            ])
            if self.apertureSize is not None:
                (fovx, fovy, focalLength, principalPoint,
                 aspectRatio) = cv2.calibrationMatrixValues(
                    cameraMatrix, self.img.shape, *self.apertureSize)
                self._coeffs.update(OrderedDict([
                    ('fovx', fovx),
                    ('fovy', fovy),
                    ('focalLength', focalLength),
                    ('principalPoint', principalPoint),
                    ('aspectRatio', aspectRatio)])
                )
        return self._coeffs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号