msight-vision 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cli/__init__.py +0 -0
- cli/launch_2d_viewer.py +10 -0
- cli/launch_custom_fuser.py +23 -0
- cli/launch_finite_difference_state_estimator.py +22 -0
- cli/launch_road_user_list_viewer.py +23 -0
- cli/launch_sort_tracker.py +24 -0
- cli/launch_yolo_onestage_detection.py +22 -0
- msight_vision/__init__.py +8 -0
- msight_vision/base.py +99 -0
- msight_vision/detector_yolo.py +87 -0
- msight_vision/fuser.py +325 -0
- msight_vision/localizer.py +32 -0
- msight_vision/msight_core/__init__.py +6 -0
- msight_vision/msight_core/detection.py +103 -0
- msight_vision/msight_core/fusion.py +64 -0
- msight_vision/msight_core/state_estimation.py +38 -0
- msight_vision/msight_core/tracking.py +31 -0
- msight_vision/msight_core/viewer.py +55 -0
- msight_vision/msight_core/warper.py +98 -0
- msight_vision/state_estimator.py +121 -0
- msight_vision/tracker.py +525 -0
- msight_vision/utils/__init__.py +3 -0
- msight_vision/utils/data.py +80 -0
- msight_vision/utils/typing.py +18 -0
- msight_vision/utils/vis.py +17 -0
- msight_vision/warper.py +89 -0
- msight_vision-0.1.0.dist-info/METADATA +28 -0
- msight_vision-0.1.0.dist-info/RECORD +31 -0
- msight_vision-0.1.0.dist-info/WHEEL +5 -0
- msight_vision-0.1.0.dist-info/entry_points.txt +7 -0
- msight_vision-0.1.0.dist-info/top_level.txt +2 -0
msight_vision/warper.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import cv2
|
|
2
|
+
import numpy as np
|
|
3
|
+
from threading import Thread
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ClassicWarper:
|
|
7
|
+
"""
|
|
8
|
+
warper class warp image to the standard image
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(self, standard_img,
|
|
12
|
+
starting_behavior="return" # "wait" or "return"
|
|
13
|
+
):
|
|
14
|
+
self.standard_img = standard_img
|
|
15
|
+
self.warp_matrix = None
|
|
16
|
+
self.step = 0
|
|
17
|
+
self.update_interval = 1000
|
|
18
|
+
self.starting_behavior = starting_behavior # "wait" or "return"
|
|
19
|
+
|
|
20
|
+
def get_warp_matrix_between_two_image(self, im1, im2):
|
|
21
|
+
|
|
22
|
+
# Convert images to grayscale
|
|
23
|
+
im1_gray = cv2.cvtColor(im1, cv2.COLOR_BGR2GRAY)
|
|
24
|
+
im2_gray = cv2.cvtColor(im2, cv2.COLOR_BGR2GRAY)
|
|
25
|
+
|
|
26
|
+
# Find size of image1
|
|
27
|
+
# sz = im1.shape
|
|
28
|
+
|
|
29
|
+
# Define the motion model
|
|
30
|
+
warp_mode = cv2.MOTION_HOMOGRAPHY
|
|
31
|
+
|
|
32
|
+
# Define 2x3 or 3x3 matrices and initialize the matrix to identity
|
|
33
|
+
if warp_mode == cv2.MOTION_HOMOGRAPHY:
|
|
34
|
+
warp_matrix = np.eye(3, 3, dtype=np.float32)
|
|
35
|
+
else:
|
|
36
|
+
warp_matrix = np.eye(2, 3, dtype=np.float32)
|
|
37
|
+
|
|
38
|
+
# Specify the number of iterations.
|
|
39
|
+
number_of_iterations = 500
|
|
40
|
+
|
|
41
|
+
# Specify the threshold of the increment
|
|
42
|
+
# in the correlation coefficient between two iterations
|
|
43
|
+
termination_eps = 1e-10
|
|
44
|
+
|
|
45
|
+
# Define termination criteria
|
|
46
|
+
criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT,
|
|
47
|
+
number_of_iterations, termination_eps)
|
|
48
|
+
|
|
49
|
+
# Run the ECC algorithm. The results are stored in warp_matrix.
|
|
50
|
+
(cc, warp_matrix) = cv2.findTransformECC(
|
|
51
|
+
im1_gray, im2_gray, warp_matrix, warp_mode, criteria)
|
|
52
|
+
return warp_matrix
|
|
53
|
+
|
|
54
|
+
def update_warp_matrix(self, image):
|
|
55
|
+
self.warp_matrix = self.get_warp_matrix_between_two_image(
|
|
56
|
+
self.standard_img, image)
|
|
57
|
+
|
|
58
|
+
def warp(self, image):
|
|
59
|
+
if self.warp_matrix is None:
|
|
60
|
+
print("WARNING: Warp matrix is not set yet. ")
|
|
61
|
+
if self.starting_behavior == "wait":
|
|
62
|
+
self.update_warp_matrix(image)
|
|
63
|
+
elif self.starting_behavior == "return":
|
|
64
|
+
t = Thread(target=self.update_warp_matrix, args=(image,))
|
|
65
|
+
t.daemon = True # Set the thread as a daemon thread
|
|
66
|
+
t.start()
|
|
67
|
+
return image
|
|
68
|
+
else:
|
|
69
|
+
raise ValueError("Invalid starting behavior. Use 'wait' or 'return'.")
|
|
70
|
+
# Apply the warp matrix to the image
|
|
71
|
+
sz = image.shape
|
|
72
|
+
new_image = cv2.warpPerspective(
|
|
73
|
+
image, self.warp_matrix, (sz[1], sz[0]), flags=cv2.INTER_LINEAR + cv2.WARP_INVERSE_MAP)
|
|
74
|
+
self.step += 1
|
|
75
|
+
if self.step % self.update_interval == 0:
|
|
76
|
+
t = Thread(target=self.update_warp_matrix, args=(image,))
|
|
77
|
+
t.daemon = True # Set the thread as a daemon thread
|
|
78
|
+
t.start()
|
|
79
|
+
return new_image
|
|
80
|
+
|
|
81
|
+
class ClassicWarperWithExternalUpdate:
|
|
82
|
+
def warp(self, image, warp_matrix):
|
|
83
|
+
if warp_matrix is None:
|
|
84
|
+
return image
|
|
85
|
+
# Apply the warp matrix to the image
|
|
86
|
+
sz = image.shape
|
|
87
|
+
new_image = cv2.warpPerspective(
|
|
88
|
+
image, warp_matrix, (sz[1], sz[0]), flags=cv2.INTER_LINEAR + cv2.WARP_INVERSE_MAP)
|
|
89
|
+
return new_image
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: msight_vision
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 2D detection module for the MSight roadside perception system
|
|
5
|
+
Author-email: Rusheng Zhang <rushengz@umich.edu>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/michigan-traffic-lab/MSight_Vision
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: numpy
|
|
11
|
+
Requires-Dist: opencv-python
|
|
12
|
+
Requires-Dist: matplotlib
|
|
13
|
+
Requires-Dist: geopy
|
|
14
|
+
Requires-Dist: filterpy
|
|
15
|
+
Requires-Dist: ultralytics
|
|
16
|
+
|
|
17
|
+
# MSight 2D Detection Library
|
|
18
|
+
|
|
19
|
+
# Installation
|
|
20
|
+
## 1. Install pre-requirment
|
|
21
|
+
This library is based on Pytorch, please follow the [the Pytorch official website](https://pytorch.org/) to install the the correct Pytorch version that is compatible with you machine's CUDA configuration.
|
|
22
|
+
|
|
23
|
+
## 2. MSight dependency
|
|
24
|
+
### MSight Base
|
|
25
|
+
This library is based on [msight_base](https://github.com/michigan-traffic-lab/MSight_base), please follow the guidance to install them.
|
|
26
|
+
|
|
27
|
+
## MSight Edge (Optional)
|
|
28
|
+
If you want to use the packed node of this library, you need to install [msight_edge](https://github.com/michigan-traffic-lab/MSight_Edge2), follow the instruction and install it.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
cli/launch_2d_viewer.py,sha256=Y7gWbGzfPAc8n3jEV6hxfXIXay1bOXAx9TYIvf1cmQQ,464
|
|
3
|
+
cli/launch_custom_fuser.py,sha256=ji2YwfZ17_W1EbLD_lb8djGLctK85tHhnpiQf346xck,855
|
|
4
|
+
cli/launch_finite_difference_state_estimator.py,sha256=iRO65_bOYYTKUiADrW8IHW6Bxx8H7I0izP6UT15rc8Y,965
|
|
5
|
+
cli/launch_road_user_list_viewer.py,sha256=tKnmQoWvqGAB3b2d2-a96j8RYpJOf26A0FyaLVYfeTY,957
|
|
6
|
+
cli/launch_sort_tracker.py,sha256=aLZQzz15mbd0ciM2TvVqjfoOT-htljS6fxdmMU_60EU,911
|
|
7
|
+
cli/launch_yolo_onestage_detection.py,sha256=9ohZFWetr9FaEKAiMid_GGusUGSstQL2QyAaN0ZSbIE,916
|
|
8
|
+
msight_vision/__init__.py,sha256=o0Ey3th8sJxpbvhpnHcBtiX_kqv3hCQ2uAdqCvsYl7U,368
|
|
9
|
+
msight_vision/base.py,sha256=IYYwxVRyCkFIjCAgvy5o_ctZp2hvAZYO6Q1Zrkbh3fM,3877
|
|
10
|
+
msight_vision/detector_yolo.py,sha256=KM5K1rrsgL9Czz48-by5IUF60VoprJwcYMl6UJs5J6I,3889
|
|
11
|
+
msight_vision/fuser.py,sha256=rDEcwMVa-a5bewayBuix_XFjomsUA7FmnpXjVNWD5_M,14978
|
|
12
|
+
msight_vision/localizer.py,sha256=cfWU31HOAnKtdR2dIvudGYHjWnAqvpz3E51hjkrneNM,1237
|
|
13
|
+
msight_vision/state_estimator.py,sha256=dJMr6w9agSFraUdalDV7bYP1Cw6y94cSsBMPOi--vLM,5684
|
|
14
|
+
msight_vision/tracker.py,sha256=P9sM9Ly5pWQ299Oh__1kVcCDPneON1ND25ZYDJdl0bk,20247
|
|
15
|
+
msight_vision/warper.py,sha256=nCm29xsaqAOpES7WI9W8wbPD-F7lRjAi40qrLz4lqhA,3333
|
|
16
|
+
msight_vision/msight_core/__init__.py,sha256=caIlPjLY3nZbWZI87tQlWWcTpnVIKK_8yUP9W16OONY,305
|
|
17
|
+
msight_vision/msight_core/detection.py,sha256=cqrAKughLHCTIkAGKMygi9CQE340Asd6ZIb-geW_9UA,5249
|
|
18
|
+
msight_vision/msight_core/fusion.py,sha256=RKbKH-TUq42bf2vwSyhz9QDODk40Mmev8oXm11IRYck,2916
|
|
19
|
+
msight_vision/msight_core/state_estimation.py,sha256=rdVoRYeJ1BaR_C4HIzyNzCnm0ZAIrpkEsbydfUG6gn8,1879
|
|
20
|
+
msight_vision/msight_core/tracking.py,sha256=qd8R0Jl2BiWMrjcwZYqto4gjgVDvKlkZCzcajfuQ314,1162
|
|
21
|
+
msight_vision/msight_core/viewer.py,sha256=Qel_5CaK38HCasIHXgzQg8HyeMLHYkF3zh1llOlJSKY,2282
|
|
22
|
+
msight_vision/msight_core/warper.py,sha256=XjM6TnEG2AxYrwSfkWkfvCBV0zuoAWupZ7kyR_NiETE,4676
|
|
23
|
+
msight_vision/utils/__init__.py,sha256=U9FxdI6-XHtKjf-jbReFQVe83eykaRo-a7y0glQcMU4,126
|
|
24
|
+
msight_vision/utils/data.py,sha256=EzMMaxo-_tIdR2Z30Ta0qBeDHZZbThqea20ozbheuSU,3736
|
|
25
|
+
msight_vision/utils/typing.py,sha256=LEGbPc8GCGuR1WoRoYtutXhfpXulr0Ri7b-O8WVTbvw,678
|
|
26
|
+
msight_vision/utils/vis.py,sha256=JP-4Iajbv4Mg6fUObhh1COW_TOyVvnjQAZtX46Gx7_Q,777
|
|
27
|
+
msight_vision-0.1.0.dist-info/METADATA,sha256=rV_Ce222OfQiCQzWUDTj1adqqaDf2mof_qK1BusQLQw,1173
|
|
28
|
+
msight_vision-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
29
|
+
msight_vision-0.1.0.dist-info/entry_points.txt,sha256=IBXVX0v7VvhZM4gPoPrSBswXjt0y5Z890vqRMDtun8A,442
|
|
30
|
+
msight_vision-0.1.0.dist-info/top_level.txt,sha256=7ZBqh5OFAK-_CxZqI3wAJnc-gwis1ena5ngU0EN_qQk,18
|
|
31
|
+
msight_vision-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
msight_launch_2d_viewer = cli.launch_2d_viewer:main
|
|
3
|
+
msight_launch_custom_fuser = cli.launch_custom_fuser:main
|
|
4
|
+
msight_launch_finite_difference_state_estimator = cli.launch_finite_difference_state_estimator:main
|
|
5
|
+
msight_launch_road_user_list_viewer = cli.launch_road_user_list_viewer:main
|
|
6
|
+
msight_launch_sort_tracker = cli.launch_sort_tracker:main
|
|
7
|
+
msight_launch_yolo_onestage_detection = cli.launch_yolo_onestage_detection:main
|