Mercurial Hosting > traffic-intelligence
comparison python/cvutils.py @ 931:8148991b1dab
bug correcting
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 13 Jul 2017 00:52:53 -0400 |
parents | 7db0f2853bfd |
children | 66f382852e61 |
comparison
equal
deleted
inserted
replaced
930:7db0f2853bfd | 931:8148991b1dab |
---|---|
538 reducedPoints = dot(invNewCameraMatrix, projected) | 538 reducedPoints = dot(invNewCameraMatrix, projected) |
539 else: | 539 else: |
540 reducedPoints = projected | 540 reducedPoints = projected |
541 projected, jacobian = cv2.projectPoints(reducedPoints.T, (0.,0.,0.), (0.,0.,0.), intrinsicCameraMatrix, distortionCoefficients) # in: 3xN, out: 2x1xN | 541 projected, jacobian = cv2.projectPoints(reducedPoints.T, (0.,0.,0.), (0.,0.,0.), intrinsicCameraMatrix, distortionCoefficients) # in: 3xN, out: 2x1xN |
542 projected = projected.reshape(-1,2).T | 542 projected = projected.reshape(-1,2).T |
543 return projected[:2,:] | 543 return projected[:2,:] |
544 | 544 |
545 def project(homography, p, intrinsicCameraMatrix = None, distortionCoefficients = None): | 545 def project(homography, p, intrinsicCameraMatrix = None, distortionCoefficients = None, newCameraMatrix = None): |
546 '''Returns the coordinates of the projection of the point p with coordinates p[0], p[1] | 546 '''Returns the coordinates of the projection of the point p with coordinates p[0], p[1] |
547 through homography''' | 547 through homography''' |
548 return projectArray(homography, array([[p[0]],[p[1]]]), intrinsicCameraMatrix, distortionCoefficients) | 548 return projectArray(homography, array([[p[0]],[p[1]]]), intrinsicCameraMatrix, distortionCoefficients, newCameraMatrix) |
549 | 549 |
550 def projectTrajectory(homography, trajectory, intrinsicCameraMatrix = None, distortionCoefficients = None): | 550 def projectTrajectory(homography, trajectory, intrinsicCameraMatrix = None, distortionCoefficients = None, newCameraMatrix = None): |
551 '''Projects a series of points in the format | 551 '''Projects a series of points in the format |
552 [[x1, x2, ...], | 552 [[x1, x2, ...], |
553 [y1, y2, ...]]''' | 553 [y1, y2, ...]]''' |
554 return projectArray(homography, array(trajectory), intrinsicCameraMatrix, distortionCoefficients) | 554 return projectArray(homography, array(trajectory), intrinsicCameraMatrix, distortionCoefficients, newCameraMatrix) |
555 | 555 |
556 def invertHomography(homography): | 556 def invertHomography(homography): |
557 '''Returns an inverted homography | 557 '''Returns an inverted homography |
558 Unnecessary for reprojection over camera image''' | 558 Unnecessary for reprojection over camera image''' |
559 invH = inv(homography) | 559 invH = inv(homography) |