Commit 3beea87
Port Python sleap-io PRs #366-373: BoundingBox, GeoJSON, ROI enhancements, bug fixes (#74)
* Add GeoJSON I/O, new geometry types, ROI instance serialization (format 1.6)
Port Python PRs #366, #367, #371:
- Extend Geometry union with LineString, MultiPoint, GeometryCollection
- Add WKB encode/decode for all new geometry types
- Add fromMultiPolygon() static factory and explode() instance method
- Add toGeoJSON() method on ROI for Feature serialization
- Create src/io/geojson.ts with roisToGeoJSON, roisFromGeoJSON, writeGeoJSON, readGeoJSON
- Add ROI instance column to SLP format (v1.6) for read/write
- Add _instanceIdx deferred resolution in Labels.materialize()
- Update bounds, area, _allPoints, rasterizeGeometry for new geometry types
- Export geojson module from both Node and browser entry points
- Add comprehensive tests for all new functionality (43 tests in roi.test.ts, 5 in geojson.test.ts)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix numpy output truncation and negative frame handling in lazy/dict codecs
Port two Python bug fixes:
- PR #368: numpy() output was truncated at last labeled frame instead of
spanning the full video length. Fixed in both Labels.numpy() and
LazyDataStore.toNumpy() by checking video.shape[0].
- PR #369: negative frames were silently dropped in lazy loading and
dictionary codec. Fixed by reading /negative_frames in readSlpLazy(),
passing them through LazyDataStore, preserving them in dictionary
toDict/fromDict round-trips, and keeping negative frames when
skipEmptyFrames is enabled.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add first-class BoundingBox type with full SLP I/O support
Port of Python PR #373. Introduces UserBoundingBox and PredictedBoundingBox
model classes, simplifies ROI/SegmentationMask by removing annotationType and
score fields, adds bboxes field to Labels with getBboxes() query method,
implements SLP read/write for bboxes (format v1.7), and migrates old
bbox-type ROIs to BoundingBox objects on read.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix review issues: xywh consistency, geojson test nesting, separator alignment
- BoundingBox.xywh now returns AABB dimensions for rotated bboxes
- Fix fromPolygon call in geojson test (wrong coordinate nesting)
- Align negative frame key separator to use ':' consistently
- Remove redundant type assertion in Labels.getBboxes()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Address code review: clean up redundant code, add type safety, add ROI instance test
- Remove unnecessary intermediate variable in readSlpLazy destructuring
- Add @internal annotation to BoundingBox._instanceIdx for consistency with ROI
- Add explicit SegmentationMask return type to BoundingBox.toMask()
- Use String() coercion instead of unsafe `as string` casts in GeoJSON parser
- Extract readRoisAndBboxes() helper to deduplicate eager/lazy read paths
- Add ROI instance association (format 1.6) round-trip tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Update docs for BoundingBox, GeoJSON I/O, and format 1.6/1.7
- docs/api.md: Add BoundingBox/GeoJSON sections, remove stale
annotationType/score references, document new ROI methods
- docs/usage.md: Update ROI section with bbox and GeoJSON examples
- docs/index.md: Update format version range to 1.0-1.7
- README.md: Add bbox/GeoJSON to feature list
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 22a5399 commit 3beea87
File tree
23 files changed
+1537
-173
lines changed- docs
- src
- codecs
- slp
- io
- model
- tests
- codecs
23 files changed
+1537
-173
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| |||
142 | 148 | | |
143 | 149 | | |
144 | 150 | | |
145 | | - | |
| 151 | + | |
| 152 | + | |
146 | 153 | | |
147 | 154 | | |
148 | 155 | | |
| |||
179 | 186 | | |
180 | 187 | | |
181 | 188 | | |
182 | | - | |
| 189 | + | |
183 | 190 | | |
184 | 191 | | |
185 | | - | |
| 192 | + | |
186 | 193 | | |
187 | 194 | | |
188 | 195 | | |
189 | 196 | | |
190 | 197 | | |
191 | | - | |
192 | 198 | | |
193 | 199 | | |
194 | 200 | | |
| |||
197 | 203 | | |
198 | 204 | | |
199 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
200 | 212 | | |
201 | 213 | | |
202 | 214 | | |
203 | 215 | | |
204 | 216 | | |
205 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
206 | 224 | | |
207 | 225 | | |
208 | 226 | | |
| |||
225 | 243 | | |
226 | 244 | | |
227 | 245 | | |
228 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
229 | 283 | | |
230 | 284 | | |
231 | 285 | | |
232 | | - | |
233 | | - | |
234 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
235 | 290 | | |
| 291 | + | |
| 292 | + | |
236 | 293 | | |
237 | 294 | | |
238 | 295 | | |
239 | | - | |
| 296 | + | |
| 297 | + | |
240 | 298 | | |
241 | 299 | | |
242 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
243 | 317 | | |
244 | 318 | | |
245 | 319 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
| 27 | + | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
| 304 | + | |
305 | 305 | | |
306 | | - | |
| 306 | + | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
310 | 314 | | |
311 | 315 | | |
312 | 316 | | |
313 | | - | |
314 | | - | |
| 317 | + | |
| 318 | + | |
315 | 319 | | |
316 | 320 | | |
317 | 321 | | |
318 | 322 | | |
| 323 | + | |
319 | 324 | | |
320 | 325 | | |
321 | | - | |
| 326 | + | |
322 | 327 | | |
323 | 328 | | |
324 | 329 | | |
325 | | - | |
| 330 | + | |
326 | 331 | | |
327 | | - | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
328 | 344 | | |
329 | 345 | | |
330 | 346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | | - | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| |||
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
124 | | - | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
| |||
0 commit comments