Sim2Real Docs: Domain Randomization for Documents in Natural Scenes using Ray-traced Rendering

Nikhil Maddikunta, Huijun Zhao, Sumit Keswani, Alfy Samuel, Fu-Ming Guo, Nishan Srishankar, Vishwa Pardeshi, Austin HuangarXiv 2021

Abstract

In the past, computer vision systems for digitized documents could rely on systematically captured, high-quality scans. Today, transactions involving digital documents are more likely to start as mobile phone photo uploads taken by non-professionals. As such, computer vision for document automation must now account for documents captured in natural scene contexts. An additional challenge is that task objectives for document processing can be highly use-case specific, which makes publicly-available datasets limited in their utility, while manual data labeling is also costly and poorly translates between use cases. To address these issues we created Sim2Real Docs - a framework for synthesizing datasets and performing domain randomization of documents in natural scenes. Sim2Real Docs enables programmatic 3D rendering of documents using Blender, an open source tool for 3D modeling and ray-traced rendering. By using rendering that simulates physical interactions of light, geometry, camera, and background, we synthesize datasets of documents in a natural scene context. Each render is paired with use-case specific ground truth data specifying latent characteristics of interest, producing unlimited fit-for-task training data. The role of machine learning models is then to solve the inverse problem posed by the rendering pipeline. Such models can be further iterated upon with real-world data by either fine tuning or making adjustments to domain randomization parameters.

Introduction

Historically, document AI systems relied on high-quality, flat-bed scans. However, modern digital transactions often begin with mobile phone photos taken in uncontrolled environments. These "natural scene" images introduce significant challenges, including uneven lighting, motion blur, perspective distortion, and complex backgrounds. Traditional 2D image augmentations—such as adding noise or simple rotations—fail to capture the 3D physical reality of a document in a real-world setting. To bridge this gap, we present Sim2Real Docs, a framework that leverages photorealistic 3D rendering to synthesize robust training data.

Methodology: The Sim2Real Pipeline

We treat document processing as an inverse problem. By simulating the forward problem—rendering a complex image from a known digital state—we can train models to infer that state from real-world photos. The Sim2Real Docs pipeline utilizes Blender and its Cycles ray-tracing engine to create these simulations.

The Sim2Real Docs pipeline: from 3D rendering to depth mapping and automated ground truth generation.

The process involves several stages of randomization:

  1. Content and Style: Digital templates are populated with synthetic data and GAN-generated handwriting. Digital "wear and tear," such as fax textures, is applied to the source.
  2. 3D Scene Randomization: The document is modeled as a 3D object. We randomize camera position, lens focus (depth of field), and the physical geometry of the paper (e.g., folds and creases).
  3. Ray-Traced Rendering: The engine simulates actual light paths, producing realistic shadows and reflections that are impossible to replicate with 2D filters.
A rendered document demonstrating complex lighting, shadows, and synthetic handwriting.

Key Insights

By simulating physical invariants, models learn to recognize document types regardless of environmental factors like shadows or surface textures. A critical advantage of this 3D approach is the elimination of "boundary artifacts" common in 2D rotations, which often allow models to "cheat" during training. Furthermore, the framework provides perfect ground truth data, including pixel-level segmentation masks and precise bounding boxes for fields of interest.

Results and Use Cases

The utility of Sim2Real Docs has been demonstrated across several tasks:

  • Orientation Estimation: Models trained on synthetic data successfully estimate document rotation without relying on augmentation artifacts.
  • Robust Classification: Models remain accurate despite variations in background and lighting.
  • Automated Labeling: Projective transformations allow for the automatic mapping of 2D digital coordinates to 3D rendered scenes, facilitating tasks like logo detection and field segmentation.
  • OCR Quality Diagnosis: By comparing OCR results on "perfect" digital sources versus "messy" renders, the framework can train models to detect poor image quality in real-time.

Conclusion

Sim2Real Docs provides a scalable solution for generating fit-for-task training data in document AI. While ray-tracing is computationally intensive, the ability to generate unlimited, perfectly labeled data justifies the cost. Future work will focus on further bridging the gap between document AI and natural scene text recognition, moving toward truly multimodal models.

Summary updated

BibTeX
@misc{maddikunta2021sim,
  author = {Nikhil Maddikunta and Huijun Zhao and Sumit Keswani and Alfy Samuel and Fu-Ming Guo and Nishan Srishankar and Vishwa Pardeshi and Austin Huang},
  title = {{Sim2Real Docs: Domain Randomization for Documents in Natural Scenes using Ray-traced Rendering}},
  year = {2021},
  eprint = {2112.09220},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2112.09220},
}
Figure