IMAGE RECOGNITION METHOD, ELECTRONIC DEVICE AND READABLE STORAGE MEDIUM

Information

  • Patent Application
  • 20240029387
  • Publication Number
    20240029387
  • Date Filed
    August 16, 2021
    3 years ago
  • Date Published
    January 25, 2024
    10 months ago
  • CPC
    • G06V10/16
    • G06V10/82
    • G06V10/764
    • G06V10/7715
    • G06V10/26
    • G06V2201/03
  • International Classifications
    • G06V10/10
    • G06V10/82
    • G06V10/764
    • G06V10/77
    • G06V10/26
Abstract
The present invention provides an image recognition method, an electronic device and a computer-readable storage medium. The method includes: segmenting an original image into a plurality of unit images having the same predetermined size; inputting the unit images into a pre-built neural network model to carry out processing, so as to correspondingly add a detection frame to a marker in each unit image to form a pre-detection unit image; stitching a plurality of pre-detection unit images into a pre-output image according to segmentation positions of each unit image in the original image; determining whether the markers selected in two adjacent detection frames in the pre-output image are the same marker; outputting the image with the detection frames until all the detection frames confirmed to have the same markers are all merged. The present invention can effectively recognize types and positions of the markers in the image.
Description
CROSS-REFERENCE OF RELATED APPLICATIONS

The application claims priority from Chinese Patent Application No. 202010881849.X, filed Aug. 28, 2020, entitled “Image Recognition Method, Electronic Device and Readable Storage Medium”, all of which are incorporated herein by reference in their entirety.


FIELD OF INVENTION

The present invention relates to the field of image recognition of medical equipment, and more particularly to an image recognition method, an electronic device, and a readable storage medium.


BACKGROUND

Gastrointestinal motility refers to the ability of normal gastrointestinal peristalsis to help complete the digestion and absorption of food. Poor gastrointestinal motility may result in an indigestion.


In the prior art, the strength of gastrointestinal motility is generally identified by gastrointestinal markers. Specifically, after a user swallows markers of different shapes in several times, the positions of the markers are determined through images obtained by X-ray imaging, and then the strength of gastrointestinal motility is determined.


In the prior art, the positions and types of the markers in a X-ray image are usually determined by manually observing the image. However, for markers of different shapes swallowed in different times, the size displayed on the X-ray image is small, and there are many types, so it is difficult to accurately count the positions and quantities of various markers by manual observation, and the gastrointestinal motility of a subject cannot be determined.


SUMMARY OF THE INVENTION

The present invention provides an image recognition method, an electronic device, and a readable storage medium.


In order to achieve one of the above-mentioned objects of the present invention, an embodiment of the present invention provides an image recognition method. The method comprises: segmenting an original image into a plurality of unit images having the same predetermined size, where a plurality of markers are distributed in the original image;

    • inputting the unit images into a pre-built neural network model to carry out processing, so as to correspondingly add a detection frame for a marker in each unit image to form a pre-detection unit image, where the detection frame is a minimum rectangular frame enclosing the marker;
    • stitching a plurality of pre-detection unit images into a pre-output image according to segmentation positions of each unit image in the original image;
    • determining whether the markers selected in two adjacent detection frames in the pre-output image are the same marker;
    • when the markers selected in two adjacent detection frames in the pre-output image are the same marker, merging the two detection frames; and
    • when the markers selected in two adjacent detection frames in the pre-output image are not the same marker, reserving different detection frames corresponding to different markers; and
    • outputting the image with the detection frames until all the detection frames confirmed to have the same markers are all merged;
    • where, determining whether the markers selected in two adjacent detection frames in the pre-output image are the same marker comprises: determining a type of the marker in each detection frame according to the probability of the type of the marker, and if the markers in two adjacent detection frames are of the same type, determining whether the markers in the frames are the same marker according to coordinate values of the two adjacent detection frames.


In an embodiment of the present invention, in the step of segmenting the original image into the plurality of unit images having the same predetermined size, the method further comprises:

    • if a size of any unit image is less than the predetermined size in the segmentation process, complementing edge pixel values to the original image before the unit images are formed, or complementing edge pixel values to the unit images with a size less than the predetermined size after the unit images are formed.


In an embodiment of the present invention, the method for building the neural network model comprises: extracting at least one feature layer by using convolutional neural networks corresponding to each unit image:

    • where in the process of extracting the feature layer, p convolution kernels of m*m are configured to convolution predictors of anchor boxes to process the unit images, p=(c1+c2)*k, where the anchor boxes are preset rectangular boxes with different aspect ratios, m is an odd positive integer, c1 represents the number of types of markers, k represents the number of anchor boxes, and c2 represents the number of offset parameters for adjusting the anchor boxes; where the detection frame is obtained by changing the size of the anchor box.


In an embodiment of the present invention, the method further comprises: performing pooling layer processing on the unit images for a plurality of times according to the types and size of the markers to obtain the corresponding feature layers.


In an embodiment of the present invention, in the process of performing pooling layer processing on the unit images for the plurality of times according to the types and size of the markers to obtain the corresponding feature layers, the method comprises:

    • before performing pooling layer processing on a unit image each time, performing convolution layer processing on the unit image at least once, and sizes of the convolution kernels are the same.


In an embodiment of the present invention, the method further comprises: setting c2=4, and the offset parameters for adjusting the anchor boxes comprise width offset values and height offset values of an upper left corner, a width scaling factor and a height scaling factor.


In an embodiment of the present invention, determining whether the markers in the frames are the same marker according to the coordinate values of the two adjacent detection frames comprises:

    • establishing a rectangular coordinate system by taking an upper left corner of the original image as a coordinate origin, and comparing whether the difference between feature values of two horizontally adjacent detection frames is within a threshold range, and determining that the markers selected in the two detection frames used in current calculation are the same marker when the difference is within the threshold range, wherein the feature values are coordinate values of the upper left corner and coordinate values of a lower right corner of each detection frame.


In an embodiment of the present invention, determining whether the markers in the boxes are the same marker according to the coordinate values of the two adjacent detection frames comprises:

    • establishing a rectangular coordinate system by taking an upper left corner of the original image as a coordinate origin, and comparing whether the difference between feature values of two vertically adjacent detection frames is within a threshold range, and determining that the markers selected in the two detection frames used in current calculation are the same marker when the difference is within the threshold range, wherein the feature values are coordinate values of the upper left corner and coordinate values of a lower right corner of each detection frame.


In an embodiment of the present invention, merging the two detection frames comprises:

    • comparing the coordinate values of the upper left corners of the two detection frames currently used for calculation, and respectively taking the minimum values of the horizontal coordinate and the vertical coordinate as the coordinate values of the upper left corner of the merged detection frame;
    • comparing the coordinate values of the lower right corners of the two detection frames, and respectively taking the maximum values of the horizontal coordinate and the vertical coordinate as the coordinate values of the lower right corner of the merged detection frame.


It is another object of the present invention to provide an electronic device. In an embodiment, the electronic device comprises a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the computer program to implement the steps of the image recognition method.


It is still another object of the present invention to provide a computer-readable storage medium. In an embodiment, the computer-readable storage medium stores a computer program and the computer program is executed by the processor to implement the steps of the image recognition method as described above.


According to all aspects of the present invention, the advantages over the prior art are that: with the image recognition method, the electronic device and the computer-readable storage medium of the present invention, the original image is automatically processed by a neural network model to add detection frames, and further, the detection frames labeled repeatedly are merged to improve the accuracy of image marking, so that the types and positions of markers in the image are effectively recognized, and the gastrointestinal motility of a subject is accurately determined.





BRIEF DESCRIPTION OF THE DRAWINGS


FIG. 1 is a flow schematic diagram of an image recognition method, in accordance with a preferred embodiment of the present invention.



FIG. 2 is a structural diagram of a neural network according to a preferred embodiment of the present invention.



FIG. 3 is a schematic diagram of a result from processing an original image in steps S1 to S3 as shown in FIG. 1.



FIG. 4 is a schematic diagram of a result from processing in step S4 shown in FIG. 1 on the basis of FIG. 3.





DETAILED DESCRIPTION

The present invention will be described in detail below with reference to the accompanying drawings and preferred embodiments. However, the embodiments are not intended to limit the present invention, and the structural, method, or functional changes made by those skilled in the art in accordance with the embodiments are included in the scope of the present invention.


Referring to FIG. 1, in an embodiment of the present invention, an image recognition method is provided, the method comprising:

    • step S1, segmenting an original image into a plurality of unit images having the same predetermined size, where a plurality of markers are distributed in the original image;
    • step S2, inputting the unit images into a pre-built neural network model to carry out processing, so as to correspondingly add a detection frame to a marker in each unit image to form a pre-detection unit image, where the detection frame is a minimum rectangular frame enclosing the marker;
    • step S3, stitching a plurality of pre-detection unit images into a pre-output image according to segmentation positions of each unit image in the original image;
    • step S4, determining whether the markers selected in two adjacent detection frames in the pre-output image are the same marker:
    • if the markers selected in two adjacent detection frames are the same marker, executing step S5: merging the two detection frames; and
    • if the markers selected in two adjacent detection frames are not the same marker, executing step S6: reserving different detection frames corresponding to different markers; and
    • step S7, outputting the image with the detection frames until all the detection frames confirmed to have the same markers are all merged.


In an embodiment of the present invention, the original image is usually large in size, and in order to improve the accuracy of recognition, it is necessary to segment the image before the recognition of the image, and restore the image according to the segmentation sequence after the recognition of the image.


In step S1, in the process of segmenting the original image into a plurality of unit images with the same predetermined size, the image may be segmented in sequence starting from the edges and corners of the original image, or the image may be segmented as required on the basis of any point in the original image after the point is selected. Correspondingly, the method further comprises: if a size of any unit image is less than the predetermined size in the segmentation process, complementing edge pixel values to the original image before the unit images are formed, or complementing edge pixel values to the unit images with a size less than the predetermined size after the unit images are formed, so that the size of each unit image is the same as the predetermined size.


It should be noted that, in a specific application process, the original image may be segmented first, and if the size of the finally formed unit image is less than the predetermined size, the edge pixel values are complemented only for the finally formed unit image. It is also possible to calculate in advance whether the current original image can be completely segmented according to the predetermined size before the image segmentation, and if it cannot be completely segmented, the edge pixel values are complemented to the original image before the segmentation. Usually, the pixel value of the complementing position can be set specifically as needed, e.g., set to 0, which is not further described here.


Preferably, after segmentation, the unit image is a square in shape. And in an embodiment of the present invention, the size of the unit image is 320*320, and the unit is a pixel.


In step S2, the method for building the neural network model comprises: extracting at least one feature layer by using convolutional neural networks (CNN) corresponding to each unit image.


In an embodiment of the present invention, in the process of extracting the feature layer, p convolution kernels of m*m are configured to convolution predictors of anchor boxes to process the unit images, so as to predict the type and the position of the markers. Where, m is an odd positive integer. The anchor box is a preset rectangular box with different aspect ratios. p=(c1+c2)*k, where c1 represents the number of types of markers, k represents the number of anchor boxes, and c2 represents the number of offset parameters for adjusting the anchor boxes. The detection frame is obtained by changing the size of the anchor box.


Further, the unit images are subjected to pooling layer processing for a plurality of times according to the types and size of the markers to obtain the corresponding feature layers; that is, the types and size of the markers determine the number and size of the feature layers. Specifically, the size of the markers on the original image is pre-divided to determine the number and size of the feature layers.


Preferably, in the process of performing pooling layer processing on the unit images for a plurality of times according to the types and size of the markers to obtain the corresponding feature layers, the method specifically comprises: before performing pooling layer processing on a unit image each time, performing convolution layer processing on the unit image at least once, and the sizes of convolution kernels are the same.


The convolution layer processing refers to dimension reduction and feature extraction on an input image through convolution operations. The pooling layer processing is used to reduce the spatial size of the image.


In order to facilitate understanding, a specific example is described below for reference.


Referring to FIGS. 2-4, in a specific embodiment of the present invention, there are three types of markers to be recognized. Referring to FIG. 3, the shapes of the markers are: dot type, O-ring type and tri-chamber type. Since an X-ray device may capture incomplete markers or overlapping markers on an X-ray image, even the markers of the same type may appear in different size on the X-ray image. Thus, the size of the markers displayed on the X-ray image needs to be pre-divided to determine the number of feature layers that need to be set up.


Referring to FIG. 2, a neural network model for feature extraction in this embodiment is established and configured with three feature layers. The original image is divided into a plurality of 320*320 unit images in sequence, and the feature extraction is carried out on each unit image by establishing convolutional neural networks. Specifically, the size of an input unit image is 320*320, and the convolution layer processing and pooling layer processing are sequentially performed on the input image to obtain the required feature layers respectively. After 2 convolution layer processing and 1 pooling layer processing, 2 convolution layer processing and 1 pooling layer processing, 3 convolution layer processing and 1 pooling layer processing, and 3 convolution layer processing are sequentially performed on the unit image (320*320), a feature layer 1 is extracted. Since a total of 3 pooling layer processing are performed, each of which reduces the image size by a factor of 2 compared to the previous image size, the image size of the feature layer 1 is reduced to 40*40, enabling detection of markers ranging in size from 8*8 to 24*24. Based on the image of the feature layer 1 (40*40), 1 pooling layer processing and 3 convolution layer processing are sequentially performed to extract a feature layer 2. The image size of the feature layer 2 is twice as small as that of the feature layer 1, which is 20*20, enabling detection of markers ranging in size from 16*16 to 48*48. Based on the image of the feature layer 2 (20*20), 1 pooling layer processing and 3 convolution layer processing are sequentially performed to extract a feature layer 3. The image size of the feature layer 3 is 10*10, enabling detection of markers ranging in size from 32*32 to 96*96. The size and number of the convolution kernels used in each convolution layer processing can be set according to actual requirements, for example, the number of the convolution kernels is 64, 128, 256, 512, etc., as shown in FIG. 2. Alternatively, in other embodiments, a neural network may be constructed and the number of feature layers may be configured according to actual requirements.


Preferably, in a specific example of the present invention, a 3*3 convolution is configured to process the image, that is, m=3 is set. There are three types of markers to be recognized, that is, c1=3 is set, which are dot type, O-ring type and tri-chamber type. The anchor box is a plurality of bounding boxes with different size and aspect ratios generated by taking any pixel point as a center. The offset parameters for adjusting the anchor box specifically comprise: width offset values and height offset values of an upper left corner, width scaling factors and height scaling factors, that is, c2=4 is set.


Specifically, the output of c1 is a one-dimensional array, denoted result c1[3]. Where result c1[0], result c1[1], and result c1[2] are three elements of the array, each representing the probability of a type that the marker in the anchor box may have. In a specific example, result c1[0] represents the probability that the marker in the anchor box is of a dot type, result c1[1] represents the probability that the marker in the anchor box is of an O-ring type, result c1[2] represents the probability that the marker in the anchor box is of a tri-chamber type, and the value ranges of the three elements are all from 0 to 1. The type of the marker in the anchor box is determined by the maximum value of the three elements. For example, when the value of result_c1[0] is the maximum among the three elements, the marker in the corresponding anchor box is of dot type.


The output of c2 is a one-dimensional array, denoted result c2[4]. Where, result c2[0], result c2[1], result_c2[2] and result c2[3] are four elements of the array, which respectively represent the width offset value of the upper left corner of the anchor box, the height offset value of the upper left corner of the anchor box, the width scaling factor of the anchor box and the height scaling factor of the anchor box, and their values range from 0 to 1. By the output of c2, the size of the anchor box is adjusted to form a detection frame.


Through the above steps, the types and positions of the markers are preliminarily determined.


In addition, it should be noted that, when the neural network model is initially built, the unit images for training are first manually labeled, and the labeling content is the type information of the marker, which includes: a detection frame enclosing each marker, and a coordinate value of the upper left corner and a coordinate value of the lower right corner corresponding to the detection frame. Then, the unlabeled unit images are input to the initially built neural network model for prediction. The closer the result of prediction is to the result of manual labeling, the higher the detection accuracy of the neural network model is, and when the ratio of the result of prediction to the result of manual labeling is greater than a preset ratio, the neural network model can be normally applied. In this process, when the ratio of the result of prediction to the result of manual labeling is not greater than the preset ratio, the neural network model needs to be adjusted until the requirement is met. Thus, the neural network model is trained through the above contents, so that the result of prediction is more accurate. In this process, when the ratio of the result of prediction to the result of manual labeling is not greater than the preset ratio, the neural network model needs to be adjusted until the requirement is met. Thus, the neural network model is trained through the above contents, so that the result of prediction is more accurate. In the process of constructing the neural network, the detection accuracy of the neural network model can be evaluated by Intersection over Union (IOU), which is not further described here.


In step S3, a neural network model is configured to add detection frames to the markers in the unit images to form a pre-output image as shown in FIG. 3, which is formed by stitching a plurality of pre-detection unit images according to the segmentation positions of the original image. In this specific embodiment, the markers at the stitching positions of the plurality of pre-detection unit images are decomposed into a plurality of parts, and the plurality of parts of the same marker in different pre-detection images are simultaneously recognized by the plurality of detection frames. This results in the marker being recognized multiple times in the resulting output image. In this specific example, the image is composed of 4 pre-detection unit images, and there are three types of markers to be recognized, namely, dot type with a number of 1,O-ring type with a number of 2, and tri-chamber type with a number of 3. Where, the same tri-chamber marker A at the boundary position of the four pre-detection unit images is repeatedly labeled by three detection frames. If the current image is used for output, the marker A may be counted for three times, and correspondingly, three recognition positions is given, which is not conducive to the statistics and position determination of the marker, thus affecting the accuracy of determining the gastrointestinal motility of a subject.


Correspondingly, in order to solve the problem, in the preferred embodiment of the present invention, multiple detection frames of the same marker need to be merged, so that only one detection frame corresponding to each marker in the finally output image is uniquely recognized, which is conducive to the statistics and position determination of the markers, thereby accurately determining the gastrointestinal motility of the subject.


Specifically, step S4 specifically comprises: determining the type of the marker in each detection frame according to the probability of the type of the marker, and if the markers in two adjacent detection frames are of the same type, determining whether the markers in the frames are the same marker according to the coordinate values of the two adjacent detection frames.


Further, determining whether the markers in the frames are the same marker according to the coordinate values of the two adjacent detection frames comprises:

    • determining whether the markers selected in two adjacent detection frames in the horizontally stitched pre-detection unit image are the same marker;
    • establishing an XY rectangular coordinate system by taking the upper left corner of the original image as a coordinate origin, extending the coordinate origin rightward as an X-axis positive direction, and extending the coordinate origin downward as a Y-axis positive direction; where the x-axis is the horizontal axis and the y-axis is the vertical axis; comparing whether the difference between the feature values of two horizontally adjacent detection frames is within a threshold range, and if the difference is within the threshold range, determining that the markers selected in the two detection frames used in current calculation are the same marker, where the feature values are the coordinate value of the upper left corner and the coordinate value of the lower right corner of each detection frame;





that is, abs(rectangles[i+1][xL]−rectangles[i][xL])<n1,





and (rectangles[i+1][yL]−rectangles[i][yL])<n2 are met at the same time;

    • where abs( ) represents the absolute value, rectangles[i][ ] represents the coordinate value of the i-th detection frame in the horizontal direction, and xL and yL respectively represent the horizontal coordinate value and vertical coordinate value of the upper left corner of the detection frame; i is an integer, n1∈(1, 2, 3), n2∈(5, 10, 15).


In addition, the step of determining whether the markers in the frames are the same marker according to the coordinate values of the two adjacent detection frames further comprises: determining whether the markers selected in two adjacent detection frames in the vertically stitched pre-detection unit image are the same marker;

    • establishing an XY rectangular coordinate system by taking the upper left corner of the original image as a coordinate origin, extending the coordinate origin rightward as an X-axis positive direction, and extending the coordinate origin downward as a Y-axis positive direction; where the x-axis is the horizontal axis and the y-axis is the vertical axis; comparing whether the difference between the feature values of two vertically adjacent detection frames is within a threshold range, and if the difference is within the threshold range, determining that the markers selected in the two detection frames used in current calculation are the same marker, wherein the feature values are the coordinate value of the upper left corner and the coordinate value of the lower right corner of each detection frame;





that is, abs(rectangles[j+1][xL]−rectangles[j][xL])<n3,





and abs(rectangles[j+1][yL]−rectangles[j][yL])<n4 are met at the same time;

    • where abs( ) represents the absolute value, rectangles[j][ ] represents the coordinate value of the j-th detection frame in the vertical direction, and xL and yL respectively represent the horizontal coordinate value and vertical coordinate value of the upper left corner of the detection frame; j is an integer, n3∈(40, 50, 60), n4∈(1, 2, 3).


Further, after determining that the markers selected in the two detection frames used in current calculation are the same marker, the two detection frames are merged, and the merging method specifically comprises: comparing the coordinate values of the upper left corners of the two detection frames currently used for calculation, and respectively taking the minimum values of the horizontal coordinate and the vertical coordinate as the coordinate values of the upper left corner of the merged detection frame; comparing the coordinate values of the lower right corners of the two detection frames, and respectively taking the maximum values of the horizontal coordinate and the vertical coordinate as the coordinate values of the lower right corner of the merged detection frame.


Correspondingly, the coordinates (xaL, yaL) of the upper left corner and the coordinates (xaR, yaR) of the lower right corner of the detection frame after the horizontal merging are respectively:






x
aL=min(rectangles[i+1][xL],rectangles[i][xL]),






y
aL=min(rectangles[i+1][yL],rectangles[i][yL]),






x
aR=max(rectangles[i+1][xR],rectangles[i][xR]),






y
aR=max(rectangles[i+1][yR],rectangles[i][yR]),


where, min( ) represents the minimum value, and max( ) represents the maximum value; xR and yR represent the horizontal coordinate value and the vertical coordinate value of the lower right corner of the detection frame, respectively.


Correspondingly, the coordinates of the upper left corner (xbL,ybL) and the coordinates of the lower right corner (xbR,ybR) of the detection frame after vertical merging are respectively:






x
bL=min(rectangles[j+1][xL],rectangles[j][xL]),






y
bL=min(rectangles[j+1][yL],rectangles[j][yL]),






x
bR=max(rectangles[j+1][xR],rectangles[j][xR]),






y
bR=max(rectangles[j+1][yR],rectangles[j][yR]).


It should be noted that, for each pre-output image, it is necessary to sequentially determine whether the markers in two adjacent detection frames are the same marker in the horizontal direction and the vertical direction respectively. The sequence of horizontal merging and vertical merging is not limited. It may be horizontal merging first and then vertical merging, or vertical merging first and then horizontal merging. The sequence of horizontal merging and vertical merging may not affect the final output result. In addition, in the above examples, the feature values are described as the coordinate value of the upper left corner and the coordinate value of the lower right corner of each detection frame. In practical application, the feature value may be selected as the same coordinate value having the same position on each detection frame. For example, the feature values are the coordinate value of the lower left corner and the coordinate value of the upper right corner, and the transformation of the feature values can not affect the final output result. The methods of selecting the feature values at different positions in the detection frame are all included in the protection scope of the application, and are not further described herein.


Referring to FIG. 4, after the combination, the tri-chamber marker A at an intersection position of the four unit images presents a display state in which the three detection frames in FIG. 3 are merged into one detection frame for output in the final output image.


Further, after the detection frames are recognized and merged, an image is output, and the output image has a unique detection frame corresponding to each marker. In this case, the type and position of the marker can be determined by the label and position of the detection frame in the image, and the locations of different types of markers in the gastrointestinal tract can be determined, so that the gastrointestinal motility of the subject can be determined.


Further, the present invention provides an electronic device. In an embodiment, the electronic device comprises a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the computer program to implement the steps of the image recognition method.


Further, the present invention provides a computer-readable storage medium. In an embodiment, the computer-readable storage medium stores a computer program and the computer program is executed by the processor to implement the steps of the image recognition method as described above.


To sum up, with the image recognition method, the electronic device and the computer-readable storage medium of the present invention, the original image is automatically processed by a neural network model to add detection frames, and further, the detection frames labeled repeatedly are merged to improve the accuracy of image marking, so that the types and positions of markers in the image are effectively recognized, the distribution of the markers in the gastrointestinal tract can be confirmed, and the gastrointestinal motility of the subject is accurately determined.


It should be understood that, although the description is described in terms of embodiments, not every embodiment merely comprises an independent technical solution. The description is presented in this way only for the sake of clarity, those skilled in the art should have the description as a whole, and the technical solutions in each embodiment may also be combined as appropriate to form other embodiments that can be understood by those skilled in the art.


The series of detailed descriptions set forth above are only specific descriptions of feasible embodiments of the present invention and are not intended to limit the scope of protection of the present invention. On the contrary, many modifications and variations are possible within the scope of the appended claims.

Claims
  • 1. An image recognition method, comprising: segmenting an original image into a plurality of unit images having the same predetermined size, wherein a plurality of markers are distributed in the original image;inputting the unit images into a pre-built neural network model to carry out processing, so as to correspondingly add a detection frame to a marker in each unit image to form a pre-detection unit image, wherein the detection frame is a minimum rectangular frame enclosing the marker;stitching a plurality of pre-detection unit images into a pre-output image according to segmentation positions of each unit image in the original image;determining whether the markers selected in two adjacent detection frames in the pre-output image are the same marker;merging the two detection frames when the markers selected in two adjacent detection frames are the same marker; andreserving different detection frames corresponding to different markers when the markers selected in two adjacent detection frames are not the same marker; andoutputting the image with the detection frames until all the detection frames confirmed to have the same markers are all merged;wherein determining whether the markers selected in two adjacent detection frames in the pre-output image are the same marker comprises: determining a type of the marker in each detection frame according to the probability of the type of the marker, and determining whether the markers in the frames are the same marker according to coordinate values of the two adjacent detection frames when the markers in two adjacent detection frames are of the same type.
  • 2. The image recognition method of claim 1, wherein segmenting the original image into the plurality of unit images having the same predetermined size, the method further comprises: if a size of any unit image is less than the predetermined size in the segmentation process, complementing edge pixel values to the original image before the unit images are formed, or complementing edge pixel values to the unit images with a size less than the predetermined size after the unit images are formed.
  • 3. The image recognition method of claim 1, wherein the method for building the neural network model comprises: extracting at least one feature layer by using convolutional neural networks corresponding to each unit image; wherein in the process of extracting the feature layer, p convolution kernels of m*m are configured to convolution predictors of anchor boxes to process the unit images, p=(c1+c2)*k, wherein the anchor boxes are preset rectangular boxes with different aspect ratios, m is an odd positive integer, c1 represents the number of types of markers, k represents the number of anchor boxes, and c2 represents the number of offset parameters for adjusting the anchor boxes; wherein the detection frame is obtained by changing the size of the anchor box.
  • 4. The image recognition method of claim 3, the method further comprises: performing pooling layer processing on the unit images for a plurality of times according to the types and size of the markers to obtain the corresponding feature layers.
  • 5. The image recognition method of claim 4, wherein performing pooling layer processing on the unit images for the plurality of times according to the types and size of the markers to obtain the corresponding feature layers, the method comprises: before performing pooling layer processing on a unit image each time, performing convolution layer processing on the unit image at least once, and sizes of the convolution kernels are the same.
  • 6. The image recognition method of claim 3, wherein the method further comprises: setting c2=4, and the offset parameters for adjusting the anchor boxes comprise width offset values and height offset values of an upper left corner, a width scaling factor and a height scaling factor.
  • 7. The image recognition method of claim 1, wherein determining whether the markers in the frames are the same marker according to the coordinate values of the two adjacent detection frames comprises: establishing a rectangular coordinate system by taking an upper left corner of the original image as a coordinate origin, and comparing whether the difference between feature values of two horizontally adjacent detection frames is within a threshold range, and determining that the markers selected in the two detection frames used in current calculation are the same marker when the difference is within the threshold range, wherein the feature values are coordinate values of the upper left corner and coordinate values of a lower right corner of each detection frame.
  • 8. The image recognition method of claim 1, wherein determining whether the markers in the boxes are the same marker according to the coordinate values of the two adjacent detection frames comprises: establishing a rectangular coordinate system by taking an upper left corner of the original image as a coordinate origin, and comparing whether the difference between feature values of two vertically adjacent detection frames is within a threshold range, and determining that the markers selected in the two detection frames used in current calculation are the same marker when the difference is within the threshold range, wherein the feature values are coordinate values of the upper left corner and coordinate values of a lower right corner of each detection frame.
  • 9. The image recognition method of claim 7, wherein merging the two detection frames comprises: comparing the coordinate values of the upper left corners of the two detection frames currently used for calculation, and respectively taking the minimum values of the horizontal coordinate and the vertical coordinate as the coordinate values of the upper left corner of the merged detection frame;comparing the coordinate values of the lower right corners of the two detection frames, and respectively taking the maximum values of the horizontal coordinate and the vertical coordinate as the coordinate values of the lower right corner of the merged detection frame.
  • 10. The image recognition method of claim 8, wherein merging the two detection frames comprises: comparing the coordinate values of the upper left corners of the two detection frames currently used for calculation, and respectively taking the minimum values of the horizontal coordinate and the vertical coordinate as the coordinate values of the upper left corner of the merged detection frame;comparing the coordinate values of the lower right corners of the two detection frames, and respectively taking the maximum values of the horizontal coordinate and the vertical coordinate as the coordinate values of the lower right corner of the merged detection frame.
  • 11. An electronic device, comprising a memory and a processor, wherein the memory stores a computer program that runs on the processor, and the processor executes the computer program to implement the steps of the image recognition method, wherein the image recognition method comprises: segmenting an original image into a plurality of unit images having the same predetermined size, wherein a plurality of markers are distributed in the original image;inputting the unit images into a pre-built neural network model to carry out processing, so as to correspondingly add a detection frame to a marker in each unit image to form a pre-detection unit image, wherein the detection frame is a minimum rectangular frame enclosing the marker;stitching a plurality of pre-detection unit images into a pre-output image according to segmentation positions of each unit image in the original image;determining whether the markers selected in two adjacent detection frames in the pre-output image are the same marker;merging the two detection frames when the markers selected in two adjacent detection frames are the same marker; andreserving different detection frames corresponding to different markers when the markers selected in two adjacent detection frames are not the same marker; andoutputting the image with the detection frames until all the detection frames confirmed to have the same markers are all merged;wherein determining whether the markers selected in two adjacent detection frames in the pre-output image are the same marker comprises: determining a type of the marker in each detection frame according to the probability of the type of the marker, and determining whether the markers in the frames are the same marker according to coordinate values of the two adjacent detection frames when the markers in two adjacent detection frames are of the same type.
  • 12. A computer-readable storage medium having stored thereon a computer program that, when executed by a processor, implements the steps in an image recognition method, wherein the image recognition method comprises: segmenting an original image into a plurality of unit images having the same predetermined size, wherein a plurality of markers are distributed in the original image;inputting the unit images into a pre-built neural network model to carry out processing, so as to correspondingly add a detection frame to a marker in each unit image to form a pre-detection unit image, wherein the detection frame is a minimum rectangular frame enclosing the marker;stitching a plurality of pre-detection unit images into a pre-output image according to segmentation positions of each unit image in the original image;determining whether the markers selected in two adjacent detection frames in the pre-output image are the same marker;merging the two detection frames when the markers selected in two adjacent detection frames are the same marker; andreserving different detection frames corresponding to different markers when the markers selected in two adjacent detection frames are not the same marker; andoutputting the image with the detection frames until all the detection frames confirmed to have the same markers are all merged;wherein determining whether the markers selected in two adjacent detection frames in the pre-output image are the same marker comprises: determining a type of the marker in each detection frame according to the probability of the type of the marker, and determining whether the markers in the frames are the same marker according to coordinate values of the two adjacent detection frames when the markers in two adjacent detection frames are of the same type.
Priority Claims (1)
Number Date Country Kind
202010881849.X Aug 2020 CN national
PCT Information
Filing Document Filing Date Country Kind
PCT/CN2021/112777 8/16/2021 WO