Disclosure of Invention
Therefore, the egg crack detection method and device based on the visual sensor are high in sorting reliability and easy to implement.
A method of poultry egg crack detection, the method comprising:
obtaining a plurality of poultry egg images of the same poultry egg;
carrying out binarization processing on a plurality of poultry egg images, and carrying out ellipse detection to obtain poultry egg area images;
performing expansion operation based on the image of the poultry egg area to obtain a connected domain to be evaluated in the image of the poultry egg area;
calculating the area of each connected domain to be evaluated and the area of a circumscribed rectangle of the connected domain to be evaluated, and calculating the ratio of the area of the connected domain to be evaluated and the area of the circumscribed rectangle;
and when the ratio corresponding to the connected domain to be evaluated in the image of the egg area is smaller than a preset value, judging that the egg has cracks.
In one embodiment, the method for detecting egg cracks further comprises: when the ratio corresponding to the connected domain to be evaluated in the egg region image is not less than a preset value, calculating the average gray value of the connected domain to be evaluated in the region of the egg image; judging whether the average gray value is larger than a gray threshold value; and if the average gray value is greater than the gray threshold value, judging that the poultry egg has cracks.
In one embodiment, the binarizing processing on a plurality of egg images and performing ellipse detection to obtain an egg area image includes: filtering a plurality of poultry egg images, and performing binarization processing to obtain a binarization image; and detecting an ellipse in the image of the binary image through Hough transform to obtain an image of the poultry egg area.
In one embodiment, the performing an expansion operation based on the image of the egg area to obtain a connected domain to be evaluated in the image of the egg area includes: acquiring the area of each connected domain in the image of the poultry egg area, and filtering the connected domains with the areas smaller than an area threshold value to obtain initial connected domains; and performing expansion operation on the initial connected domain to obtain a connected domain to be evaluated in the image of the poultry egg area.
An egg crack detection device, comprising: the hidden channel is positioned between the tail end of the front conveyor belt and the front end of the rear conveyor belt and comprises a glass partition plate, a light source, a plurality of industrial cameras and a photoelectric switch, the photoelectric switch is arranged at the inlet of the hidden channel, the glass partition plate is positioned in the middle of the hidden channel and is obliquely arranged, the light source is arranged below the glass partition plate, and the plurality of industrial cameras are arranged at the top of the hidden channel and are used for shooting images of eggs rolled off by the glass partition plate; wherein, a plurality of industrial cameras are used for shooting the egg images.
In one embodiment, the dark channel comprises an inclined section and a horizontal section, the glass partition plate, the light source and the plurality of industrial cameras are located in the inclined section, and the inclination angle of the inclined section is 5 degrees.
In one embodiment, the inclined section has a length of 0.8 meters and the horizontal section has a length of 0.2 meters.
In one of them embodiment, the dark passageway still includes the letter sorting subassembly, the letter sorting subassembly includes step motor, letter sorting pivot, baffle, step motor installs in the outside of dark passageway, and letter sorting pivot, baffle set up and are close to the exit in dark passageway, and the baffle will hide the passageway and fall into two passageways, and step motor drives the letter sorting pivot through the belt and rotates, letter sorting pivot upper end fixed stop, and the baffle drives through the letter sorting pivot and is predetermineeing the within range internal recycle and rotate.
In one embodiment, the egg crack detection device further comprises: and the controller is electrically connected with the stepping motor, and when the current egg crack condition is different from the previous egg crack condition, the controller sends a rotation signal to the stepping motor to control the partition plate to rotate to open the corresponding channel.
In one embodiment, sponge cushions are arranged on two sides of the dark channel.
According to the method and the device for detecting the cracks of the poultry eggs, the characteristics that most cracks on the surfaces of the poultry eggs have slender lines are utilized, the traditional image processing scheme is adopted, the cracks are quickly detected according to the ratio S of the area of a crack communication domain to the area of an external rectangle of the crack communication domain, the principle is simple, and the calculated amount is small; the reliability of the algorithm is improved by adopting a multi-sensor system; the implementation difficulty of the cracked egg detection device is effectively reduced by using a common basic mechanical and electrical device; the sorting is realized by adopting a channel-dividing mode of a motor, so that the sorting speed is greatly improved; in addition, the method can be carried out by a plurality of groups of equipment simultaneously, and the sorting speed is further improved under the condition of multi-channel detection.
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.
In one embodiment, as shown in fig. 1, there is provided an egg crack detection method, comprising the steps of:
and S110, obtaining a plurality of egg images of the same egg.
Wherein, the number of the poultry egg images can be two, and the poultry egg images can be collected by an industrial camera, and a plurality of poultry egg images are images of different surfaces of the same poultry egg. The fowl egg may be egg, duck egg, goose egg, etc. Specifically, the number of the poultry egg images is 3, and each poultry egg image is acquired by a different industrial camera.
S120, performing binarization processing on a plurality of egg images, and performing ellipse detection to obtain an egg area image
Specifically, binarization processing is carried out on a plurality of poultry egg images, and ellipse detection is carried out to obtain poultry egg area images; wherein the image can be filtered before the binarization processing. The ellipse detection adopts a Hough transform detection method.
And S130, performing expansion operation based on the image of the egg area to obtain a connected domain to be evaluated in the image of the egg area.
Specifically, performing expansion operation based on the image of the poultry egg area to obtain a connected domain to be evaluated in the image of the poultry egg area; for the image of the poultry egg area, a small connected component can be filtered before the expansion operation, because the small connected component can be noise or insignificant small cracks. Therefore, the calculation amount of the algorithm is reduced, the filtering capability of the algorithm is enhanced, and the reliability is enhanced.
S140, calculating the area of each connected domain to be evaluated and the area of the circumscribed rectangle of the connected domain to be evaluated, and calculating the ratio of the area of the connected domain to be evaluated and the area of the circumscribed rectangle.
The external rectangle of the connected domain to be evaluated is a rectangle surrounded by boundaries of a maximum abscissa, a minimum abscissa, a maximum ordinate and a minimum ordinate of all the pixel points of the connected domain.
For example, the area S1 of the connected component to be evaluated, the area S2 of the circumscribed rectangle of the connected component to be evaluated, and the ratio S = S1/S2 of the area of the connected component to be evaluated to the area of the circumscribed rectangle.
S150, judging that the egg has cracks when the ratio corresponding to the connected domain to be evaluated in the image of the egg area is smaller than a preset value. The preset value can be adjusted, the adjustability of the algorithm is reserved, and the method accords with the specific actual situation. Because the cracks are basically in a long, thin and zigzag linear shape, if the area corresponding to the connected domain to be evaluated is the cracks, the area of the connected domain to be evaluated is much smaller than that of the circumscribed rectangle of the connected domain to be evaluated, and therefore a preset value is set; if the areas of the connected domain to be evaluated and the external rectangle are larger than the preset value, the connected domain to be evaluated and the external rectangle are likely to be block-shaped dirt or broken holes, the connected domain to be evaluated is distinguished through the average gray value of the region to be evaluated in the corresponding region of the gray image, if the average value is larger than 100, the connected domain to be evaluated is a broken opening, and the modified poultry egg is also considered to have cracks.
According to the method for detecting the cracks of the eggs, the complete surfaces of the eggs can be extracted by obtaining the images of the surfaces of the same eggs, the egg area is obtained after ellipse detection, then the connected domain to be evaluated is obtained through expansion operation, whether the cracks exist in the eggs is judged according to the comparison between the ratio of the area of the connected domain to be evaluated and the area of the external rectangle of the connected domain to be evaluated and a preset value, and the detection cost is low and the detection efficiency is high.
In one embodiment, after step S150, the method includes: and when the ratio corresponding to the connected domain to be evaluated does not exist in the image of the poultry egg area is smaller than a preset value, judging that the poultry egg has no crack. When the poultry egg is judged to be a non-cracked egg, the poultry egg is sent to a subsequent processing conveyor belt through a non-cracked channel.
In one embodiment, the method for detecting egg cracks further comprises: when the ratio corresponding to the connected domain to be evaluated in the egg region image is not less than a preset value, calculating the average gray value of the connected domain to be evaluated in the region of the egg image; judging whether the average gray value is larger than a gray threshold value; and if the average gray value is larger than the gray threshold value, judging that the poultry egg has cracks.
Wherein, the images of a plurality of poultry eggs of the same poultry egg are all gray level images. The ratio of the area of the connected domain to be evaluated to the external rectangle of the region to be evaluated is larger than a preset value, the connected domain to be evaluated may be dirty or a break with a dirty shape, and the dirty part in the gray image of the poultry egg is dark black, but the break is different in color. Therefore, the average gray value of the corresponding area of the connected domain to be evaluated in the gray image is calculated, if the average gray value of the connected domain to be evaluated is larger than the gray threshold, the connected domain is a break, and the egg is considered to have a crack. Wherein the grayscale threshold may be set to 100.
In one embodiment, after step S150, the method includes: and when the ratio S corresponding to the connected domain to be evaluated does not exist in the egg region image is smaller than a preset value, and the average gray value of the connected domain to be evaluated in the region of the egg image is not larger than a gray threshold, judging that the egg has no crack. When the poultry egg is judged to be a non-cracked egg, the poultry egg is sent to a subsequent processing conveyor belt through a non-cracked channel.
In one embodiment, the binarizing processing on a plurality of egg images and performing ellipse detection to obtain an egg area image includes: filtering a plurality of poultry egg images, and then performing binarization processing to obtain a binarization image; and detecting an ellipse in the image through Hough transform on the binary image to obtain an image of the poultry egg area.
The poultry egg image is a color image, and is subjected to filtering processing to remove image noise and then binarization.
In one embodiment, the performing an expansion operation based on the egg area image to obtain a connected domain to be evaluated in the egg area image includes: acquiring the area of each connected domain in the image of the poultry egg area, and filtering the connected domains with the areas smaller than an area threshold value to obtain initial connected domains; and performing expansion operation on the initial connected domain to obtain a connected domain to be evaluated in the image of the poultry egg area.
The connected domain with the filtering area smaller than the area threshold can remove the small connected domain to perform expansion operation; connected domains having too small an area may be noise or insignificant small cracks, etc., so when the area of the connected domain is less than the area threshold, the connected domain is removed. The area threshold may be set by a manual preset. The connected domains with the closer distance in the binary image may belong to the same crack, so that the expansion operation needs to be performed on the image to change the connected domains with the closer distance into the same connected domain.
The invention will now be described in further detail with reference to the accompanying figures 2-3 and specific examples.
As shown in fig. 2 and 3, an egg crack detection sorting apparatus and method based on vision are provided, in which fig. 2 is a structural diagram of the entire apparatus, and fig. 3 is a structural diagram of a sorting assembly for sorting. In fig. 2, the left end is the starting point of the device and the right end is the ending point of the device. According to the division of labor, the device can be divided into a conveying and dividing assembly, a poultry egg crack detection assembly and a sorting assembly. The conveying and column dividing assembly comprises a front conveying belt 1 and an automatic column divider 2, wherein the automatic column divider 2 is positioned above the front conveying belt 1 and close to one end of the inlet of the dark channel 11. The egg crack detection component comprises a photoelectric switch 4, a singlechip 5, an industrial camera 6, a light source 7, a computer 8 and a dark channel 11, wherein the dark channel 11 is a cuboid, the inlet of the dark channel is butted with the tail end of the front conveyer belt 1, and the outlet of the dark channel is butted with the front end of the rear conveyer belt 13 and a crack egg collecting box; the photoelectric switch 4 is positioned on the side wall of the inlet of the dark channel 11 and is connected with the singlechip 5 through a data line, and the singlechip is connected with the computer 8 through a data line; behind the photoelectric switch 4, the top of the dark channel 11 near the inlet direction is provided with 3 industrial cameras 6, the middle part is provided with a glass partition, 3 light sources 7 are arranged below the glass partition, and the light sources 7 and the industrial cameras 6 irradiate oppositely. The sorting assembly comprises a stepping motor 9, a sorting rotating shaft and partition plate 10, a dark channel 11, a cracked egg collecting box 12 and a rear conveying belt 13, wherein the stepping motor 9 is installed outside the dark channel and drives the sorting rotating shaft and partition plate 10 through a belt; the sorting rotating shaft and the separating plate 10 are positioned at the position, close to the outlet, of the dark channel 11 and are used for sorting eggs, the dark channel 11 at the rear part of the sorting rotating shaft is changed from a single channel into two channels, namely a cracked egg channel and a non-cracked egg channel, as shown in figure 2, the cracked egg channel is in butt joint with the cracked egg collecting box 12, and the non-cracked egg channel is in butt joint with the rear conveying belt 13.
On the basis of the device structure, the device of the invention has the following working flows: the poultry eggs are conveyed to an automatic arraying device 2 by a front conveying belt 1 and are arrayed by the automatic arraying device 2. After being separated, the eggs 3 are arranged in a line and enter the dark channel 11 one by one for crack detection and sorting. After entering the dark channel 11, the eggs 3 go out of the industrial camera 6 through the photoelectric switch 4 to collect the images of the eggs. The egg images are transmitted to the computer 8 to detect whether cracks exist on the egg surface by using the egg crack detection method in the above embodiment. Due to the irradiation of the light source, the edges of the eggs and the background in the egg image are obvious, and cracks on the surfaces of the eggs are more obvious. As shown in fig. 5, the specific operations in detecting the egg cracks are as follows:
a. sequentially collecting 1 egg image by 3 industrial cameras; the purpose of adopting 3 industrial cameras to successively collect egg images is mainly to shoot the complete egg surface.
b. Preprocessing 3 poultry egg images to obtain binary images; in the preprocessing, filtering processing is firstly carried out on a gray level image collected by an industrial camera to remove image noise, and then binarization is carried out to obtain a binary image.
c. Performing ellipse detection and cutting the poultry egg image according to the detection result; since the edge of the egg is an ellipse, the ellipse in the image is detected by hough transform. And (4) regarding the detected ellipse as the edge of the egg, and then cutting the image to the left egg according to the ellipse detection result.
d. Removing the small connected domain, and performing expansion operation; connected domains having too small an area may be noise or insignificant small cracks, etc., so when the area of the connected domain is less than the area threshold, the connected domain is removed. The area threshold value can be set in a manually preset manner. The connected domains with the closer distance in the binary image may belong to the same crack, so that the expansion operation needs to be performed on the image to change the connected domains with the closer distance into the same connected domain.
e. Searching external rectangles of the residual connected domains; and finding out the external rectangle of each connected domain in the elliptical area, and recording the position and the size of the rectangle.
f. And calculating the ratio S of the area of each connected domain in the elliptical area to the area of the circumscribed rectangle.
g. And comparing the ratio S of the connected domains calculated in the last step with a preset area threshold, regarding the connected domains as cracks if the ratio S is smaller than the preset area threshold, calculating the average gray value of the corresponding region of the region to be evaluated in the gray image if the ratio S is greater than or equal to the area threshold, and regarding the connected domains to be evaluated as breaks if the average gray value is greater than 100, and regarding the modified poultry eggs as cracks. If the above 2 cases do not exist, no crack is formed.
h. And (6) ending.
For the eggs with cracks, the computer 8 sends an electric pulse signal to control the stepping motor 9 to close the channels of the non-cracked eggs, and the eggs enter the channels of the cracked eggs and reach the cracked egg collecting box 12; for poultry eggs without cracks, the computer 8 sends an electric pulse signal to control the stepping motor 9 to close the crack egg channel, and at the moment, the poultry eggs enter the non-crack egg channel and reach the rear conveying belt 13.
It should be understood that although the steps in the flowcharts of fig. 1 and 5 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 limited to being performed in the exact order illustrated and, unless explicitly stated herein, may be performed in other orders. Moreover, at least some of the steps in fig. 1 and 5 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. 2, there is provided an egg crack detection apparatus including: the device comprises a dark channel 11 positioned between the tail end of a front conveying belt 1 and the front end of a rear conveying belt 13, wherein the dark channel 11 comprises a glass partition plate, a light source 7, a plurality of industrial cameras 6 and a photoelectric switch 4, the photoelectric switch 4 is arranged at the inlet of the dark channel 11, the glass partition plate is positioned in the middle of the dark channel 11 and is obliquely arranged, the light source 7 is arranged below the glass partition plate, and the plurality of industrial cameras 6 are arranged at the top of the dark channel 11 and are used for shooting images of eggs 3 rolled off by the glass partition plate; a plurality of industrial cameras 6 are used for shooting the poultry egg images in the above embodiment.
The dark channel is a channel with the periphery closed, and a light source and a camera are arranged in the dark channel, so that the influence of the surrounding environment on the shot image can be avoided. The glass partition plate is obliquely arranged in the dark channel, eggs can roll off conveniently, the glass partition plate can transmit light, the light source illuminates the dark channel through the glass partition plate, and the camera can shoot clear images of the eggs. The photoelectric switch 4 is positioned at the entrance of the dark channel, and when eggs enter the dark channel, the photoelectric switch detects the entering signals of the eggs, and then controls the light source to be turned on and the industrial camera to take pictures.
Before eggs are conveyed into the dark channel through the front conveyor belt 1, the front conveyor belt 1 conveys disordered eggs to the automatic sorting device 2, the eggs are sorted by the automatic sorting device 2, the sorted eggs 3 are arranged into 1 row, one egg enters the dark channel every time, and the eggs can conveniently take pictures of the same egg by an industrial camera after entering the dark channel one by one. The eggs 3 after being arranged enter the dark channel 11 one by one and naturally roll down along the inclined dark channel 11.
Specifically, the photoelectric switch 4 is mounted on the side wall of the front end of the dark channel 11 and is connected with the single chip microcomputer 5 through a data line. Behind the photoelectric switch 4, the top of the dark channel 11 is provided with 3 industrial cameras 6, the middle of the dark channel is provided with a glass partition plate, and 3 light sources 7 are arranged below the glass partition plate. When the egg 3 rolls off from the upper part of the glass clapboard, the light source 7 is always in an open state. The photoelectric switch 4 is triggered by rolling of the eggs 3, electric signals are transmitted to the single chip microcomputer 5, then the 3 industrial cameras 6 are controlled by the computer 8 to sequentially collect an egg image, then the image is transmitted to the computer 8 to be processed according to a pre-programmed program, and whether cracks exist on the surfaces of the eggs is detected.
It will be appreciated that due to illumination by the light source, the egg and background edges in the image of the egg are apparent, and cracks in the egg surface are more apparent.
In one embodiment, as shown in fig. 4, the dark channel 11 comprises an inclined section and a horizontal section, the glass partition, the light source and the plurality of industrial cameras are located in the inclined section, and the inclination angle of the inclined section is 5 °.
Wherein the length of the inclined section is 0.8 meter, and the length of the horizontal section is 0.2 meter. In this embodiment, the inclination angle can be convenient for birds eggs to roll off, and can not lead to birds eggs to break very fast, and the horizontal segment is as the buffer area that birds eggs slowed down, is convenient for back conveyer belt 13 to carry out subsequent processing to birds eggs, and the transport surface of back conveyer belt is the same level as the horizontal segment of dark passageway. The structure of the dark channel can ensure that the eggs enter the rear input belt at a linear speed as close as possible to that of the rear conveying belt, and simultaneously, the eggs are prevented from colliding and breaking due to too high speed.
In one of the embodiments, as shown in fig. 2 and 3, the hidden channel 11 further includes a sorting assembly, the sorting assembly includes a stepping motor 9, a sorting rotating shaft and a partition plate (10), the stepping motor 9 is installed outside the hidden channel 11, the sorting rotating shaft and the partition plate (10) are arranged at a position close to an outlet of the hidden channel, the partition plate divides the hidden channel 11 into two channels, the stepping motor drives the sorting rotating shaft to rotate through a belt, the partition plate is fixed at the upper end of the sorting rotating shaft, and the partition plate is driven to rotate in a circulating manner within a preset range through the sorting rotating shaft.
As shown in fig. 3, the dark channel 11 is divided into a non-cracked egg channel and a cracked egg channel by the partition plate, when a crack is detected in an egg, the partition plate rotates to the left to open the cracked egg channel, and when no crack is detected in the egg, the partition plate rotates to the right to open the non-cracked egg channel.
Specifically, the rear end of the dark channel 11 is provided with a stepping motor 9, a sorting rotating shaft and a partition plate (10), and the stepping motor (9) drives the sorting rotating shaft and the partition plate (10) to swing through a belt. In addition, the lower end of the dark channel 11 is changed from a single channel to a double channel and is divided into a cracked egg channel and a non-cracked egg channel. After the detection result of the cracks of the poultry eggs is calculated by the computer 8, an electric pulse signal is sent to the stepping motor 9, and the stepping motor 9 is controlled to drive the sorting rotating shaft and the partition plate 10 to swing and sort. After sorting, eggs with cracks on the surfaces enter the crack egg collecting box through the crack egg channel, and the rest eggs enter the rear conveying belt 13 through the non-crack egg channel for subsequent processing operation.
In one embodiment, the egg crack detection device further comprises: and the controller is electrically connected with the stepping motor 9, and sends a rotation signal to the stepping motor to control the partition plate to rotate to open the corresponding channel when the current egg crack condition is different from the previous egg crack condition.
Egg cracking refers to both cracking and non-cracking.
In one embodiment, sponge cushions are arranged on two sides of the dark channel.
For specific limitations of the egg crack detection apparatus, reference may be made to the above limitations of the egg crack detection method, which are not described herein again. The modules in the egg crack detection device can be wholly or partially 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.
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 Memory, 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), for example.
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, and these are all within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.