The collection of number from a pulmonary capacity devices is realized through imaging method. The physical methods may cause unexpected inteference changing the location of the indicator so that the number is changed, but the imaging is a non-touching method and the accuracy can be enhanced.
the device(red one is the indicator)
Main steps:
After proper resize and rotate, choose an appropriate value to change the image to binary.
binary image
We can easily notice the red indicator cut the background black bar into two parts, which can be used to separate the bar into two parts.
Use canny algorithm to extract contours and check whther they are in a certain range of area and proper rectangle shape. Rectangle shape can be decided by comparing the contour area with the area of minimum rotated rectangle outside contour. A shape similar to rectangle has nearly the same of these two areas.
after canny
after checking shape and area
Measure the length and width of the two rectangles, the scale number can be calculated using linear transformation.