comparison trafficintelligence/cvutils.py @ 1174:2f89dc3d99e5

clarification of worldToImageProject method
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 17 Dec 2021 14:26:45 -0500
parents d71a4d174b1a
children 3905b393ade0
comparison
equal deleted inserted replaced
1173:c1766bb5076c 1174:2f89dc3d99e5
567 return homographyProject(undistortedPoints.T, homography) 567 return homographyProject(undistortedPoints.T, homography)
568 else: 568 else:
569 return homographyProject(points, homography) 569 return homographyProject(points, homography)
570 570
571 def worldToImageProject(points, intrinsicCameraMatrix = None, distortionCoefficients = None, homography = None): 571 def worldToImageProject(points, intrinsicCameraMatrix = None, distortionCoefficients = None, homography = None):
572 '''Projects points (2xN array) from image (video) space to world space 572 '''Projects points (2xN array) from world space to image (video) space
573 1. through undistorting if provided by intrinsic camera matrix and distortion coefficients 573 1. through undistorting if provided by intrinsic camera matrix and distortion coefficients
574 2. through homograph projection (from ideal point (no camera) to world)''' 574 2. through homograph projection (from ideal point (no camera) to world)
575
576 Warning: this usually means to invert the homography if computer from image (ideal point) to world space, eg using numpy.linalg.inv'''
575 if points.shape[0] != 2: 577 if points.shape[0] != 2:
576 raise Exception('points of dimension {}'.format(points.shape)) 578 raise Exception('points of dimension {}'.format(points.shape))
577 579
578 if intrinsicCameraMatrix is not None and distortionCoefficients is not None: 580 if intrinsicCameraMatrix is not None and distortionCoefficients is not None:
579 projected3D = homographyProject(points, homography, True) 581 projected3D = homographyProject(points, homography, True)