Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/cvutils.py @ 1253:ef68d4ba7dae
added loading ego vehicle in kitti 2D format and method to plot outline
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Mon, 25 Mar 2024 17:05:20 -0400 |
| parents | 371c718e57d7 |
| children |
comparison
equal
deleted
inserted
replaced
| 1252:fe35473acee3 | 1253:ef68d4ba7dae |
|---|---|
| 28 | 28 |
| 29 videoFilenameExtensions = ['mov', 'avi', 'mp4', 'MOV', 'AVI', 'MP4'] | 29 videoFilenameExtensions = ['mov', 'avi', 'mp4', 'MOV', 'AVI', 'MP4'] |
| 30 trackerExe = 'feature-based-tracking' | 30 trackerExe = 'feature-based-tracking' |
| 31 #importaggdraw # agg on top of PIL (antialiased drawing) | 31 #importaggdraw # agg on top of PIL (antialiased drawing) |
| 32 | 32 |
| 33 colors = 'rgbcymk' | |
| 33 cvRed = {'default': (0,0,255), | 34 cvRed = {'default': (0,0,255), |
| 34 'colorblind': (0,114,178)} | 35 'colorblind': (0,114,178)} |
| 35 cvGreen = {'default': (0,255,0), | 36 cvGreen = {'default': (0,255,0), |
| 36 'colorblind': (0,158,115)} | 37 'colorblind': (0,158,115)} |
| 37 cvBlue = {'default': (255,0,0), | 38 cvBlue = {'default': (255,0,0), |
| 532 [map1, map2] = computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients) | 533 [map1, map2] = computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients) |
| 533 return cv2.remap(img, map1, map2, interpolation=interpolation) | 534 return cv2.remap(img, map1, map2, interpolation=interpolation) |
| 534 | 535 |
| 535 def cartesian2Homogeneous(m): | 536 def cartesian2Homogeneous(m): |
| 536 'Transforms n x m matrix to n x (m+1) by adding last column of 1s' | 537 'Transforms n x m matrix to n x (m+1) by adding last column of 1s' |
| 537 homoM = ones((m.shape[0], m.shape[1]+1)) | 538 if len(m.shape) == 2: |
| 539 homoM = ones((m.shape[0], m.shape[1]+1)) | |
| 540 else: | |
| 541 homoM = ones((1, len(m)+1)) | |
| 538 homoM[:,:-1] = m | 542 homoM[:,:-1] = m |
| 539 return homoM | 543 return homoM |
| 540 | 544 |
| 541 def homographyProject(points, homography, output3D = False): | 545 def homographyProject(points, homography, output3D = False): |
| 542 '''Returns the coordinates of the points (2xN array) projected through homography''' | 546 '''Returns the coordinates of the points (2xN array) projected through homography''' |
