How Octopii processes images and documents
masterOctopii follows a multi-step pipeline to detect and extract PII:
- Input & Importing:
- Images (jpg, png): Detected via PIL and opened with OpenCV.
- PDFs: Converted into a list of images for OCR scanning.
- Text files (doc, txt, etc.): Read directly as strings without OCR.
- Face Detection: Uses a Haar cascade model via OpenCV to detect faces. This happens before image cleaning to preserve image data.
- Image Cleaning: Images are transformed to improve OCR accuracy through: auto-rotation, grayscaling, monochrome conversion, mean thresholding, Gaussian thresholding, and deskewing.
- OCR & Extraction:
- Tesseract extracts text strings.
- Similarity Matching: Extracted words are compared against
definitions.jsonusing Gestalt pattern matching to determine thepii_class. - Regex & NLP: Regular expressions find emails, phone numbers, and IDs, while Natural Language Processing (NLTK/Spacy) extracts addresses and countries.