Disclosure of Invention
In order to solve the problems, the present disclosure provides a method and a system for classifying and cutting wood board grades based on multi-mode image recognition, which automatically classifies wood boards and automatically divides cutting areas, thereby improving wood classification efficiency and yield.
According to some embodiments, the present disclosure employs the following technical solutions:
a plank grade classifying and cutting method based on multi-mode image recognition comprises the following steps:
acquiring a plank image to be processed, and preprocessing the plank image;
Detecting circular positioning points of the plank cutting, and obtaining a rough positioning image of the cut plank;
Extracting features of the wood board, inputting the extracted feature vectors into a support vector machine for classification, obtaining a classification type, carrying out maximum inscribed rectangle algorithm calculation on the non-defective wood board after classification, obtaining a maximum cutting area in a wood board area, further obtaining a cutting position, using an improved Mask R-CNN algorithm, using ResNeSt network to replace a Mask R-CNN backbone network, enhancing the characterization capability of the features, enabling the network to better capture local and global information of the wood board, carrying out pixel-level positioning on the wood board, carrying out maximum inscribed rectangle algorithm, obtaining the maximum cutting area in the wood board area, and determining the cutting method for cutting the wood board by utilizing the area difference value of the two and a certain threshold value size relation.
According to some embodiments, the present disclosure employs the following technical solutions:
Plank grade classification and cutting system based on multimode image recognition includes:
the plank image preprocessing module is used for acquiring a plank image to be processed and preprocessing the plank image;
The plank shielding area processing module is used for detecting circular positioning points of plank cutting and obtaining a rough positioning image of the cut plank;
the plank classifying module is used for extracting plank features of the mask image, inputting the extracted feature vectors into the support vector machine for classification, and obtaining classifying types;
The plank segmentation module is used for carrying out maximum inscribed rectangle algorithm calculation on the classified non-defective planks to obtain the maximum cutting area in the plank area, further obtaining the cutting position, using an improved Mask R-CNN algorithm, using ResNeSt networks to replace the backbone network of the Mask R-CNN, enhancing the characteristic characterization capability, enabling the network to better capture local and global information of the planks, carrying out pixel-level positioning on the planks, carrying out maximum inscribed rectangle algorithm to obtain the maximum cutting area in the plank area, and determining the segmentation of the planks by using the area difference value of the two and a certain threshold value size relation.
According to some embodiments, the present disclosure employs the following technical solutions:
A non-transitory computer readable storage medium for storing computer instructions which, when executed by a processor, implement the plank classification and cutting method based on multi-modal image recognition.
According to some embodiments, the present disclosure employs the following technical solutions:
An electronic device comprises a processor, a memory and a computer program, wherein the processor is connected with the memory, the computer program is stored in the memory, and when the electronic device runs, the processor executes the computer program stored in the memory so that the electronic device executes the plank classification and cutting method based on multi-mode image recognition.
Compared with the prior art, the beneficial effects of the present disclosure are:
The method can quickly find the image locating points and coarsely locate the wood board according to the locating points, and reduces the interference of other areas on the subsequent flow. In addition, if the locating point is not found for many times continuously, the locating point is prompted to be cleaned, the shielding position in the plank image can be removed rapidly, the influence on the image cutting position in the subsequent process is reduced, the classification and distinction of the planks can be realized rapidly, the cutting position is provided accurately by using various algorithms, the full-process and full-automatic processing method for the plank image in the wood processing field is realized, the manual operation steps can be reduced greatly, and the classification efficiency and the yield of the planks are increased.
Detailed Description
The disclosure is further described below with reference to the drawings and examples.
It should be noted that the following detailed description is illustrative and is intended to provide further explanation of the present disclosure. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure belongs.
It is noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of exemplary embodiments in accordance with the present disclosure. As used herein, the singular is also intended to include the plural unless the context clearly indicates otherwise, and furthermore, it is to be understood that the terms "comprises" and/or "comprising" when used in this specification are taken to specify the presence of stated features, steps, operations, devices, components, and/or combinations thereof.
Example 1
In one embodiment of the present disclosure, a method for classifying and cutting a board class based on multi-modal image recognition is provided, including:
Step one, acquiring a plank image to be processed, and preprocessing the plank image;
Detecting circular positioning points of the plank cutting, and obtaining a rough positioning image of the cut plank, and performing vertical projection according to the rough positioning image to obtain a mask image of a projection shielding area;
Thirdly, extracting board features of the Mask image, inputting the extracted feature vectors into a support vector machine for classification, obtaining a classification type, carrying out maximum inscribed rectangular algorithm calculation on the non-defective board after classification, obtaining the maximum cutting area in the board area, further obtaining the cutting position, and then using an improved Mask R-CNN algorithm, wherein a ResNeSt network is mainly used for replacing a Mask R-CNN backbone network, the characterization capability of the features is enhanced, the network can better capture local and global information of the board, positioning the board at pixel level is carried out, then the maximum inscribed rectangular algorithm is carried out, the maximum cutting area in the board area is obtained, and the cutting method is determined to carry out the board segmentation by utilizing the area difference value of the two and a certain threshold value size relation.
In the first step, a plank image to be processed is obtained, and preprocessing operation is carried out on the plank image, wherein the plank image obtained by shooting an industrial camera is subjected to image preprocessing, and the image is respectively subjected to graying, binarization and morphological processing;
Specifically, after a plank image shot by an industrial camera is acquired through an interface, firstly, carrying out graying operation on the plank image to obtain a two-channel gray image, then carrying out fixed-threshold binarization operation on the gray image to obtain a binarized image, and finally, removing noise points in the binarized image by using opening and closing operation.
After the image is subjected to graying and binarization, the interference of a general background can be removed by improving a binarization threshold value during binarization processing because the brightness of the image shot by the locating point and the plank is very high. Then, detecting a circular locating point on the binarized image by using Hough transformation, specifically, in the second step, the method for obtaining the rough locating image of the cut wood board comprises the following steps:
the circular anchor points of the plank cut are detected using a hough transform, wherein the detected circular anchor points in the image are controlled based on parameters of the gradient by controlling the distance between circles, the minimum radius of the circles, the maximum radius of the circles.
The parameter control based on the gradient comprises the steps of sequentially calculating angles of adjacent circular positioning points if the number of detected circular positioning points accords with the set threshold number, normally judging if the angles of the circular positioning points are within the threshold value, prompting to clean the circular positioning points if the number of the detected circular positioning points is smaller than the threshold number, and debugging camera parameters if the number of the detected circular positioning points is larger than the threshold number, and recording the current baffle position.
Specifically, a hough transform is used to detect circular anchor points on the binarized image, wherein the detected circular anchor points in the binarized image are controlled by controlling parameters such as a distance between circles, a minimum radius of circles, a maximum radius of circles, a gradient-based detection method, and the like. If the number of the detected locating points is equal to 4, angles of adjacent locating points are calculated in sequence, if the angles of the locating points are within a threshold value, the locating points are normal, and otherwise, the abnormality is required to be prompted. And if the number of the detected positioning points is smaller than 4, prompting the industrial control system to clean the positioning points. If the number of the detected positioning points is greater than 4, prompting abnormality to an industrial control system and recording. In addition, the position of the lower baffle plate can be recorded and obtained through setting camera parameters and debugging industrial control software.
After the industrial control system and the camera are debugged, the operation is stable and the acquisition of the locating points is very accurate in the normal use process. After the module is finished, the positions of the positioning points and the lower baffle are mainly recorded, and the rough positioning image of the wood board is obtained by cutting the wood board image according to the positions, so that the purpose of reducing the interference of surrounding complex backgrounds on subsequent processing flows is achieved.
Because the cutting instrument shields the plank, the plank image shot by the industrial camera is shielded up and down, and as in the left pressing plate and the right pressing plate in fig. 2, the plank shielding area processing module automatically removes the influence of shielding, and the shielding area is automatically subjected to white setting processing according to the plank trend, so that the position information of the shielding area and the image after the plank shielding treatment white are obtained. The lower baffle and the left and right pressing plates play a role in fixing the wood plate, and the upper four positioning points can play a role in assisting in fixing the wood plate and a role in facilitating the positioning of the image algorithm to the wood plate.
The method comprises the steps of carrying out vertical projection according to the obtained coarse positioning image of the wood board, and obtaining mask images of a projection shielding area, wherein the process of carrying out vertical projection according to the position information of circular positioning points of the wood board to obtain the starting position and the ending position of the shielding area in the x-axis direction in the image, then carrying out horizontal projection on the intercepted coarse positioning image to obtain the starting position and the ending position in the y-axis direction, finally obtaining the mask images of the shielding area, and carrying out white setting treatment on the shielding area according to the trend of the wood board to obtain the position information of the shielding area and the image after white shielding treatment of the wood board.
The method comprises the steps of firstly intercepting a nearby area of a shielding area according to position information to obtain an image I_cut, carrying out gray level and binarization processing on the image I_cut, then carrying out vertical projection on the binarized image to obtain a starting position X_start and an ending position X_end of the shielding area in the X-axis direction of the image, then carrying out horizontal projection on the intercepted binarized image to obtain a starting position Y_start and an ending position Y_end of the Y-axis direction, finally obtaining a mask image of the shielding area, and carrying out white supplementing processing on the mask position in the original image.
The method can prevent interference of the shielding area in the wood board grading and cutting processes, and finally obtains the positions (X_start, X_end, Y_start and Y_end) of the shielding area and the images after the wood board shielding treatment is white.
For a board, the defect is the first part to be treated. Defects mainly comprise knots, discoloration, wormholes, decay and the like, and the existence of the defects can reduce the local strength of the wood board and increase the cracking probability of the wood board. The multi-mode image recognition technology is to fuse or integrate various image features, and the characteristics and the respective unique advantages of different image recognition technologies are utilized, and the fusion technology is combined, so that the wood board grading process is more accurate, and the overall performance of the system is improved. The extracted characteristics are classified into 3 grades of wood board images including defective wood boards, straight wood boards and non-straight wood boards by using an image processing technology and some manually set extracted characteristic rules and using a machine learning method.
As one embodiment, the process of grading boards includes:
Firstly, respectively calculating the characteristics of the wood board to be extracted from the obtained image after the blocking area is whitened, wherein the characteristics mainly comprise the width of the wood board, the height of the wood board, the area of the wood board, the average pixel value of the wood board, the total circular area in the wood board, the number of the inner circles of the wood board, the integral bending degree of the wood board, the width difference of the section of the wood board, the bending degree of the lines, the number of the corresponding lines, the line spacing, the line number, the horizontal projection histogram, the longitudinal projection histogram and the like, carrying out normalization processing on the characteristics to form a characteristic vector, and classifying the characteristic vector by using a structured dataset and svm algorithm to finally obtain the three types of images of the wood board with defects, the straight lines and the wood board without straight lines.
For a three-classification problem, 3 SVM models are trained using One-vs-all strategy training, each model corresponding to a combination of One class and all other classes.
Specifically, for category 1, the samples of category 1 are labeled as positive samples, the samples of the other 2 categories are labeled as negative samples, and then an SVM model is trained. For category 2, the samples of category 2 are labeled as positive samples, the samples of the other 2 categories are labeled as negative samples, and then a second SVM model is trained. Similarly, for category 3, the sample of category 3 is labeled as a positive sample, the samples of the other 2 categories are labeled as negative samples, and then the model 3 SVM is trained.
As one embodiment, the process of wood board cutting includes:
And (3) obtaining cutting areas of the classified boards by using two methods, finding out the most reasonable cutting scheme by comparing the difference values of the two different methods, so that the cutting areas of the boards are the most accurate, obtaining a larger yield, and finally outputting cutting positions in the board images.
Under the industrial control condition, the shooting quality of the wood board image is very high. And determining the cutting position of the obtained non-defective wood board. Firstly, a method 1 is used, the method 1 is a traditional image processing algorithm, a maximum inscribed rectangle algorithm calculation is carried out on a roughly positioned plank image with shielding areas removed, a maximum cutting area S1 in the plank area is obtained, and then a cutting position is obtained, and then, a method 2, namely a Mask R-CNN algorithm, is used, an improved Mask R-CNN algorithm is used for realizing example segmentation of the plank, wherein a ResNeSt network is mainly used for replacing a Mask R-CNN backbone network, the characteristic representation capability is enhanced, and the network can better capture local and global information of the plank. The method mainly comprises the steps of obtaining a data set through a method 1 and manual labeling, and obtaining a mask of a plank image by using a training model after the model is converged. And (3) carrying out pixel-level positioning on the wood board, and then carrying out a maximum inscribed rectangle algorithm to obtain a maximum cutting area S2 in the wood board area. If the area difference obtained by the two methods is smaller than a threshold t1, the cutting position in the method 1 is used, in the method 1, an image of a binarized wood board can be obtained by using the steps, wherein the wood board section is white, the background is black, the maximum inscribed rectangle is obtained for the binarized image, 4 rectangular vertexes, namely the cutting position, are obtained, if the area difference is larger than the threshold t1 and smaller than the threshold t2, the cutting position of the method 2 is used, the cutting position is obtained by using the method 2, the method 1 is the same as the method 1, the two methods are different in the processing process of obtaining the wood board edge image, the method 1 adopts a traditional image processing method, and the method 2 uses a deep learning model to classify whether pixels in the image belong to the wood board or not. And finally obtaining a binarized image of the wood board by adopting the two methods, obtaining a vertex by adopting a maximum internal moment method, wherein the vertex is a cutting position, otherwise, the cutting position of the method 1 is used, and if the area difference of the two is larger than a threshold t2, returning to abnormality, wherein the two methods are not adopted.
Example 2
In one embodiment of the present disclosure, there is provided a plank classification and cutting system based on multi-modal image recognition, comprising:
the preprocessing module is used for acquiring a plank image to be processed and preprocessing the plank image;
The plank classifying module is used for detecting circular positioning points of plank cutting and obtaining coarse positioning images of the cut planks, and projecting in the vertical direction according to the coarse positioning images to obtain mask images of projection shielding areas;
Extracting board features of the mask image, inputting the extracted feature vectors into a support vector machine for classification, and obtaining classification types;
The plank segmentation module is used for carrying out maximum inscribed rectangle algorithm calculation on the classified non-defective planks to obtain the maximum cutting area in the plank area, further obtaining the cutting position, and then using an improved Mask R-CNN algorithm, wherein a ResNeSt network is used for replacing a backbone network of the Mask R-CNN, the characterization capability of the characteristics is enhanced, the network can better capture local and global information of the planks, pixel-level positioning is carried out on the planks, then the maximum inscribed rectangle algorithm is carried out to obtain the maximum cutting area in the plank area, and the cutting method is determined to segment the planks by utilizing the area difference value of the two areas and a certain threshold value.
Example 3
In one embodiment of the present disclosure, a non-transitory computer readable storage medium is provided for storing computer instructions that, when executed by a processor, implement the steps of the plank classification and cutting method based on multi-modal image recognition.
Example 4
In one embodiment of the disclosure, an electronic device is provided, which includes a processor, a memory, and a computer program, wherein the processor is connected to the memory, the computer program is stored in the memory, and when the electronic device is running, the processor executes the computer program stored in the memory, so that the electronic device executes the steps of implementing the plank classification and cutting method based on multi-mode image recognition.
The present disclosure is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the disclosure. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While the specific embodiments of the present disclosure have been described above with reference to the drawings, it should be understood that the present disclosure is not limited to the embodiments, and that various modifications and changes can be made by one skilled in the art without inventive effort on the basis of the technical solutions of the present disclosure while remaining within the scope of the present disclosure.