Rapid 3D Measurement Using Digital Video Cameras
Total Page:16
File Type:pdf, Size:1020Kb
Rapid 3D Measurement Using Digital Video Cameras by Willem Johannes Van der Merwe March 2008 Rapid 3D Measurement Using Digital Video Cameras by Willem Johannes Van der Merwe Thesis presented in partial fulfillment of the requirements for the degree of Master of Science in Mechatronic Engineering at the University of Stellenbosch Supervisor: Dr. K. Schreve March 2008 Declaration I, the undersigned, hereby declare that the work contained in this thesis is my own original work and that I have not previously in its entirety or in part submitted it at any university for a degree. Signature: . W. J. Van der Merwe Date: . Copyright © 2008 University of Stellenbosch All rights reserved. i Abstract A rapid measurement system is implemented using two digital video cameras, presenting a faster and less expensive solution to certain metrology problems. The cameras are calibrated from one stereo image-pair of a 3D calibration grid that allows an immediate assessment of the achievable metric accuracy of the system. Three different methods, using either laser tracking or structured light patterns, were developed and employed to solve the coordinate extraction and correspondence matching problems. Different image processing techniques were used to speed up the entire measurement process. All software development was accomplished using only freely distributed software packages. The system achieves calibration in less than a minute and accumulates point correspondences at 12 frames per second. Accuracies of greater than 0.4 mm are achieved for a 235 x 190 x 95 mm measurement volume using a single pair of images with 640 x 480 pixel resolution each. ii Uittreksel Met die gebruik van twee digitale videokameras word ‘n spoedige meetsisteem ge їmplementeer om sodoende ‘n vinniger en meer bekostigbare oplossing te bied vir sekere metrologie probleme. Die kameras word gekalibreer deur een beeldpaar van ‘n 3D kalibrasieveld te gebruik wat oombliklike assessering van die behaalbare akkuraatheid van die sisteem moontlik maak. Drie metodes is ontwikkel en ge їmplementeer om die probleme van koördinaatontginning en puntooreenstemming op te los. Die laasgenoemde metodes maak gebruik van of ligpatrone of laser. Verskillende beeldverwerkingsmetodes word gebruik om die meetproses te verspoedig. Alle sagtewareontwikkeling is met vrylik beskikbare sagteware pakette gedoen. Die sisteem kan gekalibreer word in minder as ‘n minuut en versamel puntooreenstemmings teen ‘n tempo van 12 per sekonde. Akkuraatheid van beter as 0.4 mm word behaal vir ‘n meetvolume van 235 x 190 x 95 mm deur gebruik te maak van een paar beelde, elk met ‘n resolusie van 640 x 480. iii Acknowledgements My sincerest gratitude goes to the following people for helping to make this work possible: • Dr. Kristiaan Schreve, my supervisor, for his constant encouragement and competent guidance. • The members of the Machine Vision group, led by Prof. Ben Herbst and Dr. Karin Hunter, for freely sharing resources and ideas. Above all, I thank God, His Son and the Holy Spirit, through whom all things are made possible. iv Table of Contents Declaration...................................................................................................... i Abstract ......................................................................................................... ii Uittreksel.......................................................................................................iii Acknowledgements ..................................................................................... iv Table of Contents.......................................................................................... v List of Figures .............................................................................................. ix List of Tables................................................................................................ xi Abbreviations .............................................................................................. xii Chapter 1 Introduction.................................................................................. 1 1.1 Problem Statement..........................................................................................1 1.2 Project Context................................................................................................1 1.3 Thesis Outline .................................................................................................2 Chapter 2 Literature Review......................................................................... 3 2.1 Optical Measurement Techniques ...................................................................3 2.1.1 Passive Light Systems...........................................................................3 2.1.2 Active Light Systems .............................................................................4 2.2 Stereo Vision and Photogrammetry .................................................................5 2.3 Camera Calibration..........................................................................................6 2.3.1 Methods ................................................................................................6 2.3.2 Achieving Accuracy, Fast ......................................................................9 2.3.3 Common Factors Influencing Successful Calibration ...........................10 2.3.4 Calibration Object Design ....................................................................12 Chapter 3 The Camera Model..................................................................... 16 3.1 Pinhole Model................................................................................................16 3.1.1 Intrinsic Parameters.............................................................................17 v 3.1.2 Extrinsic Parameters ...........................................................................20 3.1.3 The Camera Matrix..............................................................................21 3.2 Additional Parameters ...................................................................................22 3.3 Lens Distortion Model....................................................................................22 Chapter 4 The Measurement Process ....................................................... 25 4.1 Camera Calibration........................................................................................25 4.1.1 The Method .........................................................................................25 4.1.2 Step 1: Initialisation of Camera Parameters.........................................25 4.1.3 Step 2: Refinement of the Camera Parameters ...................................26 4.2 Triangulation: Measuring Points in Three Dimensions ...................................30 4.2.1 The DLT Method..................................................................................30 4.2.2 Other Methods.....................................................................................30 4.3 Process Summary ......................................................................................31 Chapter 5 Image Processing...................................................................... 33 5.1 Software ........................................................................................................33 5.1.1 The Python Scripting Language...........................................................33 5.1.2 The OpenCV Software Package..........................................................34 5.1.3 Data Visualisation................................................................................35 5.1.4 C++ Code in Python: the Wrapping Principle.......................................36 5.1.5 Digital Video Camera Software............................................................36 5.2 Automation ....................................................................................................37 5.2.1 Pre-processing for Calibration .............................................................37 5.2.2 Point Correspondences in Two Images ...............................................38 5.3 Automated Detection of the Calibration Grid..................................................38 5.3.1 Assumptions........................................................................................38 5.3.2 Finding All Squares .............................................................................39 5.3.3 Intermediate Steps ..............................................................................42 5.3.4 Deriving Sub-pixel Coordinates for Square Corners ............................43 5.4 Rapid Correspondence Matching ..................................................................47 vi 5.4.1 Tracking a Moving Laser Dot...............................................................47 5.4.2 Corner Detection Using Square Projections.........................................49 5.4.3 Projected Line-Crossings.....................................................................51 Chapter 6 Hardware .................................................................................... 55 6.1 Digital Video Cameras...................................................................................55 6.1.1 Camera Properties and Characteristics ...............................................55 6.1.2 Lenses.................................................................................................56 6.1.3 Communication with the Computer......................................................57