Flour Bag Counting System Based on Machine Vision

Advanced Materials Research
ISSN: 1662-8985, Vols. 562-564, pp 1625-1629
doi:10.4028/www.scientific.net/AMR.562-564.1625
© 2012 Trans Tech Publications, Switzerland
Online: 2012-08-30
Flour Bag Counting System Based on Machine Vision
Chunxia Ma 1, a, Wenhe Song *2,b , Jun Wu 3, Yue Wang 4, Zhitao Xiao 5
1
Engineering Teach Practice Training Center, Tianjin Polytechnic University, Tianjin 300387, China
2,5
Graduate School, Tianjin Polytechnic University, Tianjin 300387, China
3,4
School of Electronics and Information Engineering,Tianjin Polytechnic University, Tianjin
300387, China
a
[email protected], b [email protected]
Keywords: Machine vision, Image processing,Video capture
Abstract. According to the specific characteristics of Flour Plant production line, the bag counting
system for Flour Plant based on Daheng Image acquisition card DH-CG410 and Microsoft VC++
2005 platform is designed. Using digital image processing technology, the system can be used to
detect flour bag by analyzing real-time acquisition video of the flour bag. So it is available for flour
production counting. Test results show that the system has the advantages of stable working state,
high detection accuracy, high processing speed. It can systematize and standardize the Flour Plant
flour bag counting process.
Introduction
In modern industrial production, providing the accurate number of raw materials or finished
product is a critical problem. At present, the method of “electric field induction” is still used to
statistic the number of flour bags in most of the flour production line [1]. The disadvantages of this
counting method include: (1) When two flour bags are superimposed each other or three flour bags
are appressed together, the counting will go wrong; (2) It is unable to distinguish between big bag
and small bag so as to count respectively. To solve these problems, the automatic counting bag
system for flour production line based on machine vision is designed.
1 Introduction of machine vision detection system
Machine vision is to use machines instead of human eyes to measure and judge. The machine
vision system uses the machine vision products (that is Image acquisition devices, CMOS and
CCD) to make consumed target convert into image signal and send the image signal to a dedicated
image processing system. According to the distribution of pixel, brightness, color and other
information, image signal is turned into digital signal. Imaging processing system can extract the
characteristics of the target by processing these digital signals. Then the judgment results are used
to control the movement of equipment at the scene.
Because machine vision system can quickly obtain large amounts of information and can be
easy for automatic processing and integrating with the design information and process control
information, it is widely used in the field of condition monitoring, finished product testing and
quality control in the process of modern automated production [2-4].
All rights reserved. No part of contents of this paper may be reproduced or transmitted in any form or by any means without the written permission of Trans
Tech Publications, www.ttp.net. (ID: 130.203.136.75, Pennsylvania State University, University Park, USA-18/05/16,06:02:03)
1626
Materials Engineering and Automatic Control
2 The Method of Flour Bag Detection and Counting
2.1 The General Design Scheme of Detection
Video camera is placed above the belt in the Flour Plant workshop and is used to collect
real-time video. The real-time video is sent from the video capture card to the industrial computer.
Flour bag detection and counting can be achieved by using prepared software in the industrial
computer. Finally, the real-time data is displayed in the program interface and stored in the
database.
2.2 The Size Setting of Image Acquisition
The size of acquisition image is set to 768 × 300, which can contain a single small bag, or a
single large bag, or two superimposed large bags. Two not superimposed large bags will not be
contained, so it is easy for count processing.
2.3 The Processes of Detection and Counting
The algorithm of flour bag detection and counting is shown in Fig. 1.
Fig. 1
The flow chart of flour bag detection and counting algorithm
The specific process is as follows:
(1) Image conversion. Using only the image intensity information in the image processing, we
need to convert the color video frame collected from the color video camera to grayscale images.
(2) Noise filtering. There is large amount of dust in the process of production in Flour Plant
workshop. The dust has bad effect for the quality of acquisition image. Therefore, Gaussian filter is
used to smooth image.
(3) Initial background construction. When detection just started, there is no flour bag to enter the
scene; the first grayscale image frame G ( x, y ) by noise filtering is saved as a background image [5].
Background image can be represented as B( x, y ) , x and y are the row and column numbers of pixels
in an image.
(4) Flour bag detection. Flour bag Detection is start from the current frame.
(a) Foreground detection. Since the beginning of second frame, the image G ( x, y ) and the
background image B( x, y ) are done by the absolute difference as follow:
D ( x, y ) =| G ( x, y ) − B( x, y ) |
(1)
The foreground image F ( x, y ) can be obtained by binary processing to the operation result D( x, y ) .
The foreground image may include flour bag, but may also include spot on the conveyor belt,
reflective, discoloration and other interference. Binarization threshold is taken as 30 which have
been tested.
(b) Morphological processing. The opening and closing operations in the mathematical
morphology are performed to filtrate the noise which is generated by the interference in the
foreground image and to fill connected domain internal hole [6]. Image processing results is
represented as FM ( x, y ) .
Advanced Materials Research Vols. 562-564
1627
(c) Vertical projection processing and strip interference filtering. Vertical projection
processing is performed in the image FM ( x, y ) . The larger projection range which can be gotten from
the projection results can be used to determine the left and right margins of flour bag region. The
specific process is as follows: It is assumed that the image size is rows × cols . A one-dimensional
array can be gotten by accumulating the pixel gray value on the columns in image FM ( x, y ) . The
one-dimensional array, which is called a vertical projection array, is defined as
ro w s
PV ( x ) =
∑
F M ( x , y ), y = 1, ..., co ls
(2)
The method to determine the left and right margins of flour bag region is as follow: the array
PV ( x) is the first derivative of the PV′ ( x) . The left margin position is identified as the yl ,
yl = min( y | PV′ ( y ) > 0) ,y = 1,..., cols ; The right margin position of the target area is identified as the yr ,
yr = max( y | PV′ ( y ) < 0) , y = 1,..., cols .
The regional pixel values of outside the range in the Image FM ( x, y ) are all set to 0 to remove
the interference of horizontal strips on the conveyor belt. The result image is represented as
FMR ( x, y ) .
(d) Detection of the connected domain. The connected domain is detected in the
image FMR ( x, y ) . And the number of connected domain is counted.
(e) The flour bag region labeling. If the number of connected domains is larger than 0, the
current frame contains the flour bag. And flour bag in the foreground area is represented by the
minimum bounding rectangle. Video frame and the flour bag region detection results are shown in
Fig.2.
(5) Flour bag count. If the flour bag appears in the current frame, it needs to determine that is the
large bag, a single small bag or two superimposed large bags, and respectively statistics of the
number of both large bags and small bags.
(a) The calculation of flour bag area. The area of the minimum bounding rectangle in the flour
bag is calculated. That is, the total number of pixels is calculated. The area of flour bag is
represented by Area.
(b) The calculation of area ratio. Flour bag region area Area divided by the total area of the
entire image (the number of pixels of the entire image). And the ratio of flour bag region accounted
for the whole image is Ratio.
(c) Background update. Because of the camera moving, the light changing and so on, These
factors can cause the scene changed. Then the proportion of the area will reach the largest value of
0.95, which is tested by experiment. There is need for background update. Specific method is
weighted the original background image and the current video frame. Update formula is as follow:
y =1
Bnew ( x, y ) = Bold ( x, y ) × 0.95 + F ( x, y ) × 0.05
(3)
(d) The maximum of area ratio calculating. In the process of a flour bag getting into the scene
until moving out of the scene, the image area Ratio of continuous several frame will be from 0
before entering the scene and change to a smaller value when its part into the scene, and then
increase to maximum of flour when bag full occurrence, and reduce to the smaller value when its
part out of the scene, until 0 when it completely getting out of the scene. Therefore, the initial value
of the maximum area ratio is set to 0. When the area ratio of current frame is greater than 0.1, we
deem that the flour bag start to enter the scene and the maximum area ratio is start to recorded. If
the current frame area ratio is greater than the proportion of area saved value of the previous frame,
the maximum area ratio is reset to the current frame. The calculating process is continued until the
1628
Materials Engineering and Automatic Control
current frame area ratio is less than 0.1. At this time, we deem that the flour bag has been removed
out. The maximum area ratio also stops changing. The maximum area ratio Ratio_max achieved in
the detection processing is just the proportion of the flour bags accounted for the whole image.
(e) The count processing. According to the maximum area ratio Ratio_max, that is the
proportion of the size of the flour bag, the detected result can be determined. The flour bag in the
belt is a single small bag, a large bag or superposition of two large bags. According to the large
number of experiments, the maximum proportion of a single small bag is in the range (0.2, 0.3), the
maximum proportion of a single large bag is in the range (0.35, 0.6), and the maximum proportion
of two superimposed large bags is in the range (0.7, 0.8). If the area ratio of the maximum belongs
to the scope of a single small bag, the number of small bag plus one; if the area ratio of the
maximum belongs to the scope of a single large bag, the number of large bag plus one; if the area
ratio of the maximum belongs to the scope of superimposed large bags, then the number of large
bag plus two.
3 The Implementation of Counting Bag System
3.1 The Overall Objective of System
The flour bag on production line in the Flour Plant can be detected. When two flour bag
stacked or three flour bags are close to each other, it can also accurately count. It is able to
distinguish between large bag and small bag, and count respectively.
3.2 Hardware Components of System
(1) DH-CG410 High-performance color / monochrome acquisition card
(2) WV-CP240EX Surveillance camera
(3) AVENIR lens
The AVENIR SSV0358GNB lens is chosen. Its image size is 1/3 ", focal length is 3.5-8.0mm,
aperture range is F1.4-360, aperture control mode is automatic DC drive, focus control mode and
the zoom control mode are manual drive, perspective(D×H×V) is individually1/3 inch, Wide81.9°×
59.4°and Tele 35.0°× 26.1°, the shortest thing distance is 0.3 m, after the focal length is 7.9 mm,
the interface type is CS, the size (D x L) is Φ35 × 46 × 46.5, and its weighs is 74 grams. The lens is
very suited for the Flour Plant monitoring.
3.3 Software Development Environment
The video capture program is based on the DH-CG410 acquisition card. In the Microsoft
Visual C + + 2005 development environment, the detection algorithm is achieved by calling the
function of the machine vision library 1.0 version OpenCv.
4 Test Results and Analysis
In this paper the design automatic counting bag system has been installed and tested for long
time in Shandong province Jining city Flour Plant Company. The real-time video detection results
are shown in Fig.2. Where (a) is the background image established for the algorithm, (b) and (c) are
the video frames, (d) and (e) are the test results of the video frames. It can be seen that the algorithm
can detect flour bags from video, and use the rectangle surround the flour bag region.
The test results show that the design system is stable and the average detection accuracy reaches
99%. It takes about 30ms to deal with a frame, and takes about 40ms to deal with a frame of the
PAL duration image. Detection and counting flour bag can be completed within the time interval in
the image acquisition. And the algorithm can meet the real-time requirement.
Advanced Materials Research Vols. 562-564
(a) back ground image
(b) video frame 1
(d) detection result of video frame 1
Fig. 2
1629
(c) video frame 2
(e) detection result of video frame 2
Detection results
5 Conclusions
Flour bag counting system provides a reliable data for the Flour Plant production management. It
can improve the production management level and information technology, standardization of flour
production management step by step. And it makes production management personnel free from the
traditional heavy manual work, improves the efficiency of work and has achieved a better effect.
References
[1] Wang Weisheng, Sun Jianwen, Zheng Zelin, Li Bingsheng. Monitoring and administration
System for Flour Plant Based on industrial Ethernet and site bus [J]. Grain Processing, 2011,
36(1):66-69.
[2] Xiong Guangjie, Ma Shuyuan, Nie Xuejun, Wu Siyuan, Tang Xiaohua. Defects inspection
system of HID PCB based on machine vision [J]. Computer Measurement & Control, 2011,
19(8):1824-1826.
[3] Wang Xiaodong, Song Hongxia, Liu Chao, Luo Yi. Automatic measurement and assembly of
miniature parts based on machine vision [J]. Journal of Harbin Engineering University, 2011,
32(9): 1117-1122.
[4] Liu Jianjun, Yao Lijian, Peng Zhanglin. Detection technique for Cathay hickory grade based on
machine vision [J]. Journal of Agriculture Zhejiang, 2010, 22(6):854-858.
[5] Fan Xiaoliang, Yang Jinji. Background extraction and update algorithm based on
frame-difference [J]. Computer Engineering, 2011, 37(22):159-161.
[6] Shi Wen, Du Yuren. License plate localization method based on mathematical morphology and
color features [J]. Journal of Yangzhou University, 2010, 13(3):69-73
Materials Engineering and Automatic Control
10.4028/www.scientific.net/AMR.562-564
Flour Bag Counting System Based on Machine Vision
10.4028/www.scientific.net/AMR.562-564.1625