This project tackles the problem of distinguishing original QR codes ("First Print") from reprinted or counterfeit versions ("Second Print"). This type of QR code authentication is vital for building anti-counterfeiting systems in sectors such as packaging, product authentication, and secure document management.
We implement and compare:
- A traditional machine learning pipeline using PCA and SVM.
- A deep learning approach using transfer learning with MobileNetV2.
The dataset consists of two classes:
- First Print: Original QR codes embedded with copy detection patterns.
- Second Print: Scanned and reprinted copies of the originals (counterfeits).
Each image shows subtle differences in microstructures, print quality, and CDP degradation.
- Image quality stats: brightness, contrast, entropy
- Edge density, GLCM texture features
- Frequency analysis using FFT
- Local Binary Patterns (LBP)
- Histograms and edge comparisons
- PCA used for dimensionality reduction
- SVM (RBF kernel) trained on top principal components
- Achieved 95% test accuracy, confirmed with:
- Confusion matrix
- ROC curve (AUC = high)
- Cross-validation scores
- Used MobileNetV2 pre-trained on ImageNet
- Frozen initial layers, fine-tuned deeper layers
- Data augmentation for robustness
- Achieved 100% test accuracy
- Stress tested with blurred, noisy, and occluded QR codes
We used the following metrics for performance comparison:
- Accuracy
- Precision
- Recall
- F1-score
- Confusion Matrix
- ROC-AUC Score
- Misclassifications Analysis
CNN Model Confusion Matrix:
[[20 0]
[ 0 20]]
SVM Model Confusion Matrix:
[[18 3]
[ 0 19]]
pip install -r requirements.txt
- Traditional model:
code:
python svm_pca_model.pynotebook:svm_pca_model.ipynb - Deep learning model:
code:
python cnn_model.pynotebook:cnn_model.ipynb - EDA notebook: open
eda_analysis.ipynb
dataset/
├── First Print/
└── Second Print/
- MobileNetV2 is lightweight, ideal for edge devices
- Fast inference and robust to occlusion and distortions
- SVM model is simpler and suitable for CPU-only environments
Security implications such as tamper-proof hash binding and end-to-end encryption can further secure this pipeline in real-world systems.
- Kavish Patel kavishpatel1102@gmail.com
This project is licensed under the MIT License.