CN113870231A - Counting system and method for electronic components and computer equipment - Google Patents

Counting system and method for electronic components and computer equipment Download PDF

Info

Publication number
CN113870231A
CN113870231A CN202111163535.7A CN202111163535A CN113870231A CN 113870231 A CN113870231 A CN 113870231A CN 202111163535 A CN202111163535 A CN 202111163535A CN 113870231 A CN113870231 A CN 113870231A
Authority
CN
China
Prior art keywords
image
target
counting
pixel
processing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111163535.7A
Other languages
Chinese (zh)
Inventor
罗军
王小强
唐锐
罗道军
支越
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Electronic Product Reliability and Environmental Testing Research Institute
Original Assignee
China Electronic Product Reliability and Environmental Testing Research Institute
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Electronic Product Reliability and Environmental Testing Research Institute filed Critical China Electronic Product Reliability and Environmental Testing Research Institute
Priority to CN202111163535.7A priority Critical patent/CN113870231A/en
Publication of CN113870231A publication Critical patent/CN113870231A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration using local operators
    • G06T5/30Erosion or dilatation, e.g. thinning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/155Segmentation; Edge detection involving morphological operators
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/62Analysis of geometric attributes of area, perimeter, diameter or volume
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30242Counting objects in image

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Geometry (AREA)
  • Quality & Reliability (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

The application relates to a counting system, a counting method, a counting device, a computer device and a storage medium of electronic components. The system comprises: counting platform, components and parts accommodate device, shield assembly, image acquisition device and computer equipment. The shielding device is detachably arranged on the counting platform, surrounds the outside of the component accommodating device and forms a closed space with the counting platform so as to shield ambient light; wherein, shielding device's one side is equipped with the opening, and the opening is used for supplying taking out and putting into of components and parts accommodate device. By adopting the method, the electronic components can be automatically counted accurately and efficiently.

Description

Counting system and method for electronic components and computer equipment
Technical Field
The present application relates to the field of electronic device technologies, and in particular, to a counting system, a counting method, a counting device, a computer device, and a storage medium for electronic devices.
Background
Due to the wide variety of electronic components and different overall dimensions, and with the progress of microelectronic process technology, the development of ultrahigh integration, miniaturization, customization and the like, the counting requirements on the electronic components in the screening, identification, test evaluation of electronic component products are increasingly urgent.
Due to the increasing demand for counting and counting electronic components in identification, screening, test and evaluation, various types of electronic components have different sizes, models and specifications, and the like, and the electronic components are placed at any position in the tray, so that the phenomena that two or more adjacent electronic components are adjacent or slightly overlapped and the like may exist, and how to count and count the electronic components becomes an urgent need and technical difficulty. Traditionally, the mode of manual counting statistics is adopted to count and count electronic components in any shapes, the defect of high error detection rate exists, and the increasingly complex and diversified counting requirements of the electronic components are difficult to meet.
Disclosure of Invention
In view of the above, it is necessary to provide a counting system, a method, an apparatus, a computer device and a storage medium for electronic components, which can improve the accuracy of counting the electronic components.
A system for counting electronic components, the system comprising: the counting platform is used for bearing the component accommodating device; the component accommodating device is placed on the counting platform and used for accommodating components to be counted; the shielding device is detachably arranged on the counting platform, surrounds the outside of the component accommodating device and forms a closed space with the counting platform so as to shield ambient light; an opening is formed in one surface of the shielding device, and the opening is used for taking out and putting in the component accommodating device; the image acquisition device is arranged above the component accommodating device and used for shooting components placed in the component accommodating device from different angles and obtaining component images; and the computer equipment is used for receiving the component images acquired and transmitted by the image acquisition device at a plurality of acquisition angles, counting the component images and obtaining the counting result of the components.
In one embodiment, the image acquisition device is arranged above the component accommodating device through a fixing support, the support comprises a transverse support and a longitudinal support, the transverse support is used for driving the image acquisition device to rotate, and the longitudinal support is a telescopic rod.
In one embodiment, the shielding device is made of a flexible material; the shielding device is erected on the counting platform through a supporting bracket.
In one embodiment, the computer device is configured to obtain a plurality of counting results according to the component images acquired by the image acquisition device at a plurality of acquisition angles, respectively; and carrying out average value processing on the plurality of counting results to obtain a final counting result.
In one embodiment, the computer device is configured to: preprocessing the component image received from the image acquisition device to obtain a preprocessed image, and taking the preprocessed image as a primary edge image to be processed; acquiring a current edge image to be processed, and performing morphological corrosion processing and morphological expansion processing on the current edge image to be processed respectively to obtain a current morphological image; performing region extraction on the current morphological image to obtain a target image comprising a plurality of target regions and the number of the target regions; if the number of the target areas obtained by the current processing is not consistent with the number of the target areas obtained by the previous processing, performing image area segmentation processing on the current target image to obtain a segmented edge image; taking the segmented edge image as a to-be-processed edge image of the next round, returning to the step of respectively performing morphological erosion processing and morphological dilation processing on the to-be-processed edge image, and continuing to execute the steps until the number of target areas obtained by the next round of processing is consistent with the number of target areas obtained by the last round of processing, and stopping the circular processing; and determining a plurality of connected regions in the target image based on the target image obtained by the last processing, counting the components according to the connected regions, and obtaining a counting result.
A method of counting electronic components, the method comprising: acquiring a component image, preprocessing the component image to obtain a preprocessed image, and taking the preprocessed image as a primary edge image to be processed; the component images are obtained by shooting components to be counted in the component accommodating device in the shielding device by using an image acquisition device arranged above the component accommodating device; acquiring a current edge image to be processed, and performing morphological corrosion processing and morphological expansion processing on the current edge image to be processed respectively to obtain a current morphological image; performing region extraction on the current morphological image to obtain a target image comprising a plurality of target regions and the number of the target regions; if the number of the target areas obtained by the current processing is not consistent with the number of the target areas obtained by the previous processing, performing image area segmentation processing on the current target image to obtain a segmented edge image; taking the segmented edge image as a to-be-processed edge image of the next round, returning to the step of respectively performing morphological erosion processing and morphological dilation processing on the to-be-processed edge image, and continuing to execute the steps until the number of target areas obtained by the next round of processing is consistent with the number of target areas obtained by the last round of processing, and stopping the circular processing; and determining a plurality of connected regions in the target image based on the target image obtained by the last processing, counting the components according to the connected regions, and obtaining a counting result.
In one embodiment, the determining a plurality of connected regions in the target image includes: determining a current pixel row to be processed in all pixel rows in the target image; sequentially determining label values corresponding to all pixels in the current pixel processing row; taking the next pixel row as the pixel row to be processed in the next round, and returning to the step of sequentially determining the label value corresponding to each pixel in the pixel row to be processed in the current round to continue to execute until all the pixel rows are traversed; forming an equivalence pair by the label values with equivalence relation in the plurality of label values to obtain at least one group of equivalence pairs; taking the minimum value of the label value in each equivalent pair as the standard label value in the corresponding equivalent pair; traversing the target image according to each equivalent pair, and updating the label value of the pixel corresponding to the same equivalent pair into the standard label value of the corresponding equivalent pair; and determining pixels corresponding to the same standard label value as a connected region to obtain a plurality of connected regions in the target image.
In one embodiment, the sequentially determining a standard tag value corresponding to each pixel in the current pixel row to be processed includes: determining a current pixel to be processed in a current pixel row, and determining a neighborhood of the pixel to be processed; if the label value of the connected pixels is null in the neighborhood of the pixel to be processed, updating the label value of the current pixel into a new label value; if the label value of the connected pixel is not null in the neighborhood of the pixel to be processed, determining the minimum value in the label values corresponding to the connected pixels, and updating the label value of the current pixel to the minimum value; and taking the next pixel as the pixel to be processed in the next round, returning to the step of determining the neighborhood of the pixel to be processed, and continuing to execute the step until all pixels in the current pixel row are traversed, and obtaining the label values corresponding to all pixels.
In one embodiment, the counting the components according to the connected region and obtaining a counting result includes: determining the areas of the connected regions corresponding to the connected regions in the target image respectively, and calculating the average area of the target at the current time according to the areas of the connected regions corresponding to the connected regions respectively; determining a plurality of target connected regions with the connected region areas smaller than the target average area, calculating candidate average areas of the plurality of target connected regions, and taking the candidate average areas as the target average areas of the next round; returning to the step of determining a plurality of target connected regions with the connected region areas smaller than the target average area and continuing to execute until the obtained target average area is consistent with the target average area obtained in the previous round; and carrying out rounding operation according to the total area corresponding to the component area in the target image and the finally obtained target average area to obtain a counting result.
An electronic component counting apparatus, the apparatus comprising: the device comprises a preprocessing module, a processing module and a processing module, wherein the preprocessing module is used for acquiring a device image, preprocessing the device image to obtain a preprocessed image and taking the preprocessed image as a primary edge image to be processed; the component images are obtained by shooting components to be counted in the component accommodating device in the shielding device by using an image acquisition device arranged above the component accommodating device; the morphological processing module is used for acquiring a current edge image to be processed, and performing morphological erosion processing and morphological expansion processing on the current edge image to be processed respectively to obtain a current morphological image; the region extraction module is used for performing region extraction on the current morphological image to obtain a target image comprising a plurality of target regions and the number of the target regions; the region segmentation module is used for performing image region segmentation processing on the current target image to obtain a segmented edge image if the number of the target regions obtained by the current processing is inconsistent with the number of the target regions obtained by the previous processing; the circular processing module is used for taking the segmented edge image as a to-be-processed edge image of the next round, returning to the morphological processing module for continuous execution, and stopping circular processing when the number of the target areas obtained by processing of the next round is consistent with the number of the target areas obtained by processing of the previous round; and the counting module is used for determining a plurality of connected areas in the target image based on the target image obtained by the last processing, counting the components according to the connected areas and obtaining a counting result.
In one embodiment, the counting module is further configured to: determining a current pixel row to be processed in all pixel rows in the target image; sequentially determining label values corresponding to all pixels in the current pixel processing row; taking the next pixel row as the pixel row to be processed in the next round, and returning to the step of sequentially determining the label value corresponding to each pixel in the pixel row to be processed in the current round to continue to execute until all the pixel rows are traversed; forming an equivalence pair by the label values with equivalence relation in the plurality of label values to obtain at least one group of equivalence pairs; taking the minimum value of the label value in each equivalent pair as the standard label value in the corresponding equivalent pair; traversing the target image according to each equivalent pair, and updating the label value of the pixel corresponding to the same equivalent pair into the standard label value of the corresponding equivalent pair; and determining pixels corresponding to the same standard label value as a connected region to obtain a plurality of connected regions in the target image.
In one embodiment, the counting module is further configured to: determining a current pixel to be processed in a current pixel row, and determining a neighborhood of the pixel to be processed; if the label value of the connected pixels is null in the neighborhood of the pixel to be processed, updating the label value of the current pixel into a new label value; if the label value of the connected pixel is not null in the neighborhood of the pixel to be processed, determining the minimum value in the label values corresponding to the connected pixels, and updating the label value of the current pixel to the minimum value; and taking the next pixel as the pixel to be processed in the next round, returning to the step of determining the neighborhood of the pixel to be processed, and continuing to execute the step until all pixels in the current pixel row are traversed, and obtaining the label values corresponding to all pixels.
In one embodiment, the counting module is further configured to: determining the areas of the connected regions corresponding to the connected regions in the target image respectively, and calculating the average area of the target at the current time according to the areas of the connected regions corresponding to the connected regions respectively; determining a plurality of target connected regions with the connected region areas smaller than the target average area, calculating candidate average areas of the plurality of target connected regions, and taking the candidate average areas as the target average areas of the next round; returning to the step of determining a plurality of target connected regions with the connected region areas smaller than the target average area and continuing to execute until the obtained target average area is consistent with the target average area obtained in the previous round; and carrying out rounding operation according to the total area corresponding to the component area in the target image and the finally obtained target average area to obtain a counting result.
A computer device comprising a memory storing a computer program and a processor implementing the steps of the method described above when executing the computer program.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method.
According to the counting system of the electronic components, the counting platform, the component accommodating device, the detachable shielding device, the image acquisition device capable of shooting the components from different angles and the computer equipment are arranged, so that the counting system which is movable, low in cost and easy to operate is formed, and the influence of environment light rays which cause inaccurate counting results of the computer equipment is avoided; simultaneously, the computer equipment carries out image processing on the component images acquired and transmitted by the image acquisition device under a plurality of acquisition angles so as to count, and does not need to count specific types of components respectively.
According to the counting method and device of the electronic components, the computer equipment and the storage medium, the image of the components collected by the image collecting device arranged above the component containing device in the shielding device is obtained, edge enhancement processing, morphological corrosion processing, morphological expansion processing and region extraction are sequentially carried out, whether the number of the target regions obtained by current processing is changed or not is judged, if the number of the target regions obtained by current processing is changed, the step of morphological processing is returned and repeated to be circulated until the number of the target regions is not changed, counting is carried out based on the finally obtained target images, the counting accuracy of the electronic components is improved, and the error detection rate is low.
Drawings
Fig. 1 is a schematic structural diagram of a counting system of an electronic component according to an embodiment;
fig. 2 is a schematic flowchart of a counting method of an electronic component according to an embodiment;
FIG. 3 is a flowchart illustrating the steps of the computer device determining a plurality of connected regions in the target image according to one embodiment;
FIG. 4 is a flowchart illustrating steps of a computer device sequentially determining a standard tag value corresponding to each pixel in a current pixel row to be processed according to an embodiment;
fig. 5 is a schematic flowchart of a step of counting components according to the connected region and obtaining a counting result by the computer device according to the embodiment;
fig. 6 is a schematic flow chart of a counting method of an electronic component according to another embodiment;
fig. 7 is a schematic diagram illustrating an actual application effect of the counting method for electronic components according to an embodiment;
fig. 8 is a block diagram showing a counting apparatus for electronic components according to an embodiment;
FIG. 9 is an internal block diagram of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
Due to the wide variety of electronic components and different overall dimensions, and with the progress of microelectronic process technology, the development of ultrahigh integration, miniaturization, customization and the like, the counting requirements on the electronic components in the screening, identification, test evaluation of electronic component products are increasingly urgent. For example, in the screening of electronic components, generally, after the performance parameter test is performed on the electronic component product, the electronic components that are qualified and unqualified in the test are classified and placed in different trays respectively, and in order to save time and improve efficiency, the electronic components are generally placed randomly in the trays, and no rule can be followed. For the electronic component products which are randomly placed, the number of the electronic component products needs to be counted after testing, and preparation is made for subsequent reliability tests or electrical tests.
Due to the increasing demand for counting and counting electronic components in identification, screening, test and evaluation, various types of electronic components have different sizes, models and specifications, and the like, and the electronic components are placed at any position in the tray, so that the phenomena that two or more adjacent electronic components are adjacent or slightly overlapped and the like may exist, and how to count and count the electronic components becomes an urgent need and technical difficulty. Traditionally, counting statistics is carried out on electronic components in any shapes by adopting a manual counting and counting mode, the defects of low efficiency, low repeatability, high error detection rate and the like exist, and increasingly complex and diversified electronic component counting requirements are difficult to meet. At present, the existing counting and counting system in the market can only count one or several types of electronic components which are packaged at fixed positions and in specific mode, and the counting and counting requirements of general electronic components which are packaged at any position and in different modes cannot be met.
In view of the above, the application provides a counting system for electronic components, which includes a counting platform, a component accommodating device, a shielding device, an image acquisition device, and a computer device, and makes full use of the versatility, portability, light weight, and universality of the component accommodating device, and the anti-interference performance of the shielding device to the light environment, so as to ensure the high quality and high stability of the image acquisition of the electronic components; the computer equipment has the characteristics of wide variety of identified electronic components, high identification precision, arbitrary placing positions of the electronic components and the like based on an image preprocessing, image enhancement, morphological expansion, corrosion and automatic counting comprehensive processing algorithm, can be widely applied to intelligent and automatic counting statistics of electronic components such as resistors, capacitors, integrated circuit chips, discrete devices and the like, can improve the counting efficiency and accuracy of the electronic components, and has low error detection rate.
As shown in fig. 1, the counting system for electronic components provided by the present application includes a counting platform 101, a component accommodating device 102, a shielding device 103, an image capturing device 104, and a computer device 105. The counting platform 101 is used for carrying the component accommodation device 102. A component holding device 102 is disposed on the counting platform 101 for holding one or more electronic components to be counted, such as resistors, capacitors, chips, and discrete devices. The shielding device 103 is detachably arranged on the counting platform 101, surrounds the component accommodating device 102, and forms a closed space with the counting platform 101 to shield ambient light and ensure the imaging image quality of the electronic component; wherein, one side of the shielding device 103 is provided with an opening for taking out and putting in the component containing device 102; the image acquisition device 104 is arranged above the component accommodating device 102 and is used for shooting components placed in the component accommodating device 102 from different angles and obtaining component images; the computer device 105 is configured to receive the component images acquired and transmitted by the image acquisition device 104 at a plurality of acquisition angles, and count the component images to obtain a counting result of the component. Wherein the image capturing apparatus 104 and the computer device 105 are connected via a network, which may be the internet, a mobile network, a local area network, a wide area network, a storage area network, one or more intranets, etc., or a suitable combination thereof.
In some embodiments, the component accommodating device is a portable mobile tray, for example, and is convenient and flexible to take out. Illustratively, the component containing device can be pasted with antistatic foam to prevent the electronic components from being stuck or stacked together due to electrostatic adsorption.
In some embodiments, the shielding device is, for example, a box-shaped studio with a side opening, which can be fixed to the counting platform or can be detachably arranged on the counting platform. When the side opening is opened or opened, an operator can put the component accommodating device on the counting platform into the shielding device or take the component accommodating device placed on the counting platform out of the shielding device; when the side opening is closed by the shielding device, the shielding device and the counting platform form a closed space, so that light rays of the external environment are isolated from entering, and the quality of the image acquisition device during shooting is guaranteed.
In some embodiments, the shielding device may also be flexible for portability. When the system is used, the flexible shielding device can be supported by the supporting bracket to be erected on the counting platform, so that a cavity for shielding ambient light is formed. When the system is in an idle state, the support bracket may be folded/stowed, thereby folding the flexible shielding device for portability. The flexible shielding device can be detachably mounted on the counting platform, is supported by the supporting bracket when in use, can be detached from the counting platform when not in use, and is folded for storage, convenient and flexible to assemble and easy to carry. In addition, the flexible material has a buffering effect, so that noise is reduced to a great extent, and the influence of vibration caused by the noise on the electronic components with small size and light weight is avoided. The flexible material may include synthetic fiber, animal or plant fiber, or other fiber materials known in the art, such as polyester rubber.
In some embodiments, the image capturing Device includes, but is not limited to, a camera module integrated with an optical system or a CCD (Charge Coupled Device) chip, a camera module integrated with an optical system and a CMOS (Complementary Metal Oxide Semiconductor) chip, and the like. The image acquisition device can be fixedly arranged on the fixed support, and can also be arranged on the fixed support in a detachable mode such as clamping, magnetic attraction, sticking and the like, so that the portability and the flexibility of the system are improved.
In order to improve the accuracy of counting, the image acquisition device acquires component images at a plurality of acquisition angles and transmits the component images to computer equipment; the computer equipment synthesizes a plurality of counting results under different acquisition angles to obtain a final counting result, the counting result is more accurate, and the false detection rate is low. To this end, in some embodiments, as shown in fig. 1, the image capturing device is disposed above the component accommodating device through a fixing bracket, and the fixing bracket includes a transverse bracket 1041 and a longitudinal bracket 1042, where the transverse bracket 1041 is used to rotate the image capturing device, and the longitudinal bracket 1042 is a telescopic rod. Wherein, the fixed bolster is based on the screw thread design, and horizontal support is fixed in on the vertical support to realize moving the position up and down through the flexible of vertical support, conveniently move image acquisition device and components and parts accommodate device's distance. The transverse support can rotate 360 degrees, so that the image acquisition device and the component containing device can be adjusted to be in a horizontal position, and the visual field range covers the component containing device.
Illustratively, the image capture device is set vertically downward by default, with its optical axis (camera mid-axis) perpendicular to the counting platform 101. When shooting for the first time, the image acquisition device vertically gathers the image downwards, then horizontal support 1041 drives the image acquisition device rotation through modes such as rotation or wrench movement to make image acquisition device and optical axis form certain angle, and gather the image once more. Therefore, compared with a mode that an operator places electronic components manually to enable the electronic components to be distributed uniformly, the image acquisition device does not need to place the components manually and uniformly specially in a mode of acquiring images at a plurality of acquisition angles, and counting accuracy is improved.
Correspondingly, in some embodiments, the computer device is configured to obtain a plurality of counting results according to the component images acquired by the image acquisition device at a plurality of acquisition angles, respectively; and carrying out average value processing on the plurality of counting results to obtain a final counting result. Specifically, the image acquisition device can transmit the component images acquired at different acquisition angles to the computer equipment for multiple times, and can also transmit all the component images to the computer equipment after the acquisition at all the acquisition angles is finished; after receiving the component images, the computer equipment respectively carries out image processing according to the component images acquired under a plurality of acquisition angles to obtain a plurality of counting results, then averages the plurality of technical results, and takes the average value as a final counting result.
Above-mentioned electronic components's counting system through setting up count platform, components and parts accommodate device, detachable shield assembly, can follow image acquisition device and the computer equipment that different angles shot components and parts, has constituted portable nimble, the easily counting system of operation, has avoided leading to the influence of the inaccurate environment light of computer equipment counting result, has improved the efficiency and the rate of accuracy of electronic components count to the error detection rate is low.
In order to further improve the accuracy of the counting result of the electronic component, the application also provides a counting method of the electronic component, which can be applied to the computer equipment shown in fig. 1. The computer device may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices. It will be appreciated that the method may also be applied to a server, and may also be applied to a system comprising a computer device and a server, and be implemented by interaction of the computer device and the server.
In one embodiment, as shown in fig. 2, the counting method for electronic components provided by the present application includes the following steps:
step S202, acquiring a component image, preprocessing the component image to obtain a preprocessed image, and taking the preprocessed image as a primary edge image to be processed; the component images are obtained by shooting components to be counted placed in the component accommodating device in the shielding device by using an image acquisition device arranged above the component accommodating device.
Wherein, when electronic components's counting system operation back, the image acquisition device who sets up in components and parts accommodate device top is under an acquisition angle, and the components and parts of treating the count of putting in the components and parts accommodate device are shot, obtain one or more components and parts images. The image acquisition device can transmit the component images acquired at different acquisition angles to the computer equipment for multiple times, and can also transmit all the component images to the computer equipment after the acquisition at all the acquisition angles is finished, and the computer equipment performs image processing.
Illustratively, the image acquisition device inputs a color image shot in a studio into the computer device through a transmission line, and at the same time, the computer device synchronously saves the received color image in a storage space of the computer device.
Specifically, the computer device acquires a component image acquired by the image acquisition device, and preprocesses the component image to obtain a preprocessed image. The preprocessing of the component image includes, but is not limited to, one or more of graying processing, binarization processing and the like. Among them, in order to simplify the amount of calculation and improve the calculation efficiency and accuracy, the computer device needs to convert the received color image into a grayscale image. For example, the computer may process in a weighted average manner:
Gray(i,j)=0.2989×R(i,j)+0,5870×G(i,j)+0.1140×B(i,j)
where (i, j) represents the pixel in the ith row and the jth column in the image.
The image binarization is a process of setting the gray value of a pixel point on an image to be 0 or 255, namely, the whole image presents an obvious black and white effect. In the embodiment of the application, the computer equipment performs binarization processing on the gray level image by using a global threshold value mode, and firstly, the computer equipment determines an initial estimation value T of the global threshold value; then, the image is divided by T, resulting in two sets of pixels: g consisting of all pixels with a grey value greater than T1And G consisting of all pixels having a gradation value of T or less2(ii) a Subsequently, the computer device calculates G separately1、G2Mean gray value m within a region1And m2(ii) a Calculating a new threshold value by the following formula, and repeating the steps until the difference between the T values of the two times before and after is smaller than a preset parameter Delta T:
Figure BDA0003290650370000111
therefore, the computer equipment completes the preprocessing of the component images, obtains the preprocessed images, and takes the obtained preprocessed images as the initial edge images to be processed so as to perform subsequent image processing.
And step S204, acquiring the current edge image to be processed, and performing morphological erosion processing and morphological expansion processing on the edge image to be processed respectively to obtain the current morphological image.
The dilation operation in the morphological processing may enlarge the target region in the image, and the erosion operation may reduce the target region in the image. Although the preprocessed binary image can well separate the target from the background and completely retain the boundary information of the target object, the extracted target has the problems of hollow inside, burrs and adhesion at the edge, and the like, and the problems can bring influence to subsequent processing, so that the accuracy of counting electronic components is poor, and the calculation complexity is increased.
Therefore, in order to remove noise and impurities, a morphological processing algorithm is required to be used for the result after binarization to solve the problem, and the electronic component is restored to the original shape in the image, so that the subsequent segmentation result achieves a better effect. In the embodiment of the present application, the binary image is optimized using morphological processing. Specifically, the computer device takes the obtained preprocessed image as a primary to-be-processed edge image, and performs morphological erosion processing and morphological dilation processing on the to-be-processed edge image in sequence to obtain a current morphological image.
The morphological erosion operation can reduce the sensitive region range, and can well eliminate small objects and image impurities. In the morphological erosion operation, the calculation formula for eroding the image a by the structural element B can be expressed as:
Figure BDA0003290650370000121
if the element position of the structural element B is the same as the element at the corresponding position of the image A when the structural element B is at the pixel point (x, y), the result representing the pixel point (x, y) is 1, otherwise, the result is 0. The structural Element (Structure Element) is a two-dimensional or multi-dimensional binary neighborhood, and the central pixel of the structural Element is called an origin for identifying the pixel being processed in the image.
In morphological dilation operations, the formula for dilation of image a with structuring element B can be expressed as:
Figure BDA0003290650370000122
the meaning of the above formula is the mapping of the structural element B with respect to the origin, and the mapped structural element
Figure BDA0003290650370000125
Is translated to the image pixel point (x, y) if
Figure BDA0003290650370000123
The intersection with A at image pixel point (x, y) is not empty (i.e., it is
Figure BDA0003290650370000124
At least one of the pixels corresponding to the image A at the pixel position with the middle value of 1 is 1), the value of the pixel point (x, y) corresponding to the output image is 1, otherwise, the value is 0.
In step S206, region extraction is performed on the current morphological image, and a target image including a plurality of target regions and the number of target regions are obtained.
Specifically, the computer device extracts the region of interest from the current morphological image, and obtains a target image including a plurality of target regions and the number of the target regions. The target area is an interested area, and the image containing the extracted interested area is a target image.
Illustratively, in the image boundary contour processing and the region of interest extraction, the computer device in the embodiment of the application performs the image boundary contour processing and the region of interest extraction by using a Canny edge detection algorithm. Since the gradient operator is used to enhance the image essentially by enhancing the edge contour, the gradient operator can also be used to detect the image boundary. However, the gradient operator is greatly influenced by noise, and the noise is a place with large gray scale change, so that the computer device firstly performs image noise reduction and then calculates the gradient and the direction of each pixel point in the image. Usually, the gray scale change places are concentrated, if the pixel point with the largest gray scale change in the gradient direction in the local range is reserved, and the other pixel points are not reserved, most of the pixel points can be eliminated, so that the edge with a plurality of pixel widths is changed into an edge with a single pixel width, and the process is the non-maximum suppression. After the computer device performs non-maximum suppression processing, there may still be many edge points in the image, and for this reason, the computer device sets a double threshold (i.e., a low threshold and a high threshold), sets the pixel points whose gray values are greater than the high threshold as strong edge pixels, eliminates the pixel points whose gray values are lower than the low threshold, and sets the pixel points whose gray values are between the low threshold and the high threshold as weak edges. Thus, the computer device makes a traversal judgment for each pixel: if there is a strong edge pixel in its neighborhood, then the pixel is retained; otherwise, the pixel is culled. The computer device thus obtains the boundary information and the relevant regions of interest in the image and counts the number of regions of interest.
It should be noted that, when the computer device processes the image for the first time, after obtaining the number of the regions of interest for the first time, the computer device returns to the step of step S204 to continue the execution until obtaining the number of the regions of interest for the second time, and then executes the subsequent steps S208 to S212.
In step S208, if the number of target regions obtained in the current processing is not equal to the number of target regions obtained in the previous processing, the current target image is subjected to image region segmentation processing to obtain a segmented edge image.
Specifically, the computer device compares the number of target regions obtained by the current processing with the number of target regions obtained by the previous processing, so as to determine whether the number of target regions obtained by the two processing is consistent. And if the computer equipment determines that the number of the target areas obtained by the current processing is inconsistent with the number of the target areas obtained by the previous processing, performing image area segmentation processing on the current target image to obtain a segmented edge image.
In some embodiments, the computer device performs an image region segmentation process on the current target image using a watershed segmentation algorithm to obtain a segmented edge image.
The watershed segmentation algorithm can effectively extract an interested region in an image, is beneficial to further processing a subregion of the image, and has the basic idea that the image is regarded as a topologic geomorphology in geodetic science, the gray value of each point pixel in the image represents the altitude of the point, each local minimum value and an influence region thereof are called as a catchbasin, and the boundary of the catchbasin forms a watershed. The concept and formation of watershed can be illustrated by simulating the immersion process. And (3) piercing a small hole on the surface of each local minimum value, then slowly immersing the whole model into water, wherein the influence area of each local minimum value is gradually expanded outwards along with the deepening of the immersion, and constructing a dam at the junction of two water collecting basins, namely forming a watershed. The calculation process of watershed is an iterative labeling process, firstly, the gray levels of each pixel are sequenced from low to high, and then, in the process of realizing inundation from low to high, the influence domain of each local minimum value at the h-order height is judged and labeled by adopting a first-in first-out structure. The watershed transform obtains a catchbasin image of the input image, and boundary points between catchbasins are watershed. Clearly, the watershed represents the input image maxima points. Therefore, to obtain edge information of an image, a gradient image is usually taken as an input image, i.e.
Figure BDA0003290650370000141
In the formula, f (x, y) represents an original image, and grad (·) represents a gradient operation. Because the noise in the image and the fine gray level change of the object surface can generate the phenomenon of over segmentation, the watershed segmentation algorithm adopted in the embodiment of the application can have good response to the weak edge. In addition, the closed water collecting basin obtained by the watershed algorithm provides possibility for analyzing the regional characteristics of the image. In order to eliminate the excessive segmentation generated by the watershed algorithm, two processing methods can be generally adopted, and firstly, the irrelevant edge information is removed by using the priori knowledge. The second is to modify the gradient function so that the catch basin responds only to the target that it is desired to detect. To reduce the over-segmentation caused by the watershed algorithm, the gradient function is usually modified, and a simple method is to threshold the gradient image to eliminate the over-segmentation caused by the slight change of the gray level.
Therefore, after the computer equipment carries out image area segmentation processing on the current target image, a segmented edge image is obtained, and the subsequent processing steps are carried out.
And step S210, taking the segmented edge image as a to-be-processed edge image of the next round, returning to the step of respectively performing morphological erosion processing and morphological dilation processing on the to-be-processed edge image, and continuing to execute the steps until the number of the target areas obtained by the processing of the next round is consistent with the number of the target areas obtained by the processing of the previous round, and stopping the circular processing.
Specifically, the computer device takes the edge image obtained after the segmentation as the edge image to be processed in the next round, and returns to the step of step S204 to continue the execution, thereby performing loop iteration until the loop processing is stopped when the number of target regions obtained in the next round of processing is consistent with the number of target regions obtained in the previous round of processing.
When the number of the target areas obtained by circulating to the current processing is consistent with that of the target areas obtained by the previous processing, the computer equipment obtains a final target image, and the target image comprises a plurality of interested areas (namely target areas).
Step S212, based on the target image obtained by the last processing, determining a plurality of connected regions in the target image, counting the components according to the connected regions, and obtaining a counting result.
Specifically, the computer device determines a plurality of connected regions in the target image based on the target image obtained by the last processing and a plurality of interested regions contained in the target image, counts the components according to the connected regions, and obtains a counting result.
According to the counting method of the electronic components, the images of the components collected by the image collecting device arranged above the component containing device in the shielding device are obtained, edge enhancement processing, morphological corrosion processing, morphological expansion processing and region extraction are sequentially carried out, whether the number of target regions obtained by current processing is changed or not is judged, if the number of the target regions is changed, the steps of morphological processing are returned and repeated for circulation until the number of the target regions is not changed, counting is carried out based on the finally obtained target images, counting results are obtained, the counting accuracy of the electronic components is improved, and the error detection rate is low.
In some embodiments, as shown in FIG. 3, the step of the computer device determining a plurality of connected regions in the target image comprises:
in step S302, the current pixel row to be processed is determined in all pixel rows in the target image.
In step S304, label values corresponding to the pixels in the current pixel row to be processed are sequentially determined.
And step S306, taking the next pixel row as the pixel row to be processed in the next round, and returning to the step of sequentially determining the label value corresponding to each pixel in the current pixel row to be processed to continue to execute until all the pixel rows are traversed.
Step S308, forming an equivalence pair by the label values with equivalence relation in the plurality of label values to obtain at least one group of equivalence pairs.
And step S310, taking the minimum value of the label values in each equivalent pair as the standard label value in the corresponding equivalent pair.
Step S312, traverse the target image according to each equivalence pair, and update the label value of the pixel corresponding to the same equivalence pair to the standard label value of the corresponding equivalence pair.
Step S314, determining pixels corresponding to the same standard label value as a connected region, and obtaining a plurality of connected regions in the target image.
Specifically, the computer device determines all the pixel rows to be processed in the target image, and determines the current pixel row to be processed therein. Taking the first row of pixel rows as an example, the computer device determines the label values corresponding to the pixels in the first row of pixel rows from left to right, then turns to the second row of pixel rows, determines the label values … … corresponding to the pixels in the second row of pixel rows, and so on, respectively, until all pixel rows in the target image are traversed, and obtains the label values corresponding to the pixels in the pixel rows. Then, the computer device determines the label values with equivalence relation in the plurality of label values, and forms equivalence pairs with the label values with equivalence relation in the plurality of label values to obtain at least one group of equivalence pairs. For example, a tag value of "1" has an equivalence relationship with a tag value of "3", then the computer device treats tag value "1" and tag value "3" as a set of equivalence pairs {1,3 }. In the resulting at least one set of equivalent pairs, the computer device determines the minimum of the label values in each equivalent pair as the standard label value in the corresponding equivalent pair, e.g., the label value "1" in the equivalent pair {1,3} is taken as the standard label value in the equivalent pair. Then, the computer device traverses the target image according to each equivalent pair, updates the label value of the pixel corresponding to the same equivalent pair to the standard label value of the corresponding equivalent pair, and determines the pixel corresponding to the same standard label value as a connected region to obtain a plurality of connected regions in the target image. For example, the computer device updates all the label values of all the pixels in the target image corresponding to the equivalence pair (i.e., the pixels corresponding to the label value "1" and the label value "3") to the standard label value "1" according to the standard label value "1" in the equivalence pair {1,3 }. Thus, all pixels having a label value of "1" constitute one connected region. And traversing all pixel rows by analogy to obtain a plurality of connected regions.
In the embodiment, the label value of each pixel is determined by traversing each pixel row, and the region formed by connecting the pixels with the same label value is used as the connected region, so that the pixels in different connected regions in the image can be provided with unique labels, and the pixels with the same property and the same label are classified together, thereby facilitating the subsequent accurate counting of the electronic components.
In some embodiments, as shown in fig. 4, the step of sequentially determining, by the computer device, the standard label value corresponding to each pixel in the current processing pixel row includes:
step S402, determining the current pixel to be processed in the current pixel row, and determining the neighborhood of the pixel to be processed.
In step S404, if the label value of the connected pixel is null in the neighborhood of the pixel to be processed, the label value of the current pixel is updated to a new label value.
Step S406, if the label value of the connected pixel is not empty in the neighborhood of the pixel to be processed, determining the minimum value of the label values corresponding to the connected pixels, and updating the label value of the current pixel to the minimum value.
Step S408, taking the next pixel as the pixel to be processed in the next round, returning to the step of determining the neighborhood of the pixel to be processed, and continuing to execute the process until all pixels in the current pixel row are traversed, and obtaining the label values corresponding to all pixels.
Where a neighborhood refers to surrounding pixels of a pixel, typically includes 8 neighborhoods (i.e., pixels adjacent thereto in the up, down, left, right, and diagonal directions of the current pixel) and 4 neighborhoods (i.e., pixels adjacent thereto in the up, down, left, and right directions of the current pixel).
Specifically, after determining the current pixel row to be processed, the computer device determines that the current pixel row to be processed is the current pixel row, and determines the current pixel to be processed in the current pixel row. Taking the current pixel to be processed as the first pixel of the current pixel row from left to right as an example, the computer device determines the neighborhood of the first pixel. And if the computer equipment determines that the label value of the connected pixel is null in the neighborhood of the pixel to be processed, updating the label value of the current pixel into a new label value. For example, for the first pixel in the first row, there is no pixel with a label value adjacent to it in any of the top, bottom, left, and right directions, the computer device updates the label value of the first pixel to a new label value, e.g., "1". For another example, for the nth pixel on the nth row, there is no pixel having a label value adjacent thereto in the upper, lower, left, and right directions, and the label values of the pixels are "1" and "2", respectively, then the computer device updates the label value of the pixel to a new label value "3".
And if the computer equipment determines that the label values of the connected pixels are not null in the neighborhood of the pixel to be processed, determining the minimum value of the label values corresponding to the connected pixels, and updating the label value of the current pixel to the minimum value. For example, for the nth pixel of the nth row, the label value of the pixel adjacent to the nth pixel on the previous row is "1", and the label value of the pixel adjacent to the nth pixel on the left side is "3", the computer device updates the label value of the current pixel to the minimum value "1" of the label values corresponding to the connected pixels.
Therefore, after the computer finishes processing the current pixel of the current pixel row, the next pixel of the current pixel row is taken as the pixel to be processed in the next round, the step of determining the neighborhood of the pixel to be processed is returned, the execution is continued until all pixels in the current pixel row are traversed, and the label values corresponding to all pixels are obtained. In general, a computer may traverse a row of pixels from left to right.
In the embodiment, the label value of each pixel is determined by traversing each pixel row, and the region formed by connecting the pixels with the same label value is used as the connected region, so that the pixels in different connected regions in the image can be provided with unique labels, and the pixels with the same property and the same label are classified together, thereby facilitating the subsequent accurate counting of the electronic components.
In some embodiments, as shown in fig. 5, the counting the components according to the connected region by the computer device and obtaining a counting result includes:
step S502, determining the areas of the connected regions corresponding to the connected regions in the target image, and calculating the target average area of the current time according to the areas of the connected regions corresponding to the connected regions.
Step S504, a plurality of target connected regions with the connected region area smaller than the target average area are determined, candidate average areas of the plurality of target connected regions are calculated, and the candidate average areas are used as the target average areas of the next round.
Step S506, return to the step of determining a plurality of target connected regions having connected region areas smaller than the target average area and continue to be executed until the obtained target average area is consistent with the target average area obtained in the previous round.
And step S508, performing rounding operation according to the total area corresponding to the component area in the target image and the finally obtained target average area to obtain a counting result.
Specifically, after traversing all pixels of all pixel rows, the computer device obtains a plurality of connected regions, determines the area of the connected region corresponding to each connected region in the target image, and calculates the current target average area according to the area of the connected region corresponding to each connected region. Then, the computer apparatus determines a plurality of target connected regions having a connected region area smaller than the target average area, for example, determines a plurality of target connected regions having a connected region area of 1/2 or 1/3 or the like that is the target average area of the current round, and calculates a candidate average area with these target connected regions, and takes the candidate average area as the target average area of the next round; the computer device then returns to the step of determining a plurality of target connected regions having connected region areas smaller than the target average area and continues to execute, thereby looping the iteration until the obtained target average area coincides with the target average area obtained in the previous round. And finally, the computer equipment performs rounding operation according to the finally obtained target average area and the total area corresponding to the component area in the target image, wherein the obtained integer is the counting result.
Exemplarily, the computer device calculates the number N of connected regions in the image and calculates the area a of each connected region, and sorts the areas a of the connected regions in the image from small to large to obtain an average area Avg; to further refine the average area, the average area in the range of 0.3Avg to Avg is counted based on the calculated Avg, and the procedure is repeated until the average area Avg does not change any more. Then, the computer device takes the quotient approximate integer of the total area and the average area of the single electronic component as the number of the components:
Figure BDA0003290650370000191
where N is the number of components sought, S is the total area of the component regions, Avg is the average area of individual components, and round represents rounding by a rounding method.
In the above embodiment, the electronic components are counted by using the area method through loop iteration until the average area of the components in the image does not change any more, so that the accuracy of the counting result can be improved.
In a specific example, as shown in fig. 6, the above counting method for electronic components may be integrated in a software program, and image processing is implemented by running a program code to complete automatic counting of electronic components. Practical application scenarios are for example: the computer device inputs the received color image into a software program that performs processing of the image to complete the counting. Firstly, a software program converts a color image into a gray image and carries out binarization processing on the gray image; then, sequentially carrying out image corrosion operation and image expansion operation, realizing image boundary contour processing and image interesting region extraction by using an edge detection algorithm, and counting whether the number of interesting regions is changed from the previous time; if the change is detected, carrying out image segmentation processing based on a watershed segmentation algorithm, and carrying out operations of corrosion, expansion, boundary contour processing and region-of-interest extraction again; and if the number of the interested areas is unchanged from the last time, marking the connected areas, counting based on the connected areas, and finally outputting and displaying the counting result on a display device by the computer equipment. The display device is, for example, a display screen. Fig. 7 shows the image processing and counting results of the above-mentioned counting method for electronic components, and fig. (a) and (c) show the originally captured images of the capacitor in the component accommodating device captured by the image capturing device, and fig. (b) and (d) show the corresponding counting results of fig. (a) and (c), respectively; the originally acquired image of the conversion chip in the component accommodating device acquired by the image acquisition device is shown in the diagram (e), and the diagram (f) is the corresponding counting result; the diagram (g) shows the originally acquired image of the power chip in the component accommodating device acquired by the image acquisition device, and the diagram (h) is the corresponding counting result.
The counting method of the electronic components, provided in the embodiment of the application, realizes the accurate counting of the electronic components of different types, different shapes and different positions, has the characteristics of wide type of identified electronic components, high identification precision, arbitrary placing position of the electronic components, portability, flexibility, convenience and the like, solves the problems of low universality, narrow application range, low counting efficiency, high error rate and the like of manual counting of the electronic components such as resistors, capacitors, integrated circuit chips, discrete devices and the like due to various types, improves the counting detection efficiency, reduces the cost and has wide application prospect.
It should be understood that although the various steps in the flow charts of fig. 2-6 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-6 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps.
In one embodiment, as shown in fig. 8, there is provided an electronic component counting apparatus 800, including: a preprocessing module 801, a morphology processing module 802, a region extraction module 803, a region segmentation module 804, a loop processing module 805, and a counting module 806, wherein:
the preprocessing module 801 is configured to acquire a component image, preprocess the component image to obtain a preprocessed image, and use the preprocessed image as a primary edge image to be processed; the component images are obtained by shooting components to be counted placed in the component accommodating device in the shielding device by using an image acquisition device arranged above the component accommodating device.
The morphology processing module 802 is configured to acquire a current edge image to be processed, and perform morphology erosion processing and morphology expansion processing on the current edge image to be processed, so as to obtain a current morphology image.
The region extraction module 803 is configured to perform region extraction on the current morphological image to obtain a target image including a plurality of target regions and the number of the target regions.
And the region segmentation module 804 is configured to, if the number of the target regions obtained by the current processing is not consistent with the number of the target regions obtained by the previous processing, perform image region segmentation processing on the current target image to obtain a segmented edge image.
And a loop processing module 805, configured to take the segmented edge image as an edge image to be processed in the next round, and return to the morphology processing module 802 to continue executing until the number of target regions obtained in the next round is consistent with the number of target regions obtained in the previous round, and stop the loop processing.
And the counting module 806 is configured to determine a plurality of connected regions in the target image based on the target image obtained through the last processing, count the components according to the connected regions, and obtain a counting result.
In one embodiment, the counting module is further configured to: determining a current pixel row to be processed in all pixel rows in the target image; sequentially determining label values corresponding to all pixels in the current pixel processing row; taking the next pixel row as the pixel row to be processed in the next round, and returning to the step of sequentially determining the label value corresponding to each pixel in the pixel row to be processed in the current round to continue to execute until all the pixel rows are traversed; forming an equivalence pair by the label values with equivalence relation in the plurality of label values to obtain at least one group of equivalence pairs; taking the minimum value of the label value in each equivalent pair as the standard label value in the corresponding equivalent pair; traversing the target image according to each equivalent pair, and updating the label value of the pixel corresponding to the same equivalent pair into the standard label value of the corresponding equivalent pair; and determining pixels corresponding to the same standard label value as a connected region to obtain a plurality of connected regions in the target image.
In one embodiment, the counting module is further configured to: determining a current pixel to be processed in a current pixel row, and determining a neighborhood of the pixel to be processed; if the label value of the connected pixels is null in the neighborhood of the pixel to be processed, updating the label value of the current pixel into a new label value; if the label value of the connected pixels is not null in the neighborhood of the pixel to be processed, determining the minimum value in the label values corresponding to the connected pixels, and updating the label value of the current pixel to the minimum value; and taking the next pixel as the pixel to be processed in the next round, returning to the step of determining the neighborhood of the pixel to be processed, and continuing to execute the step until all pixels in the current pixel row are traversed, and obtaining the label values corresponding to all pixels.
In one embodiment, the counting module is further configured to: determining the areas of the connected regions corresponding to the connected regions in the target image, and calculating the average area of the target at the current time according to the areas of the connected regions corresponding to the connected regions; determining a plurality of target connected regions with the connected region area smaller than the target average area, calculating candidate average areas of the plurality of target connected regions, and taking the candidate average areas as the target average areas of the next round; returning to the step of determining a plurality of target connected regions with the connected region areas smaller than the target average area and continuing to execute until the obtained target average area is consistent with the target average area obtained in the previous round; and carrying out rounding operation according to the total area corresponding to the component area in the target image and the finally obtained target average area to obtain a counting result.
For specific limitations of the counting device for electronic components, reference may be made to the above limitations on the counting method for electronic components, and details are not described here. All or part of each module in the counting device of the electronic component can be realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, and the computer device may be the computer device in the foregoing embodiments, and its internal structure diagram may be as shown in fig. 9. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a method of counting electronic components. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 9 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is further provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the above method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A system for counting electronic components, the system comprising:
the counting platform is used for bearing the component accommodating device;
the component accommodating device is placed on the counting platform and used for accommodating components to be counted;
the shielding device is detachably arranged on the counting platform, surrounds the outside of the component accommodating device and forms a closed space with the counting platform so as to shield ambient light; an opening is formed in one surface of the shielding device, and the opening is used for taking out and putting in the component accommodating device;
the image acquisition device is arranged above the component accommodating device and used for shooting components placed in the component accommodating device from different angles and obtaining component images;
and the computer equipment is used for receiving the component images acquired and transmitted by the image acquisition device at a plurality of acquisition angles, counting the component images and obtaining the counting result of the components.
2. The system according to claim 1, wherein the image capturing device is disposed above the component receiving device via a fixing bracket, the bracket comprises a transverse bracket and a longitudinal bracket, the transverse bracket is used for driving the image capturing device to rotate, and the longitudinal bracket is a telescopic rod.
3. The system of claim 1, wherein the shielding device is a flexible material; the shielding device is erected on the counting platform through a supporting bracket.
4. The system of claim 1, wherein the computer device is configured to obtain a plurality of counting results according to the component images acquired by the image acquisition device at a plurality of acquisition angles, respectively; and carrying out average value processing on the plurality of counting results to obtain a final counting result.
5. The system of any one of claims 1 to 4, wherein the computer device is configured to:
preprocessing the component image received from the image acquisition device to obtain a preprocessed image, and taking the preprocessed image as a primary edge image to be processed;
acquiring a current edge image to be processed, and performing morphological corrosion processing and morphological expansion processing on the current edge image to be processed respectively to obtain a current morphological image;
performing region extraction on the current morphological image to obtain a target image comprising a plurality of target regions and the number of the target regions;
if the number of the target areas obtained by the current processing is not consistent with the number of the target areas obtained by the previous processing, performing image area segmentation processing on the current target image to obtain a segmented edge image;
taking the segmented edge image as a to-be-processed edge image of the next round, returning to the step of respectively performing morphological erosion processing and morphological dilation processing on the to-be-processed edge image, and continuing to execute the steps until the number of target areas obtained by the next round of processing is consistent with the number of target areas obtained by the last round of processing, and stopping the circular processing;
and determining a plurality of connected regions in the target image based on the target image obtained by the last processing, counting the components according to the connected regions, and obtaining a counting result.
6. A counting method of electronic components, characterized in that the method comprises:
acquiring a component image, preprocessing the component image to obtain a preprocessed image, and taking the preprocessed image as a primary edge image to be processed; the component images are obtained by shooting components to be counted in the component accommodating device in the shielding device by using an image acquisition device arranged above the component accommodating device;
acquiring a current edge image to be processed, and performing morphological corrosion processing and morphological expansion processing on the current edge image to be processed respectively to obtain a current morphological image;
performing region extraction on the current morphological image to obtain a target image comprising a plurality of target regions and the number of the target regions;
if the number of the target areas obtained by the current processing is not consistent with the number of the target areas obtained by the previous processing, performing image area segmentation processing on the current target image to obtain a segmented edge image;
taking the segmented edge image as a to-be-processed edge image of the next round, returning to the step of respectively performing morphological erosion processing and morphological dilation processing on the to-be-processed edge image, and continuing to execute the steps until the number of target areas obtained by the next round of processing is consistent with the number of target areas obtained by the last round of processing, and stopping the circular processing;
and determining a plurality of connected regions in the target image based on the target image obtained by the last processing, counting the components according to the connected regions, and obtaining a counting result.
7. The method of claim 6, wherein the determining a plurality of connected regions in the target image comprises:
determining a current pixel row to be processed in all pixel rows in the target image;
sequentially determining label values corresponding to all pixels in the current pixel processing row;
taking the next pixel row as the pixel row to be processed in the next round, and returning to the step of sequentially determining the label value corresponding to each pixel in the pixel row to be processed in the current round to continue to execute until all the pixel rows are traversed;
forming an equivalence pair by the label values with equivalence relation in the plurality of label values to obtain at least one group of equivalence pairs;
taking the minimum value of the label value in each equivalent pair as the standard label value in the corresponding equivalent pair;
traversing the target image according to each equivalent pair, and updating the label value of the pixel corresponding to the same equivalent pair into the standard label value of the corresponding equivalent pair;
and determining pixels corresponding to the same standard label value as a connected region to obtain a plurality of connected regions in the target image.
8. The method of claim 7, wherein the sequentially determining the standard label value corresponding to each pixel in the current row of processed pixels comprises:
determining a current pixel to be processed in a current pixel row, and determining a neighborhood of the pixel to be processed;
if the label value of the connected pixels is null in the neighborhood of the pixel to be processed, updating the label value of the current pixel into a new label value;
if the label value of the connected pixel is not null in the neighborhood of the pixel to be processed, determining the minimum value in the label values corresponding to the connected pixels, and updating the label value of the current pixel to the minimum value;
and taking the next pixel as the pixel to be processed in the next round, returning to the step of determining the neighborhood of the pixel to be processed, and continuing to execute the step until all pixels in the current pixel row are traversed, and obtaining the label values corresponding to all pixels.
9. The method of claim 6, wherein counting the components according to the connected region and obtaining a counting result comprises:
determining the areas of the connected regions corresponding to the connected regions in the target image respectively, and calculating the average area of the target at the current time according to the areas of the connected regions corresponding to the connected regions respectively;
determining a plurality of target connected regions with the connected region areas smaller than the target average area, calculating candidate average areas of the plurality of target connected regions, and taking the candidate average areas as the target average areas of the next round;
returning to the step of determining a plurality of target connected regions with the connected region areas smaller than the target average area and continuing to execute until the obtained target average area is consistent with the target average area obtained in the previous round;
and carrying out rounding operation according to the total area corresponding to the component area in the target image and the finally obtained target average area to obtain a counting result.
10. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor realizes the steps of the method of any one of claims 6 to 9 when executing the computer program.
CN202111163535.7A 2021-09-30 2021-09-30 Counting system and method for electronic components and computer equipment Pending CN113870231A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111163535.7A CN113870231A (en) 2021-09-30 2021-09-30 Counting system and method for electronic components and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111163535.7A CN113870231A (en) 2021-09-30 2021-09-30 Counting system and method for electronic components and computer equipment

Publications (1)

Publication Number Publication Date
CN113870231A true CN113870231A (en) 2021-12-31

Family

ID=79001246

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111163535.7A Pending CN113870231A (en) 2021-09-30 2021-09-30 Counting system and method for electronic components and computer equipment

Country Status (1)

Country Link
CN (1) CN113870231A (en)

Similar Documents

Publication Publication Date Title
CN109978839B (en) Method for detecting wafer low-texture defects
US10049492B2 (en) Method and apparatus for rendering facades of objects of interest from three-dimensional point clouds
US9846946B2 (en) Objection recognition in a 3D scene
CN111340752A (en) Screen detection method and device, electronic equipment and computer readable storage medium
CN110717489B (en) Method, device and storage medium for identifying text region of OSD (on Screen display)
CN108460362B (en) System and method for detecting human body part
CN110766679A (en) Lens contamination detection method and device and terminal equipment
CN108564579B (en) Concrete crack detection method and detection device based on time-space correlation
CN108986152B (en) Foreign matter detection method and device based on difference image
CN109711246B (en) Dynamic object recognition method, computer device and readable storage medium
CN109272060B (en) Method and system for target detection based on improved darknet neural network
CN113837079B (en) Automatic focusing method, device, computer equipment and storage medium of microscope
CN110910445B (en) Object size detection method, device, detection equipment and storage medium
CN110428394B (en) Method, apparatus and computer storage medium for target movement detection
CN107578424B (en) Dynamic background difference detection method, system and device based on space-time classification
CN112014413A (en) Mobile phone glass cover plate window area defect detection method based on machine vision
Shostko et al. Optical-electronic system of automatic detection and higt-precise tracking of aerial objects in real-time.
CN113470065B (en) Moving object detection and tracking method and apparatus
CN113870231A (en) Counting system and method for electronic components and computer equipment
CN115063473A (en) Object height detection method and device, computer equipment and storage medium
CN115330705A (en) Skin paint surface defect detection method based on adaptive weighting template NCC
CN108734175A (en) A kind of extracting method of characteristics of image, device and electronic equipment
CN111709377B (en) Feature extraction method, target re-identification method and device and electronic equipment
Xu Study on moving objects by video monitoring system of recognition and tracing scheme
CN113963004A (en) Sampling method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination