Method and apparatus for recognizing bar codes
BACKGROUND OF THE INVENTION 
     The present invention relates to a system for recognizing bar codes having wide and narrow bars, and more particularly to a system in which a threshold value for discriminating each bar width is corrected automatically. 
     A bar code recognition system in which an information is coded into a bar code and each information is recognized by scanning each bar code is known well. It is also a well known matter in this prior art system that the bar code is scanned and converted into a rectangular signal having a time width proportional to each bar width, and the bar width is discriminated by comparing each time width of the rectangular signal with a threshold value, thus decoding the bar code. The threshold value is predetermined to be constant in general, therefore the validity of decoded information becomes low when, for instance, some of bar codes are recorded smaller than the other. 
     SUMMARY OF THE INVENTION 
     It is, therefore, a primary object of the invention to provide a bar code recognition system in which a threshold value for discriminating the bar width is automatically corrected. 
     It is another object of the invention to correct the threshold value in accordance with total bar widths of bars scanned in one scanning cycle. 
     It is a further object of this invention to correct the threshold value in proportion to total widths of bars detected in the preceding scanning cycle. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     In the accompanying drawings: 
     FIG. 1 is a schematic view illustrating a bar code recognition system according to the present invention; 
     FIG. 2 is an enlarged plan view illustrating the information card shown in FIG. 1; 
     FIG. 3 is an enlarged view illustrating two group bar codes recorded on the card shown in FIG. 2; and 
     FIG. 4 is an electric wiring diagram illustrating the detail construction of the electric circuit portion shown in FIG. 1. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     The overall construction of the system is described at first with reference to FIG. 1. 
     In FIG. 1, a light source 10 such as a reflector lamp is employed to uniformly supply illumination light 10a over a card 70 by which bar codes 70b are carried. A lens 20a for converging the reflection light 10b reflected by the card 70 and an image sensor 20 having a plurality of light responsive elements aligned to constitute a straight scanning line 20b for receiving the converged light are optically coupled over the card 70. The bar codes 70b has a plurality of bars arranged parallelly on the card 70. The card 70 is moved in a direction 70a which is parallel with the longitudinal direction of the bars and orthogonal to the scanning line 20b of the image sensor 20. The image sensor 20 is connected to a clock circuit 50 so that each element of the image sensor 20 is driven one by one in response to each clock pulse of a fixed frequency generated by the clock circuit 50 and generates an image signal having the signal level corresponding to the light density of the reflected light 10b. The elements of the image sensor 20 are further adapted to be driven in a cyclic manner so that each bar code on the card 70 is scanned repeatedly. It should be noted that the image signal generated by the image sensor 20 is not affected by variations in the moving speed of the card 70, because the bar code scanning direction is orthogonal to the card moving direction 70a. The image sensor 20 is connected to an analog circuit 30 in which the image signal successively applied from the image sensor 20 is converted into a rectangular signal having the signal level and the time width corresponding to the density and the width of the reflected light 10b, respectively. It must be understood herein that the level and the width of the rectangular signal respectively represent the light reflectivity and the width of bars of the bar codes 70b, since the light density of the reflected light 10b is dependent on the light reflectivity of the bars. A digital circuit 40 is connected to receive the rectangular signal from the analog circuit 30 and clock pulses from the clock circuit 50, for converting the serial rectangular signal into a parallel digital signal which is available for signal processing operation in a central processing unit 60. The central processing unit 60 is constructed as a digital computer in which bar code decoding process is programmed. A card detector 80 is positioned beneath a card moving passage (not shown) to detect the existence of the card 70. The card detector 80 generates a detection signal indicative of the existence of the card 70, when the illumination light 10a is cut off by the card 70. This detection signal is applied to the central processing unit 60 which is adapted to start decoding process. 
     In the digital circuit 40, numeral 41 denotes a threshold circuit for determining the threshold value in response to the time width of the rectangular signal applied during each scanning cycle of the image sensor 20, 42 denotes a counter circuit for measuring the width of each bar by counting the clock pulses during each time width of the rectangular signal, and 43 denotes a discrimination circuit for discriminating each bar width by comparing the output value of the counter circuit 42 with the threshold value determined by the threshold circuit 41. The discrimination result with respect to each bar is represented by a binary number &#34;1&#34; or &#34;0&#34; which is an output of the discrimination circuit 43. Further in the digital circuit 40, numeral 44 denotes a shift register for sequentially storing the binary output of the discrimination circuit 43, and numeral 45 denotes a buffer register for temporarily storing the binary output of the shift register 44 at every time when the shift register 44 completes storing as many numbers of discrimination outputs as bars in each bar code. 
     The bar codes 70b schematically illustrated in FIG. 1 are described next with reference to FIGS. 2 and 3. 
     As shown in FIG. 2, twelve group bar codes (  , 0, 1, 2, . . . . , 8, 9, *) are juxtaposed from the head (left side in the Figure) to the tail (right side in the Figure) of the card 70. The group bar code is spaced from the adjacent group bar code by a predetermined width. Each group bar code lying in the central portion of the card 70 includes four bar codes which are divided by a dotted line in the Figure. 
     Two exemplary group bar codes (  and 9) are shown in FIG. 3 in which two space bars SB are illustrated at the head and the tail of each group. Each bar code has seven bars among which four bars are recorded in black and three bars are recorded in white. Each white bar in one bar code is arranged between the black bars so that each bar code starts with the black bar and ends with the black bar. Further among seven bars, constituting one bar code which is a numerical bar code, five bars are determined to be narrow (N) and two bars are determined to be wide (W) in such a manner that the wide bar is three times wider than the narrow bar. One wide bar and the other wide bar between two wide bars are recorded in black and in white, respectively. The space bar SB is determined to be a narrow bar in black and a narrow bar in white is interposed between the adjacent bar codes. A narrow bar in white is interposed between the space bar SB and an index bar code such as   and *, whereas a wide bar in white is interposed between the space bar SB and the numerical bar code such as 1, 2, . . . 9. Each group bar code including two space bars SB, as a result, has the constant length 53 N. It should be noted herein that the first and the twelfth group bar codes have respective index bar codes and * which includes three wide bars. These index bar codes   and * are advantageous in that whether the scanning direction is forward or reverse is discriminated. Record prohibition spaces having the width 6 N are provided beside each group bar code. 
     The operation mode of the system shown in FIG. 1 is described on condition that the card 70 carrying the bar codes shown in FIG. 3 is moved to be scanned. 
     When the card 70 is moved over the card detector 80, the card detection signal is generated by the detector 80 and the central processing unit 60 is rendered operative by the detection signal. During the movement of the card 70, the first group bar code having the index bar code   is supplied with the illumination light 10a thereon and the reflection light 10b having the light density which is dependent on the color of the bar is received at the sensing line 20b of the image sensor 20. The image sensor 20 having light responsive elements which are driven one by one by the clock pulse generates the image signal corresponding to the reflection light 10b. Four light responsive elements are alotted for scanning the reflection light 10b reflected by the narrow bar and twelve light responsive elements are allotted for scanning the reflection light 10b reflected by the wide bar. Therefore, 4 pulses and 12 pulses of the clock circuit 50 are necessitated for scanning the narrow bar and wide bar, respectively. The image signal is then applied serially to the analog circuit 30 and converted into the rectangular signal. This rectangular signal becomes high level and low level while the black bar and the white bar are scanned, respectively. This rectangular signal has a time width which is substantially proportional to the bar width. The rectangular signal is then applied serially to the digital circuit 40 to be converted into the parallel digital signal. In this digital circuit 40, the time width of the rectangular signal is discriminated whether it corresponds to the wide bar or the narrow bar so that each digit of the parallel digital signal represents each bar width and that the wide bar and the narrow bar are represented by the respective low level &#34;0&#34; and high level &#34;1&#34;. Therefore, the index bar code   shown in FIG. 3 is converted into the parallel digital signal &#34;1100101&#34;. Other numerical bar codes among the first group bar code are also converted into the parallel digital signal in the same manner as the index bar code  . After scanning the first group bar code repeatedly, the other group bar codes are scanned sequentially from the second group to the last group in the same manner as the first group. 
     It should be noted in the above described operation that the time width of the rectangular signal is discriminated with reference to the threshold value which is corrected in accordance with the total time width of the rectangular signal generated in one scanning cycle. Provided that each bar is recorded precisely on the card 70, the threshold value is desirably determined to be the medium value (2 N) between the narrow bar width (N) and the wide bar width (W=3 N). The threshold value must be increased and decreased proportionally as the bar width increases and decreases, respectively. The threshold values H w  and H B  for respective white bar and black bar are corrected in accordance with the total width L w  of the white bars and the total width L B  of the black bars in each group bar code, respectively. Since the total width L w  including five spaces in white becomes 27 N and the total width L B  including two space bars in black becomes 26 N when all the bar codes are recorded desirably as described in detail with reference to FIG. 3, the threshold values H w  and H B  are corrected according to the following equations. 
     
         H.sub.w =2N ·(L.sub.w /27 N)=(2/27)·L.sub.w 
    
     
         H.sub.B =2 N·(L.sub.B /26 N)=(2/26)·L.sub.B 
    
     the detail construction of the system shown in FIG. 1 is shown in FIG. 4 with reference to which further description is made. 
     The clock circuit 50 is constituted by an oscillator 51, a signal distributor for distributing the clock pulses T 0  and T 2  which are equal in frequency and different in phase, a signal reshaper 53 for reshaping the clock pulse T 0  to generate the clock pulse T 1  and a driver 54 for driving the image sensor 20 by the clock pulse T 1 . The image sensor 20 has 512 photo diodes as the light responsive elements which are sequentially rendered operative by the clock pulse T 1 . The analog circuit 30 is constituted by an amplifier 301 for amplifying the image signal and a signal reshaper 302 for converting the amplified image signal into the rectangular signal which has the high level indicative of the black bar and the low level indicative of the white bar. 
     The threshold circuit 41 is constituted by an OR gate 41a for passing both clock pulses T 0  and T 2 , an inverter 41b for inverting the signal level of the rectangular signal, and AND gate 41c for passing the clock pulses only when the rectangular signal level is high, another AND gate 41d for passing the clock pulses only when the rectangular signal level is low, a frequency divider 41e for frequency dividing the clock pulses in one twenty-sixth, a counter 41f for counting the frequency-divided pulses, a register 41g for storing the count value of the counter 41f, another frequency divider 41h for frequency dividing the clock pulses in one twenty-seventh, another counter 41i for counting the frequency-divided pulses, another register 41j for storing the count value of the counter 41i, and a selector 41k for selecting either the output value of the register 41g or the output value of the register 41j. Since the AND gate 41c passes the clock pulses T 0  and T 2  while the rectangular signal level is high indicative of the black bar and the clock pulses T 0  and T 2  are frequency divided in one twenty-sixth, the count value of the counter 41f becomes equal to the value 2·L B  /26 which is the threshold value H B . The count value of the counter 41i similary becomes equal to the value 2·L w  /27 which is the threshold value H w , since the clock pulses T 0  and T 2  are frequency-divided in one twenty-seventh by the frequency divider 41h while the rectangular signal level is low indicative of the white bar. These threshold values H B  and H w  are stored in the registers 41g and 41j, respectively. 
     The counter circuit 42 is constituted by a digital filter 42a for eliminating a noise pulse having a time width shorter than the one cycle period of the clock pulse T 1 , a lever change detector 42b for detecting the level change of the rectangular signal and generating a detection pulse, a group scan detector for counting the detection pulse and generating a command signal when the count value thereof reaches thirty-six indicative of the completion of one scanning for one group bar code including the space bars SB, a space detector 42d for detecting a record prohibition space (6 N) allotted in the left side of the card 70 in FIG. 3 and generating a clear signal when 24 clock pulses are counted during the one cycle period of the detection pulse, a delay circuit 42e for delaying the rectangular signal applied through the digital filter 42a by a predetermined time period which is equal to one scanning cycle period of the image sensor 20, another level change detector 42f for detecting the level change of the delayed rectangular signal and generating a detection pulse, a code scan detector 42g for counting the number of detection pulses and generating a command signal when the count value thereof reaches eight indicative of the completion of one scanning for one bar code, another space detector 42h for detecting a record prohibition space (6 N) allotted in the right side of the card 70 in FIG. 3 and generating a clear signal which presets -1 in the code scan detector 42g, and a bar width counter 42i for counting the clock pulse T 0  during one cycle period of the detection pulse generated by the level change detector 42f. 
     The operation mode of the digital circuit 40 is described hereinunder. 
     It is first assumed that the card 70 is moved in such a direction that the scanning is attained from the group bar code having the index code   to the group bar code having the index code * which are shown in FIG. 2. The image sensor 20, driven by the clock pulse T 1 , scans the first group bar code having the index code   at a constant speed from the left to the right of the card 70 shown in FIG. 3. While the first group bar code is scanned for the first time, the rectangular signal generated by the analog circuit 30 is delayed by the delay circuit 42e and resultantly the discrimination circuit 43, the shift register 44 and the buffer register 45 does not start to operate. On the contrary, the threshold circuit 41 starts to operate in the following manner. While the left record prohibition space (6 N) of the card 70 is scanned, the analog circuit 30 keeps producing low level signal indicative of the white bar and the level change detector 42b does not generate the detection pulse which is designed to reset the space detector 42d. The space detector 42d, as a result, counts the clock pulse T 0  and generates the clear pulse when the count value reaches twenty-four at the completion of scanning the space (6 N). This clear pulse resets the group scan detector 42c and the counters 41f and 41i. When the space bar SB in black is scanned, the output signal level of the analog circuit 30 is charged from low to high and the level change detector 42b generates the detection pulse which resets the space detector 42d. The space detector 42d, as a result, does not generate the clear signal any more, and the group scan detector 42c and counters 41f and 41i are allowed to become operative. 
     While the group bar code including the space bars SB is scanned, the analog circuit 30 produces the rectangular signal which is kept at the high level and the low level during the scanning of the respective black bars and white bars. The counter 41f counts the pulse applied during the scanning of black bars, whereas the counter 41i counts the pulse applied during the scanning of white bars. Provided that the total width L B  of 18 black bars in the first group bar code is 26 N, 208 (26×4×2) clock pulses are applied to the frequency divider 41e through the AND gate 41c due to the fact that 4 clock pulses T 1  are applied to scan the unit bar width N and the frequency of the clock pulse produced by the OR gate 41c is doubled. The 208 clock pulses are frequency-divided in one twenty-sixth by the divider 41e, the count value of the counter 41f resultantly becomes eight. On the other hand, the count value of the counter 41i also becomes 8, provided that the total width L w  of 17 white bars in the first group bar code is 27 N. When the space bar SB in black at the tail of the first group bar code is completed to be scanned, the group scan detector 42c generates the command signal which causes the registers 41g and 41j to store the count values of the counters 41f and 41i, respectively. It should be noticed that the values stored in the registers 41g and 41j are equal to the threshold values H B  and H w . 
     After the completion of the abovedescribed first scanning, the first group bar code is again scanned due to such a construction that the image sensor 20 is driven cyclically. The portion of the group bar code scanned during the second scanning cycle is different from that scanned during the preceding first scanning cycle, since the card 70 is moved. During this second scanning cycle, the threshold circuit 41 operates in the same manner as described with reference to the first scanning cycle and the level change detector 42f, the code scan detector 42g, the space detector 42h and the bar width counter 42i also operate this time. While the second scanning is attained, the rectangular signal generated during the first scanning cycle is passed through the delay circuit 42e. When the rectangular signal delayed by the delay circuit 42e is at low level indicative of the left space (6 N), the level change detector 42f does not generate the detection pulse which resets the space detector 42h. The space detector 42h, therefore, counts the clock pulse T 0  and generates the clear signal at the count value 24. The code scan detector 42g presets -1 therein in response to the clear signal. When the delayed rectangular signal is changed from low level to high level for the first time, the level change detector 42f generates the detection pulse. This detection pulse resets the space detector 42h and concurrently the code scan detector 42g is allowed to count the detection pulse. The delayed rectangular signal is applied to the selector 41k which in turn selects the threshold value H B  stored in the register 41g and the threshold value H w  stored in the register 41j in response to the high level signal and the low level signal, respectively. Since the level change detector 42f generates the detection pulse each time the level of the delayed rectangular signal is reversed, the count value of the bar width counter 42i which counts the clock pulse T 0  during one cycle period of the detection pulse is equal to the width of each bar. When the delayed rectangular signal is at high level indicative of the black bar, the discrimination circuit 43 compares the width of the black bar counted by the counter 42i with the threshold value H B  selected by the selector 41k. The discrimination circuit 43 compares the width of the white bar counted by the counter 42i with the threshold value H w  selected by the selector 41k, when the delayed rectangular signal is at low level. Comparing the count value of the counter 42i with the threshold value, the discrimination circuit 43 discriminates whether the bar is wide or narrow and generates high level signal &#34;1&#34; and low level signal &#34;0&#34; indicative of respective narrow bar and wide bar. The output signal successively generated by the discrimination circuit 43 is applied to the shift register 44 to be stored at the application of the detection pulse indicative of the completion of scanning each bar. When 8 detection pulses are applied to the code scan detector 42g, indicating the completion of scanning the bar code, the code scan detector 42g generates the command signal which is applied to the buffer register 45 so that the output signal of the shift register 44 is transferred to the buffer register 45 to be stored as the parallel digital signal. Each digit of the stored parallel digital signal is indicative of each bar width. After the completion of discriminating the index bar code  , the following numerical codes 1, 2, 3, are sequentially discriminated in the same manner as the index code  . It should be noted herein that, while the abovedescribed discriminating step is attained, the threshold circuit 41 determines the threshold values H B  and H w  in accordance with the result of second scanning so that these threshold values H B  and H w  are made available for discriminating the width of bars scanned during the second scanning cycle. 
     Repeating the scanning at plural numbers of times for each group bar code, the central processing unit 60 shown in FIG. 1 is enabled to decode the group bar code at each completion of the scanning. The validity of decoded information is enhanced, provided that the central process unit 60 is designed to discriminate whether the presently decoded information is identical with the precedingly decoded information or not. 
     The above described embodiment may be modified as follows as well. The width of bars scanned in the present scanning cycle may be discriminated with reference to the threshold value determined in proportion to the total width of bars scanned in the preceding scanning cycle without delaying the rectangular signal. 
     According to this modification, the level change detectors 42b and 42f are replaced by a single level change detector, and the space detectors 42d and 42h are also replaced by a single space detector, thus simplifying the counter circuit 42. The width of bars may be discriminated with reference to a single threshold value determined in proportion to the total bar width of either black bars or white bars. According to this modification, the AND gates 41c and 41d, the frequency dividers 41e and 41h, the counters 41f and 41i and the registers 41g and 41j are respectively replaced by a single AND gate, a single frequency divider, a single counter and a single register, and the inverter 41b and the selector 41k are eliminated, thus simplifying the threshold circuit 41. 
     Whatever modification the present invention may be subjected to, the following advantage is obtained. Various bar codes having respective bar width, having respective distances from the image sensor or having respective moving directions which are aslant to the scanning line of the image sensor are correctly recognized, since the threshold value is automatically corrected in proportion to the total bar width.