ailia-tracker 1.1.1__tar.gz
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.
- ailia_tracker-1.1.1/PKG-INFO +66 -0
- ailia_tracker-1.1.1/README.md +47 -0
- ailia_tracker-1.1.1/ailia_tracker/__init__.py +363 -0
- ailia_tracker-1.1.1/ailia_tracker/linux/arm64-v8a/libailia_tracker.so +0 -0
- ailia_tracker-1.1.1/ailia_tracker/linux/x64/libailia_tracker.so +0 -0
- ailia_tracker-1.1.1/ailia_tracker/mac/libailia_tracker.dylib +0 -0
- ailia_tracker-1.1.1/ailia_tracker/windows/arm64/ailia_tracker.dll +0 -0
- ailia_tracker-1.1.1/ailia_tracker/windows/x64/ailia_tracker.dll +0 -0
- ailia_tracker-1.1.1/ailia_tracker.egg-info/PKG-INFO +66 -0
- ailia_tracker-1.1.1/ailia_tracker.egg-info/SOURCES.txt +12 -0
- ailia_tracker-1.1.1/ailia_tracker.egg-info/dependency_links.txt +1 -0
- ailia_tracker-1.1.1/ailia_tracker.egg-info/top_level.txt +1 -0
- ailia_tracker-1.1.1/setup.cfg +4 -0
- ailia_tracker-1.1.1/setup.py +57 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ailia_tracker
|
|
3
|
+
Version: 1.1.1
|
|
4
|
+
Summary: ailia Tracker
|
|
5
|
+
Home-page: https://ailia.jp/
|
|
6
|
+
Author: ax Inc.
|
|
7
|
+
Author-email: contact@axinc.jp
|
|
8
|
+
License: https://ailia.ai/en/license/
|
|
9
|
+
Requires-Python: >3.6
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Dynamic: author
|
|
12
|
+
Dynamic: author-email
|
|
13
|
+
Dynamic: description
|
|
14
|
+
Dynamic: description-content-type
|
|
15
|
+
Dynamic: home-page
|
|
16
|
+
Dynamic: license
|
|
17
|
+
Dynamic: requires-python
|
|
18
|
+
Dynamic: summary
|
|
19
|
+
|
|
20
|
+
# ailia Tracker Python API
|
|
21
|
+
|
|
22
|
+
!! CAUTION !!
|
|
23
|
+
“ailia” IS NOT OPEN SOURCE SOFTWARE (OSS).
|
|
24
|
+
As long as user complies with the conditions stated in [License Document](https://ailia.ai/license/), user may use the Software for free of charge, but the Software is basically paid software.
|
|
25
|
+
|
|
26
|
+
## About ailia Tracker
|
|
27
|
+
|
|
28
|
+
ailia Tracker is a library for tracking the movement of objects based on object detection results. It provides a C API for native applications and a C# API for Unity. By using ailia Tracker, you can easily implement object tracking in your application.
|
|
29
|
+
|
|
30
|
+
## Install from pip
|
|
31
|
+
|
|
32
|
+
You can install the ailia SDK free evaluation package with the following command.
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
pip3 install ailia_tracker
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Install from package
|
|
39
|
+
|
|
40
|
+
You can install the ailia SDK from Package with the following command.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
python3 bootstrap.py
|
|
44
|
+
pip3 install .
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import ailia_tracker
|
|
51
|
+
|
|
52
|
+
tracker = ailia_tracker.AiliaTracker()
|
|
53
|
+
|
|
54
|
+
for frame in frames:
|
|
55
|
+
for detection in detections(frame):
|
|
56
|
+
tracker.add_target(detection.category, detection.prob, detection.x, detection.y, detection.w, detection.h)
|
|
57
|
+
tracker.compute()
|
|
58
|
+
for obj in tracker.get_objects():
|
|
59
|
+
print(obj.id, obj.category, obj.prob, obj.x, obj.y, obj.w, obj.h)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The coordinates of `add_target` and the tracking results are normalized to the image size (1 for the image width / height).
|
|
63
|
+
|
|
64
|
+
## API specification
|
|
65
|
+
|
|
66
|
+
https://github.com/ailia-ai/ailia-sdk
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# ailia Tracker Python API
|
|
2
|
+
|
|
3
|
+
!! CAUTION !!
|
|
4
|
+
“ailia” IS NOT OPEN SOURCE SOFTWARE (OSS).
|
|
5
|
+
As long as user complies with the conditions stated in [License Document](https://ailia.ai/license/), user may use the Software for free of charge, but the Software is basically paid software.
|
|
6
|
+
|
|
7
|
+
## About ailia Tracker
|
|
8
|
+
|
|
9
|
+
ailia Tracker is a library for tracking the movement of objects based on object detection results. It provides a C API for native applications and a C# API for Unity. By using ailia Tracker, you can easily implement object tracking in your application.
|
|
10
|
+
|
|
11
|
+
## Install from pip
|
|
12
|
+
|
|
13
|
+
You can install the ailia SDK free evaluation package with the following command.
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
pip3 install ailia_tracker
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Install from package
|
|
20
|
+
|
|
21
|
+
You can install the ailia SDK from Package with the following command.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
python3 bootstrap.py
|
|
25
|
+
pip3 install .
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import ailia_tracker
|
|
32
|
+
|
|
33
|
+
tracker = ailia_tracker.AiliaTracker()
|
|
34
|
+
|
|
35
|
+
for frame in frames:
|
|
36
|
+
for detection in detections(frame):
|
|
37
|
+
tracker.add_target(detection.category, detection.prob, detection.x, detection.y, detection.w, detection.h)
|
|
38
|
+
tracker.compute()
|
|
39
|
+
for obj in tracker.get_objects():
|
|
40
|
+
print(obj.id, obj.category, obj.prob, obj.x, obj.y, obj.w, obj.h)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The coordinates of `add_target` and the tracking results are normalized to the image size (1 for the image width / height).
|
|
44
|
+
|
|
45
|
+
## API specification
|
|
46
|
+
|
|
47
|
+
https://github.com/ailia-ai/ailia-sdk
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
#### python binding of ailia tracker ####
|
|
2
|
+
|
|
3
|
+
import ctypes
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
import platform
|
|
8
|
+
|
|
9
|
+
#### dependency check
|
|
10
|
+
if sys.platform == "win32":
|
|
11
|
+
import ctypes
|
|
12
|
+
if platform.machine() != "ARM64":
|
|
13
|
+
try:
|
|
14
|
+
for library in ["vcruntime140.dll", "vcruntime140_1.dll", "msvcp140.dll"]:
|
|
15
|
+
ctypes.windll.LoadLibrary(library)
|
|
16
|
+
except:
|
|
17
|
+
print(" WARNING Please install MSVC 2015-2019 runtime from https://docs.microsoft.com/ja-jp/cpp/windows/latest-supported-vc-redist")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
#### loading DLL / DYLIB / SO ####
|
|
21
|
+
if sys.platform == "win32":
|
|
22
|
+
if platform.machine() == "ARM64":
|
|
23
|
+
dll_platform = "windows/arm64"
|
|
24
|
+
else:
|
|
25
|
+
dll_platform = "windows/x64"
|
|
26
|
+
dll_name = "ailia_tracker.dll"
|
|
27
|
+
load_fn = ctypes.WinDLL
|
|
28
|
+
elif sys.platform == "darwin":
|
|
29
|
+
dll_platform = "mac"
|
|
30
|
+
dll_name = "libailia_tracker.dylib"
|
|
31
|
+
load_fn = ctypes.CDLL
|
|
32
|
+
else:
|
|
33
|
+
is_arm = "arm" in platform.machine() or platform.machine() == "aarch64"
|
|
34
|
+
if is_arm:
|
|
35
|
+
if platform.architecture()[0] == "32bit":
|
|
36
|
+
dll_platform = "linux/armeabi-v7a"
|
|
37
|
+
else:
|
|
38
|
+
dll_platform = "linux/arm64-v8a"
|
|
39
|
+
else:
|
|
40
|
+
dll_platform = "linux/x64"
|
|
41
|
+
dll_name = "libailia_tracker.so"
|
|
42
|
+
load_fn = ctypes.CDLL
|
|
43
|
+
|
|
44
|
+
dll_found = False
|
|
45
|
+
candidate = ["", str(os.path.dirname(os.path.abspath(__file__))) + str(os.sep), str(os.path.dirname(os.path.abspath(__file__))) + str(os.sep) + dll_platform + str(os.sep)]
|
|
46
|
+
for dir in candidate:
|
|
47
|
+
try:
|
|
48
|
+
dll = load_fn(dir + dll_name)
|
|
49
|
+
dll_found = True
|
|
50
|
+
except:
|
|
51
|
+
pass
|
|
52
|
+
if not dll_found:
|
|
53
|
+
msg = "DLL load failed : \'" + dll_name + "\' is not found"
|
|
54
|
+
raise ImportError(msg)
|
|
55
|
+
|
|
56
|
+
# ==============================================================================
|
|
57
|
+
|
|
58
|
+
from ctypes import *
|
|
59
|
+
|
|
60
|
+
#### constants definition ####
|
|
61
|
+
|
|
62
|
+
AILIA_STATUS_SUCCESS = ( 0 )
|
|
63
|
+
|
|
64
|
+
AILIA_TRACKER_ALGORITHM_BYTE_TRACK = ( 0 )
|
|
65
|
+
|
|
66
|
+
AILIA_TRACKER_OBJECT_VERSION = ( 1 )
|
|
67
|
+
AILIA_TRACKER_SETTINGS_VERSION = ( 1 )
|
|
68
|
+
AILIA_DETECTOR_OBJECT_VERSION = ( 1 )
|
|
69
|
+
|
|
70
|
+
AILIA_TRACKER_FLAG_NONE = ( 0 )
|
|
71
|
+
AILIA_TRACKER_FLAG_ALLOW_WIDE_ASPECT_RATIO = ( 1 )
|
|
72
|
+
|
|
73
|
+
#### data structure definition ####
|
|
74
|
+
|
|
75
|
+
# AILIATrackerSettings
|
|
76
|
+
class TrackerSettings(ctypes.Structure):
|
|
77
|
+
""" settings of the tracker (AILIATrackerSettings)
|
|
78
|
+
|
|
79
|
+
Attributes
|
|
80
|
+
----------
|
|
81
|
+
score_threshold : float
|
|
82
|
+
Minimum confidence score to accept a detection result.
|
|
83
|
+
nms_threshold : float
|
|
84
|
+
Non-Maximum Suppression (NMS) threshold used to remove duplicate detections.
|
|
85
|
+
track_threshold : float
|
|
86
|
+
Confidence threshold for updating active tracks.
|
|
87
|
+
track_buffer : int
|
|
88
|
+
Maximum number of frames to keep lost tracks in memory.
|
|
89
|
+
match_threshold : float
|
|
90
|
+
IoU threshold used for matching objects between frames.
|
|
91
|
+
"""
|
|
92
|
+
_fields_ = [
|
|
93
|
+
("score_threshold", ctypes.c_float),
|
|
94
|
+
("nms_threshold", ctypes.c_float),
|
|
95
|
+
("track_threshold", ctypes.c_float),
|
|
96
|
+
("track_buffer", ctypes.c_int),
|
|
97
|
+
("match_threshold", ctypes.c_float)]
|
|
98
|
+
VERSION = ctypes.c_int(AILIA_TRACKER_SETTINGS_VERSION)
|
|
99
|
+
|
|
100
|
+
# AILIATrackerObject
|
|
101
|
+
class TrackerObject(ctypes.Structure):
|
|
102
|
+
""" tracking result (AILIATrackerObject)
|
|
103
|
+
|
|
104
|
+
Attributes
|
|
105
|
+
----------
|
|
106
|
+
id : int
|
|
107
|
+
Object tracking id.
|
|
108
|
+
category : int
|
|
109
|
+
Object category number (0 to category_count-1).
|
|
110
|
+
prob : float
|
|
111
|
+
Estimated probability (0 to 1).
|
|
112
|
+
x : float
|
|
113
|
+
X position at the top left (1 for the image width).
|
|
114
|
+
y : float
|
|
115
|
+
Y position at the top left (1 for the image height).
|
|
116
|
+
w : float
|
|
117
|
+
Width (1 for the width of the image, negative numbers not allowed).
|
|
118
|
+
h : float
|
|
119
|
+
Height (1 for the height of the image, negative numbers not allowed).
|
|
120
|
+
"""
|
|
121
|
+
_fields_ = [
|
|
122
|
+
("id", ctypes.c_uint),
|
|
123
|
+
("category", ctypes.c_uint),
|
|
124
|
+
("prob", ctypes.c_float),
|
|
125
|
+
("x", ctypes.c_float),
|
|
126
|
+
("y", ctypes.c_float),
|
|
127
|
+
("w", ctypes.c_float),
|
|
128
|
+
("h", ctypes.c_float)]
|
|
129
|
+
VERSION = ctypes.c_uint(AILIA_TRACKER_OBJECT_VERSION)
|
|
130
|
+
|
|
131
|
+
# AILIADetectorObject
|
|
132
|
+
class DetectorObject(ctypes.Structure):
|
|
133
|
+
""" tracking target (AILIADetectorObject)
|
|
134
|
+
|
|
135
|
+
Attributes
|
|
136
|
+
----------
|
|
137
|
+
category : int
|
|
138
|
+
Object category number (0 to category_count-1).
|
|
139
|
+
prob : float
|
|
140
|
+
Estimated probability (0 to 1).
|
|
141
|
+
x : float
|
|
142
|
+
X position at the top left (1 for the image width).
|
|
143
|
+
y : float
|
|
144
|
+
Y position at the top left (1 for the image height).
|
|
145
|
+
w : float
|
|
146
|
+
Width (1 for the width of the image, negative numbers not allowed).
|
|
147
|
+
h : float
|
|
148
|
+
Height (1 for the height of the image, negative numbers not allowed).
|
|
149
|
+
"""
|
|
150
|
+
_fields_ = [
|
|
151
|
+
("category", ctypes.c_uint),
|
|
152
|
+
("prob", ctypes.c_float),
|
|
153
|
+
("x", ctypes.c_float),
|
|
154
|
+
("y", ctypes.c_float),
|
|
155
|
+
("w", ctypes.c_float),
|
|
156
|
+
("h", ctypes.c_float)]
|
|
157
|
+
VERSION = ctypes.c_int(AILIA_DETECTOR_OBJECT_VERSION)
|
|
158
|
+
|
|
159
|
+
#### API prototypes ####
|
|
160
|
+
|
|
161
|
+
dll.ailiaTrackerCreate.restype = ctypes.c_int
|
|
162
|
+
dll.ailiaTrackerCreate.argtypes = (
|
|
163
|
+
ctypes.POINTER(ctypes.c_void_p), # tracker
|
|
164
|
+
ctypes.c_int, # algorithm
|
|
165
|
+
ctypes.POINTER(TrackerSettings), # settings
|
|
166
|
+
ctypes.c_int, # version
|
|
167
|
+
ctypes.c_int) # flags
|
|
168
|
+
|
|
169
|
+
dll.ailiaTrackerAddTarget.restype = ctypes.c_int
|
|
170
|
+
dll.ailiaTrackerAddTarget.argtypes = (
|
|
171
|
+
ctypes.c_void_p, # tracker
|
|
172
|
+
ctypes.POINTER(DetectorObject), # detector_object
|
|
173
|
+
ctypes.c_int) # version
|
|
174
|
+
|
|
175
|
+
dll.ailiaTrackerCompute.restype = ctypes.c_int
|
|
176
|
+
dll.ailiaTrackerCompute.argtypes = (
|
|
177
|
+
ctypes.c_void_p, ) # tracker
|
|
178
|
+
|
|
179
|
+
dll.ailiaTrackerGetObjectCount.restype = ctypes.c_int
|
|
180
|
+
dll.ailiaTrackerGetObjectCount.argtypes = (
|
|
181
|
+
ctypes.c_void_p, # tracker
|
|
182
|
+
ctypes.POINTER(ctypes.c_uint)) # obj_count
|
|
183
|
+
|
|
184
|
+
dll.ailiaTrackerGetObject.restype = ctypes.c_int
|
|
185
|
+
dll.ailiaTrackerGetObject.argtypes = (
|
|
186
|
+
ctypes.c_void_p, # tracker
|
|
187
|
+
ctypes.POINTER(TrackerObject), # obj
|
|
188
|
+
ctypes.c_uint, # index
|
|
189
|
+
ctypes.c_uint) # version
|
|
190
|
+
|
|
191
|
+
dll.ailiaTrackerDestroy.restype = ctypes.c_int
|
|
192
|
+
dll.ailiaTrackerDestroy.argtypes = (
|
|
193
|
+
ctypes.c_void_p, ) # tracker
|
|
194
|
+
|
|
195
|
+
dll.ailiaTrackerGetErrorDetail.restype = ctypes.c_char_p
|
|
196
|
+
dll.ailiaTrackerGetErrorDetail.argtypes = (
|
|
197
|
+
ctypes.c_void_p, ) # tracker
|
|
198
|
+
|
|
199
|
+
#### exception ####
|
|
200
|
+
|
|
201
|
+
class AiliaTrackerError(RuntimeError):
|
|
202
|
+
""" exception raised when an ailia tracker API call fails
|
|
203
|
+
|
|
204
|
+
Attributes
|
|
205
|
+
----------
|
|
206
|
+
code : int
|
|
207
|
+
Error code (AILIA_STATUS_*) returned from the ailia tracker API.
|
|
208
|
+
"""
|
|
209
|
+
def __init__(self, message, code):
|
|
210
|
+
super().__init__(message)
|
|
211
|
+
self.code = code
|
|
212
|
+
|
|
213
|
+
#### API wrapper ####
|
|
214
|
+
|
|
215
|
+
class AiliaTracker:
|
|
216
|
+
""" wrapper class for ailia tracker instance """
|
|
217
|
+
|
|
218
|
+
def __init__(self, algorithm=AILIA_TRACKER_ALGORITHM_BYTE_TRACK, score_threshold=0.1, nms_threshold=0.7, track_threshold=0.5, track_buffer=30, match_threshold=0.8, flags=AILIA_TRACKER_FLAG_NONE):
|
|
219
|
+
""" constructor of ailia tracker instance.
|
|
220
|
+
|
|
221
|
+
Parameters
|
|
222
|
+
----------
|
|
223
|
+
algorithm : int, optional, default: AILIA_TRACKER_ALGORITHM_BYTE_TRACK(0)
|
|
224
|
+
tracking algorithm.
|
|
225
|
+
score_threshold : float, optional, default: 0.1
|
|
226
|
+
minimum confidence score to accept a detection result.
|
|
227
|
+
nms_threshold : float, optional, default: 0.7
|
|
228
|
+
Non-Maximum Suppression (NMS) threshold used to remove duplicate detections.
|
|
229
|
+
track_threshold : float, optional, default: 0.5
|
|
230
|
+
confidence threshold for updating active tracks.
|
|
231
|
+
track_buffer : int, optional, default: 30
|
|
232
|
+
maximum number of frames to keep lost tracks in memory.
|
|
233
|
+
match_threshold : float, optional, default: 0.8
|
|
234
|
+
IoU threshold used for matching objects between frames.
|
|
235
|
+
flags : int, optional, default: AILIA_TRACKER_FLAG_NONE(0)
|
|
236
|
+
logical OR of AILIA_TRACKER_FLAG_*.
|
|
237
|
+
"""
|
|
238
|
+
self.__tracker = ctypes.c_void_p(None)
|
|
239
|
+
settings = TrackerSettings(
|
|
240
|
+
score_threshold=score_threshold,
|
|
241
|
+
nms_threshold=nms_threshold,
|
|
242
|
+
track_threshold=track_threshold,
|
|
243
|
+
track_buffer=track_buffer,
|
|
244
|
+
match_threshold=match_threshold)
|
|
245
|
+
code = dll.ailiaTrackerCreate(
|
|
246
|
+
ctypes.byref(self.__tracker),
|
|
247
|
+
ctypes.c_int(algorithm),
|
|
248
|
+
ctypes.byref(settings),
|
|
249
|
+
TrackerSettings.VERSION,
|
|
250
|
+
ctypes.c_int(flags))
|
|
251
|
+
self.__check(code, "ailiaTrackerCreate")
|
|
252
|
+
|
|
253
|
+
def __check(self, code, function_name):
|
|
254
|
+
if code != AILIA_STATUS_SUCCESS:
|
|
255
|
+
detail = "code : " + str(code)
|
|
256
|
+
if self.__tracker:
|
|
257
|
+
error_detail = dll.ailiaTrackerGetErrorDetail(self.__tracker)
|
|
258
|
+
if error_detail:
|
|
259
|
+
detail = error_detail.decode("utf-8") + " (" + detail + ")"
|
|
260
|
+
raise AiliaTrackerError(function_name + " failed : " + detail, code)
|
|
261
|
+
|
|
262
|
+
def add_target(self, category, prob, x, y, w, h):
|
|
263
|
+
""" set a tracking target detected in the current frame.
|
|
264
|
+
|
|
265
|
+
Parameters
|
|
266
|
+
----------
|
|
267
|
+
category : int
|
|
268
|
+
object category number.
|
|
269
|
+
prob : float
|
|
270
|
+
estimated probability (0 to 1).
|
|
271
|
+
x : float
|
|
272
|
+
x position at the top left (1 for the image width).
|
|
273
|
+
y : float
|
|
274
|
+
y position at the top left (1 for the image height).
|
|
275
|
+
w : float
|
|
276
|
+
width (1 for the width of the image).
|
|
277
|
+
h : float
|
|
278
|
+
height (1 for the height of the image).
|
|
279
|
+
"""
|
|
280
|
+
obj = DetectorObject(
|
|
281
|
+
category=category,
|
|
282
|
+
prob=prob,
|
|
283
|
+
x=x,
|
|
284
|
+
y=y,
|
|
285
|
+
w=w,
|
|
286
|
+
h=h)
|
|
287
|
+
code = dll.ailiaTrackerAddTarget(
|
|
288
|
+
self.__tracker,
|
|
289
|
+
ctypes.byref(obj),
|
|
290
|
+
DetectorObject.VERSION)
|
|
291
|
+
self.__check(code, "ailiaTrackerAddTarget")
|
|
292
|
+
|
|
293
|
+
def compute(self):
|
|
294
|
+
""" run tracking with the targets given by add_target().
|
|
295
|
+
|
|
296
|
+
Get the tracking result with get_objects() or get_object().
|
|
297
|
+
"""
|
|
298
|
+
code = dll.ailiaTrackerCompute(self.__tracker)
|
|
299
|
+
self.__check(code, "ailiaTrackerCompute")
|
|
300
|
+
|
|
301
|
+
def get_object_count(self):
|
|
302
|
+
""" get the number of tracked objects.
|
|
303
|
+
|
|
304
|
+
Returns
|
|
305
|
+
-------
|
|
306
|
+
int
|
|
307
|
+
number of tracked objects.
|
|
308
|
+
"""
|
|
309
|
+
count = ctypes.c_uint(0)
|
|
310
|
+
code = dll.ailiaTrackerGetObjectCount(self.__tracker, ctypes.byref(count))
|
|
311
|
+
self.__check(code, "ailiaTrackerGetObjectCount")
|
|
312
|
+
return count.value
|
|
313
|
+
|
|
314
|
+
def get_object(self, index):
|
|
315
|
+
""" get a tracked object specified by index.
|
|
316
|
+
|
|
317
|
+
Parameters
|
|
318
|
+
----------
|
|
319
|
+
index : int
|
|
320
|
+
object index.
|
|
321
|
+
valid values : range(0, get_object_count())
|
|
322
|
+
|
|
323
|
+
Returns
|
|
324
|
+
-------
|
|
325
|
+
TrackerObject
|
|
326
|
+
tracking result.
|
|
327
|
+
"""
|
|
328
|
+
obj = TrackerObject()
|
|
329
|
+
code = dll.ailiaTrackerGetObject(
|
|
330
|
+
self.__tracker,
|
|
331
|
+
ctypes.byref(obj),
|
|
332
|
+
ctypes.c_uint(index),
|
|
333
|
+
TrackerObject.VERSION)
|
|
334
|
+
self.__check(code, "ailiaTrackerGetObject")
|
|
335
|
+
return obj
|
|
336
|
+
|
|
337
|
+
def get_objects(self):
|
|
338
|
+
""" get all tracked objects.
|
|
339
|
+
|
|
340
|
+
Returns
|
|
341
|
+
-------
|
|
342
|
+
list of TrackerObject
|
|
343
|
+
tracking results.
|
|
344
|
+
"""
|
|
345
|
+
objects = []
|
|
346
|
+
for index in range(self.get_object_count()):
|
|
347
|
+
objects.append(self.get_object(index))
|
|
348
|
+
return objects
|
|
349
|
+
|
|
350
|
+
def release(self):
|
|
351
|
+
""" destroy the ailia tracker instance. """
|
|
352
|
+
if self.__tracker:
|
|
353
|
+
dll.ailiaTrackerDestroy(self.__tracker)
|
|
354
|
+
self.__tracker = ctypes.c_void_p(None)
|
|
355
|
+
|
|
356
|
+
def __del__(self):
|
|
357
|
+
self.release()
|
|
358
|
+
|
|
359
|
+
def __enter__(self):
|
|
360
|
+
return self
|
|
361
|
+
|
|
362
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
363
|
+
self.release()
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ailia_tracker
|
|
3
|
+
Version: 1.1.1
|
|
4
|
+
Summary: ailia Tracker
|
|
5
|
+
Home-page: https://ailia.jp/
|
|
6
|
+
Author: ax Inc.
|
|
7
|
+
Author-email: contact@axinc.jp
|
|
8
|
+
License: https://ailia.ai/en/license/
|
|
9
|
+
Requires-Python: >3.6
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Dynamic: author
|
|
12
|
+
Dynamic: author-email
|
|
13
|
+
Dynamic: description
|
|
14
|
+
Dynamic: description-content-type
|
|
15
|
+
Dynamic: home-page
|
|
16
|
+
Dynamic: license
|
|
17
|
+
Dynamic: requires-python
|
|
18
|
+
Dynamic: summary
|
|
19
|
+
|
|
20
|
+
# ailia Tracker Python API
|
|
21
|
+
|
|
22
|
+
!! CAUTION !!
|
|
23
|
+
“ailia” IS NOT OPEN SOURCE SOFTWARE (OSS).
|
|
24
|
+
As long as user complies with the conditions stated in [License Document](https://ailia.ai/license/), user may use the Software for free of charge, but the Software is basically paid software.
|
|
25
|
+
|
|
26
|
+
## About ailia Tracker
|
|
27
|
+
|
|
28
|
+
ailia Tracker is a library for tracking the movement of objects based on object detection results. It provides a C API for native applications and a C# API for Unity. By using ailia Tracker, you can easily implement object tracking in your application.
|
|
29
|
+
|
|
30
|
+
## Install from pip
|
|
31
|
+
|
|
32
|
+
You can install the ailia SDK free evaluation package with the following command.
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
pip3 install ailia_tracker
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Install from package
|
|
39
|
+
|
|
40
|
+
You can install the ailia SDK from Package with the following command.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
python3 bootstrap.py
|
|
44
|
+
pip3 install .
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import ailia_tracker
|
|
51
|
+
|
|
52
|
+
tracker = ailia_tracker.AiliaTracker()
|
|
53
|
+
|
|
54
|
+
for frame in frames:
|
|
55
|
+
for detection in detections(frame):
|
|
56
|
+
tracker.add_target(detection.category, detection.prob, detection.x, detection.y, detection.w, detection.h)
|
|
57
|
+
tracker.compute()
|
|
58
|
+
for obj in tracker.get_objects():
|
|
59
|
+
print(obj.id, obj.category, obj.prob, obj.x, obj.y, obj.w, obj.h)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The coordinates of `add_target` and the tracking results are normalized to the image size (1 for the image width / height).
|
|
63
|
+
|
|
64
|
+
## API specification
|
|
65
|
+
|
|
66
|
+
https://github.com/ailia-ai/ailia-sdk
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
ailia_tracker/__init__.py
|
|
4
|
+
ailia_tracker.egg-info/PKG-INFO
|
|
5
|
+
ailia_tracker.egg-info/SOURCES.txt
|
|
6
|
+
ailia_tracker.egg-info/dependency_links.txt
|
|
7
|
+
ailia_tracker.egg-info/top_level.txt
|
|
8
|
+
ailia_tracker/linux/arm64-v8a/libailia_tracker.so
|
|
9
|
+
ailia_tracker/linux/x64/libailia_tracker.so
|
|
10
|
+
ailia_tracker/mac/libailia_tracker.dylib
|
|
11
|
+
ailia_tracker/windows/arm64/ailia_tracker.dll
|
|
12
|
+
ailia_tracker/windows/x64/ailia_tracker.dll
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ailia_tracker
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import glob
|
|
2
|
+
|
|
3
|
+
from setuptools import setup
|
|
4
|
+
|
|
5
|
+
with open("README.md", encoding="utf-8") as f:
|
|
6
|
+
long_description = f.read()
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def find_libraries():
|
|
10
|
+
dll_names = []
|
|
11
|
+
platforms = ["win32", "win32_aarch64", "darwin", "linux_armv7l", "linux_aarch64", "linux_x86_64"]
|
|
12
|
+
|
|
13
|
+
for platform in platforms:
|
|
14
|
+
if platform == "win32":
|
|
15
|
+
dll_platform = "windows/x64"
|
|
16
|
+
dll_type = ".dll"
|
|
17
|
+
elif platform == "win32_aarch64":
|
|
18
|
+
dll_platform = "windows/arm64"
|
|
19
|
+
dll_type = ".dll"
|
|
20
|
+
elif platform == "darwin":
|
|
21
|
+
dll_platform = "mac"
|
|
22
|
+
dll_type = ".dylib"
|
|
23
|
+
else:
|
|
24
|
+
if platform == "linux_armv7l":
|
|
25
|
+
dll_platform = "linux/armeabi-v7a"
|
|
26
|
+
elif platform == "linux_aarch64":
|
|
27
|
+
dll_platform = "linux/arm64-v8a"
|
|
28
|
+
else:
|
|
29
|
+
dll_platform = "linux/x64"
|
|
30
|
+
dll_type = ".so"
|
|
31
|
+
|
|
32
|
+
dll_path = "./ailia_tracker/" + dll_platform + "/"
|
|
33
|
+
|
|
34
|
+
for f in glob.glob(dll_path + "*" + dll_type):
|
|
35
|
+
f = f.replace("\\", "/")
|
|
36
|
+
f = f.replace("./ailia_tracker/", "./")
|
|
37
|
+
dll_names.append(f)
|
|
38
|
+
|
|
39
|
+
return dll_names
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if __name__ == "__main__":
|
|
43
|
+
setup(
|
|
44
|
+
name="ailia_tracker",
|
|
45
|
+
version="1.1.1",
|
|
46
|
+
description="ailia Tracker",
|
|
47
|
+
long_description=long_description,
|
|
48
|
+
long_description_content_type="text/markdown",
|
|
49
|
+
author="ax Inc.",
|
|
50
|
+
author_email="contact@axinc.jp",
|
|
51
|
+
url="https://ailia.jp/",
|
|
52
|
+
license="https://ailia.ai/en/license/",
|
|
53
|
+
packages=["ailia_tracker"],
|
|
54
|
+
package_data={"ailia_tracker": find_libraries()},
|
|
55
|
+
include_package_data=True,
|
|
56
|
+
python_requires=">3.6",
|
|
57
|
+
)
|