Canny Edge Detection Shaders
Total Page:16
File Type:pdf, Size:1020Kb
GPU Accelerated Feature Algorithms for Mobile Devices A thesis submitted to the Auckland University of Technology, In fulfilment of the requirements for the degree of Doctor of Philosophy (PhD) Seth George Hall School of Computing and Mathematical Sciences March 2014 Primary Supervisor: Dr. Andrew Ensor Secondary Supervisor: Dr. Roy Davies Table of Contents List of Figures ........................................................................................................................... 5 List of Tables ............................................................................................................................ 7 Attestation of Authorship ........................................................................................................ 8 Acknowledgements ................................................................................................................... 9 Abstract ................................................................................................................................... 10 Chapter 1 Introduction .......................................................................................................... 11 Chapter 2 Literature Review ................................................................................................ 22 2.1 : Augmented Reality ................................................................................................... 22 2.2 : Mobile Smartphone Platforms Overview ................................................................. 24 2.3 : Computer Vision: ..................................................................................................... 28 2.3.1 : Fiducial Markers ................................................................................................ 29 2.3.2 : Feature Detection ............................................................................................... 30 2.3.3 : Image Convolutions ........................................................................................... 31 2.3.4 : Canny Edge Detection ....................................................................................... 32 2.3.5 : FAST.................................................................................................................. 34 2.3.6 : SIFT ................................................................................................................... 35 2.3.7 : SURF ................................................................................................................. 36 2.3.8 : Lucas Kanade..................................................................................................... 36 2.4 : General Purpose Computing on the GPU: ............................................................... 38 2.4.1 : GPU programming and Shaders: ....................................................................... 38 2.4.2 GPU based feature descriptors ............................................................................. 43 2.5 : Cluster Analysis ....................................................................................................... 44 2.5.1 : DBSCAN ........................................................................................................... 45 2.5.2 : K-means Clustering ........................................................................................... 46 2.6 : Location Based Services .......................................................................................... 47 2 | Page 2.7 : Existing Computer Vision and MAR Applications: ................................................ 49 2.8 Significance for Mobile Augmented Reality .............................................................. 51 Chapter 3 GPU Based Canny Edge Detection ..................................................................... 53 3.1 : Image Analysis on Mobile Devices ......................................................................... 54 3.2 : Canny Shader Implementation ................................................................................. 57 3.2.1 : CPU side setup ................................................................................................... 58 3.2.2 : Gaussian Smoothing Steps ................................................................................ 59 3.2.3 : Sobel XY Steps .................................................................................................. 59 3.2.4 : Non-Maximal Suppression & Double Threshold Steps .................................... 59 3.2.5 : Weak and Strong Pixel Tests ............................................................................. 60 Chapter 4 Performance Comparison of Canny Edge Detection on Mobile Platforms ... 62 4.1 Mobile Performance Results ...................................................................................... 62 4.2 Results Discussion ...................................................................................................... 65 Chapter 5 GPU-based Feature point detection ................................................................... 67 5.1 Feature Detection and Description ............................................................................. 67 5.2 : GPU FAST implementation ..................................................................................... 69 5.3 : ColourFAST Feature Point Detection Implementation ............................................ 71 5.3.1 : CPU Side Setup and Android Camera Capture ................................................. 72 5.3.2 : Colour Conversion ............................................................................................. 73 5.3.3 : Smoothing .......................................................................................................... 74 5.3.4 : Half Bresenham and Feature Strength Calculation ........................................... 74 5.3.5 Feature Direction Calculation .............................................................................. 76 5.4 ColourFAST Results and Comparison to FAST ........................................................ 78 Chapter 6 GPU-based Feature Tracking ............................................................................. 83 6.1 : GPU-based Lucas Kanade implementation .............................................................. 84 6.2 : ColourFAST Feature Search implementation .......................................................... 85 6.2.1 Feature Point Difference Calculation .................................................................. 87 3 | Page 6.2.2 : Two-Step Hierarchical Approach ...................................................................... 87 6.2.3 Feature Blending .................................................................................................. 88 6.3 Results and Comparison with Lucas-Kanade ............................................................. 89 6.3.1 : Frame rate throughput tests ............................................................................... 89 6.3.2 : Tracking accuracy tests...................................................................................... 90 6.3.3 : Feature value repeatability tests......................................................................... 93 Chapter 7 Cluster Analysis & GPU-based Feature Discovery .......................................... 98 7.1 : GPU Feature Discovery Implementation ................................................................. 98 7.2 : Point Clustering ...................................................................................................... 101 7.3 : Results and Testing ................................................................................................ 105 7.4 : Future Work ........................................................................................................... 107 Chapter 8 GPU-based Object Recognition ........................................................................ 109 8.1 : Object Recognition and Feature Descriptions ........................................................ 109 8.2 : GPU-based Object Recognition version 1.............................................................. 110 8.3 : GPU Based Object Recognition Version 2 ............................................................ 114 8.4 : Results and testing .................................................................................................. 116 8.4.1 : Match Accuracy test ........................................................................................ 116 8.4.2 : Match Speed Test ............................................................................................ 122 8.5 : Future Work ........................................................................................................... 124 Chapter 9 Conclusion .......................................................................................................... 126 Appendix A: Canny Edge Detection Shaders .................................................................... 129 Appendix B: ColourFAST Feature Detection Shaders .................................................... 132 Appendix C: ColourFAST Feature Tracking Shaders .................................................... 134 Appendix D: Feature Discovery Shader ............................................................................ 137 Appendix E: ColourFAST Object Recognition Shaders .................................................. 138 References ............................................................................................................................