Zing Forum

Reading

VisionInspect-AI: A Machine Learning-Based Visual Inspection System for Smartphone Screen Defects

A complete pipeline for detecting smartphone screen cracks using OpenCV and classic machine learning models, including a real-time Streamlit demo

计算机视觉机器学习OpenCV缺陷检测质量控制LBP特征SVM随机森林Streamlit图像处理
Published 2026-05-16 03:26Recent activity 2026-05-16 03:32Estimated read 6 min
VisionInspect-AI: A Machine Learning-Based Visual Inspection System for Smartphone Screen Defects
1

Section 01

VisionInspect-AI Project Introduction

VisionInspect-AI is an intelligent visual inspection system for quality control in manufacturing, focusing on the automatic identification of crack defects on smartphone screens. Developed by the ifra817 team, it uses classic machine learning algorithms combined with computer vision technology to build a complete solution from image preprocessing to real-time detection. The tech stack includes Python 3.10+, OpenCV, scikit-learn, and Streamlit, which can be used as an academic reference case or for industrial quality inspection prototype verification.

2

Section 02

Project Background and Overview

This project targets quality inspection scenarios in manufacturing, aiming to realize automatic identification of smartphone screen cracks. The tech stack is mature and stable, with clear code structure and complete documentation. It is suitable for both academic research reference and providing quality inspection prototype verification for small manufacturing enterprises.

3

Section 03

Technical Architecture and Preprocessing Pipeline

The core architecture is a pipeline design: Raw images undergo OpenCV preprocessing (unified scaling to 128×128, grayscale conversion, 5×5 Gaussian blur for noise reduction, Canny edge detection (thresholds 50/150), normalization to the 0-1 range), then feature extraction, classifier training, and finally building an interactive application via Streamlit. The modular design supports subsequent upgrades to deep learning models.

4

Section 04

Feature Extraction and Multi-Model Comparison

Feature extraction uses LBP (radius 3, 24 sampling points, generating a 26-dimensional normalized histogram) and edge density (4×4 grid, 16-dimensional regional edge proportion), which are concatenated into a 42-dimensional feature vector. Three classifiers are trained and compared: KNN (5 neighbors), SVM (RBF kernel + grid search optimization), and Random Forest (200 trees). Tuning is done via 5-fold cross-validation, features are standardized with StandardScaler, and users can switch models for comparison in Streamlit.

5

Section 05

Dataset and Model Evaluation

The Kaggle dataset "Cracked and Intact Smartphone Images" is used. It is recommended to have 300-500 images per class, divided into training/validation/test sets in a 70%/15%/15% ratio. If data is insufficient, augmentation via OpenCV (flip, brightness jitter, slight rotation) can be applied. Evaluation metrics include accuracy, precision, recall (key point to avoid false negatives), F1 score, ROC-AUC, and confusion matrix visualization is provided.

6

Section 06

Streamlit Application and Deployment

The Streamlit web application includes 4 pages: Prediction (single image upload/real-time camera, displaying intermediate results and confidence), Real-time Demo (continuous camera frame processing, frame rate + heatmap, etc.), Model Comparison (interactive charts showing metrics), and Evaluation Metrics (confusion matrix, ROC curve, etc.). Deployment steps: Clone the repository → Create a virtual environment → Install dependencies → Run streamlit run app.py. An alternative is the pure OpenCV version demo_live.py.

7

Section 07

Application Scenarios, Limitations, and Recommendations

Applicable scenarios: Computer vision/ML teaching cases, quality inspection prototypes for small manufacturing enterprises. Limitations: Traditional ML has insufficient generalization ability (for complex defects), and relies on fixed shooting conditions. Production deployment recommendations: Test cameras/lighting in advance, prepare an OpenCV alternative, perform data augmentation (when data is insufficient), continuously monitor model performance and retrain regularly.