Skip to main content

[Vision AI] Overcoming Blurry Blackbox Artifacts: Deep Super-Resolution (EDSR vs FSRCNN) & Multi-Frame Image Stacking (#4)

ยท 3 min read
Jaybee
AI & Robotics Engineer

EDSR Deep Super-Resolution Results

๐Ÿ“Œ Key Takeaways (TL;DR)

  • Problem: Cropped license plates from dashcam footage often measure under 40x20 pixels with heavy H.264 macroblocking; standard bicubic interpolation fails to resolve character contours.
  • Solution: Integrated EDSR_x4 deep residual networks (EDSR_x4.pb) that omit batch normalization to preserve dynamic range, combined with temporal multi-frame image stacking across 3 to 5 consecutive frames.
  • Result: Quadrupled plate pixel density and sharpened stroke edges, lifting downstream EasyOCR accuracy on Korean characters from 32% to over 91%.

1. Resolution Limitations & The Need for Deep Super-Resolutionโ€‹

Even with precise license plate localization, optical limitations thwart standard OCR:

  1. Failure of Bicubic Scaling: Interpolation algorithms blur edges further without hallucinating high-frequency contours.
  2. H.264 Compression & Sensor Noise: Dashcam compression creates severe pixelation that distorts alphanumeric strokes.

We integrated EDSR_x4 via the OpenCV DNN Super-Resolution module to reconstruct high-frequency details:

import cv2
from cv2 import dnn_superres

def init_super_resolution_engine(model_path="EDSR_x4.pb"):
sr = dnn_superres.DnnSuperResImpl_create()
sr.readModel(model_path)
sr.setModel("edsr", 4)
sr.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
sr.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
return sr

2. Multi-Frame Image Stacking for Noise Reductionโ€‹

Multi-frame Image Stacking Comparison

I_stacked(x, y) = (1 / N) * ฮฃ Warp(I_i(x, y))

This temporal stacking cancels random sensor noise while boosting text-background contrast.


3. Real Runtime Errors & Debugging Logโ€‹

Bug 1: EDSR_x4 Frame Freeze (420ms per Call) When Invoked on Every Tracked Frameโ€‹

Running sr.upsample(plate_crop) on every frame where a vehicle was tracked caused the pipeline latency to spike from 19ms to 440ms per frame (2.2 FPS), completely breaking real-time playback.

  • Failed Attempt: Switching to FSRCNN_x4.pb reduced latency to 45ms, but introduced severe ringing artifacts around vertical Korean Hangul strokes (๊ฐ€, ๋‚˜, ๋‹ค, ๋ผ), dropping OCR accuracy from 91% down to 58%.
  • Root Cause & Fix: First, pre-compiled OpenCV wheels on Windows/Linux ship with DNN_BACKEND_CUDA disabled by default, silently falling back to single-core CPU execution. Second, upsampling every frame is redundant when CSRT tracks the same plate across 30+ frames. We implemented a Sharpness-Gated Buffer: we compute the Laplacian variance (cv2.Laplacian(gray, cv2.CV_64F).var()) across a 15-frame window, align only the top 3 sharpest crops via cv2.findTransformECC, stack them into a single denoised patch, and invoke EDSR_x4 only once per vehicle event.
# Sharpness-gated single-shot EDSR invocation
scores_and_crops.sort(key=lambda item: item[0], reverse=True)
top_crops = [crop for _, crop in scores_and_crops[:3]]
stacked_patch = align_and_average_ecc(top_crops)
upscaled_plate = sr.upsample(stacked_patch) # Invoked once per violation event

Bug 2: cv2.error in findTransformECC When Sub-pixel Alignment Fails to Convergeโ€‹

On motion-blurred night plates with low gradient contrast, cv2.findTransformECC() threw cv2.error: (-7:Iterations do not converge) and aborted the stacking pipeline.

  • Fix: Wrapped findTransformECC in a try/except cv2.error block with TermCriteria(COUNT | EPS, 30, 1e-3) and fell back to the single highest-Laplacian-variance frame whenever ECC alignment failed to converge.

4. Next in This Seriesโ€‹

In Post #5: Korean ANPR OCR Engine, Regex Normalization & Temporal Majority Voting, we conclude the series with Korean ANPR OCR tuning, regex syntactic validation, and the temporal majority voting engine, recounting our engineering evolution from initial gibberish to finalized recognition (64๊ฐ€1511).