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
评论列表
文章目录