Quality control is an important process in all manufacturing industries. Normally, it includes checking the final product on sample basis and confirming whether the whole lot is suitable for dispatch or not. However, it is not a foolproof method to ensure quality as:
1. The whole lot is judged on the basis of a few samples. There is a possibility that the samples selected conform to quality standards but many others in the lot don’t.
2. Quality judgement depends on the expertise of the person checking the samples.
That is where computer vision comes into play. With systems using computer vision to judge the quality, you can implement 100 per cent quality check independent of human interference. The computer vision system presented here for quality control of blister-packed medical pills is just a proof of this concept, which can be used across industries after appropriate adjustment.
This camera-based system takes pictures of the product, which are analysed after image extraction through image processing and checked against quality standards. In case of blister packing, manufacturers need to check whether all the blisters have been filled with unbroken tablets. The system automatically checks the number of pills through the camera and indicates if the number is less than expected.
The software for this system is written in Python and uses SimpleCV image processing library. Even beginners can easily get started with computer vision as all the steps, from installation, program creation to running the program, have been detailed here. The software was successfully tested on Windows 7 and Windows 10 environments. With little adjustment, it can be made to work on Linux systems as well.
The software and hardware prerequisites to run this program are:
1. Python 2.7.11
2. Python added to path environment variable
3. SimpleCV and its dependencies
4. USB camera (you can also use the one in your laptop but testing with USB camera is easier)
5. Windows 7/10 system
The steps to install Python and add it to the path environment are the same as given in the ‘Time For a Break’ article published in March issue, hence not detailed here.
SimpleCV is an easy-to-use image processing library. It is a Python framework that bundles together open source computer vision libraries and algorithms. Installing SimpleCV is relatively easy on Windows. Follow the steps below:
1. Download SimpleCV Version 1.3 Superpack from http://simplecv.org/download/ link as shown in Fig. 2. The Superpack already has all the dependencies bundled into it for installation. The dependencies for SimpleCV are:
• Python 2.7.3
• Python Setup Tools
2. Once SimpleCV is downloaded, double-click the file to start installation. This will install SimpleCV and all the dependencies one by one
3. Download Python Imaging Library (PIL) for Python 2.7 from http://www.pythonware.com/products/pil/ as shown in Fig. 3 and install it
Run command prompt (as administrator), type in SimpleCV and press Enter. SimpleCV shell should appear now for accepting commands as shown in Fig. 4.
As the recent version of SimpleCV doesn’t work well with the latest version of ipython, you need to uninstall the latest version of ipython and install an older one using below commands under C:\Windows\Systems32:[stextbox id=”info”]
> pip uninstall ipython
> pip install ipython==4.2.0
(Before you run these commands in command prompt, you need ‘pip’ already installed. You can install it by using >python -m pip install -U pip command.)
Setup for USB camera
You need to complete the setup before proceeding further. The setup is simple, requiring just a USB camera attached to a laptop or PC. This project used a regular USB webcam, which is easily available in the market. Plug in the camera and check whether it is detected in Device Manager (Fig. 5). The camera should be mounted such that it does not move and captures the whole tablet pack underneath. No additional lighting is required. The camera effectively captures images in low lighting as well.
Run the command prompt as an administrator, type SimpleCV and press ‘Enter.’
Once you get SimpleCV shell, type the following commands to test the camera (Fig. 6):[stextbox id=”info”]>cam = Camera(0)
>img = cam.getImage()
If you get images from the USB camera, your camera has been detected as Camera(0) by the operating system. Otherwise, change Camera(0) to Camera(1) in above commands and try again. The reference camera is used in the software.
Python IDE, which comes with Python installation, is used to write, test and debug Python programs. When Python is run, it opens up a Python Shell window as shown in Fig. 7.