OpenScrub 1.0.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.
@@ -0,0 +1,607 @@
1
+ Metadata-Version: 2.4
2
+ Name: OpenScrub
3
+ Version: 1.0.0
4
+ Summary: Local, GPU-accelerated redaction for video and screen recordings — blur, black-box, or mosaic faces, names, and any regex-matchable PII, with human review.
5
+ Project-URL: Homepage, https://github.com/austinmabry/OpenScrub
6
+ Project-URL: Repository, https://github.com/austinmabry/OpenScrub
7
+ Project-URL: Issues, https://github.com/austinmabry/OpenScrub/issues
8
+ Author: Austin Mabry
9
+ License: Apache License
10
+ Version 2.0, January 2004
11
+ http://www.apache.org/licenses/
12
+
13
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
14
+
15
+ 1. Definitions.
16
+
17
+ "License" shall mean the terms and conditions for use, reproduction,
18
+ and distribution as defined by Sections 1 through 9 of this document.
19
+
20
+ "Licensor" shall mean the copyright owner or entity authorized by
21
+ the copyright owner that is granting the License.
22
+
23
+ "Legal Entity" shall mean the union of the acting entity and all
24
+ other entities that control, are controlled by, or are under common
25
+ control with that entity. For the purposes of this definition,
26
+ "control" means (i) the power, direct or indirect, to cause the
27
+ direction or management of such entity, whether by contract or
28
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
29
+ outstanding shares, or (iii) beneficial ownership of such entity.
30
+
31
+ "You" (or "Your") shall mean an individual or Legal Entity
32
+ exercising permissions granted by this License.
33
+
34
+ "Source" form shall mean the preferred form for making modifications,
35
+ including but not limited to software source code, documentation
36
+ source, and configuration files.
37
+
38
+ "Object" form shall mean any form resulting from mechanical
39
+ transformation or translation of a Source form, including but
40
+ not limited to compiled object code, generated documentation,
41
+ and conversions to other media types.
42
+
43
+ "Work" shall mean the work of authorship, whether in Source or
44
+ Object form, made available under the License, as indicated by a
45
+ copyright notice that is included in or attached to the work
46
+ (an example is provided in the Appendix below).
47
+
48
+ "Derivative Works" shall mean any work, whether in Source or Object
49
+ form, that is based on (or derived from) the Work and for which the
50
+ editorial revisions, annotations, elaborations, or other modifications
51
+ represent, as a whole, an original work of authorship. For the purposes
52
+ of this License, Derivative Works shall not include works that remain
53
+ separable from, or merely link (or bind by name) to the interfaces of,
54
+ the Work and Derivative Works thereof.
55
+
56
+ "Contribution" shall mean any work of authorship, including
57
+ the original version of the Work and any modifications or additions
58
+ to that Work or Derivative Works thereof, that is intentionally
59
+ submitted to Licensor for inclusion in the Work by the copyright owner
60
+ or by an individual or Legal Entity authorized to submit on behalf of
61
+ the copyright owner. For the purposes of this definition, "submitted"
62
+ means any form of electronic, verbal, or written communication sent
63
+ to the Licensor or its representatives, including but not limited to
64
+ communication on electronic mailing lists, source code control systems,
65
+ and issue tracking systems that are managed by, or on behalf of, the
66
+ Licensor for the purpose of discussing and improving the Work, but
67
+ excluding communication that is conspicuously marked or otherwise
68
+ designated in writing by the copyright owner as "Not a Contribution."
69
+
70
+ "Contributor" shall mean Licensor and any individual or Legal Entity
71
+ on behalf of whom a Contribution has been received by Licensor and
72
+ subsequently incorporated within the Work.
73
+
74
+ 2. Grant of Copyright License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ copyright license to reproduce, prepare Derivative Works of,
78
+ publicly display, publicly perform, sublicense, and distribute the
79
+ Work and such Derivative Works in Source or Object form.
80
+
81
+ 3. Grant of Patent License. Subject to the terms and conditions of
82
+ this License, each Contributor hereby grants to You a perpetual,
83
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
84
+ (except as stated in this section) patent license to make, have made,
85
+ use, offer to sell, sell, import, and otherwise transfer the Work,
86
+ where such license applies only to those patent claims licensable
87
+ by such Contributor that are necessarily infringed by their
88
+ Contribution(s) alone or by combination of their Contribution(s)
89
+ with the Work to which such Contribution(s) was submitted. If You
90
+ institute patent litigation against any entity (including a
91
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
92
+ or a Contribution incorporated within the Work constitutes direct
93
+ or contributory patent infringement, then any patent licenses
94
+ granted to You under this License for that Work shall terminate
95
+ as of the date such litigation is filed.
96
+
97
+ 4. Redistribution. You may reproduce and distribute copies of the
98
+ Work or Derivative Works thereof in any medium, with or without
99
+ modifications, and in Source or Object form, provided that You
100
+ meet the following conditions:
101
+
102
+ (a) You must give any other recipients of the Work or
103
+ Derivative Works a copy of this License; and
104
+
105
+ (b) You must cause any modified files to carry prominent notices
106
+ stating that You changed the files; and
107
+
108
+ (c) You must retain, in the Source form of any Derivative Works
109
+ that You distribute, all copyright, patent, trademark, and
110
+ attribution notices from the Source form of the Work,
111
+ excluding those notices that do not pertain to any part of
112
+ the Derivative Works; and
113
+
114
+ (d) If the Work includes a "NOTICE" text file as part of its
115
+ distribution, then any Derivative Works that You distribute must
116
+ include a readable copy of the attribution notices contained
117
+ within such NOTICE file, excluding those notices that do not
118
+ pertain to any part of the Derivative Works, in at least one
119
+ of the following places: within a NOTICE text file distributed
120
+ as part of the Derivative Works; within the Source form or
121
+ documentation, if provided along with the Derivative Works; or,
122
+ within a display generated by the Derivative Works, if and
123
+ wherever such third-party notices normally appear. The contents
124
+ of the NOTICE file are for informational purposes only and
125
+ do not modify the License. You may add Your own attribution
126
+ notices within Derivative Works that You distribute, alongside
127
+ or as an addendum to the NOTICE text from the Work, provided
128
+ that such additional attribution notices cannot be construed
129
+ as modifying the License.
130
+
131
+ You may add Your own copyright statement to Your modifications and
132
+ may provide additional or different license terms and conditions
133
+ for use, reproduction, or distribution of Your modifications, or
134
+ for any such Derivative Works as a whole, provided Your use,
135
+ reproduction, and distribution of the Work otherwise complies with
136
+ the conditions stated in this License.
137
+
138
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
139
+ any Contribution intentionally submitted for inclusion in the Work
140
+ by You to the Licensor shall be under the terms and conditions of
141
+ this License, without any additional terms or conditions.
142
+ Notwithstanding the above, nothing herein shall supersede or modify
143
+ the terms of any separate license agreement you may have executed
144
+ with Licensor regarding such Contributions.
145
+
146
+ 6. Trademarks. This License does not grant permission to use the trade
147
+ names, trademarks, service marks, or product names of the Licensor,
148
+ except as required for reasonable and customary use in describing the
149
+ origin of the Work and reproducing the content of the NOTICE file.
150
+
151
+ 7. Disclaimer of Warranty. Unless required by applicable law or
152
+ agreed to in writing, Licensor provides the Work (and each
153
+ Contributor provides its Contributions) on an "AS IS" BASIS,
154
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
155
+ implied, including, without limitation, any warranties or conditions
156
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
157
+ PARTICULAR PURPOSE. You are solely responsible for determining the
158
+ appropriateness of using or redistributing the Work and assume any
159
+ risks associated with Your exercise of permissions under this License.
160
+
161
+ 8. Limitation of Liability. In no event and under no legal theory,
162
+ whether in tort (including negligence), contract, or otherwise,
163
+ unless required by applicable law (such as deliberate and grossly
164
+ negligent acts) or agreed to in writing, shall any Contributor be
165
+ liable to You for damages, including any direct, indirect, special,
166
+ incidental, or consequential damages of any character arising as a
167
+ result of this License or out of the use or inability to use the
168
+ Work (including but not limited to damages for loss of goodwill,
169
+ work stoppage, computer failure or malfunction, or any and all
170
+ other commercial damages or losses), even if such Contributor
171
+ has been advised of the possibility of such damages.
172
+
173
+ 9. Accepting Warranty or Additional Liability. While redistributing
174
+ the Work or Derivative Works thereof, You may choose to offer,
175
+ and charge a fee for, acceptance of support, warranty, indemnity,
176
+ or other liability obligations and/or rights consistent with this
177
+ License. However, in accepting such obligations, You may act only
178
+ on Your own behalf and on Your sole responsibility, not on behalf
179
+ of any other Contributor, and only if You agree to indemnify,
180
+ defend, and hold each Contributor harmless for any liability
181
+ incurred by, or claims asserted against, such Contributor by reason
182
+ of your accepting any such warranty or additional liability.
183
+
184
+ END OF TERMS AND CONDITIONS
185
+
186
+ Copyright 2026 [YOUR NAME OR ORGANIZATION — edit this line]
187
+
188
+ Licensed under the Apache License, Version 2.0 (the "License");
189
+ you may not use this file except in compliance with the License.
190
+ You may obtain a copy of the License at
191
+
192
+ http://www.apache.org/licenses/LICENSE-2.0
193
+
194
+ Unless required by applicable law or agreed to in writing, software
195
+ distributed under the License is distributed on an "AS IS" BASIS,
196
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
197
+ See the License for the specific language governing permissions and
198
+ limitations under the License.
199
+ License-File: LICENSE
200
+ Keywords: anonymization,face-blur,ffmpeg,gdpr,hipaa,ocr,opencv,phi,pii,privacy,redaction,screen-recording,video-redaction
201
+ Classifier: Development Status :: 4 - Beta
202
+ Classifier: Environment :: Console
203
+ Classifier: Environment :: Web Environment
204
+ Classifier: Intended Audience :: Developers
205
+ Classifier: Intended Audience :: Healthcare Industry
206
+ Classifier: Intended Audience :: Information Technology
207
+ Classifier: License :: OSI Approved :: Apache Software License
208
+ Classifier: Operating System :: OS Independent
209
+ Classifier: Programming Language :: Python :: 3
210
+ Classifier: Programming Language :: Python :: 3.9
211
+ Classifier: Programming Language :: Python :: 3.10
212
+ Classifier: Programming Language :: Python :: 3.11
213
+ Classifier: Programming Language :: Python :: 3.12
214
+ Classifier: Topic :: Multimedia :: Video
215
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
216
+ Classifier: Topic :: Security
217
+ Requires-Python: >=3.9
218
+ Requires-Dist: cryptography
219
+ Requires-Dist: flask
220
+ Requires-Dist: numpy
221
+ Requires-Dist: opencv-python
222
+ Requires-Dist: pillow
223
+ Requires-Dist: pytesseract
224
+ Requires-Dist: pyyaml
225
+ Requires-Dist: rapidfuzz
226
+ Provides-Extra: all
227
+ Requires-Dist: spacy>=3.7; extra == 'all'
228
+ Provides-Extra: ner
229
+ Requires-Dist: spacy>=3.7; extra == 'ner'
230
+ Description-Content-Type: text/markdown
231
+
232
+ # OpenScrub — local video & screen-recording redaction
233
+
234
+ **A local, GPU-accelerated tool that blurs faces and any on-screen text —
235
+ names, phone numbers, SSNs, emails, dates, ID numbers, or anything you can
236
+ express as a regex — in videos and screen recordings, with a human review
237
+ step before anything is published.**
238
+
239
+ Runs entirely on your own machine (no cloud, no upload of sensitive
240
+ footage). OCR-driven, so it catches text anywhere on screen; face-tracked,
241
+ so a face detected once stays covered even when the detector blinks;
242
+ scroll- and motion-aware, so blur boxes follow content as it moves; and
243
+ onset-aware, so redaction starts on the exact frame a detail first appears
244
+ rather than a half-second late. Ships with a HIPAA preset out of the box,
245
+ but the engine is general-purpose.
246
+
247
+ > Keywords: video redaction · blur faces in video · redact screen recording ·
248
+ > PII redaction · anonymize video · blur license plates · GDPR / CCPA /
249
+ > FERPA / PCI / HIPAA · OCR text redaction · face blur · privacy tool
250
+
251
+ ## What it does
252
+
253
+ - **Blur faces** — detected with a DNN model and visually tracked, so a
254
+ single detection covers a face across frames it would otherwise be missed on.
255
+ - **Redact text by pattern** — bring your own regex for account numbers,
256
+ license plates, case numbers, employee IDs, order numbers; built-in
257
+ patterns for SSNs, phone numbers, emails, dates, addresses (including
258
+ multi-line street/city/state/ZIP blocks), credit/debit card numbers (Luhn-validated), API keys/tokens, IP addresses,
259
+ and medical record numbers.
260
+ - **Redact names** — via named-entity recognition plus heuristics, with no
261
+ list required (though you can supply an allowlist to *keep* specific names
262
+ visible and a blocklist to *always* remove others).
263
+ - **Detection zones** — restrict redaction to a region, or invert it: keep a
264
+ central subject sharp and blur everyone/everything around them, or vice versa.
265
+ - **Redaction styles** — blur, solid black box (irreversible), or mosaic
266
+ pixelation, choosable per category (black-box the SSNs, blur the faces).
267
+ - **Human review** — every detection is shown as a thumbnail you can keep or
268
+ blur, with an interactive box editor to resize, move, add, or time-bound
269
+ any blur before rendering.
270
+ - **Audit trail** — each run produces a report with SHA-256 hashes of input
271
+ and output for provenance.
272
+
273
+ ## Use cases
274
+
275
+ PHI redaction for medical practices is the flagship use — it's the hardest
276
+ version of the problem (dense, scrolling, fast-changing screens) and the
277
+ tool is built to handle it. But the same engine fits many privacy workflows:
278
+
279
+ - **Content creators & tutorials** — strip inboxes, browser tabs, API keys,
280
+ file paths, and notification pop-ups out of screen-recorded walkthroughs
281
+ before publishing. Onset detection catches a notification that flashes for
282
+ a fraction of a second.
283
+ - **Legal e-discovery & court exhibits** — redact names, SSNs, account
284
+ numbers, and minors' identities from video exhibits, deposition
285
+ recordings, and bodycam footage; keep the named party visible, blur the rest.
286
+ - **Journalism & documentary** — protect sources by blurring informants'
287
+ faces and on-screen identifying text (badges, plates, addresses,
288
+ shared documents); face tracking survives a source turning their head.
289
+ - **Law-enforcement & FOIA release** — redact bystander faces, minors, and
290
+ visible PII from body-cam footage for public-records compliance, with a
291
+ hashed audit report for chain-of-custody.
292
+ - **GDPR / CCPA compliance** — anonymize identifiable people and personal
293
+ data in any recorded video before it's shared or published.
294
+ - **Fintech & financial support videos** — blur account numbers, balances,
295
+ routing and card numbers in screen recordings of banking or accounting
296
+ software (PCI-DSS-relevant), via built-in and custom regex.
297
+ - **Education & research (FERPA)** — protect student names, IDs, and grades
298
+ in recorded lectures, gradebook screen-shares, and classroom video;
299
+ "blur every face except the presenter" with an inverted zone.
300
+ - **Corporate training & internal demos going public** — remove real
301
+ customer names, employee directories, internal URLs, and chat
302
+ notifications when repurposing production-system recordings for marketing.
303
+ - **Real-estate & property walkthroughs** — blur faces, family photos,
304
+ mail with addresses, and documents on desks captured incidentally.
305
+ - **Streaming & gaming VODs** — redact Discord DMs, donation alerts with
306
+ real names, second-monitor leaks, and non-consenting on-cam guests.
307
+ - **Dashcam footage** — blur license plates and pedestrian faces before
308
+ posting insurance or public clips (plates via regex + OCR).
309
+ - **UX & usability research** — anonymize participants' faces, names, and
310
+ on-screen account data before sharing session recordings internally.
311
+ - **Government document-on-screen redaction** — remove names, locations,
312
+ and marked strings from recordings that walk through sensitive documents,
313
+ with zones, regex, and an audit trail.
314
+
315
+ Several of these depend on you supplying the right regex, and on OCR
316
+ reading the target text reliably at your recording's resolution — see
317
+ [Caveats](#caveats--read-these). Face tracking works best on footage where
318
+ faces are stationary or scroll with the page rather than moving rapidly
319
+ across the frame. In all cases this is a **best-effort assistive tool:
320
+ review the output before publishing.**
321
+
322
+ ## Windows install — easy way
323
+
324
+ Download everything into one folder and double-click **install.bat**.
325
+ It bootstraps Python if needed (via winget), then runs `installer.py`,
326
+ which probes every dependency and installs what's missing with your
327
+ consent: core pip packages, spaCy NER, Tesseract, ffmpeg (full build with
328
+ NVENC), and PaddleOCR — automatically offering the GPU build when an
329
+ NVIDIA GPU is detected, and offering an ffmpeg upgrade when NVENC is
330
+ present but broken (old build vs. new driver). Re-run any time with
331
+ `python installer.py --check` to audit, or `--yes` for unattended install.
332
+
333
+ ## Windows install — manual way
334
+
335
+ 1. **Python 3.10+** from python.org (check "Add to PATH" during install)
336
+ 2. **Tesseract OCR**: installer from https://github.com/UB-Mannheim/tesseract/wiki
337
+ (default location is auto-detected; no PATH edit needed)
338
+ 3. **ffmpeg**: `winget install ffmpeg` in PowerShell (needed for audio + h264 output)
339
+ 4. Python packages:
340
+ ```
341
+ pip install opencv-python rapidfuzz pytesseract spacy
342
+ python -m spacy download en_core_web_sm
343
+ ```
344
+ spaCy is strongly recommended — it's the primary name detector. The tool
345
+ still runs without it using heuristics, but NER is more accurate.
346
+
347
+ Optional, better OCR on small UI fonts (large install):
348
+ `pip install paddleocr paddlepaddle`
349
+
350
+ ## Web interface (LAN)
351
+
352
+ Run `python openscrub_web.py` on an always-on machine and open the printed
353
+ URL (includes a required access token) from any device on your network —
354
+ laptop or phone. Workflow: upload a recording (or point at a server-side
355
+ path) → scan runs on the server with a live preview and log → **review
356
+ page**: every detection shown as a thumbnail grouped by category, uncheck
357
+ false positives, per-category all-on/all-off, draw missed regions directly
358
+ on any frame (works with touch) → render → download the redacted video and
359
+ the audit report. Jobs queue one at a time so they don't fight over the GPU.
360
+
361
+ Security: LAN-grade token auth only — never expose the port to the
362
+ internet. The jobs folder on the server contains PHI (uploads + reports);
363
+ protect it accordingly.
364
+
365
+ ## ⚠️ Disclaimer — read this before using openscrub on real PHI
366
+
367
+ **openscrub is a best-effort assistive tool, not a HIPAA compliance
368
+ guarantee, a de-identification certification, or a substitute for human
369
+ review.** It uses OCR, named-entity recognition, pattern matching, and
370
+ face detection — all of which can and do miss things: low-contrast text,
371
+ unusual names, stylized fonts, partially occluded faces, content visible
372
+ for only a fraction of a second, handwriting, text inside images, and
373
+ categories of identifiers it was never designed to detect.
374
+
375
+ **You remain fully responsible for reviewing every output before it is
376
+ shared, published, or distributed.** The built-in review workflow and the
377
+ final QC scrub are not optional extras — they are the compensating
378
+ control this tool is designed around. If a redacted video leaks protected
379
+ health information, that is your exposure, not this software's.
380
+
381
+ Specifically:
382
+
383
+ - The validation numbers in this README are measurements against a
384
+ **synthetic corpus**. They demonstrate the pipeline works as designed;
385
+ they are **not** a guarantee of performance on your recordings, your
386
+ EMR, your fonts, or your screen resolution.
387
+ - Audit reports, job folders, and normalized/intermediate video files
388
+ **contain PHI in plaintext**. Protect them with the same controls as
389
+ any other PHI: restricted access, encryption at rest where required,
390
+ and deletion when no longer needed.
391
+ - The web interface provides **LAN-grade token access control only**.
392
+ Never expose it to the internet, and run it only on networks and
393
+ machines already authorized to handle PHI.
394
+ - This tool addresses **on-screen visual content only**. Audio narration,
395
+ metadata, file names, and embedded subtitles are untouched and can all
396
+ carry PHI.
397
+ - Nothing in this project constitutes legal, compliance, or regulatory
398
+ advice. Consult your privacy officer or counsel for questions about
399
+ HIPAA, state privacy law, or your organization's obligations.
400
+
401
+ This software is provided "AS IS" without warranty of any kind — see the
402
+ [LICENSE](LICENSE) (Apache-2.0, §7–8) for the governing terms.
403
+
404
+ ## Install
405
+
406
+ One installer covers Windows and Linux (macOS best-effort). It installs the
407
+ Python dependencies, sets up GPU-accelerated OCR when an NVIDIA card is
408
+ present, installs Tesseract and ffmpeg via your system package manager,
409
+ verifies NVENC hardware encoding, and creates a launchable "OpenScrub"
410
+ shortcut with the program icon.
411
+
412
+ Windows: double-click install.bat (or: python install.py)
413
+ Linux/macOS: ./install.sh (or: python3 install.py)
414
+
415
+ `--check` reports what's present without changing anything; `--yes` runs
416
+ unattended; `--cpu-only` skips GPU OCR. Start the app from the created
417
+ shortcut, or `python openscrub_web.py` — the web interface at the printed
418
+ HTTPS URL is the primary interface. (`openscrub_gui.py`, the desktop Tk
419
+ interface, still works but is legacy: new features land in the web app.)
420
+
421
+ ## Validation
422
+
423
+ The corpus generator (`make_corpus.py`) plants fake PHI at known
424
+ locations across the hard cases — static charts, schedule grids,
425
+ scrolling notes, OCR-disrupting highlights, embedded face photos — and
426
+ `validate.py` scores the pipeline against the ground truth:
427
+
428
+ PHI recall: 100.0% (102/102 planted samples blurred)
429
+ Benign preservation: 100.0% (39/39 benign samples left readable)
430
+
431
+ (measured with the Tesseract fallback engine; PaddleOCR + spaCy NER, the
432
+ recommended stack, is stronger). Run it yourself:
433
+ `python make_corpus.py --out corpus && python validate.py --corpus corpus`.
434
+ CI runs the regression suite (`pytest test_openscrub.py`) and re-validates
435
+ recall on every commit — a detection regression fails the build.
436
+
437
+ ## What's new in v4.1
438
+
439
+ - **VFR normalization** — OBS/Game Bar variable-frame-rate recordings are
440
+ detected (ffprobe) and normalized to CFR before processing, preventing
441
+ blur-timing drift and audio desync; recorded in provenance.
442
+ - **OCR quality**: low-confidence words that are structurally PHI-shaped
443
+ (emails, phones, digit runs) are rescued instead of dropped; small text
444
+ triggers an automatic 2x re-OCR; a reverse pass re-searches the whole
445
+ timeline for near-misses of remembered PHI. `--paranoid` preset maxes
446
+ recall at the cost of false positives (clean up in review).
447
+ - **False-positive economics**: names must be caught by a primary detector
448
+ on two separate scans before memory starts recalling them; a top-recalls
449
+ summary prints after every scan; the web review suggests allowlisting
450
+ strings you disabled everywhere, building a permanent allow-list.
451
+ - **Web**: before/after compare scrubber on finished jobs, ETA on the
452
+ progress bar, `--retain-days` auto-deletes PHI-bearing job folders
453
+ (default 7 days).
454
+ - **Batch resume** — re-running `--batch` skips files already done
455
+ (`--overwrite` to redo).
456
+ - **Packaging**: `pip install .` gives `openscrub`, `openscrub-web`,
457
+ `openscrub-gui` commands.
458
+
459
+ ## What's new in v4
460
+
461
+ - **Review workflow** — scan and render are separate phases; between them
462
+ you can audit every detection and correct both false positives and
463
+ misses. CLI equivalent: run with `--report audit.json`, edit the JSON
464
+ (set `"enabled": false`, or append boxes), then
465
+ `openscrub.py video.mp4 --from-report audit.json` re-renders in seconds
466
+ without re-scanning.
467
+ - **Face detection** — new `face` category (on by default) blurs faces in
468
+ clinical photos and webcam bubbles, which OCR is blind to. Uses the
469
+ YuNet DNN detector (auto-downloaded, ~230 KB) with a Haar-cascade
470
+ fallback. Faces re-detect on every scan; boxes are expanded 15%.
471
+ - **Config profiles** — `--config ema.yaml` loads per-environment settings
472
+ (engine, MRN regex, categories, ignore regions…). CLI flags override the
473
+ file. See the included `ema.yaml`.
474
+ - **Ignore regions** — `--ignore-region X1,Y1,X2,Y2` (repeatable, or in
475
+ config) excludes screen areas like the taskbar clock from all blurring.
476
+ - **Batch mode** — `--batch folder` processes every video, writing
477
+ per-file outputs + audit reports and a `batch_summary.json`.
478
+ - **Provenance** — every audit report now records tool version, timestamp,
479
+ full settings, and SHA256 of input and output, making the audit trail
480
+ independently verifiable.
481
+
482
+ ## GUI (Windows)
483
+
484
+ `python openscrub_gui.py` (or double-click `openscrub_gui.bat`) opens a
485
+ desktop app covering everything the CLI does:
486
+
487
+ - Source / output / audit-report file pickers
488
+ - OCR engine selection with live status (Tesseract / PaddleOCR / spaCy NER
489
+ / NVENC detected or missing) and one-click **Install** buttons for
490
+ PaddleOCR (CPU or GPU CUDA 12.6) and spaCy NER
491
+ - GPU/CPU toggle for OCR, NVENC/x264 toggle for encoding
492
+ - Category checkboxes, blur vs box, preview mode, memory on/off
493
+ - Allow-names and always-blur name lists (type directly or load a file)
494
+ - Sample interval / scan trigger / padding / bridge gap / MRN regex fields
495
+ - Live preview showing each frame as it's analyzed with detection boxes
496
+ - Progress bar, log pane, and a Cancel button that cleans up partial output
497
+
498
+ Extra requirement for the preview pane: `pip install pillow`
499
+
500
+ ## Usage
501
+
502
+ ```
503
+ :: standard run
504
+ python openscrub.py recording.mp4
505
+
506
+ :: keep provider/staff names visible (one name per line in the file)
507
+ python openscrub.py recording.mp4 --allow-names providers.txt
508
+
509
+ :: tuning pass — draws boxes instead of blurring
510
+ :: (red = detected PHI, orange = unscanned scroll safety band)
511
+ python openscrub.py recording.mp4 --preview
512
+
513
+ :: everything
514
+ python openscrub.py recording.mp4 --allow-names providers.txt ^
515
+ --extra-names always_blur.txt --sample-interval 0.5 --scan-trigger 60 ^
516
+ --pad 8 --mode blur --report audit.json -o recording_redacted.mp4
517
+ ```
518
+
519
+ ## How names are detected (no patient list)
520
+
521
+ Three stacked signals, any of which triggers a blur:
522
+ 1. **spaCy NER** — PERSON entities in reconstructed text lines
523
+ 2. **Label heuristic** — text following "Patient:", "Name:", "Pt:",
524
+ "Member:", "Insured:", "Guarantor:", etc., stopping at the next label
525
+ 3. **Capitalized-pair heuristic** — adjacent capitalized non-UI words
526
+ ("Maria Gonzalez", "Henderson, Robert", "Mrs. Whitfield"); auto-enabled
527
+ as fallback when spaCy is missing, or force with --heuristic-names on
528
+
529
+ `--allow-names providers.txt` whitelists names to KEEP visible (your
530
+ physicians/PAs, e.g. Smith, Patel, Nguyen, Garcia).
531
+ `--extra-names` force-blurs specific names the detectors might miss.
532
+
533
+ ## How scrolling is handled
534
+
535
+ Three mechanisms working together:
536
+ 1. **Per-frame motion tracking** — global scroll offset is measured every
537
+ frame via phase correlation against a keyframe (drift-bounded, verified
538
+ to a few px over a 500px scroll). Every blur box is anchored in content
539
+ coordinates and translated with the scroll, so blur rides along with
540
+ the text on every single frame — not just at sample times.
541
+ 2. **Motion-triggered scans** — in addition to the time-based interval,
542
+ an OCR scan fires after every --scan-trigger pixels of scroll (default
543
+ 60), so newly revealed content is scanned almost immediately.
544
+ 3. **Safety bands** — any strip of screen that scrolled into view since
545
+ the last OCR scan is blurred wholesale until it has been scanned.
546
+ Unverified content is never shown, even between scans.
547
+
548
+ Net effect: text detected once stays covered while it moves, and text
549
+ scrolling into view is covered by the safety band before it's even been
550
+ read. Verified in testing with 26/26 PHI regions covered across static,
551
+ mid-scroll, and post-scroll frames.
552
+
553
+ ## PHI memory and gap bridging (v3)
554
+
555
+ Two reasoning layers prevent "flash of PHI" from intermittent OCR misses:
556
+
557
+ 1. **PHI text memory** — every string confirmed as PHI is remembered for
558
+ the rest of the video. Each scan checks all OCR'd words against memory
559
+ (fuzzy for names, near-exact for numbers), so "Henderson" identified
560
+ once gets blurred on every later appearance anywhere on screen, even
561
+ where NER/heuristics would fail (e.g. a bare surname mid-sentence).
562
+ Disable with --no-memory. Memory is per-run only; nothing persists.
563
+ 2. **Evidence-based gap bridging** — if the same PHI is detected, missed
564
+ for a few scans, then re-detected in the same region, the blur is held
565
+ straight through the gap (up to --bridge-gap seconds, default 4.0) —
566
+ UNLESS an intermediate scan positively read different text there,
567
+ meaning the content genuinely changed. Unreadable or empty gaps fail
568
+ closed: they stay blurred.
569
+
570
+ ## Caveats — read these
571
+
572
+ - **Best-effort, not a guarantee.** OCR can miss low-contrast or tiny
573
+ text; NER can miss unusual names (heuristics + label detection back it
574
+ up, but nothing is 100%). Do a final QC scrub in Resolve at 2x before
575
+ anything goes public. Treat this as removing ~95% of the manual work.
576
+ - **All dates are blurred**, since the tool can't distinguish DOBs from
577
+ visit dates. Usually right on a medical UI; drop `dob` from
578
+ --categories if too aggressive for a given recording.
579
+ - **Partial-screen scrolling** (one panel scrolls while the rest is
580
+ static) is tracked as whichever motion dominates. If a recording is
581
+ mostly panel-scrolling, use --preview to check coverage and consider
582
+ --sample-interval 0.25.
583
+ - **MRN default** is standalone 7+ digit runs, or 6+ digits near an
584
+ MRN/chart/acct label. Tighten with --mrn-regex if benign numbers get
585
+ caught (e.g. `\b\d{7}\b` for an exact-width MRN).
586
+ - **The --report JSON contains PHI in plaintext.** Handle it like any
587
+ PHI file.
588
+
589
+ ## Recommended workflow
590
+
591
+ 1. Record as usual
592
+ 2. `--preview` pass, spot-check red boxes and orange bands
593
+ 3. Real pass (optionally with --report)
594
+ 4. Import `_redacted.mp4` into Resolve, edit normally
595
+ 5. Final QC scrub before publishing
596
+
597
+ ## Tuning cheat sheet
598
+
599
+ | Symptom | Fix |
600
+ |---|---|
601
+ | Provider names blurred | add them to --allow-names |
602
+ | A name slips through | add to --extra-names; install spaCy if not present |
603
+ | Random capitalized words blurred | install spaCy so the pair heuristic turns off, or --heuristic-names off |
604
+ | Text slips through during very fast scrolling | --scan-trigger 40 and/or --sample-interval 0.25 |
605
+ | Benign numbers blurred as MRN | tighten --mrn-regex |
606
+ | Blur box clips edges of text | --pad 12 |
607
+ | Small text missed entirely | install paddleocr; record at native resolution |
@@ -0,0 +1,8 @@
1
+ openscrub.py,sha256=DCEriczNyyMx1BmbeTAcb7-BVlLDmVXYt7iHsgZhz0I,110537
2
+ openscrub_web.py,sha256=jfuIX3DwFCA_SgGugLXa_ZlnABhctQ2_mzN73n_YlPQ,123986
3
+ zones_ui.py,sha256=fwm3KtUKtz_SjpcQfrridZV0uju7vf1Fo-4uxLNNNN0,17239
4
+ openscrub-1.0.0.dist-info/METADATA,sha256=uKNxkPhLQjTiOfV2ov-e6BfC1mwnirRdAcMWYol1j08,33896
5
+ openscrub-1.0.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
6
+ openscrub-1.0.0.dist-info/entry_points.txt,sha256=tpiWZTyHbkA0UhBMnjuHJ0tHZM80RnwLgC_OlXE9oJY,80
7
+ openscrub-1.0.0.dist-info/licenses/LICENSE,sha256=_5jiujjv-oJocorIG7G2ZmNMixvzlczbJ8rs49SrLzo,10791
8
+ openscrub-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ openscrub = openscrub:main
3
+ openscrub-web = openscrub_web:main