Kye-Si Kwon and Steven Ready Practical Guide to Machine Vision Software An Introduction with LabVIEW Kye-SiKwon StevenReady PracticalGuideto MachineVisionSoftware Related Titles Hornberg,A.(ed.) Korvink,J.G.,Smith,P.J.,Shin,D.-Y. (eds.) Handbook of Machine Vision Inkjet-based 2006 Micromanufacturing PrintISBN:978-3-527-40584-8;alsoavailable Series:AdvancedMicroand inelectronicformats Nanosystems(Volume9) Cyganek,B.,Siebert,J. 2012 An Introduction to 3D ISBN:978-3-527-31904-6;alsoavailablein Computer Vision Techniques electronicformats and Algorithms Cristobal,G.,Perrinet,L.,Keil,M.(eds.) 2008 Biologically-inspired PrintISBN:978-0-470-01704-3;alsoavailable Computer Vision inelectronicformats FundamentalsandApplications Steger,C.,Ulrich,M.,Wiedemann,C. 2016 Machine Vision Algorithms PrintISBN:978-3-527-41264-8;alsoavailable and Applications inelectronicformats 2008 PrintISBN:978-3-527-40734-7 Gevers,T.,Gijsenij,A.,vandeWeijer,J., Geusebroek,J. Color in Computer Vision FundamentalsandApplications 2012 PrintISBN:978-0-470-89084-4;alsoavailable inelectronicformats Kye-Si Kwon and Steven Ready Practical Guide to Machine Vision Software An Introduction with LabVIEW Authors AllbookspublishedbyWiley-VCHarecarefully produced.Nevertheless,authors,editors,and Prof.Kye-SiKwon publisherdonotwarranttheinformationcontained SoonChunHyangUniversity inthesebooks,includingthisbook,tobefreeof DepartmentofMechanicalEngineering errors.Readersareadvisedtokeepinmindthat 646Eupnae-ri statements,data,illustrations,proceduraldetailsor Shinchang-myeon otheritemsmayinadvertentlybeinaccurate. Chungnam 336-745Asai-si LibraryofCongressCardNo.:appliedfor SouthKorea BritishLibraryCataloguing-in-PublicationData Acataloguerecordforthisbookisavailablefromthe StevenReady BritishLibrary. PaloAltoResearchCenter ElectronicMaterialsandDevicesLab. Bibliographicinformationpublishedbythe 3333CoyoteHillRoad DeutscheNationalbibliothek 94304PaloAlto,CA TheDeutscheNationalbibliothekliststhis UnitedStatesofAmerica publicationintheDeutscheNationalbibliografie; detailedbibliographicdataareavailableonthe Internetathttp://dnb.d-nb.de. 2015Wiley-VCHVerlagGmbH&Co.KGaA, Boschstr.12,69469Weinheim,Germany Allrightsreserved(includingthoseoftranslationinto otherlanguages).Nopartofthisbookmayberepro- ducedinanyform–byphotoprinting,microfilm,or anyothermeans–nortransmittedortranslatedinto amachinelanguagewithoutwrittenpermissionfrom thepublishers.Registerednames,trademarks,etc. usedinthisbook,evenwhennotspecificallymarked assuch,arenottobeconsideredunprotectedbylaw. PrintISBN:978-3-527-33756-9 ePDFISBN:978-3-527-68412-0 ePubISBN:978-3-527-68411-3 MobiISBN:978-3-527-68410-6 oBookISBN:978-3-527-68277-5 CoverDesign Formgeber,Mannheim,Germany Typesetting ThomsonDigital,Noida,India PrintingandBinding MarkonoPrintMediaPteLtd, Singapore Printedonacid-freepaper V Contents AbouttheAuthors IX Preface XI 1 BasicsofMachineVision 1 1.1 DigitalImages 1 1.1.1 GrayscaleImage 1 1.1.2 BinaryImage 2 1.1.3 ColorImage 3 1.2 ComponentsofImagingSystem 5 1.2.1 Camera 6 1.2.2 CameraBus:TheMethodtoConnectPCandCamera 10 1.2.3 Lens 13 1.2.4 Lighting 15 2 ImageAcquisitionwithLabVIEW 17 2.1 AcquiringImageswithMAX 17 2.2 AcquiringImagesUsingLabVIEW 19 2.2.1 IMAQdxFunctions 19 2.2.2 ImageManagementFunctions 21 2.2.3 BlockDiagramforImageAcquisition 23 2.2.4 ImageAcquisitionfromExample 23 2.2.5 VisionAcquisitionExpress 26 3 ParticleAnalysis 33 3.1 ParticleAnalysisUsingVisionAssistant 34 3.1.1 ImageAcquisitionUsingVisionAssistant 35 3.1.2 ImageProcessingFunctions 37 3.1.3 SettingaROI(RegionofInterest) 38 3.1.4 BinaryImageConversion 40 3.1.5 Morphology 43 3.1.6 ParticleAnalysis 44 3.2 LabVIEWCodeCreationUsingVisionAssistant 47 VI Contents 3.2.1 BlockDiagramofCreatedLabVIEWCode 50 3.2.2 ImageTypeModification 54 3.3 LabVIEWCodeModification 55 3.3.1 SubVIforParticleAnalysis 55 3.4 ParticleAnalysisUsingVisionExpress 67 3.4.1 VisionAcquisitionExpress 67 3.4.2 VisionAssistantExpress 68 3.5 ConversionofPixelstoReal-WorldUnits 71 4 EdgeDetection 75 4.1 EdgeDetectionviaVisionAssistant 75 4.2 LabVIEWCodeforEdgeDetection 78 4.3 VIforReal-Time-BasedEdgeDetection 81 4.4 TheUseofVisionAssistantExpressforReal-TimeEdgeDetection 85 5 PatternMatching 89 5.1 PatternMatchingUsingVisionAssistant 90 5.2 LabVIEWCodeCreationandModification 96 5.3 MainVIforPatternMatching 99 5.4 VisionAssistantExpress 101 6 ColorPatternMatching 105 6.1 ColorPatternMatchingUsingVisionAssistantExpress 105 6.1.1 VisionAcquisitionExpress 107 6.1.2 VisionAssistantExpress 108 6.1.3 MainVI 112 7 DimensionMeasurement 117 7.1 DimensionMeasurementUsingVisionAssistantExpress 117 7.1.1 FindCircularEdgeFunction 119 7.1.2 ClampFunction 119 7.1.3 CaliperFunction 123 7.2 VICreationforDimensionMeasurement 126 7.2.1 VisionAssistantExpressVIforDimensionMeasurement 126 7.2.2 ROIArray 127 7.2.3 FrontPanelofMainVI 129 7.2.4 BlockDiagramoftheMainVI 130 8 DimensionMeasurementUsingCoordinateSystem 135 8.1 MeasurementBasedonaReferenceCoordinateSystemUsingVision AssistantExpress 135 8.1.1 PatternMatching 137 8.1.2 CoordinateSystem 138 8.1.3 DimensionMeasurementUsingtheClampFunction 141 8.1.4 MeasurementofCircleEdge 142 8.2 ConversionofVisionAssistantExpresstoaStandardVI 145 Contents VII 9 GeometricMatching 149 9.1 GeometricMatchingUsingVisionAssistantExpress 150 9.1.1 GeometricMatchingforCircles 151 9.1.2 GeometricMatchingforEllipses 155 9.2 VICreationforGeometricMatching 158 9.3 ShapeDetection 159 10 BinaryShapeMatching 165 10.1 AccessingPreviouslySavedImageswithVisionAcquisitionExpress 166 10.2 BinaryShapeMatchingUsingVisionAssistant 168 10.2.1 BinaryTemplateImages 169 10.2.2 BinaryShapeMatching 170 10.3 OverlayVICreationforShapeMatching 172 10.4 VIforBinaryShapeMatching 173 11 OCR(OpticalCharacterRecognition) 177 11.1 OCRUsingVisionAssistant 177 11.1.1 CharacterTrainingUsingVisionAssistant 177 11.1.2 CharacterIdentificationUsingVisionAssistant 181 11.2 VIforOCR 185 11.2.1 VICreationforOCRUsingVisionAssistant 185 11.2.2 SubVIforOCR 185 11.2.3 MainVI 187 12 BinaryParticleClassification 191 12.1 VisionAcquisitionExpresstoLoadImageFiles 192 12.2 VisionAssistantExpressforClassification 194 12.2.1 TrainforParticleClassification 194 12.2.2 VICreation 199 12.3 VIModification 200 12.4 OverlayforClassification 204 12.5 MainVIforClassification 206 13 ContourAnalysis 209 13.1 ContourAnalysis 210 13.1.1 ImageAcquisitionUsingaUSBCamera 210 13.1.2 ContourAnalysisUsingVisionAssistant 212 13.1.3 DefectDetectionUsingCurvature 215 13.1.4 DefectDetectionbyComparingContours 216 13.1.5 VICreation 219 13.2 VIsforContourAnalysis 219 13.2.1 MainVI 219 13.2.2 OverlayforDefects 222 13.2.3 PerspectiveErrorsinImages 225 VIII Contents 14 ImageCalibrationandCorrection 227 14.1 MethodforCreatinganImageCorrectionFile 227 14.1.1 ImageAcquisition 228 14.1.2 NewCalibrationFile 228 14.2 ImageCorrection 234 14.2.1 ImageCorrectionUsingVisionAssistantExpress 234 14.2.2 VICreationforImageCorrection 237 15 SavingandReadingImages 241 15.1 SavingImage 241 15.2 ImageReadfromFile 245 15.2.1 IMAQReadfile 245 15.2.2 ExampleofReadingImagefromImageFiles 246 16 AVIFileWriteandRead 249 16.1 AVIFileCreationUsingImageFiles 249 16.2 AVIFileCreationBasedonReal-TimeImageAcquisition 251 16.3 ReadFramefromAVIFiles 252 17 Tracking 255 17.1 TrackingwiththeUseofVisionAssistant 255 17.2 VICreationforTrackingObjects 259 18 LabVIEWMachineVisionApplications* 263 18.1 SemiconductorManufacturing 263 18.2 AutomobileIndustry 264 18.3 MedicalandBioApplications 266 18.4 Inspection 268 18.5 IndustrialPrinting 269 19 StudentProjects 271 Project1:NoncontactMotionMeasurementanditsAnalysis 271 Project2:IntelligentSurveillanceCamera 271 Project3:DrivingaLEGONXTCar(LEGOMindstorm)with FingerMotion 273 Project4:PianoKeyboardUsingMachineVision 273 Index 275 *All images containing (LabVIEW, IMAQ and LabVIEW Vision applications in chapter 18) are providedbyororiginatefromthehardwareandsoftwareofNationalInstrumentsCorporationandits affiliates.NationalInstrumentsreservesallrightsincludingtrademarksinsuchimages.
Description: