pixelflow 0.6.0__tar.gz → 0.8.0__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.
Files changed (100) hide show
  1. pixelflow-0.8.0/LICENSE +201 -0
  2. pixelflow-0.8.0/NOTICE +7 -0
  3. {pixelflow-0.6.0 → pixelflow-0.8.0}/PKG-INFO +17 -11
  4. {pixelflow-0.6.0 → pixelflow-0.8.0}/README.md +13 -8
  5. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/__init__.py +1 -1
  6. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/crossing.py +1 -1
  7. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/mask.py +52 -41
  8. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/buffer.py +91 -131
  9. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/classifications/classifications.py +76 -0
  10. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/colors.py +14 -0
  11. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/crossings.py +85 -140
  12. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/detections/__init__.py +0 -2
  13. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/detections/converters.py +26 -160
  14. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/detections/detections.py +198 -4
  15. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/detections/filters.py +8 -14
  16. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/masks.py +35 -0
  17. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/media.py +126 -11
  18. pixelflow-0.8.0/pixelflow/serialization.py +72 -0
  19. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/slicer.py +63 -53
  20. pixelflow-0.8.0/pixelflow/smoother.py +190 -0
  21. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/strategies.py +13 -0
  22. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/timer.py +23 -65
  23. pixelflow-0.8.0/pixelflow/tracker/UPSTREAM.md +74 -0
  24. pixelflow-0.8.0/pixelflow/tracker/__init__.py +45 -0
  25. pixelflow-0.8.0/pixelflow/tracker/base.py +387 -0
  26. pixelflow-0.8.0/pixelflow/tracker/botsort/__init__.py +0 -0
  27. pixelflow-0.8.0/pixelflow/tracker/botsort/tracker.py +587 -0
  28. pixelflow-0.8.0/pixelflow/tracker/botsort/tracklet.py +95 -0
  29. pixelflow-0.8.0/pixelflow/tracker/botsort/utils.py +82 -0
  30. pixelflow-0.8.0/pixelflow/tracker/bytetrack/__init__.py +0 -0
  31. pixelflow-0.8.0/pixelflow/tracker/bytetrack/tracker.py +287 -0
  32. pixelflow-0.8.0/pixelflow/tracker/bytetrack/tracklet.py +70 -0
  33. pixelflow-0.8.0/pixelflow/tracker/bytetrack/utils.py +65 -0
  34. pixelflow-0.8.0/pixelflow/tracker/cbiou/__init__.py +0 -0
  35. pixelflow-0.8.0/pixelflow/tracker/cbiou/tracker.py +365 -0
  36. pixelflow-0.8.0/pixelflow/tracker/ocsort/__init__.py +0 -0
  37. pixelflow-0.8.0/pixelflow/tracker/ocsort/tracker.py +464 -0
  38. pixelflow-0.8.0/pixelflow/tracker/ocsort/tracklet.py +582 -0
  39. pixelflow-0.8.0/pixelflow/tracker/ocsort/utils.py +103 -0
  40. pixelflow-0.8.0/pixelflow/tracker/sort/__init__.py +0 -0
  41. pixelflow-0.8.0/pixelflow/tracker/sort/tracker.py +236 -0
  42. pixelflow-0.8.0/pixelflow/tracker/sort/tracklet.py +81 -0
  43. pixelflow-0.8.0/pixelflow/tracker/sort/utils.py +56 -0
  44. pixelflow-0.8.0/pixelflow/tracker/utils/__init__.py +0 -0
  45. pixelflow-0.8.0/pixelflow/tracker/utils/base_tracklet.py +107 -0
  46. pixelflow-0.8.0/pixelflow/tracker/utils/cmc.py +876 -0
  47. pixelflow-0.8.0/pixelflow/tracker/utils/converters.py +199 -0
  48. pixelflow-0.8.0/pixelflow/tracker/utils/iou.py +512 -0
  49. pixelflow-0.8.0/pixelflow/tracker/utils/kalman_filter.py +169 -0
  50. pixelflow-0.8.0/pixelflow/tracker/utils/matrix.py +30 -0
  51. pixelflow-0.8.0/pixelflow/tracker/utils/motion_models.py +382 -0
  52. pixelflow-0.8.0/pixelflow/tracker/utils/predict_timing.py +67 -0
  53. pixelflow-0.8.0/pixelflow/tracker/utils/scale_aware_tracklet.py +194 -0
  54. pixelflow-0.8.0/pixelflow/tracker/utils/state_representations.py +370 -0
  55. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/transforms/__init__.py +6 -8
  56. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/transforms/detections.py +160 -241
  57. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/transforms/image.py +58 -49
  58. pixelflow-0.8.0/pixelflow/transforms/inverse.py +232 -0
  59. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/zones.py +2 -8
  60. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow.egg-info/PKG-INFO +17 -11
  61. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow.egg-info/SOURCES.txt +33 -4
  62. {pixelflow-0.6.0 → pixelflow-0.8.0}/pyproject.toml +6 -2
  63. pixelflow-0.6.0/LICENSE +0 -21
  64. pixelflow-0.6.0/pixelflow/smoother.py +0 -671
  65. pixelflow-0.6.0/pixelflow/tracker/__init__.py +0 -19
  66. pixelflow-0.6.0/pixelflow/tracker/bytetrack.py +0 -837
  67. pixelflow-0.6.0/pixelflow/tracker/kalman_filter.py +0 -182
  68. pixelflow-0.6.0/pixelflow/tracker/matching.py +0 -178
  69. pixelflow-0.6.0/pixelflow/tracker/track.py +0 -239
  70. pixelflow-0.6.0/pixelflow/transforms/inverse.py +0 -355
  71. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/__init__.py +0 -0
  72. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/anchors.py +0 -0
  73. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/blur.py +0 -0
  74. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/box.py +0 -0
  75. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/classification.py +0 -0
  76. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/dot.py +0 -0
  77. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/filled_box.py +0 -0
  78. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/fps_counter.py +0 -0
  79. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/grid_overlay.py +0 -0
  80. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/heatmap.py +0 -0
  81. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/keypoint.py +0 -0
  82. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/keypoint_skeleton.py +0 -0
  83. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/label.py +0 -0
  84. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/motion_dots.py +0 -0
  85. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/motion_trails.py +0 -0
  86. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/oval.py +0 -0
  87. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/pixelate.py +0 -0
  88. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/polygon.py +0 -0
  89. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/scale_bar.py +0 -0
  90. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/utils.py +0 -0
  91. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/annotators/zones.py +0 -0
  92. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/arrays.py +0 -0
  93. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/classifications/__init__.py +0 -0
  94. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/classifications/converters.py +0 -0
  95. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/labels.py +0 -0
  96. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow/validators.py +0 -0
  97. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow.egg-info/dependency_links.txt +0 -0
  98. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow.egg-info/requires.txt +0 -0
  99. {pixelflow-0.6.0 → pixelflow-0.8.0}/pixelflow.egg-info/top_level.txt +0 -0
  100. {pixelflow-0.6.0 → pixelflow-0.8.0}/setup.cfg +0 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
pixelflow-0.8.0/NOTICE ADDED
@@ -0,0 +1,7 @@
1
+ PixelFlow
2
+ Copyright 2025-2026 Emrah Nazif
3
+
4
+ This product includes software developed by Roboflow:
5
+ roboflow/trackers (https://github.com/roboflow/trackers), Copyright (c) 2026 Roboflow,
6
+ licensed under the Apache License, Version 2.0. The ByteTrack and SORT trackers in
7
+ pixelflow/tracker/ are ported from it and modified; see pixelflow/tracker/UPSTREAM.md.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pixelflow
3
- Version: 0.6.0
3
+ Version: 0.8.0
4
4
  Summary: Computer vision processing library for visualizing and analyzing detection results from ML models
5
5
  Author-email: Emrah Nazif <emrah@datamarkin.com>
6
- License: MIT
6
+ License: Apache-2.0
7
7
  Project-URL: Homepage, https://github.com/emrahnazif/pixelflow
8
8
  Project-URL: Repository, https://github.com/emrahnazif/pixelflow
9
9
  Project-URL: Issues, https://github.com/emrahnazif/pixelflow/issues
@@ -12,7 +12,7 @@ Keywords: computer-vision,visualization,annotation,post-processing,tracking,open
12
12
  Classifier: Development Status :: 3 - Alpha
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: Intended Audience :: Science/Research
15
- Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
16
  Classifier: Operating System :: OS Independent
17
17
  Classifier: Programming Language :: Python :: 3
18
18
  Classifier: Programming Language :: Python :: 3.10
@@ -24,6 +24,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
24
  Requires-Python: >=3.10
25
25
  Description-Content-Type: text/markdown
26
26
  License-File: LICENSE
27
+ License-File: NOTICE
27
28
  Requires-Dist: shapely>=2.0.0
28
29
  Requires-Dist: numpy>=1.21.0
29
30
  Requires-Dist: opencv-python>=4.8.0
@@ -40,7 +41,7 @@ Dynamic: license-file
40
41
  [![PyPI version](https://badge.fury.io/py/pixelflow.svg)](https://badge.fury.io/py/pixelflow)
41
42
  [![CI](https://github.com/emrahnazif/pixelflow/actions/workflows/ci.yml/badge.svg)](https://github.com/emrahnazif/pixelflow/actions/workflows/ci.yml)
42
43
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
43
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
44
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
44
45
 
45
46
  **The computer vision library that gets out of your way.**
46
47
 
@@ -52,7 +53,7 @@ from ultralytics import YOLO
52
53
 
53
54
  model = YOLO("yolo11n.pt")
54
55
  video = pf.VideoReader("traffic.mp4")
55
- tracker = pf.tracker.ByteTracker()
56
+ tracker = pf.tracker.ByteTrack()
56
57
  zones = pf.Zones()
57
58
  zones.add_zone([(100, 400), (500, 400), (500, 600), (100, 600)], zone_id="entrance")
58
59
 
@@ -100,7 +101,7 @@ from detectron2.engine import DefaultPredictor
100
101
  predictor = DefaultPredictor(cfg)
101
102
  detections = pf.from_detectron2(predictor(image), labels=["person", "car"])
102
103
 
103
- # Mayaku (returns Instances directly; take labels from the checkpoint)
104
+ # Mayaku (take labels from the checkpoint)
104
105
  from mayaku import from_pretrained
105
106
  predictor = from_pretrained("mayaku-n-det")
106
107
  detections = pf.from_mayaku(predictor("photo.jpg"), labels=predictor.class_names)
@@ -156,7 +157,7 @@ result = pf.from_ultralytics_classification(model.predict("dog.jpg"))
156
157
 
157
158
  result.top1.class_name # 'golden retriever'
158
159
  result.top_k(5) # -> Classifications, best first
159
- result.to_json()
160
+ result.to_json() # pf.Classifications.from_json() reads it back
160
161
 
161
162
  # Plain scores - CLIP zero-shot, a vendored ResNet, anything with a score vector
162
163
  prompts = ["a photo of a cat", "a photo of a dog"]
@@ -313,12 +314,13 @@ not_restricted = zones.filter_by_zones(detections, ["restricted"], exclude=True)
313
314
 
314
315
  ### Object Tracking
315
316
 
316
- Built-in ByteTrack for multi-object tracking:
317
+ Five multi-object trackers, ported from [roboflow/trackers](https://github.com/roboflow/trackers):
318
+ `ByteTrack`, `SORT`, `OCSORT`, `BoTSORT` (camera motion compensation) and `CBIoU`.
317
319
 
318
320
  ```python
319
321
  import pixelflow as pf
320
322
 
321
- tracker = pf.tracker.ByteTracker()
323
+ tracker = pf.tracker.ByteTrack()
322
324
 
323
325
  for frame in video:
324
326
  detections = pf.from_ultralytics(model.predict(frame))
@@ -445,6 +447,10 @@ df = pd.DataFrame(data)
445
447
 
446
448
  # With metrics
447
449
  report = detections.to_json_with_metrics()
450
+
451
+ # And back - masks decoded, keypoints rebuilt, every field restored
452
+ detections = pf.Detections.from_json(json_str)
453
+ detections = pf.Detections.from_dict(data)
448
454
  ```
449
455
 
450
456
  ## Supported Frameworks
@@ -463,7 +469,6 @@ report = detections.to_json_with_metrics()
463
469
  | Supervision | `from_supervision()` | Boxes, masks, keypoints |
464
470
  | Falcon Perception | `from_falcon_perception()` | Boxes, masks |
465
471
  | EasyOCR | `from_easyocr()` | Quads, text, scores |
466
- | Datamarkin API | `from_datamarkin()` | Boxes, masks, keypoints |
467
472
 
468
473
  ## Documentation
469
474
 
@@ -475,7 +480,8 @@ Contributions welcome! Please read our contributing guidelines.
475
480
 
476
481
  ## License
477
482
 
478
- MIT License - see LICENSE file for details.
483
+ Apache License 2.0 - see [LICENSE](LICENSE) and [NOTICE](NOTICE). Releases up to 0.7.0 were
484
+ published under the MIT License.
479
485
 
480
486
  ---
481
487
 
@@ -3,7 +3,7 @@
3
3
  [![PyPI version](https://badge.fury.io/py/pixelflow.svg)](https://badge.fury.io/py/pixelflow)
4
4
  [![CI](https://github.com/emrahnazif/pixelflow/actions/workflows/ci.yml/badge.svg)](https://github.com/emrahnazif/pixelflow/actions/workflows/ci.yml)
5
5
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
7
7
 
8
8
  **The computer vision library that gets out of your way.**
9
9
 
@@ -15,7 +15,7 @@ from ultralytics import YOLO
15
15
 
16
16
  model = YOLO("yolo11n.pt")
17
17
  video = pf.VideoReader("traffic.mp4")
18
- tracker = pf.tracker.ByteTracker()
18
+ tracker = pf.tracker.ByteTrack()
19
19
  zones = pf.Zones()
20
20
  zones.add_zone([(100, 400), (500, 400), (500, 600), (100, 600)], zone_id="entrance")
21
21
 
@@ -63,7 +63,7 @@ from detectron2.engine import DefaultPredictor
63
63
  predictor = DefaultPredictor(cfg)
64
64
  detections = pf.from_detectron2(predictor(image), labels=["person", "car"])
65
65
 
66
- # Mayaku (returns Instances directly; take labels from the checkpoint)
66
+ # Mayaku (take labels from the checkpoint)
67
67
  from mayaku import from_pretrained
68
68
  predictor = from_pretrained("mayaku-n-det")
69
69
  detections = pf.from_mayaku(predictor("photo.jpg"), labels=predictor.class_names)
@@ -119,7 +119,7 @@ result = pf.from_ultralytics_classification(model.predict("dog.jpg"))
119
119
 
120
120
  result.top1.class_name # 'golden retriever'
121
121
  result.top_k(5) # -> Classifications, best first
122
- result.to_json()
122
+ result.to_json() # pf.Classifications.from_json() reads it back
123
123
 
124
124
  # Plain scores - CLIP zero-shot, a vendored ResNet, anything with a score vector
125
125
  prompts = ["a photo of a cat", "a photo of a dog"]
@@ -276,12 +276,13 @@ not_restricted = zones.filter_by_zones(detections, ["restricted"], exclude=True)
276
276
 
277
277
  ### Object Tracking
278
278
 
279
- Built-in ByteTrack for multi-object tracking:
279
+ Five multi-object trackers, ported from [roboflow/trackers](https://github.com/roboflow/trackers):
280
+ `ByteTrack`, `SORT`, `OCSORT`, `BoTSORT` (camera motion compensation) and `CBIoU`.
280
281
 
281
282
  ```python
282
283
  import pixelflow as pf
283
284
 
284
- tracker = pf.tracker.ByteTracker()
285
+ tracker = pf.tracker.ByteTrack()
285
286
 
286
287
  for frame in video:
287
288
  detections = pf.from_ultralytics(model.predict(frame))
@@ -408,6 +409,10 @@ df = pd.DataFrame(data)
408
409
 
409
410
  # With metrics
410
411
  report = detections.to_json_with_metrics()
412
+
413
+ # And back - masks decoded, keypoints rebuilt, every field restored
414
+ detections = pf.Detections.from_json(json_str)
415
+ detections = pf.Detections.from_dict(data)
411
416
  ```
412
417
 
413
418
  ## Supported Frameworks
@@ -426,7 +431,6 @@ report = detections.to_json_with_metrics()
426
431
  | Supervision | `from_supervision()` | Boxes, masks, keypoints |
427
432
  | Falcon Perception | `from_falcon_perception()` | Boxes, masks |
428
433
  | EasyOCR | `from_easyocr()` | Quads, text, scores |
429
- | Datamarkin API | `from_datamarkin()` | Boxes, masks, keypoints |
430
434
 
431
435
  ## Documentation
432
436
 
@@ -438,7 +442,8 @@ Contributions welcome! Please read our contributing guidelines.
438
442
 
439
443
  ## License
440
444
 
441
- MIT License - see LICENSE file for details.
445
+ Apache License 2.0 - see [LICENSE](LICENSE) and [NOTICE](NOTICE). Releases up to 0.7.0 were
446
+ published under the MIT License.
442
447
 
443
448
  ---
444
449
 
@@ -1,4 +1,4 @@
1
- __version__ = "0.6.0"
1
+ __version__ = "0.8.0"
2
2
  __author__ = "Emrah NAZIF"
3
3
 
4
4
  # Import core modules
@@ -249,7 +249,7 @@ def crossings(image: np.ndarray, crossings_manager) -> np.ndarray:
249
249
  >>> annotated = pf.annotate.crossings(image, crossings_manager)
250
250
  >>>
251
251
  >>> # Alternative workflow with tracking integration
252
- >>> tracker = pf.tracker.ByteTracker()
252
+ >>> tracker = pf.tracker.ByteTrack()
253
253
  >>> for frame in frames:
254
254
  ... outputs = yolo_model.predict(frame)
255
255
  ... results = pf.from_ultralytics(outputs)
@@ -71,63 +71,74 @@ def mask(
71
71
  - Supports both binary mask arrays (boolean or uint8) and polygon coordinate lists
72
72
  - Binary masks must match frame dimensions exactly
73
73
  - Polygon coordinates are automatically converted to binary masks using cv2.fillPoly
74
- - Uses single-pass rendering for optimal performance with multiple masks
75
- - OpenCV's addWeighted function provides hardware-accelerated blending
74
+ - Where masks overlap, the later detection's colour is drawn; each pixel is
75
+ blended once
76
76
  - Empty or None mask data is automatically skipped
77
-
77
+
78
78
  Performance Notes:
79
- - Single overlay creation minimizes memory allocation
80
- - Batch blending operation reduces computational overhead
79
+ - Drawing and blending run inside each mask's bounding rectangle, so the cost
80
+ follows the area the masks cover, not the frame size times the mask count
81
81
  - Direct pixel assignment used for full opacity (opacity=1.0) to bypass blending
82
- - Polygon-to-mask conversion cached within the function scope
83
82
  """
84
- # Create a single overlay for all masks
83
+ # Every step works inside each mask's bounding rectangle, not the whole frame: an
84
+ # object usually covers a small part of the frame, and full-frame boolean indexing
85
+ # per mask was the cost (about 7 ms per mask at 1080p).
86
+ height, width = frame.shape[:2]
85
87
  overlay = np.zeros_like(frame, dtype=np.uint8)
86
- has_mask = np.zeros(frame.shape[:2], dtype=bool)
87
-
88
- # Draw all masks to the overlay in a single pass
88
+ has_mask = np.zeros((height, width), dtype=bool)
89
+ rects = [] # (y0, y1, x0, x1) of each drawn mask
90
+
91
+ # Draw all masks to the overlay; where masks overlap, the later one's colour wins
89
92
  for result in detections:
90
93
  if result.masks is None:
91
94
  continue
92
-
95
+
93
96
  color = _get_color_for_prediction(result, colors)
94
-
97
+
95
98
  for mask_data in result.masks:
96
- binary_mask = None
97
-
99
+ local = None # the mask inside its rectangle
100
+
98
101
  if isinstance(mask_data, np.ndarray):
99
102
  # Binary mask format
100
- if mask_data.dtype == bool:
101
- if mask_data.shape[:2] != frame.shape[:2]:
102
- raise ValueError(f"Mask dimensions {mask_data.shape[:2]} do not match frame dimensions {frame.shape[:2]}.")
103
- binary_mask = mask_data
104
- else:
105
- binary_mask = mask_data.astype(bool)
106
- if binary_mask.shape[:2] != frame.shape[:2]:
107
- raise ValueError(f"Mask dimensions {binary_mask.shape[:2]} do not match frame dimensions {frame.shape[:2]}.")
108
-
103
+ if mask_data.shape[:2] != (height, width):
104
+ raise ValueError(f"Mask dimensions {mask_data.shape[:2]} do not match frame dimensions {frame.shape[:2]}.")
105
+ binary_mask = mask_data if mask_data.dtype == bool else mask_data.astype(bool)
106
+ x, y, w, h = cv2.boundingRect(np.ascontiguousarray(binary_mask).view(np.uint8))
107
+ if w and h:
108
+ local = binary_mask[y:y + h, x:x + w]
109
+
109
110
  elif isinstance(mask_data, list) and len(mask_data) > 0:
110
- # Polygon format - convert to binary mask
111
- mask_img = np.zeros(frame.shape[:2], dtype=np.uint8)
111
+ # Polygon format - rasterise into a canvas the size of its rectangle
112
112
  points = np.array(mask_data, dtype=np.int32)
113
113
  if len(points.shape) == 2 and points.shape[1] == 2:
114
- points = points.reshape((-1, 1, 2))
115
- cv2.fillPoly(mask_img, [points], 1)
116
- binary_mask = mask_img.astype(bool)
117
-
118
- if binary_mask is not None:
119
- # Draw mask to overlay and track which pixels have masks
120
- overlay[binary_mask] = color
121
- has_mask |= binary_mask
122
-
123
- # Single blend operation for all masks
124
- if has_mask.any(): # Only blend if there are masks
114
+ x = int(np.clip(points[:, 0].min(), 0, width))
115
+ y = int(np.clip(points[:, 1].min(), 0, height))
116
+ w = int(np.clip(points[:, 0].max() + 1, 0, width)) - x
117
+ h = int(np.clip(points[:, 1].max() + 1, 0, height)) - y
118
+ if w > 0 and h > 0:
119
+ canvas = np.zeros((h, w), dtype=np.uint8)
120
+ cv2.fillPoly(canvas, [(points - (x, y)).reshape((-1, 1, 2))], 1)
121
+ local = canvas.astype(bool)
122
+
123
+ if local is not None:
124
+ overlay[y:y + h, x:x + w][local] = color
125
+ has_mask[y:y + h, x:x + w] |= local
126
+ rects.append((y, y + h, x, x + w))
127
+
128
+ # Blend rectangle by rectangle. Clearing has_mask after each one keeps a pixel
129
+ # shared by overlapping rectangles from being blended twice, so every masked pixel
130
+ # is blended once, from the original frame and the final overlay.
131
+ for y0, y1, x0, x1 in rects:
132
+ region = frame[y0:y1, x0:x1]
133
+ hit = has_mask[y0:y1, x0:x1]
134
+ if not hit.any():
135
+ continue
125
136
  if opacity >= 1.0:
126
137
  # Direct copy for full opacity
127
- frame[has_mask] = overlay[has_mask]
138
+ region[hit] = overlay[y0:y1, x0:x1][hit]
128
139
  else:
129
- # Use OpenCV's optimized blending for partial opacity
130
- blended = cv2.addWeighted(frame, 1 - opacity, overlay, opacity, 0)
131
- frame[has_mask] = blended[has_mask]
132
-
140
+ blended = cv2.addWeighted(region, 1 - opacity, overlay[y0:y1, x0:x1], opacity, 0)
141
+ region[hit] = blended[hit]
142
+ hit[:] = False
143
+
133
144
  return frame