DEVICE FOR READING RESISTOR VALUE WITH COMPUTER VISION AND METHOD THEREOF
20170221200 · 2017-08-03
Inventors
Cpc classification
G06V10/243
PHYSICS
G06V10/26
PHYSICS
H01C1/04
ELECTRICITY
G06V10/28
PHYSICS
International classification
Abstract
Disclosed are a cost-effective light source device that can eliminate highlights or hotspots and reduce halo phenomenon on resistor surface and a method for reading resistor value with computer vision, in which an image of a body of a resistor is extracted through irradiation by an annular light source and reflection by a replaceable diffuse reflection hood such as paper box, paper bowl, or paper cup inside pasted with white paper and extraction by an image extraction device, followed by a series of image processing operations conducted by a control unit to calculate a disposition angle of the resistor in an image. Luminous elements on opposite axial ends of the resistor are activated, according to the disposition angle, for illumination, while luminous elements on opposite lateral sides of the resistor are shut down so that a clear color resistor image can be obtained.
Claims
1. A method for reading resistor value with computer vision, in which a cost-effective light source device is used to eliminate highlights or hotspots and reduce halo phenomenon on a resistor surface, the method comprising: acquiring an image of a resistor to extract color bands; training the color bands for 4-band, 5-band and establishing colors of a body of the resistor in a control unit and storing different files of color classifier for each 4-band, 5-band, and resistor body color; in reading a resistor, retracting an image of the resistor to be read; converting the color image so extracted into a gray-scale image, executing binarization treatment, and executing noise removal; calculating a resistor disposition angle in the image, activating luminous elements at opposite axial ends of the disposition position of the resistor according to the angle for illumination, while luminous elements on opposite lateral sides of the resistor are deactivated in order to extract a clear color resistor image having no light reflection and low halo; adjusting the clear color resistor image such that the resistor in the image is set to the horizontal and separating a resistor body image; establishing a resistor body color image diagram having a size that is the same as that of the resistor body image and carrying colors extremely close to resistor body colors; executing differencing between the resistor body image and the resistor body color image diagram and converting a result color image of differencing into a gray-scale image and executing binarization on the gray-scale image with a binarization process to generate a binarized image; and calculating coordinates of a centroid of each of the color bands of the resistor in the binarized image and extracting the color bands according to an x-axis coordinate of the centroid and a y-axis coordinate of a centroid of the resistor body image in order to recognize and convert a color of each of the color bands into a color code and calculating and displaying a resistor value of the resistor.
2. The method for reading resistor value with computer vision according to claim 1, wherein the binarization treatment comprises a first stage of detecting a directional angle of the resistor of the resistor image and a second stage of extracting the color bands.
3. The method for reading resistor value with computer vision according to claim 1, wherein the resistor image, after binarization, is subjected to convex hull treatment to generate one or multiple blocks.
4. The method for reading resistor value with computer vision according to claim 1, wherein adjusting the clear color resistor image to the horizontal comprises calculating a directional angle of a single block or a largest one of multiple blocks with a moment of inertia based process and calculating an angle of a centroid line of the block with a lowest moment of inertial process.
5. The method for reading resistor value with computer vision according to claim 1, wherein a y-axis range of a resistor body is separated by re-calculating coordinates of the centroid of the clear color resistor image that has been adjusted to the horizontal are calculated and selecting 40 pixels above and 40 pixels below a y-axis coordinate of the centroid, reducing an x-axis range of the y-range resistor body by calculating coordinates of intersection points of top and bottom boundaries of the y-axis range, comparing and selecting a relatively large one of minimums of the x-axis coordinates of the intersection points of the top and bottom boundaries as an x-axis range in a left end and comparing and selecting a relatively small one of maximums of the x-axis coordinates of the intersection points of the top and bottom boundaries as an x-axis range in a right end so as to separate a resistor body image.
6. The method for reading resistor value with computer vision according to claim 1, wherein the step of comparing and selecting a relatively large one of minimums of the x-axis coordinates of the intersection points of the top and bottom boundaries as an x-axis range in a left end comprises providing histograms for values of basic colors of red, green, and blue of pixels of the resistor body image, counting individual pixel number of the red values, the green values, and the blue values, and selecting the red value having a greatest pixel number, the green value having a greatest pixel number, and a blue value having a greatest pixel number to establish the resistor body color image diagram.
7. The method for reading resistor value with computer vision according to claim 1, wherein extracting color bands comprises differencing between the resistor body image and the resistor body color image diagram and binarization such that a binarized color band image is obtained and a centroid thereof is calculated to extract a color band sample.
8. The method for reading resistor value with computer vision according to claim 1, wherein extracting color bands is conducted in sequence in a direction from left to right such that the color bands are extracted and converted into color codes with which a predetermined formula is applied to calculate the resistor value.
9. The device and method for reading resistor value with computer vision according to claim 8, wherein calculating the resistor value is such that positions of the color bands are analyzed and when a first one or second one of the color bands on the left end of the resistor is recognized as a gold or silver color, the sequence of reading the color codes is inversed for calculating the resistor value.
10. The method for reading resistor value with computer vision according to claim 8 further comprising sequentially determining a centroid distance between the first color band and the second color band on the left end and a centroid distance between a first color band and a second color band on a right end such that a mechanism of comparison is activated only when the first color band and the last color band are brown, red, green, blue, purple, and grey and when the centroid distance between the first color band and the second color band on the left end is greater that the centroid distance between the first color band and second color band on the right end, the sequence of reading color codes is inversed for calculating the resistor value.
11. The method for reading resistor value with computer vision according to claim 1, wherein an application comprises an observation table on which a resistor is positionable, an annular light source, a reflection hood, a microscope, and a control unit such that in file establishing or reading of resistor colors, the resistor is positioned on the observation table and through irradiation by the annular light source and reflection by the reflection hood and extraction and transmission of a resistor image by the microscope to the control unit, file establishing or reading of a resistor value can be performed.
13. The method for reading resistor value with computer vision according to claim 3, wherein adjusting the clear color resistor image to the horizontal comprises calculating a directional angle of a single block or a largest one of multiple blocks with a moment of inertia based process and calculating an angle of a centroid line of the block with a lowest moment of inertial process.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0015]
[0016]
[0017]
[0018]
[0019]
[0020]
[0021]
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0022] The following descriptions are exemplary embodiments only, and are not intended to limit the scope, applicability or configuration of the invention in any way. Rather, the following description provides a convenient illustration for implementing exemplary embodiments of the invention. Various changes to the described embodiments may be made in the function and arrangement of the elements described without departing from the scope of the invention as set forth in the appended claims.
[0023] Referring to
[0024] (1) controlling annular light source 3 and acquiring an image of a resistor 1 (see
[0025] (2) Converting a color image of the resistor image 11 (
T.sub.yj=m+√{square root over (j×Σp.sub.i.sup.2/n)}
where m is the local sample mean, j is a scaling factor of yj, n is the total number of pixels in the gray image, and p.sub.i is a pixel value of the gray-scale image.
[0026] (3) executing noise removal and convex hull treatment and calculating a disposition angle of the resistor 1 in the resistor image 11 (see
[0027] where one or multiple blocks may be generated by the convex hull treatment of the binarized resistor image 11,
[0028] wherein in case that one single block is generated, a moment of inertia based process is used to calculate a directional angle of the single block in order to determine an angle of a center line of the block that exhibits the lowest moment of inertia:
where M.sub.xy is xy moment of inertia, M.sub.xx is xx′ moment of inertia, and M.sub.yy is yy′ moment of inertia; and
[0029] wherein in case that multiple blocks are generated, a moment of inertia based process is used to calculate a directional angle of the largest one of the blocks, such that the directional angle is regarded as the directional angle of the resistor 1;
[0030] where in the above calculation, θ.sub.rad is of the unit of radian, and a process involving the following algorithm can be used to calculate an angle θ.sub.ar for automatically adjusting the resistor 1 in the resistor image 11 to the horizontal is as follows:
θ.sub.deg=θ.sub.rad×360/2π
if θ.sub.deg≦90°, then θ.sub.ar=−θ.sub.deg,
else θ.sub.ar=−(180−θ.sub.deg)
[0031] (4) after the calculation of the disposition angle of the resistor 1, controlling the annular light source 3 such that luminous elements 31 that are located at opposite axial ends of the resistor 1 are energized for illumination, while luminous elements 31 that are located on opposite lateral sides of the resistor 1 are de-energized and set off (see
[0032] (5) automatically adjusting the image of the resistor 1 in the clear color resistor image 12 to the horizontal (see
[0033] (6) isolating or separating a body image 16 of the resistor in the clear color resistor image 12 (see
[0034] (7) establishing and separating a resistor body color image diagram 17 (see
[0035] (8) executing image differencing (subtracting) absolute value treatment on the resistor body image 16 and the resistor body color image diagram 17 so established to obtain a result color image and converting the result color image into a gray-scale image (
[0036] (9) executing binarization treatment, where the YJ adaptive binarization process so established is applied to execute binarization treatment to generate a binarized image and calculating coordinates of a centroid of each color band (
[0037] (I) if the number of the color bands is counted 5 for pixels of the binarized image extending upward and downward by 80 pixels from the middle, then the number of the color bands is 5;
[0038] (II) otherwise the number of color bands is determined by recognizing the resistor body color, where height of the binarized colorband is taken as the first priority factor for selecting resistor color band candidate and the YJ adaptive binarization process mentioned herein provides an excellent effect of suppressing noise in order to obtain a correct result. The colorband centroid is selected, according to the number of the color bands, from the binarized image as the centroid of the color band having a relatively great color band height (see
[0039] (10) training a computer to recognize the resistor body color and the colorband colors so established and storing different files of color classifier for each 4-band, 5-band, and resistor body color of a color classifier such that the resistor body color so established and the colorband sample so extracted are used for training in a color learning phase and stored in the classifier files for the purpose for recognition in a resistor reading phase.
[0040] Referring to
[0041] (1) controlling an annular light source 3 for illumination and acquiring an image of a resistor 1 (see
[0042] (2) converting a color image of the image 11 of the resistor into a gray-scale image and executing binarized treatment (see
[0043] (3) executing noise removal and convex hull treatment and calculating a disposition angle of the resistor 1 in the resistor image 11 (see
[0044] (4) controlling the annular light source 3 such that luminous elements 31 that are located at opposite axial ends of the resistor 1 are energized for illumination, while luminous elements 31 that are located on opposite lateral sides of the resistor 1 are de-energized and set off (see
[0045] (5) automatically adjusting the clear color resistor image 12 such that the image of the resistor 1 is set to the horizontal (see
[0046] (6) isolating or separating a body image 16 of the resistor in the clear color resistor image 12 (see
[0047] (7) establishing and separating a resistor body color image diagram 17 (see
[0048] (8) recognizing the resistor body image 16 as a four-color colorband resistor or a five-color colorband resistor.
[0049] (9) executing absolute differencing treatment on the resistor body image 16 and the resistor body color image diagram 17 so established and converting a result color image into a gray-scale image (
[0050] (10) executing binarization treatment to obtain a binarized image and calculating coordinates of a centroid of each color band (
[0051] (11) recognizing and converting the color of each color band sample into a color code.
[0052] (12) operating the control unit to read and calculate the resistor value and display a result (see
[0053] The present invention reads the color bands by the sequence that is determined according the rule of being from the left end to the right end and the color bands or the resistors, after being extracted, are converted into the color code and the resistor value can be then calculated according to predetermined formula. When the clear color resistor image is automatically adjusted to the horizontal, the tolerance band may be on the left end or the right end and the present invention provides functions of colorband code position switching analysis and reading color code in an inversed sequence. Inversion of color code is determined according to the analysis of the following two situations:
[0054] (1) if the first or second color band on the left end is recognized as a gold or silver one, then the color codes are inversed or flipped over.
[0055] (2) the distance between color bands are inspected and identified (see
d.sub.1L-d.sub.2L: centroid distance between the first color band and the second color band on the left end;
d.sub.1R-d.sub.2R: centroid distance between the first color band and the second color band on the right end; and
a mechanism for comparison of d.sub.1L-d.sub.2L and d.sub.1R-d.sub.2R is activated only when the first color band and the last color band are of a color of brown, red, green, blue, purple, and grey and when d.sub.1L-d.sub.2L>d.sub.1R-d.sub.2R, the reading sequence of the color band is inversed or flipped over.
[0056] The above examples are given to demonstrate the best mode of practicing the present invention, but not for imposing undue constraints to the present invention. Minor modifications and variations, without departing the essence of the present invention, are considered falling within the scope of the present invention.
[0057] In summary, the present invention involves a control unit to train color bands and establish colors of a resistor body and storing different files of color classifier for each 4-band, 5-band, and resistor body color so that in reading a resistor, an image of the resistor is acquired for identifying the color of each color band for being subsequently converted into a color code, which is then calculated to obtain and display the value of the resistor.
[0058] It will be understood that each of the elements described above, or two or more together may also find a useful application in other types of methods differing from the type described above.
[0059] While certain novel features of this invention have been shown and described and are pointed out in the annexed claim, it is not intended to be limited to the details above, since it will be understood that various omissions, modifications, substitutions and changes in the forms and details of the device illustrated and in its operation can be made by those skilled in the art without departing in any way from the claims of the present invention.