Counting System, Method and Computer Device for Electronic Components
Through the system of counting platform and image acquisition device combined with computer equipment, the problems of low counting efficiency and low accuracy of electronic components are solved, and efficient and accurate counting of components of different types and locations are achieved, with portability and flexibility.
Patent Information
- Application Number
- CN202111163535.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2041-09-30
AI Technical Summary
The prior art is difficult to count electronic components efficiently and accurately, especially in the face of various types, different shapes and randomly placed components, resulting in low counting efficiency, low accuracy and high error detection rate.
A system consisting of a counting platform, component accommodating device, a detachable shielding device and an image acquisition device is adopted to combine computer equipment for image preprocessing, morphological corrosion and expansion processing, area extraction and segmentation, and automated counting is achieved through multi-angle image acquisition and processing.
It improves the efficiency and accuracy of electronic component counting, reduces the error detection rate, adapts to the requirements of components counting in different types and locations, and has portability and flexibility.
Smart Images

Figure CN113870231B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic components, and particularly to a counting system, method, device, computer device, and storage medium for electronic components. Background Art
[0002] Due to the wide variety of electronic components and their different shapes and sizes, and with the progress of microelectronic technology towards ultra-high integration, miniaturization, and customization, the need for counting electronic components in the screening, identification, testing, and evaluation of electronic component products is becoming increasingly urgent.
[0003] Due to the increasing demand for counting and statistics of electronic components in identification, screening, testing, and evaluation, various types of electronic components have different sizes, models, and specifications, and their placement positions in the tray are arbitrary. There may be adjacent two or more electronic components adjacent to each other or slightly overlapping. How to count and statistics them has become an urgent need and a technical difficulty. Traditionally, the method of manual counting and statistics is used to count and statistics electronic components of arbitrary shapes, which has the disadvantage of high error detection rate and is difficult to meet the increasingly complex and diverse counting requirements of electronic components. Summary of the Invention
[0004] Based on this, in view of the above technical problems, it is necessary to provide a counting system, method, device, computer device, and storage medium for electronic components that can improve the counting accuracy of electronic components.
[0005] A counting system for electronic components, the system includes: a counting platform for carrying a component accommodating device; a component accommodating device placed on the counting platform for accommodating components to be counted; a shielding device detachably arranged on the counting platform, surrounding the outside of the component accommodating device, and forming a closed space with the counting platform to shield ambient light; wherein, one side of the shielding device is provided with an opening for taking out and putting in the component accommodating device; an image acquisition device arranged above the component accommodating device for photographing the components placed in the component accommodating device from different angles and obtaining component images; a computer device for receiving the component images collected and transmitted by the image acquisition device at multiple acquisition angles and counting the component images to obtain a counting result of the components.
[0006] In one embodiment, the image acquisition device is arranged above the component accommodating device through a fixed bracket, and the bracket includes a horizontal bracket and a vertical bracket. Among them, the horizontal bracket is used to drive the image acquisition device to rotate, and the vertical bracket is a telescopic rod.
[0007] In one embodiment, the shielding device is made of a flexible material; the shielding device is erected on the counting platform through a support bracket.
[0008] In one embodiment, the computer device is configured to obtain multiple counting results respectively according to the component images collected by the image acquisition device at multiple acquisition angles; and perform mean processing on the multiple counting results to obtain a final counting result.
[0009] In one embodiment, the computer device is configured to: preprocess the component image received from the image acquisition device to obtain a preprocessed image, and use the preprocessed image as the initial edge image to be processed; obtain the edge image to be processed for the current time, perform morphological erosion processing and morphological dilation processing on the edge image to be processed respectively to obtain the morphological image for the current time; perform region extraction on the morphological image for the current time to obtain a target image including multiple target regions and the number of target regions; if the number of target regions obtained by the current processing is inconsistent with the number of target regions obtained by the previous round of processing, perform image region segmentation processing on the target image for the current time to obtain a segmented edge image; use the segmented edge image as the edge image to be processed for the next round, and return to the step of performing morphological erosion processing and morphological dilation processing on the edge image to be processed respectively and continue to execute until the number of target regions obtained by the current processing is consistent with the number of target regions obtained by the previous round of processing, then stop the loop processing; based on the target image obtained by the last processing, determine multiple connected regions in the target image, and count the components according to the connected regions to obtain a counting result.
[0010] A counting method for electronic components, the method comprising: acquiring a component image, preprocessing the component image to obtain a preprocessed image, and using the preprocessed image as the initial edge image to be processed; the component image is obtained by taking pictures of the components to be counted placed in a component accommodating device by an image acquisition device disposed above the component accommodating device within a shielding device; acquiring the edge image to be processed for the current time, performing morphological erosion processing and morphological dilation processing on the edge image to be processed respectively to obtain the morphological image for the current time; performing region extraction on the morphological image for the current time to obtain a target image including a plurality of target regions and the number of target regions; if the number of target regions obtained from the current processing is inconsistent with the number of target regions obtained from the previous round of processing, performing image region segmentation processing on the target image for the current time to obtain a segmented edge image; using the segmented edge image as the edge image to be processed for the next round, and returning to the step of performing morphological erosion processing and morphological dilation processing on the edge image to be processed respectively to continue execution until the number of target regions obtained from the current processing is consistent with the number of target regions obtained from the previous round of processing, then stopping the loop processing; based on the target image obtained from the last processing, determining a plurality of connected regions in the target image, and counting the components according to the connected regions to obtain a counting result.
[0011] In one embodiment, the determining a plurality of connected regions in the target image includes: determining the pixel row to be processed for the current time among all pixel rows in the target image; sequentially determining the label values corresponding to each pixel in the pixel row to be processed for the current time; using the next pixel row as the pixel row to be processed for the next round, and returning to the step of sequentially determining the label values corresponding to each pixel in the pixel row to be processed for the current time to continue execution until all pixel rows are traversed; forming equivalence pairs with the label values having an equivalence relationship among the plurality of label values to obtain at least one group of equivalence pairs; using the minimum value of the label values in each equivalence pair as the standard label value in the corresponding equivalence pair; traversing the target image according to each equivalence pair, and updating the label values of the pixels corresponding to the same equivalence pair to the standard label value of the corresponding equivalence pair; determining the pixels corresponding to the same standard label value as a connected region to obtain a plurality of connected regions in the target image.
[0012] In one embodiment, the step of sequentially determining the standard label values corresponding to each pixel in the current processing pixel row includes: determining the pixel to be processed in the current pixel row for the current time, and determining the neighborhood of the pixel to be processed; if the label values of the connected pixels in the neighborhood of the pixel to be processed are empty, updating the label value of the current pixel to a new label value; if the label values of the connected pixels in the neighborhood of the pixel to be processed are not empty, determining the minimum value among the label values corresponding to the connected pixels, and updating the label value of the current pixel to the minimum value; taking the next pixel as the pixel to be processed in the next round, and returning to the step of determining the neighborhood of the pixel to be processed and continuing to execute until all pixels in the current pixel row are traversed and the label values corresponding to all pixels are obtained.
[0013] In one embodiment, the step of counting the components according to the connected regions and obtaining a counting result includes: determining the connected region areas corresponding to the respective connected regions in the target image, and calculating the target average area for the current time according to the connected region areas corresponding to the respective connected regions; determining a plurality of target connected regions whose connected region areas are smaller than the target average area, and calculating the candidate average area of the plurality of target connected regions, and taking the candidate average area as the target average area for the next round; returning to the step of determining the plurality of target connected regions whose connected region areas are smaller than the target average area and continuing to execute until the obtained target average area is the same as the target average area obtained in the previous round; performing a rounding operation according to the total area corresponding to the component region in the target image and the finally obtained target average area to obtain the counting result.
[0014] A counting device for electronic components, the device comprising: a preprocessing module for acquiring a component image, preprocessing the component image to obtain a preprocessed image, and using the preprocessed image as the initial edge image to be processed; the component image is obtained by taking pictures of the components to be counted placed in a component accommodating device by an image acquisition device disposed above the component accommodating device within a shielding device; a morphological processing module for acquiring the edge image to be processed for the current time, performing morphological erosion processing and morphological dilation processing on the edge image to be processed respectively to obtain the morphological image for the current time; a region extraction module for performing region extraction on the morphological image for the current time to obtain a target image including a plurality of target regions and the number of target regions; a region segmentation module for, if the number of target regions obtained in the current processing is inconsistent with the number of target regions obtained in the previous round of processing, performing image region segmentation processing on the target image for the current time to obtain a segmented edge image; a loop processing module for using the segmented edge image as the edge image to be processed in the next round and returning to the morphological processing module to continue execution until the number of target regions obtained in the current processing is consistent with the number of target regions obtained in the previous round of processing, at which point the loop processing is stopped; a counting module for determining a plurality of connected regions in the target image based on the target image obtained in the last processing, counting the components according to the connected regions, and obtaining a counting result.
[0015] In one embodiment, the counting module is further configured to: determine the pixel row to be processed for the current time among all pixel rows in the target image; sequentially determine the label values corresponding to each pixel in the pixel row to be processed for the current time; use the next pixel row as the pixel row to be processed in the next round and return to the step of sequentially determining the label values corresponding to each pixel in the pixel row to be processed for the current time to continue execution until all pixel rows are traversed; form equivalence pairs with the label values having an equivalence relationship among the plurality of label values to obtain at least one set of equivalence pairs; use the minimum value of the label values in each equivalence pair as the standard label value in the corresponding equivalence pair; traverse the target image according to each equivalence pair and update the label values of the pixels corresponding to the same equivalence pair to the standard label value of the corresponding equivalence pair; determine the pixels corresponding to the same standard label value as a connected region to obtain a plurality of connected regions in the target image.
[0016] In one embodiment, the counting module is further configured to: determine the to-be-processed pixel in the current pixel row for the current time, and determine the neighborhood of the to-be-processed pixel; if the label value of the connected pixel in the neighborhood of the to-be-processed pixel is empty, update the label value of the current pixel to a new label value; if the label value of the connected pixel in the neighborhood of the to-be-processed pixel is not empty, determine the minimum value among the label values corresponding to the connected pixels, and update the label value of the current pixel to the minimum value; take the next pixel as the to-be-processed pixel for the next round, and return to the step of determining the neighborhood of the to-be-processed pixel and continue to execute until all pixels in the current pixel row are traversed and the label values corresponding to all pixels are obtained.
[0017] In one embodiment, the counting module is further configured to: determine the connected region area corresponding to each connected region in the target image, and calculate the target average area for the current time according to the connected region area corresponding to each connected region; determine multiple target connected regions whose connected region area is less than the target average area, and calculate the candidate average area of the multiple target connected regions, and use the candidate average area as the target average area for the next round; return to the step of determining multiple target connected regions whose connected region area is less than the target average area and continue to execute until the obtained target average area is the same as the target average area obtained in the previous round; perform a rounding operation according to the total area corresponding to the component region in the target image and the finally obtained target average area to obtain the counting result.
[0018] A computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps of the above method are implemented.
[0019] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0020] The above counting system for electronic components forms a movable, low-cost, and easy-to-operate counting system by setting a counting platform, a component accommodating device, a detachable shielding device, an image acquisition device capable of capturing images of components from different angles, and a computer device, avoiding the influence of ambient light that may cause inaccurate counting results of the computer device; at the same time, the computer device performs image processing on the component images collected and transmitted by the image acquisition device at multiple acquisition angles for counting, without the need to count specific types of components separately. Compared with the manual counting method, the efficiency and accuracy of electronic component counting are greatly improved, and the error detection rate is low.
[0021] The above counting method, device, computer equipment and storage medium for electronic components obtain the images of the components collected by the image acquisition device arranged above the component accommodation device within the shielding device, and successively perform edge enhancement processing, morphological erosion processing, morphological dilation processing, and region extraction, and determine whether the number of target regions obtained in the current processing changes. If it changes, return to the steps of morphological processing and repeat the loop until the number of target regions no longer changes. Then, count based on the finally obtained target image to obtain the counting result, improving the accuracy of electronic component counting and having a low error detection rate. Description of the Drawings
[0022] Figure 1 It is a schematic structural diagram of a counting system for electronic components in an embodiment;
[0023] Figure 2 It is a schematic flowchart of a counting method for electronic components in an embodiment;
[0024] Figure 3 It is a schematic flowchart of the steps for a computer device in an embodiment to determine multiple connected regions in the target image;
[0025] Figure 4 It is a schematic flowchart of the steps for a computer device in an embodiment to sequentially determine the standard label values corresponding to each pixel in the current processing pixel row;
[0026] Figure 5 It is a schematic flowchart of the steps for a computer device in an embodiment to count the components according to the connected regions and obtain the counting result;
[0027] Figure 6 It is a schematic flowchart of a counting method for electronic components in another embodiment;
[0028] Figure 7 It is a schematic diagram of the actual application effect of a counting method for electronic components in an embodiment;
[0029] Figure 8 It is a structural block diagram of a counting device for electronic components in an embodiment;
[0030] Figure 9 It is an internal structure diagram of a computer device in an embodiment. Detailed Description of the Embodiments
[0031] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0032] Due to the wide variety of electronic components and their different dimensions, and with the advancement of microelectronics process technology, the development of ultra-high integration, miniaturization, and customization, the demand for counting electronic components in the screening, identification, testing and evaluation of electronic component products is becoming increasingly urgent. For example, in the screening of electronic components, after the performance parameter test of electronic component products, the qualified and unqualified electronic components are usually classified and placed in different trays. In order to save time and improve efficiency, electronic components are usually placed randomly in the trays without any rules to follow. For these randomly placed electronic component products, their number needs to be counted after testing to prepare for subsequent reliability tests or electrical tests.
[0033] Due to the increasing demand for counting and statistics of electronic components in identification, screening, testing and evaluation, various types of electronic components have different sizes, models and specifications, and are placed in arbitrary positions on the tray. It is possible that two or more adjacent electronic components are adjacent or slightly overlapped. How to count and count them has become an urgent need and technical difficulty. Traditionally, manual counting and statistics are used to count and count electronic components of arbitrary shapes, which has the disadvantages of low efficiency, low repeatability and high error detection rate, and it is difficult to meet the increasingly complex and diverse counting needs of electronic components. At present, the existing counting and statistics systems on the market can only count a certain type or several types of electronic components in fixed positions and specific packages, and cannot meet the counting and statistics needs of general electronic components in arbitrary positions and different packages.
[0034] In view of this, the present application provides a counting system for electronic components, which includes a counting platform, a component containing device, a shielding device, an image acquisition device, and a computer device. The system fully utilizes the versatility, portability, lightness and extensiveness brought by the component containing device, and the anti-interference performance of the shielding device to the light environment, thereby ensuring the high quality and high stability of the electronic component image acquisition; the computer equipment is based on image preprocessing, image enhancement, morphological expansion, corrosion and automatic counting comprehensive processing algorithms, and has the characteristics of identifying a wide range of electronic components, high recognition accuracy, and arbitrary placement of electronic components. It can be widely used in the intelligent and automated counting and statistics of electronic components such as resistors, capacitors, integrated circuit chips, discrete devices, etc., which can improve the efficiency and accuracy of electronic component counting, and has a low error detection rate.
[0035] like Figure 1As shown in the figure, 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 acquisition device 104, and a computer device 105. Among them, the counting platform 101 is used to carry the component accommodating device 102. The component accommodating device 102 is placed on the counting platform 101 and is used to accommodate the electronic components to be counted, such as one or more of resistors, capacitors, chips, and discrete devices. The shielding device 103 is detachably arranged on the counting platform 101, surrounds the outside of the component accommodating device 102, and forms a closed space with the counting platform 101 to shield ambient light and ensure the image quality of the electronic component imaging; among them, one side of the shielding device 103 is provided with an opening for taking out and putting in the component accommodating device 102; the image acquisition device 104 is arranged above the component accommodating device 102 and is used to take pictures of the components placed in the component accommodating device 102 from different angles and obtain component images; the computer device 105 is used to receive the component images collected and transmitted by the image acquisition device 104 at multiple acquisition angles, and count the component images to obtain the counting result of the components. Among them, the image acquisition device 104 and the computer device 105 are connected through a network, and the network can be the Internet, a mobile network, a local area network, a wide area network, a storage area network, or one or more internal networks, etc., or a suitable combination thereof.
[0036] In some embodiments, the component accommodating device is, for example, a portable mobile tray, which is convenient and flexible to take out. Exemplarily, anti-static foam can be pasted on the component accommodating device to prevent the electronic components from sticking or stacking together due to electrostatic adsorption.
[0037] In some embodiments, the shielding device is, for example, a box-shaped photography studio with a side opening, which can be fixed on the counting platform or detachably arranged on the counting platform. When the side opening is opened / closed, the operator can put the component accommodating device on the counting platform into the shielding device or take out the component accommodating device placed on the counting platform from the inside of the shielding device; when the shielding device closes the side opening, the shielding device and the counting platform form a closed space, thereby isolating the light of the external environment from entering and ensuring the quality during the shooting of the image acquisition device.
[0038] In some embodiments, the shielding device can also be made of a flexible material for easy carrying. When using the system, the flexible shielding device can be supported by a support bracket and erected on the counting platform to form a cavity that shields ambient light. When the system is in an idle state, the support bracket can be folded / retracted, thus folding and storing the flexible shielding device for easy carrying. The flexible shielding device can also be detachably mounted on the counting platform, supported by the support bracket when in use, and detached from the counting platform and folded for storage when idle, which is convenient and flexible to assemble and easy to carry. In addition, since the flexible material has a buffering effect, it greatly reduces noise and avoids the impact of vibrations caused by noise on small-sized and light-weight electronic components. Among them, the flexible material includes synthetic fibers, animal or plant fibers, or other fiber materials known in the art, such as polyester rubber, etc.
[0039] In some embodiments, the image acquisition device includes, but is not limited to, a camera module integrated with an optical system or a CCD (Charge Coupled Device) chip, and a camera module integrated with an optical system and a CMOS (Complementary Metal Oxide Semiconductor) chip, etc. The image acquisition device can be fixedly mounted on a fixed bracket, or can be detachably mounted on the fixed bracket, such as by clamping, magnetic attraction, and pasting, etc., so as to improve the portability and flexibility of the system.
[0040] To improve the accuracy of counting, the image acquisition device acquires component images at multiple acquisition angles and transmits them to a computer device; the computer device synthesizes multiple counting results at different acquisition angles to obtain the final counting result, which is more accurate and has a low misdetection rate. For this reason, in some embodiments, as Figure 1 shown, the image acquisition device is arranged above the component accommodating device through a fixed bracket. The bracket includes a horizontal bracket 1041 and a vertical bracket 1042. Among them, the horizontal bracket 1041 is used to drive the image acquisition device to rotate, and the vertical bracket 1042 is a telescopic rod. Among them, the fixed bracket is designed based on a thread. The horizontal bracket is fixed to the vertical bracket and moves up and down through the telescoping of the vertical bracket, facilitating the adjustment of the distance between the image acquisition device and the component accommodating device. The horizontal bracket can rotate 360°, so that the image acquisition device and the component accommodating device can adjust the horizontal position to make the field of view cover the component accommodating device.
[0041] Exemplarily, the image acquisition device is set vertically downward by default, and its optical axis (the central axis of the camera) is perpendicular to the counting platform 101. During the initial shooting, the image acquisition device vertically downward acquires an image, and then the lateral bracket 1041 drives the image acquisition device to rotate by means of rotation or twisting, etc., so that the image acquisition device forms a certain angle with the optical axis, and acquires an image again. Thus, compared with the way of manually placing electronic components by the operator to make them evenly distributed, the way of the image acquisition device acquiring images at multiple acquisition angles does not require manual uniform placement of components deliberately, and improves the counting accuracy.
[0042] Correspondingly, in some embodiments, the computer device is used to obtain multiple counting results respectively according to the component images acquired by the image acquisition device at multiple acquisition angles; and perform mean processing on the multiple counting results to obtain the final counting result. Specifically, the image acquisition device can transmit the component images acquired at different acquisition angles to the computer device in multiple times, or after all the acquisition angles are completed, transmit all the component images to the computer device; after receiving the component images, the computer device performs image processing respectively according to the component images acquired at multiple acquisition angles to obtain multiple counting results, and then calculates the average of the multiple technical results, and takes the average value as the final counting result.
[0043] The above counting system for electronic components forms a portable, flexible and easy-to-operate counting system by setting a counting platform, a component accommodating device, a detachable shielding device, an image acquisition device that can photograph components from different angles, and a computer device, avoiding the influence of ambient light that causes inaccurate counting results of the computer device, improving the efficiency and accuracy of electronic component counting, and having a low error detection rate.
[0044] To further improve the accuracy of the counting result of electronic components, the present application also provides a counting method for electronic components, which can be applied to a computer device as shown in Figure 1 wherein the computer device can be but is not limited to various personal computers, laptop computers, smart phones, tablet computers and portable wearable devices. It can be understood that this method can also be applied to a server, and can also be applied to a system including a computer device and a server, and is realized through the interaction between the computer device and the server.
[0045] In one embodiment, as shown in Figure 2 the counting method for electronic components provided by the present application includes the following steps:
[0046] Step S202: Obtain a component image, preprocess the component image to obtain a preprocessed image, and use the preprocessed image as the initial edge image to be processed. The component image is obtained by taking pictures of the components to be counted placed in the component accommodating device within the shielding device using an image acquisition device arranged above the component accommodating device.
[0047] Among them, after the counting system of the electronic components runs, the image acquisition device arranged above the component accommodating device takes pictures of the components to be counted placed in the component accommodating device at a collection angle, obtaining one or more component images. The image acquisition device can transmit the component images collected at different collection angles to the computer device in multiple times, or after all the collection angles are completed, transmit all the component images to the computer device for image processing by the computer device.
[0048] Exemplarily, the image acquisition device inputs the color image taken in the studio into the computer device through a transmission line. At the same time, the computer device synchronously stores the received color image in the storage space of the computer device.
[0049] Specifically, the computer device obtains the component image collected by the image acquisition device and preprocesses the component image to obtain a preprocessed image. Among them, preprocessing the component image includes, but is not limited to, one or more of grayscale processing and binarization processing, etc. Among them, in order to simplify the calculation amount, improve the calculation efficiency and accuracy, the computer device needs to convert the received color image into a grayscale image. For example, the computer can perform processing according to the weighted average method:
[0050] Gray(i,j) = 0.2989×R(i,j) + 0.5870×G(i,j) + 0.1140×B(i,j)
[0051] Among them, (i,j) represents the pixel at the i-th row and j-th column in the image.
[0052] Image binarization is the process of setting the grayscale value of the pixel points on the image to 0 or 255, that is, presenting the entire image with an obvious black and white effect. In the embodiment of the present application, the computer device performs binarization processing on the grayscale image using the global threshold method. First, the computer device determines the initial estimated value T of the global threshold; then, divides the image with T to generate two groups of pixels: G1 composed of all pixels with grayscale values greater than T and G2 composed of all pixels with grayscale values less than or equal to T; subsequently, the computer device calculates the average grayscale values m1 and m2 within the regions of G1 and G2 respectively; calculates the new threshold by the following formula, and repeats the above steps until the difference between the T values of the previous and subsequent times is smaller than the preset parameter ΔT:
[0053]
[0054] Thus, the computer device completes the preprocessing of the component image, obtains the preprocessed image, and uses the obtained preprocessed image as the initial edge image to be processed for subsequent image processing.
[0055] Step S204: Obtain the edge image to be processed for the current time, perform morphological erosion processing and morphological dilation processing on the edge image to be processed respectively, and obtain the morphological image for the current time.
[0056] In the morphological processing, the dilation operation can expand the target area in the image, and the erosion operation can shrink the target area in the image. Although the preprocessed binary image can well separate the target and the background and can completely retain the boundary information of the target object, there are problems such as internal hollowing, burrs and adhesions on the edge in the extracted target. These problems will affect the subsequent processing, resulting in poor accuracy of electronic component counting and increased computational complexity.
[0057] Therefore, in order to remove noise and impurities, it is necessary to use the morphological processing algorithm to solve the above problems for the binarized result, restore the electronic components to their original shapes in the image, and make the subsequent segmentation results achieve better effects. In the embodiments of the present application, morphological processing is used to optimize the binary image. Specifically, the computer device uses the obtained preprocessed image as the initial edge image to be processed, and sequentially performs morphological erosion processing and morphological dilation processing on the edge image to be processed respectively to obtain the morphological image for the current time.
[0058] The morphological erosion operation can reduce the range of the sensitive area and can well eliminate small target objects and image impurities. In the morphological erosion operation, the calculation formula for eroding image A with structure element B can be expressed as:
[0059]
[0060] Among them, if the structure element B is at the pixel point (x, y), and the element position of the structure element B is the same as the corresponding position element of the image A, it means that the result of the pixel point (x, y) is 1, otherwise it is 0. Among them, the structure element (StructureElement) is a two-dimensional or multi-dimensional binary neighborhood, and the central pixel of the structure element is called the origin, which is used to identify the pixel being processed in the image.
[0061] In the morphological dilation operation, the calculation formula for dilating image A with structure element B can be expressed as:
[0062]
[0063] The meaning of the above formula is the mapping of the structural element B with respect to the origin, and the origin of the structural element after mapping is translated to the image pixel point (x, y). If the intersection of and A at the image pixel point (x, y) is not empty (that is, at least one of the pixels corresponding to A at the pixel positions where is 1 in is 1), then the pixel point (x, y) corresponding to the output image is assigned 1; otherwise, it is assigned 0.
[0064] Step S206: Perform region extraction on the morphological image of the current time to obtain a target image including multiple target regions and the number of target regions.
[0065] Specifically, the computer device performs extraction of the region of interest on the morphological image of the current time to obtain a target image including multiple target regions and the number of target regions. Among them, the target region is the region of interest, and the image including the extracted region of interest is the target image.
[0066] Exemplarily, in image boundary contour processing and region of interest extraction, the computer device in the embodiment of the present application uses the Canny edge detection algorithm for image boundary contour processing and region of interest extraction. Since the gradient operator enhances 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 affected by noise, and the noise is the place where the gray level changes greatly. Therefore, the computer device first performs image denoising, and then calculates the gradient and direction of each pixel point in the image. Usually, the places where the gray level changes are relatively concentrated. If the pixel points with the largest gray level change in the gradient direction within the local range are retained and the others are not retained, a large number of pixel points can be removed, so that the edge with multiple pixel widths becomes an edge with a single pixel width. This process is non-maximum suppression. After the computer device performs non-maximum suppression processing, there may still be many edge points in the image. For this reason, the computer device sets a double threshold (that is, a low threshold and a high threshold), sets the pixel points with gray values greater than the high threshold as strong edge pixels, removes the pixel points with gray values lower than the low threshold, and sets the pixel points with gray values between the low threshold and the high threshold as weak edges. Thus, the computer device traverses and judges each pixel: if there is a strong edge pixel in its neighborhood, the pixel is retained; otherwise, the pixel is removed. Thus, the computer device obtains the boundary information and related regions of interest in the image and counts the number of regions of interest.
[0067] It should be noted that when the computer device processes an image for the first time, after obtaining the number of regions of interest for the first time, the computer device returns to step S204 and continues to execute until the number of regions of interest for the second time is obtained, and then the subsequent steps S208 to S212 are executed.
[0068] Step S208: If the number of target regions obtained in the current processing is inconsistent with the number of target regions obtained in the previous round of processing, perform image region segmentation processing on the target image of the current time to obtain the segmented edge image.
[0069] Specifically, the computer device compares the number of target regions obtained in the current processing with the number of target regions obtained in the previous round of processing, so as to determine whether the number of target regions obtained in the two processes is consistent. If the computer device determines through comparison that the number of target regions obtained in the current processing is inconsistent with the number of target regions obtained in the previous round of processing, perform image region segmentation processing on the target image of the current time to obtain the segmented edge image.
[0070] In some embodiments, the computer device uses the watershed segmentation algorithm to perform image region segmentation processing on the target image of the current time to obtain the segmented edge image.
[0071] The watershed segmentation algorithm can effectively extract the regions of interest in the image, which is beneficial for further processing of the sub-regions of the image. Its basic idea is to regard the image as a topological landform in geodesy. The gray value of each pixel in the image represents the altitude of that point. Each local minimum value and its influence region are called catchment basins, and the boundaries of the catchment basins form watersheds. The concept and formation of the watershed can be illustrated by simulating the immersion process. On the surface of each local minimum value, a small hole is pierced, and then the whole model is slowly immersed in water. As the immersion deepens, the influence domain of each local minimum value slowly expands outward. A dam is built at the confluence of two catchment basins, that is, the watershed is formed. The calculation process of the watershed is an iterative labeling process. First, the gray levels of each pixel are sorted from low to high, and then during the flooding process from low to high, the influence domain of each local minimum value at the h-order height is judged and labeled using a first-in-first-out structure. What the watershed transformation obtains is the catchment basin image of the input image, and the boundary points between the catchment basins are the watersheds. Obviously, the watershed represents the maximum value points of the input image. Therefore, in order to obtain the edge information of the image, usually the gradient image is used as the input image, that is
[0072]
[0073] In the formula, f(x, y) represents the original image, and grad(·) represents the gradient operation. Due to the noise in the image and the subtle gray-scale changes on the object surface, over-segmentation phenomena will occur. Therefore, in the embodiments of the present application, the watershed segmentation algorithm is adopted, which can have a good response to weak edges. In addition, the closed catch basins obtained by the watershed algorithm provide the possibility for analyzing the regional features of the image. To eliminate the over-segmentation generated by the watershed algorithm, usually two processing methods can be adopted. One is to use prior knowledge to remove irrelevant edge information. The other is to modify the gradient function so that the catch basins only respond to the targets to be detected. To reduce the over-segmentation generated by the watershed algorithm, usually the gradient function needs to be modified. A simple method is to perform threshold processing on the gradient image to eliminate the over-segmentation caused by the subtle gray-scale changes.
[0074] Thus, after the computer device performs image region segmentation processing on the target image of the current time, a segmented edge image is obtained, and subsequent processing steps are performed.
[0075] Step S210: Use the segmented edge image as the edge image to be processed in the next round, and return to the steps of respectively performing morphological erosion processing and morphological dilation processing on the edge image to be processed, and continue to execute until the number of target regions obtained in the current processing is the same as the number of target regions obtained in the previous round, then stop the loop processing.
[0076] Specifically, the computer device uses the obtained segmented edge image as the edge image to be processed in the next round, and returns to step S204 to continue execution. Thus, through iterative loop, until the number of target regions obtained in the current processing is the same as the number of target regions obtained in the previous round, the loop processing is stopped.
[0077] When the loop reaches the point where the number of target regions obtained in the current processing is the same as the number of target regions obtained in the previous round, the computer device obtains the final target image, and the target image contains several regions of interest (i.e., target regions).
[0078] Step S212: Based on the target image obtained in the last processing, determine multiple connected regions in the target image, count the components according to the connected regions, and obtain a counting result.
[0079] Specifically, the computer device is based on the target image obtained in the last processing. Based on the several regions of interest included in the target image, determine multiple connected regions in the target image, count the components according to the connected regions, and obtain a counting result.
[0080] The above method for counting electronic components obtains the images of components collected by an image acquisition device disposed above a component accommodating device within a shielding device, and sequentially performs edge enhancement processing, morphological erosion processing, morphological dilation processing, and region extraction, and determines whether the number of target regions obtained in the current processing changes. If it changes, the steps of morphological processing are returned and the loop is repeated until the number of target regions no longer changes. Then, counting is performed based on the finally obtained target image to obtain a counting result, improving the accuracy of electronic component counting and having a low error detection rate.
[0081] In some embodiments, as Figure 3 shown, the steps for a computer device to determine multiple connected regions in a target image include:
[0082] Step S302, in all pixel rows of the target image, determine the pixel row to be processed in the current time.
[0083] Step S304, sequentially determine the label values corresponding to each pixel in the pixel row to be processed in the current time.
[0084] Step S306, take the next pixel row as the pixel row to be processed in the next round, and return to the step of sequentially determining the label values corresponding to each pixel in the pixel row to be processed in the current time to continue execution until all pixel rows are traversed.
[0085] Step S308, form equivalence pairs with the label values having an equivalence relationship among the multiple label values to obtain at least one group of equivalence pairs.
[0086] Step S310, take the minimum value of the label values in each equivalence pair as the standard label value in the corresponding equivalence pair.
[0087] Step S312, traverse the target image according to each equivalence pair, and update the label values of the pixels corresponding to the same equivalence pair to the standard label value of the corresponding equivalence pair.
[0088] Step S314, determine the pixels corresponding to the same standard label value as a connected region to obtain multiple connected regions in the target image.
[0089] Specifically, the computer device determines all the pixel rows to be processed in the target image and determines the pixel row to be processed for this time among them. Taking the first row of pixel rows as an example, the computer device sequentially determines the label values corresponding to each pixel in the first row of pixel rows from left to right, then turns to the second row of pixel rows, and then sequentially determines the label values corresponding to each pixel in the second row of pixel rows... and so on until all the pixel rows in the target image are traversed, and the label values corresponding to each pixel in each pixel row are obtained. Then, the computer device determines the label values with an equivalence relationship among the multiple label values and forms equivalence pairs with the label values with an equivalence relationship among the multiple label values to obtain at least one set of equivalence pairs. For example, if the label value of "1" and the label value of "3" have an equivalence relationship, the computer device takes the label value "1" and the label value "3" as a set of equivalence pairs {1, 3}. Among the at least one set of equivalence pairs obtained, the computer device determines the minimum value of the label values in each equivalence pair as the standard label value in the corresponding equivalence pair. For example, the label value "1" in the equivalence pair {1, 3} is taken as the standard label value in this equivalence pair. Then, the computer device traverses the target image according to each equivalence pair, updates the label values of the pixels corresponding to the same equivalence pair to the standard label value of the corresponding equivalence pair, and determines the pixels corresponding to the same standard label value as a connected region to obtain multiple connected regions in the target image. For example, the computer device updates the label values of all the pixels in the target image corresponding to the equivalence pair {1, 3} (that is, 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 the pixels with the label value corresponding to "1" form a connected region. And so on, traversing all the pixel rows, multiple connected regions can be obtained.
[0090] In the above embodiments, by traversing each pixel row to determine the label value of each pixel and taking the region formed by connecting the pixels with the same label value as a connected region, it is possible to set a unique label for the pixels in different connected regions in the image and classify the pixels with the same nature and the same label together, which is convenient for the subsequent accurate counting of electronic components.
[0091] In some embodiments, as Figure 4 shown, the steps for the computer device to sequentially determine the standard label value corresponding to each pixel in the pixel row to be processed for this time include:
[0092] Step S402, determine the pixel to be processed for this time in the current pixel row and determine the neighborhood of the pixel to be processed.
[0093] Step S404, if the label values of the connected pixels in the neighborhood of the pixel to be processed are empty, update the label value of the current pixel to a new label value.
[0094] Step S406: If, in the neighborhood of the pixel to be processed, the label values of the connected pixels are not empty, determine the minimum value among the label values corresponding to the connected pixels, and update the label value of the current pixel to the minimum value.
[0095] Step S408: Take the next pixel as the pixel to be processed in the next round, and return to the step of determining the neighborhood of the pixel to be processed and continue to execute until all pixels in the current pixel row are traversed and the label values corresponding to all pixels are obtained.
[0096] Among them, the neighborhood refers to the surrounding pixels of a pixel, usually including an 8-neighborhood (i.e., the pixels adjacent to the current pixel in the up, down, left, right, and diagonal directions) and a 4-neighborhood (i.e., the pixels adjacent to the current pixel in the up, down, left, and right directions).
[0097] Specifically, after the computer device determines the pixel row to be processed for the current time, the pixel row to be processed for the current time is the current pixel row, and the current pixel to be processed in the current pixel row is determined. Taking the first pixel from left to right in the current pixel row as the current pixel to be processed as an example, the computer device determines the neighborhood of the first pixel. If the computer device determines that in the neighborhood of the pixel to be processed, the label values of the connected pixels are empty, the label value of the current pixel is updated to a new label value. For example, for the first pixel in the first row, there are no adjacent pixels with label values in its up, down, left, and right directions, then the computer device updates the label value of the first pixel to a new label value, such as "1". Another example is that for the Nth pixel in the Nth row, there are no adjacent pixels with label values in its up, down, left, and right directions, and the label values of multiple existing pixels are "1" and "2" respectively, then the computer device updates the label value of this pixel to the new label value "3".
[0098] If the computer device determines that in the neighborhood of the pixel to be processed, the label values of the connected pixels are not empty, determine the minimum value among the label values corresponding to the connected pixels, and update the label value of the current pixel to the minimum value. For example, for the Nth pixel in the Nth row, the label value of the pixel adjacent to it in the previous row is "1", and the label value of the pixel adjacent to it on the left is "3", then the computer device updates the label value of the current pixel to the minimum value "1" among the label values corresponding to the connected pixels.
[0099] Thus, after the computer processes the current pixel in the current pixel row, it takes the next pixel in the current pixel row as the pixel to be processed in the next round, and returns to the step of determining the neighborhood of the pixel to be processed and continues to execute until all pixels in the current pixel row are traversed and the label values corresponding to all pixels are obtained. Usually, the computer can traverse a row of pixels from left to right.
[0100] In the above embodiments, by traversing each pixel row to determine the label value of each pixel, and connecting the pixels with the same label value to form a region as a connected region, it is possible to set a unique label for the pixels in different connected regions in the image, and classify the pixels with the same property and the same label together, which is convenient for accurate counting of electronic components in the subsequent process.
[0101] In some embodiments, as Figure 5 shown, the computer device counts the components according to the connected regions and obtains a counting result, including:
[0102] Step S502: Determine the connected region area corresponding to each connected region in the target image, and calculate the target average area for this time according to the connected region areas corresponding to each connected region.
[0103] Step S504: Determine multiple target connected regions whose connected region areas are smaller than the target average area, calculate the candidate average area of the multiple target connected regions, and use the candidate average area as the target average area for the next round.
[0104] Step S506: Return to the step of determining multiple target connected regions whose connected region areas are smaller than the target average area and continue to execute until the obtained target average area is the same as the target average area obtained in the previous round.
[0105] Step S508: Perform a rounding operation according to the total area corresponding to the component region in the target image and the finally obtained target average area to obtain the counting result.
[0106] Specifically, after the computer device traverses all the pixels in all pixel rows and obtains multiple connected regions, it determines the connected region area corresponding to each connected region in the target image, and calculates the target average area for this time according to the connected region areas corresponding to each connected region. Then, the computer device determines multiple target connected regions whose connected region areas are smaller than the target average area. For example, it determines multiple target connected regions whose connected region areas are 1 / 2 or 1 / 3, etc. of the target average area for this time, calculates the candidate average area with these target connected regions, and uses the candidate average area as the target average area for the next round; then, the computer device returns to the step of determining multiple target connected regions whose connected region areas are smaller than the target average area and continues to execute, and thus iterates in a loop until the obtained target average area is the same as the target average area obtained in the previous round. Finally, the computer device performs a rounding operation according to the finally obtained target average area and the total area corresponding to the component region in the target image, and the obtained integer is the counting result.
[0107] Exemplarily, the computer device calculates the number N of connected regions in the image and calculates the area A of each connected region, sorts the areas A of the connected regions in the image from small to large, and obtains the average area Avg; to further accurately calculate the average area, based on the obtained Avg, the average area within the range of 0.3Avg to Avg is statistically calculated, and this step is continuously repeated until the average area Avg no longer changes. Then, the computer device takes the quotient of the total area and the average area of a single electronic component and approximates it to an integer as the number of components:
[0108]
[0109] In the formula, N is the number of components to be obtained, S is the total area of the component region, Avg is the average area of a single component, and round represents rounding to an integer using the rounding method.
[0110] In the above embodiments, when the average area of the components in the image no longer changes through cyclic iteration, the area method is used to count the electronic components, which can improve the accuracy of the counting result.
[0111] In a specific example, as Figure 6 shown, the above counting method for electronic components can be integrated into a software program, and image processing is implemented by running the program code to complete the automatic counting of electronic components. An actual application scenario is, for example: the computer device inputs the received color image into the software program, and the software program performs image processing to complete the counting. First, the software program converts the color image into a grayscale image and performs binarization processing on the grayscale image; then, successively performs image erosion operation and image dilation operation, and then uses an edge detection algorithm to implement image boundary contour processing and extraction of the region of interest in the image, and statistically calculates whether the number of regions of interest has changed compared with the previous time; if there is a change, image segmentation processing is performed based on the watershed segmentation algorithm, and the operations of erosion, dilation, boundary contour processing, and extraction of the region of interest are re-executed; if the number of regions of interest has not changed compared with the previous time, the connected regions are marked, and counting is performed based on the connected regions. Finally, the computer device outputs and displays the counting result on a display device. Among them, the display device is, for example, a display screen, etc. Figure 7 Shows the image processing and counting results of the above counting method for electronic components. Figures (a) and (c) show the original captured images of capacitors in the component accommodating device captured by the image capturing device, and Figures (b) and (d) are the corresponding counting results of Figures (a) and (c) respectively; Figure (e) shows the original captured image of a conversion chip in the component accommodating device captured by the image capturing device, and Figure (f) is the corresponding counting result; Figure (g) shows the original captured image of a power chip in the component accommodating device captured by the image capturing device, and Figure (h) is the corresponding counting result.
[0112] The counting method of electronic components provided in the embodiments of the present application realizes the accurate counting of electronic components of different types, shapes, and positions, and has the characteristics of wide variety of recognized electronic components, high recognition accuracy, arbitrary placement positions of electronic components, portability, flexibility and convenience, etc. It solves the problems of weak universality, narrow adaptation range caused by the large number of types and models of electronic components, and low counting efficiency and high error rate in the manual counting of electronic components such as resistors, capacitors, integrated circuit chips, discrete devices, etc., improves the counting detection efficiency, reduces the cost, and has a wide application prospect.
[0113] It should be understood that although Figure 2-6 the steps in the flowchart of Figure 2-6 are shown in sequence according to the indication of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover,
[0114] In one embodiment, as Figure 8 shown, a counting device 800 for electronic components is provided, including: a preprocessing module 801, a morphological processing module 802, a region extraction module 803, a region segmentation module 804, a loop processing module 805, and a counting module 806, where:
[0115] The preprocessing module 801 is used to obtain a component image, preprocess the component image to obtain a preprocessed image, and use the preprocessed image as the initial edge image to be processed; the component image is obtained by taking a picture of the components to be counted placed in the component accommodating device by using an image acquisition device arranged above the component accommodating device in a shielding device.
[0116] The morphological processing module 802 is used to obtain the edge image to be processed for the current time, and perform morphological erosion processing and morphological dilation processing on the edge image to be processed respectively to obtain the morphological image for the current time.
[0117] The region extraction module 803 is used to extract regions from the morphological image for the current time to obtain a target image including multiple target regions and the number of target regions.
[0118] The region segmentation module 804 is configured to, if the number of target regions obtained in the current processing is inconsistent with the number of target regions obtained in the previous round of processing, perform image region segmentation processing on the target image in the current time to obtain a segmented edge image.
[0119] The loop processing module 805 is configured to use the segmented edge image as the edge image to be processed in the next round, and return to the morphological processing module 802 to continue execution until the number of target regions obtained in the current processing is consistent with the number of target regions obtained in the previous round of processing, and then stop the loop processing.
[0120] The counting module 806 is configured to, based on the target image obtained in the last processing, determine multiple connected regions in the target image, count the components according to the connected regions, and obtain a counting result.
[0121] In one embodiment, the counting module is further configured to: in all pixel rows of the target image, determine the pixel row to be processed in the current time; sequentially determine the label values corresponding to each pixel in the pixel row to be processed in the current time; use the next pixel row as the pixel row to be processed in the next round, and return to the step of sequentially determining the label values corresponding to each pixel in the pixel row to be processed in the current time to continue execution until all pixel rows are traversed; form equivalence pairs with the label values having an equivalence relationship among the multiple label values to obtain at least one group of equivalence pairs; use the minimum value of the label values in each equivalence pair as the standard label value in the corresponding equivalence pair; traverse the target image according to each equivalence pair, and update the label values of the pixels corresponding to the same equivalence pair to the standard label value of the corresponding equivalence pair; determine the pixels corresponding to the same standard label value as a connected region to obtain multiple connected regions in the target image.
[0122] In one embodiment, the counting module is further configured to: determine the pixel to be processed in the current time in the current pixel row, and determine the neighborhood of the pixel to be processed; if the label values of the connected pixels in the neighborhood of the pixel to be processed are empty, update the label value of the current pixel to a new label value; if the label values of the connected pixels in the neighborhood of the pixel to be processed are not empty, determine the minimum value of the label values corresponding to the connected pixels, and update the label value of the current pixel to the minimum value; use the next pixel as the pixel to be processed in the next round, and return to the step of determining the neighborhood of the pixel to be processed and continue execution until all pixels in the current pixel row are traversed and the label values corresponding to all pixels are obtained.
[0123] In one embodiment, the counting module is further configured to: determine the area of each connected region corresponding to the target image, and calculate the target average area for this time according to the area of each connected region; determine multiple target connected regions whose connected region areas are smaller than the target average area, calculate the candidate average area of the multiple target connected regions, and use the candidate average area as the target average area for the next round; return to the step of determining multiple target connected regions whose connected region areas are smaller than the target average area and continue to execute until the obtained target average area is the same as the target average area obtained in the previous round; perform a rounding operation according to the total area corresponding to the component region in the target image and the finally obtained target average area to obtain the counting result.
[0124] For the specific limitations of the counting device for electronic components, reference can be made to the limitations on the counting method for electronic components in the foregoing text, which will not be elaborated here. Each module in the above-mentioned counting device for electronic components can be implemented in whole or in part by software, hardware, and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or stored in the memory of the computer device in the form of software, so as to facilitate the processor to call and execute the operations corresponding to the above-mentioned modules.
[0125] In one embodiment, a computer device is provided. The computer device may be the computer device in the foregoing embodiment, and its internal structure diagram may be as Figure 9 shown. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile 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 the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a carrier network, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a counting method for electronic components. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, a trackball, or a touchpad provided on the housing of the computer device, or an external keyboard, a touchpad, or a mouse, etc.
[0126] Those skilled in the art can understand, Figure 9The structure shown is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0127] In one embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in the above method embodiments are implemented.
[0128] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0129] Those of ordinary skill in the art can understand that all or part of the processes of implementing the above method embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above method embodiments. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memories. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0130] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0131] The above-described embodiments only represent several implementation manners of this application, and their descriptions are relatively specific and detailed, but they should not be construed as a limitation on the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of this application, several modifications and improvements can still be made, and these all belong to the protection scope of this application. Therefore, the protection scope of this application patent should be subject to the appended claims.
Claims
1. A counting system for electronic components, characterized in that, The system includes: A counting platform for carrying a component accommodating device; A component accommodating device placed on the counting platform for accommodating components to be counted; A shielding device detachably arranged on the counting platform, surrounding the outside of the component accommodating device and forming a closed space with the counting platform to shield ambient light; wherein, one side of the shielding device is provided with an opening for taking out and putting in the component accommodating device; the shielding device is a box-shaped photography studio with a side opening; An image acquisition device for taking pictures of the components placed in the component accommodating device from different angles and obtaining component images; the image acquisition device is arranged above the component accommodating device through a fixed bracket, and the bracket includes a horizontal bracket and a vertical bracket. Among them, the horizontal bracket is used to drive the image acquisition device to rotate, the vertical bracket is a telescopic rod, the horizontal bracket is fixed on the vertical bracket, and the vertical movement position is realized through the telescopic of the vertical bracket, and the horizontal bracket can rotate 360°; A computer device for preprocessing the component images received from the image acquisition device to obtain preprocessed images, and using the preprocessed images as the initial edge images to be processed; obtaining the edge images to be processed for the current time, respectively performing morphological erosion processing and morphological dilation processing on the edge images to be processed to obtain the morphological images for the current time; performing region extraction on the morphological images for the current time to obtain a target image including multiple target regions and the number of target regions; if the number of target regions obtained from the current processing is inconsistent with the number of target regions obtained from the previous round of processing, performing image region segmentation processing on the target image for the current time to obtain the segmented edge images; using the segmented edge images as the edge images to be processed for the next round, and returning to the step of respectively performing morphological erosion processing and morphological dilation processing on the edge images to be processed and continuing to execute until the number of target regions obtained from the current processing is consistent with the number of target regions obtained from the previous round of processing, then stopping the loop processing; based on the target image obtained from the last processing, determining multiple connected regions in the target image; determining the connected region areas respectively corresponding to the connected regions in the target image, and calculating the target average area for the current time according to the connected region areas respectively corresponding to the connected regions; determining multiple target connected regions with connected region areas smaller than the target average area, calculating the candidate average areas of the multiple target connected regions, and using the candidate average areas as the target average area for the next round; returning to the step of determining multiple target connected regions with 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 from the previous round; performing a rounding operation according to the total area corresponding to the component region in the target image and the finally obtained target average area to obtain a counting result; averaging the counting results of the multiple component images taken from different angles, and using the average value as the final calculation result.
2. The system according to claim 1, characterized in that, The shielding device is made of flexible material; the shielding device is erected on the counting platform through a support bracket.
3. The system according to claim 1, characterized in that, The computer device is configured to obtain multiple counting results respectively according to the component images collected by the image acquisition device at multiple acquisition angles; and perform mean processing on the multiple counting results to obtain a final counting result.
4. A counting method for electronic components, characterized in that, The method includes: Obtain a component image, perform preprocessing on the component image to obtain a preprocessed image, and use the preprocessed image as the initial edge image to be processed; the component image is obtained by taking pictures of the components to be counted placed in the component accommodating device from different angles by using an image acquisition device arranged above the component accommodating device inside a shielding device; the shielding device is a box-shaped photography studio with a side opening; the image acquisition device is arranged above the component accommodating device through a fixed bracket, and the bracket includes a horizontal bracket and a vertical bracket, wherein the horizontal bracket is used to drive the image acquisition device to rotate, the vertical bracket is a telescopic rod, the horizontal bracket is fixed on the vertical bracket, and the position is moved up and down through the telescopic movement of the vertical bracket, and the horizontal bracket can rotate 360°. Obtain the edge image to be processed for the current time, perform morphological erosion processing and morphological dilation processing on the edge image to be processed respectively to obtain the morphological image for the current time. Perform region extraction on the morphological image for the current time to obtain a target image including multiple target regions and the number of target regions. If the number of target regions obtained in the current processing is inconsistent with the number of target regions obtained in the previous round of processing, perform image region segmentation processing on the target image for the current time to obtain a segmented edge image. Use the segmented edge image as the edge image to be processed in the next round, and return to the step of performing morphological erosion processing and morphological dilation processing on the edge image to be processed respectively and continue to execute until the number of target regions obtained in the current processing is consistent with the number of target regions obtained in the previous round of processing, and then stop the loop processing. Based on the target image obtained in the last processing, determine multiple connected regions in the target image. Determine the connected region area corresponding to each connected region in the target image, and calculate the target average area for the current time according to the connected region area corresponding to each connected region. Determine multiple target connected regions with a connected region area smaller than the target average area, calculate the candidate average area of the multiple target connected regions, and use the candidate average area as the target average area in the next round. Return to the step of determining multiple target connected regions with a connected region area smaller than the target average area and continue to execute until the obtained target average area is consistent with the target average area obtained in the previous round. Perform a rounding operation according to the total area corresponding to the component region in the target image and the finally obtained target average area to obtain a counting result. Calculate the average value of the counting results of multiple component images taken at different angles, and use the average value as the final calculation result.
5. The method according to claim 4, wherein Said determining multiple connected regions in the target image includes: In all pixel rows of the target image, determine the pixel row to be processed for the current time; Sequentially determine the label values respectively corresponding to each pixel in the pixel row to be processed for the current time; Take the next pixel row as the pixel row to be processed for the next round, and return to the step of sequentially determining the label values respectively corresponding to each pixel in the pixel row to be processed for the current time to continue execution until all pixel rows are traversed; Form equivalence pairs with the label values having an equivalence relationship among the multiple label values to obtain at least one set of equivalence pairs; Take the minimum value of the label values in each equivalence pair as the standard label value in the corresponding equivalence pair; 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; Determine the pixels corresponding to the same standard label value as one connected region to obtain multiple connected regions in the target image.
6. The method according to claim 5, characterized in that Said sequentially determining the standard label values respectively corresponding to each pixel in the pixel row to be processed for the current time includes: Determine the pixel to be processed for the current time in the current pixel row, and determine the neighborhood of the pixel to be processed; If the label values of the connected pixels in the neighborhood of the pixel to be processed are empty, update the label value of the current pixel to a new label value; If the label values of the connected pixels in the neighborhood of the pixel to be processed are not empty, determine the minimum value among the label values corresponding to the connected pixels, and update the label value of the current pixel to the minimum value; Take the next pixel as the pixel to be processed for the next round, and return to the step of determining the neighborhood of the pixel to be processed and continue execution until all pixels in the current pixel row are traversed and the label values corresponding to all pixels are obtained.
7. The method according to claim 4, characterized in that Said preprocessing the component image includes grayscale processing and binarization processing.
8. The method according to claim 4, characterized in that, Said performing image region segmentation processing on the target image for the current time to obtain the segmented edge image includes: Perform image region segmentation processing on the target image for the current time by using the watershed segmentation algorithm to obtain the segmented edge image.
9. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 4 to 8.
Citation Information
Patent Citations
Method and device for automatically counting components
CN102521648A
Electronic component automatic counting method based on connected domain recognition
CN107749059A