Our demo's main script takes everything we have learned in this chapter about ANNs and MNIST and combines it with some of the object detection techniques that we studied in previous chapters. Thus, in many ways, this is a capstone project for us.
Let's implement the main script in a new file called detect_and_classify_digits.py:
- To begin, we will import OpenCV, NumPy, and our digits_ann module:
import cv2import numpy as npimport digits_ann
- Now, let's write a couple of helper functions to analyze and adjust the bounding rectangles of digits and other contours. As we have seen in previous chapters, overlapping detections are a common problem. The following function, called inside, will help us determine whether ...