Skip to content

Perceptual frame deduplication to eliminate redundant I/O #10

@sunnypatneedi

Description

@sunnypatneedi

Problem

Every screen still is written to disk and enqueued for OCR even when the screen hasn't changed — wasting disk I/O, storage, and OCR quota on identical frames.

Solution

Implement perceptual dHash (difference hash) to compare each new frame against the last saved frame. Frames that are visually identical (Hamming distance below threshold) are skipped before any file write.

Algorithm

  • Resize thumbnail to 9×8 using Electron's NativeImage API (no extra deps)
  • Compare each pixel's grayscale to its right neighbour → 64-bit BigInt
  • Hamming distance: 0 = identical, 10+ = meaningful change
  • Threshold is configurable via deduplication.threshold in settings

Acceptance criteria

  • frame-hash.js exports computeDHash, hammingDistance, isSimilarFrame
  • Recorder skips duplicate frames without writing to disk
  • Hash is reset on session stop
  • Tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions