Design and Field-Programmable Gate Array Implementation of Streaming Contour-Geometry Architecture for Real-Time Classification of Five Geometric Shapes
Keywords:
FPGA, Hardware image processing, Image moments, Real-time vision, Shape classification, Streaming architecture, Verilog, VLSIAbstract
Real-time geometric shape classification is usually implemented in software with OpenCV, which gives no deterministic latency and needs a processor and a frame store. This paper presents a hardware realisation: a streaming Register-Transfer-Level (RTL) architecture, written in Verilog, that converts a raw RGB pixel stream into one of five shape labels (triangle, square, rectangle, pentagon, circle) or an Ellipse/Other label. The pipeline performs grey conversion, 5×5 binomial Gaussian filtering, frame-adaptive thresholding, 4-neighbour boundary extraction and raster accumulation of area and second-order moments at one pixel per clock; a short per-frame stage applies a rotation-invariant integer rule set on one shared 64-bit bit-serial multiplier/divider. The RTL matched a bit-accurate integer model over 600 consecutive 320×240 synthetic frames, and the original rule constants classified 97.7% of them correctly. To test generalisation, a Python reference model was evaluated on newly generated training, validation, test and domain-shifted sets (2,400, 1,200, 3,000 and 1,200 frames). The original constants reached 88.0% on the new test set; an error analysis traced the errors to corner erosion of rectangles and to the axis ratio of ellipses, and a refined rule set built on the moment ratio A²/det, an affine invariant, reached 100% on all four synthetic sets. Accuracy was unchanged by noise up to σ = 48 grey levels, illumination gradients, and contrast down to 25 levels, but fell sharply under cast shadows, background texture, and bright clutter, and the threshold stage failed on all six in-vocabulary real photographs. A Hu-moment decision tree reached 98.9% on the test set but lost accuracy faster under perspective. Place-and-route of the original sources for a Lattice ECP5 LFE5U-85F gave about 4,057 logic cells, 2,857 flip-flops, 7 block RAMs and 8 multipliers at 320×240, with a maximum clock of 79 to 81 MHz. The design was then rebuilt as a new RTL version (v2), simulated cycle by cycle against a bit-accurate integer model, and taken through an open-source synthesis and place-and-route flow. The post-route critical path was traced to the boundary-list memory and the decision-stage arithmetic, and three pipelining steps raised the maximum clock from 54–57 MHz to 88–97 MHz over six placement seeds, still below the 100 MHz target.
References
A. Mogelmose, M. M. Trivedi, and T. B. Moeslund, “Vision-Based Traffic Sign Detection and Analysis for Intelligent Driver Assistance Systems: Perspectives and Survey,” IEEE Transactions on Intelligent Transportation Systems, vol. 13, no. 4, pp. 1484–1497, Dec. 2012.
A. Ten Pas, M. Gualtieri, K. Saenko, and R. Platt, "Grasp pose detection in point clouds," The International Journal of Robotics Research, vol. 36, no. 13–14, pp. 1455–1473, Dec. 2017.
M. Moganti, F. Ercal, C. H. Dagli, and S. Tsunekawa, "Automatic PCB inspection algorithms: A survey," Computer Vision and Image Understanding, vol. 63, no. 2, pp. 287–313, Mar. 1996.
I. Abigo, E. O. Isaac, and B. Nkoi, "Application of artificial neural network in optimization of soap production," World Journal of Engineering Research and Technology, vol. 5, pp. 128–138, Dec. 2019.
I. Abigo, "Development and testing of a mosquito attracting, trapping and eliminating device," IRE Journals, vol. 7, no. 7, pp. 325–332, Jan. 2024.
O. E. Isaac, W. Fortune, and I. Abigo, "Development and optimization of multi-objective flow modelling of pipeline rate and corrosion defect used for oil and gas," World Journal of Advanced Engineering Technology and Science, vol. 20, no. 1, pp. 127–139, Jul. 2026.
I. Abigo, "Building-integrated photovoltaics (BIPV) technologies and mode of operation," International Journal of Engineering Applied Sciences and Technology, vol. 8, no. 8, pp. 29–33, 2023, ISSN 2455-2143.
I. Abigo, "Energy trading using blockchain technology for solar energy," Global Science Journal. (GSJ), vol. 12, no. 1, pp. 520–523, Jan. 2024.
S. Song, S. Lee, J. P. Ko, and J. W. Jeon, "A hardware architecture design for real-time Gaussian filter," in Proceedings of the IEEE International Conference on Industrial Technology (ICIT), Busan, South Korea, Feb. 2014, pp. 626–629.
Q. Xu, C. Chakrabarti, and L. J. Karam, “A Distributed Canny Edge Detector and Its Implementation on FPGA,” In 2011 Digital Signal Processing and Signal Processing Education Meeting (DSP/SPE), IEEE, Jan. 2011, pp. 500–505.
Z. Zhang, “Towards Real-Time High-Resolution Edge Detection: A Highly Efficient FPGA Implementation of the Canny Algorithm,” University of Illinois Urbana-Champaign, 2024.
A. Alhomoud, R. Ghodhbani, T. Saidani, H. M. Zayani, Y. Said, M. Ben Ammar, and J. Ben Slimane, "Model-based design of a high-throughput Canny edge detection accelerator on Zynq-7000 FPGA," Engineering, Technology & Applied Science Research., vol. 14, no. 2, pp. 13547–13553, Apr. 2024.
F. Zhao, H. Zhang Lu, and Z. Yong Zhang, “Real-Time Single-Pass Connected Components Analysis Algorithm,” EURASIP Journal on Image and Video Processing, vol. 2013, no. 1, Art. no. 21, Apr. 2013.
K.-H. Chang and R. Paramesran, “A Configurable Architecture for Fast Moments Computation,” Journal of Signal Processing Systems, vol. 78, no. 2, pp. 179–186, Oct. 2013.
C. Raffaitin, J.-S. Romero, J.-S. Romero, and L.-M. Procel, “Hardware Implementation of a Shape Recognition Algorithm Based on Invariant Moments,” Proceedings of the 32nd Symposium on Integrated Circuits and Systems Design, pp. 1–5, Aug. 2019.
A. Borja, F. Toscano, D. Cardenas, R. Taco, L. Trojman, and L. M. Procel, "720p-HD gray-scale and color images shape recognition system implementation on an FPGA platform with a 1080p Full-HD HDMI interface using a Hu moments algorithm," In Proceedings of the IEEE Andean Conference (ANDESCON), Quito, Ecuador, Oct. 2020.
G. Bradski and A. Kaehler, Learning OpenCV: Computer Vision with the OpenCV Library. Sebastopol, CA, USA: O'Reilly Media, 2008.
M. Everingham, L. Van Gool, C. K. I. Williams, J. Winn, and A. Zisserman, "The PASCAL visual object classes (VOC) challenge," International Journal of Computing, vol. 88, no. 2, pp. 303–338, Jun. 2010.
T.-Y. Lin, M. Maire, S. Belongie, J. Hays, P. Perona, D. Ramanan, P. Dollár, and C. L. Zitnick, "Microsoft COCO: Common objects in context," In Proceedings of the European Conference on Computer Vision, Zurich, Switzerland, Sep. 2014, pp. 740–755.
A. Rosebrock, Practical Python and OpenCV + Case Studies. PyImageSearch, Aug. 2016.
U. Ramer, "An iterative procedure for the polygonal approximation of plane curves," Computer Graph Image Process., vol. 1, no. 3, pp. 244–256, Nov. 1972.
R. J. Prokop and A. P. Reeves, "A survey of moment-based techniques for unoccluded object representation and recognition," CVGIP: Graph. Models Image Process., vol. 54, no. 5, pp. 438–460, Sep. 1992.
S. Belongie, J. Malik, and J. Puzicha, "Shape matching and object recognition using shape contexts," IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 24, no. 4, pp. 509–522, Apr. 2002.
L. J. Latecki and R. Lakamper, "Shape similarity measure based on correspondence of visual parts," IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 22, no. 10, pp. 1185–1190, Nov. 2000.
M. K. Hu, "Visual pattern recognition by moment invariants," IRE Transactions on Information Theory, vol. 8, no. 2, pp. 179–187, Feb. 1962.
R. C. Gonzalez and R. E. Woods, Digital Image Processing, 4th ed. New York, NY, USA: Pearson, 2018.
D. H. Douglas and T. K. Peucker, "Algorithms for the reduction of the number of points required to represent a digitized line or its caricature," Cartographica: The International Journal for Geographic Information and Geovisualization, vol. 10, no. 2, pp. 112–122, Dec. 1973.
J. Redmon and A. Farhadi, "YOLOv3: An incremental improvement," Arxiv:1804.02767, Apr. 2018.
J. Canny, "A computational approach to edge detection," IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 8, no. 6, pp. 679–698, Nov. 1986.
K. He, X. Zhang, S. Ren, and J. Sun, "Deep residual learning for image recognition," in Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Las Vegas, NV, USA, Jun. 2016, pp. 770–778.
S. Suzuki and K. Abe, "Topological structural analysis of digitized binary images by border following," Computer Vision, Graphics, and Image Processing, vol. 30, no. 1, pp. 32–46, Apr. 1985.
M. Sandler, A. Howard, M. Zhu, A. Zhmoginov, and L.-C. Chen, "MobileNetV2: Inverted residuals and linear bottlenecks, " in Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Jun. 2018, pp. 4510–4520.
E. B. Wilson, "Probable inference, the law of succession, and statistical inference," Journal of the American Statistical Association, vol. 22, no. 158, pp. 209–212, Jun. 1927.
F. Pedregosa et al., "Scikit-learn: Machine learning in Python," Journal of Machine Learning Research, vol. 12, pp. 2825–2830, Oct. 2011.
E. P. Onen, E. B. Nzubechukwu, T. Enibo, N. J. Divinefavour, and N. L. Emmanuel, "Drone-based shape recognition and identification (10 shapes)," Group 6 project report, MCE 514 Machine Vision, Dept. Mechatronic Eng., Federal Univ. Otuoke, Nigeria, 2026.
J. Flusser and T. Suk, "Pattern recognition by affine moment invariants," Pattern Recognition, vol. 26, no. 1, pp. 167–174, Jan. 1993.
H. Ishii and B. Ullmer, “Tangible Bits,” Proceedings of the SIGCHI conference on Human Factors in Computing Systems - CHI ’97, vol. 1, no. 1, 1997.
N. Otsu, "A threshold selection method from gray-level histograms," IEEE Transactions on Systems, Man, and Cybernetics, vol. SMC-9, no. 1, pp. 62–66, Jan. 1979.
I. Abigo, T. Faisal, M. Iwan, H. M. Al-Assadi, and H. Ramli, "Programming ABB industrial robot for an accurate handwriting," In Latest Advances in Systems Science and Computational Intelligence. Athens, Greece: WSEAS, may. 2012, pp. 80–85.