Calculation method and system for identifying number of insects and cigarettes based on RGB color
Technical Field
The invention relates to the technical field of tobacco leaf pest identification, in particular to a calculation method and a system for identifying the number of insects and worms on the basis of RGB (red, green and blue) colors.
Background
The tobacco industry in China rapidly develops, the scale and the quantity of tobacco leaf storage are larger and larger, the storage time is correspondingly prolonged, the storage period of the tobacco leaves is approximately from six months to two years after harvesting, and insect damage and disaster of the tobacco leaves caused by environmental factors of a warehouse are prevented during the period, so that the quality of tobacco products is affected.
One of the traditional basic modes of tobacco pest control is to paste insect attracting sheets on multiple tobacco pests, and check the trapping condition regularly. The insect pest situation workers regularly check the insect pest attracting sheet, paper records the insect pest situation, regularly observe, pay important attention if the number of insect pests is increased, but do not particularly record the time and place of pesticide killing. At present, tobacco companies generally use a sticky trap to hang on a wall and send special persons to check the number of tobacco worms regularly, but the method consumes a great deal of manpower.
Along with the progress of science and technology, technologies such as deep learning, neural network, machine vision and the like are introduced into an insect condition recognition monitoring system, but a tobacco insect plate is simpler than other insect condition recognition environments, the tobacco insect plate has no other interference items except the interference of edges and middle insect medicaments, has single color, can be recognized without using black and white pictures, is relatively dispersed and huge in quantity aiming at the situation that the insect plate deployment in the tobacco industry is relatively large in quantity, is difficult to control in terms of preparing technical cost such as deep learning, neural network, machine vision and the like when a large number of terminals are required for acquiring image data, has lower operation speed, cannot meet the requirement of batch rapid recognition processing, and is large in size.
In chinese patent document CN110569858a, a method for identifying tobacco plant diseases and insect pests based on deep learning algorithm is disclosed, comprising: collecting a large number of tobacco leaf plant diseases and insect pests pictures; removing unqualified tobacco leaf plant diseases and insect pests pictures, and classifying and storing the qualified tobacco leaf plant diseases and insect pests pictures according to the types of the tobacco leaf plant diseases and insect pests to serve as a training sample library; using GoogLeNet model and adopting improved Inception structure to realize the establishment of tobacco plant diseases and insect pests identification model; acquiring RGB image information of a disease and pest image to be detected; judging whether the image information is tobacco leaf image information or not, if so, executing the following steps; and identifying the tobacco leaf disease types by using the established tobacco leaf disease and pest identification model.
The technical scheme has the defect that a large number of terminals are required to collect image data, and the requirement of batch rapid identification processing cannot be met.
Disclosure of Invention
The invention aims to solve the technical problem of providing a calculation method for identifying the number of insects, namely insects, by utilizing RGB color grids, adjacent grouping and merging can be utilized to process and analyze insect condition images, so that the method is low in cost, simple in algorithm, flexible in model and high in operation speed.
In order to solve the technical problems, the invention adopts the following technical scheme: the calculating method for identifying the number of the insects and the tobacco insects based on the RGB color comprises the following steps:
s1: collecting a two-dimensional image photographed by the insect plate, initializing a collecting area to be set as a sticky area of the insect plate, and uploading the sticky area to a server; the sticky area is used for sticking the tobacco insects so that the tobacco insects cannot fly away or run off;
s2: initializing the two-dimensional image acquired in the step S1, and initializing the insect plate photo into a black-and-white picture;
s3: converting each pixel in the black-and-white picture in the step S2 into grids, wherein each obtained grid data forms a small square, and each small square stores the RGB value of the corresponding black-and-white pixel; s4: obtaining all the grid length and width quantity values in the step S3;
S5: filtering the insect medicine in the middle area by the RGB value of the black-and-white pixels of the grid; because the specification and the size of the insect medicine can be predicted in advance, and the tobacco insects are stuck on the periphery of the sticking plate due to the sticking plate, the possibility of flying to the insect medicine area is small, so that the numerical value can be directly set to remove the insect medicine without entering the calculation range;
S6: grouping and combining adjacent suspected tobacco pest pattern spot grids, wherein the number of each group of squares is the area of the combined adjacent grids;
the grid pattern is converted into small squares of rows and columns which are regularly arranged, but not complex irregular patterns, so that pattern calculation is not adopted, and the algorithm has the advantages of simplicity and high efficiency;
s7: setting the area of RGB value of single pixel as a basic unit area; setting an estimated value range of the pixel area occupied by a single tobacco pest, determining a threshold value, and filtering out smaller grouping merging pattern spots;
The sizes of the tobacco insects which can fly onto the insect plates in the tobacco warehouse are basically consistent, the resolution of the acquisition terminal is known to be unchanged, and the RGB values of the number of pixels of the grid square occupied by one tobacco insect can be estimated through the shooting result, so that the area interval range of the RGB values of the pixels of the single tobacco insect is obtained;
Filtering out smaller groups of combined spots, including smaller worms such as spiders or smaller stains, leaving the suspected tobacco worm spot raster data;
S8: estimating the specific number of tobacco worms.
By adopting the technical scheme, the RGB color grid adjacent grouping and merging technology is used, compared with deep learning, a neural network, machine vision and the like, the method is lower in cost, simple in algorithm, flexible in model and high in operation speed, real-time monitoring of insect conditions can be realized, the current manual inspection mode can be changed through the scheme, the labor intensity is reduced, the data reading frequency and accuracy are improved, and the monitoring density is increased.
As a preferable technical solution of the present invention, in the step S1, the flash intensity during shooting is adjusted according to the external light intensity, so that the most common value of the black-and-white pixel RGB values corresponding to the grid obtained in the step S3 is within a predetermined range interval, thereby determining that the shot photo image data is a qualified data source.
The intensity of the flash lamp during shooting is adjusted according to the intensity of external light, so that the sensitivity of the two-dimensional image shot by the insect collecting plate is ensured to be within a specified standard range.
In the step S1, the two-dimensional image photographed by the collecting insect plate and the actual insect plate are kept in the same horizontal and vertical directions by adjusting the photographing angle; and two-dimensional images of the insect plates are collected at fixed time.
If the equipment terminal is not fine enough in installation and deployment, the shooting angle can be adjusted through the system platform, so that the collected data and the actual insect plate keep the same horizontal and vertical directions.
In the step S1, the server receives the uploaded two-dimensional image, and displays the area and position information of the insect board on the screen.
In the step S1, the distance between the photographing device for collecting the two-dimensional image and the insect plate is deployed according to standard measurement, and the resolution of the photographing device for collecting the two-dimensional image is a fixed value; in the step S4, the grid length and width number value is within a specified range and is a qualified data source.
In the step S6, the row-column adjacency is adopted to perform judgment, grouping and merging, and the positioning calculation is performed by taking the row and the column of the matrix as attributes, wherein the column attributes are defined as follows: column, row attribute is defined as Row, when the Column and Row of two grids are within plus or minus one unit range, judging that the grids are adjacent to square; and firstly, carrying out row-column combination and sorting from small to large, setting the obtained adjacent grid squares as the same group, and calculating all groups.
As a preferred technical scheme of the present invention, in the step S7, a cigarette occupies RGB values of 7 to 9 pixels of the grid square, and an RGB value of 8 pixels is set as a pixel RGB area value where a cigarette occupies; the threshold is at least an RGB value of 5 pixels; and the maximum threshold value is 15 pixels of RGB values, and the situation of bundling a plurality of tobacco worms is judged.
The invention also provides a computing system for identifying the number of insects, namely the insects, the cigarettes and the insects based on RGB color, the computing system comprises a data acquisition module, a data uploading communication module and a server, and the server comprises a data analysis module and a data display module;
The data acquisition module is used for shooting image information of the insect plate, can select an area of the insect plate, which is stuck with the plate, as an effective uploading area, and sets period reporting time and interval;
The data uploading communication module is used for uploading the acquired image information to a server;
the data analysis module is used for receiving the data uploading of the data uploading communication module, carrying out RGB color grid processing on the data, and converting the image information into point position information and the number of tobacco insects on a screen;
And the data display module displays the tobacco insects in a contour mode according to the tobacco insect position information analyzed by the data analysis module and marks the total tobacco insect quantity of the insect plate.
The data acquisition module equipment terminal is powered by a battery, so that the requirement of mass deployment of insect plates in the tobacco industry is met, and the data acquisition module equipment terminal has the advantages of no wiring, safety, fire resistance and the like; and the data uploading communication module is preferably a 4G communication module, has strong signals and high uploading speed.
As the preferable technical scheme of the invention, the equipment terminal containing the data acquisition module adopts an IP68 waterproof design; the computing system also includes a trap for pest capture in the production area.
As a preferable technical scheme of the invention, the data acquisition module transmits acquired picture information to the server for RGB color grid processing through the internet of things by the data uploading communication module; and the server stores the original image data and processes and analyzes the insect condition image.
By adopting the technical scheme of the computing system for identifying the number of the insects and the worms based on the RGB color, the invention obtains the insect condition image in a certain time period in a certain area through data acquisition, data transmission and RGB color grid processing and connection with an application display platform (data display module), and then transmits the insect condition image to the application display platform in real time after processing through the data platform, so that management personnel and inspection personnel can check the data (the number of the insects and the worms) in real time and check history curves, early warning information and the like, thereby realizing real-time monitoring of the insect condition, reducing the labor intensity, improving the data reading frequency and accuracy and increasing the monitoring density.
Drawings
The invention can be further illustrated by means of non-limiting examples given in the accompanying drawings;
FIG. 1 is a schematic diagram of a worm plate according to the method for calculating the number of insects and tobacco based on RGB color identification;
FIG. 2 is a schematic diagram of a region of removing middle worm medicine based on raster data of a calculation method for identifying the number of insects and cigarettes based on RGB color;
Fig. 3 is a schematic diagram of adjacent grids of the calculation method for identifying the number of insects and cigarettes based on RGB color, after grouping and removing small interference pattern spots.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the drawings of the embodiments of the present invention.
The invention discloses a calculation method for identifying the number of insects and cigarettes based on RGB colors, which comprises the following steps:
s1: collecting a two-dimensional image photographed by the insect plate, initializing a collecting area to be set as a sticky area of the insect plate, and uploading the sticky area to a server;
s2: initializing the two-dimensional image acquired in the step S1, and initializing the insect plate photo into a black-and-white picture;
s3: converting each pixel in the black-and-white picture in the step S2 into grids, wherein each obtained grid data forms a small square, and each small square stores the RGB value of the corresponding black-and-white pixel; s4: obtaining all the grid length and width quantity values in the step S3;
s5: filtering the insect medicine in the middle area by the RGB value of the black-and-white pixels of the grid;
S6: grouping and combining adjacent suspected tobacco pest pattern spot grids, wherein the number of each group of squares is the area of the combined adjacent grids;
s7: setting the area of RGB value of single pixel as a basic unit area; setting an estimated value range of the pixel area occupied by a single tobacco pest, determining a threshold value, and filtering out smaller grouping merging pattern spots;
S8: estimating the specific number of tobacco worms.
In the step S1, the flash light intensity at the time of shooting is adjusted according to the external light intensity, so that the most common value of the RGB values of the black and white pixels corresponding to the grid obtained in the step S3 is within a predetermined range section, thereby judging the shot photo image data as a qualified data source.
In the step S1, a two-dimensional image photographed by the collecting insect plate and the actual insect plate keep a horizontal and vertical consistent direction by adjusting a photographing angle; and two-dimensional images of the insect plates are collected at fixed time.
In the step S1, the server receives the uploaded two-dimensional image, and displays the area and position information of the insect board on a screen.
In the step S1, a distance between a photographing device for collecting a two-dimensional image and a worm plate is deployed according to standard measurement, and a resolution ratio of the photographing device for collecting the two-dimensional image is a fixed value; in the step S4, the grid length and width number value is within a specified range and is a qualified data source.
In the step S6, the row-column adjacency is adopted to perform judgment, grouping and merging, and the positioning calculation is performed by taking the row and the column of the matrix as attributes, wherein the column attributes are defined as follows: column, row attribute is defined as Row, when the Column and Row of two grids are within plus or minus one unit range, judging that the grids are adjacent to square; and firstly, carrying out row-column combination and sorting from small to large, setting the obtained adjacent grid squares as the same group, and calculating all groups.
In the step S7, a tobacco pest occupies RGB values of 7 to 9 pixels of the grid square, and RGB values of 8 pixels are set as RGB area values of the pixel where the tobacco pest occupies; the threshold is at least an RGB value of 5 pixels; and the maximum threshold value is 15 pixels of RGB values, and the situation of bundling a plurality of tobacco worms is judged.
The calculation method is realized by adopting a calculation system based on RGB color recognition of the number of insects, the calculation system comprises a data acquisition module, a data uploading communication module and a server, and the server comprises a data analysis module and a data display module;
The data acquisition module is used for shooting image information of the insect plate, can select an area of the insect plate, which is stuck with the plate, as an effective uploading area, and sets period reporting time and interval;
The data uploading communication module is used for uploading the acquired image information to a server;
the data analysis module is used for receiving the data uploading of the data uploading communication module, carrying out RGB color grid processing on the data, and converting the image information into point position information and the number of tobacco insects on a screen;
And the data display module displays the tobacco insects in a contour mode according to the tobacco insect position information analyzed by the data analysis module and marks the total tobacco insect quantity of the insect plate.
The equipment terminal containing the data acquisition module adopts an IP68 waterproof design; the computing system also includes a trap for pest capture in the production area.
The data acquisition module transmits the acquired picture information to the server through the Internet of things by the data uploading communication module for RGB color grid processing; and the server stores the original image data and processes and analyzes the insect condition image.
Specifically, during processing, the data platform (comprising a data acquisition module and a data uploading communication module) is in communication connection with the application display platform (data display module) and forms bidirectional data transmission; the data platform is used for carrying out image acquisition, image transmission, image processing and tobacco worm identification, the equipment of the data acquisition module is used for carrying out image acquisition on tobacco worm capturing data to obtain tobacco worm image data, the tobacco worm image data is transmitted to the data analysis module through the data uploading communication module by adopting the Internet of things (4G or 5G) to carry out RGB color grid processing, the acquired tobacco worm image data is subjected to cutting, leveling and rotation when the acquisition terminal is installed and deployed, as shown in the attached figure 1, only a sticky board area is reserved by words with edges removed, and a calculation system based on the quantity of tobacco worms of the RGB color identification tobacco worm board is initialized to be black-white pictures; the data analysis module converts the received black-and-white pictures to obtain raster data as shown in figure 2, each raster stores RGB values corresponding to black-and-white pixels, and filters out the middle insect and medicine areas; the data analysis module judges that if the obtained image grid length and width quantity value is within a tolerance of 250 x 150 plus or minus 20, the obtained image is a qualified data source; the most common value 70 of the RGB values is that the data analysis module filters out the raster data with the RGB value more than 70, namely a clean sticky board area on the picture, wherein the RGB value is 255 at the maximum, the pure black seen by the right eye is 0 at the minimum, and the pure white seen by the right eye is obtained; if the most common value of the RGB values of the black and white pixels corresponding to the grids of the whole is obtained through analysis and is not in the range of 60 to 80, judging that the shot picture is a disqualified data source; then taking one tenth of one grid as a buffer value to buffer each suspected grid outwards, merging adjacent pattern spots together through an adjacent grid grouping technology, calculating the area of a single combined suspected tobacco worm pattern spot, setting a tobacco worm to occupy 8 grid square units through big data analysis, and filtering out smaller pixel RGB values smaller than 5 units, wherein the smaller pattern spots can be mud spots and small worms; if the calculated diameter of the minimum circumscribing circle is larger than 4 units, the situation of thin black edges is judged, and the minimum circumscribing circle can be filtered directly; if the combined pattern area is larger than 15, the situation that at least more than two tobacco insects are piled up can be considered to occur, and the data analysis module can estimate the quantity of piled up tobacco insects; preferably, the above values can be finely tuned after big data analysis. The example calculation gave 6 tobacco worms as shown in figure 3.
The display platform of the data display module comprises a pest situation early warning function and statistical analysis, the pest situation early warning is used for setting a threshold value of pest situation alarm, and early warning reminding is carried out and early warning reminding information is pushed after the pest situation early warning exceeds the threshold value, wherein the early warning reminding information comprises the number of newly-increased tobacco worms, the total quantity of tobacco worms, the replacement reminding of a pest sucking plate and zero clearing of the number of tobacco worms; the statistical analysis is used for displaying insect condition information including the number of the tobacco insects, the newly-increased number of the tobacco insects and the killing situation in a certain period of time in the monitoring area on the display platform through a table, a histogram and a line graph, and archiving or/and exporting data in a table form.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather to enable any modification, equivalent replacement, improvement or the like to be made within the spirit and principles of the invention.