Target object shape framing method based on image recognition and terminal

文档序号:8533 发布日期:2021-09-17 浏览:28次 中文

1. A target object shape framing method based on image recognition is characterized by comprising the following steps:

s1, acquiring the shooting angle of the image to be recognized, and restoring the imaging shape of the target object to be recognized based on the shooting angle;

step S2, classifying and recognizing the image to be recognized by adopting a sliding window to obtain a detection frame with the maximum confidence as a target detection frame, and then performing secondary frame selection on the target detection frame according to the imaging shape to obtain a target contour frame;

and step S3, marking and displaying the target detection frame and/or the target outline frame.

2. The method as claimed in claim 1, wherein the step S2 of performing secondary framing on the target detection frame according to the imaging shape to obtain the target contour frame specifically includes the following steps:

step S21, obtaining a first contour frame which is maximally internally tangent to the target detection frame according to the imaging shape, and placing the first contour frame at the center position of the target detection frame;

step S22, determining all interval frame edges of the first contour frame, which are not vertically tangent to the target detection frame, according to the internally tangent position of the first contour frame in the target detection frame;

step S23, sequentially moving the first contour frame toward the interval frame sides according to a preset size, and performing confidence calculation on the moved real-time contour after each movement, so as to obtain a confidence of each real-time contour in the moving process of the first contour frame toward all the interval frame sides;

and step S24, taking the real-time contour with the maximum confidence coefficient as a target contour frame.

3. The method for framing the shape of the object based on image recognition according to claim 2, wherein the step S23 specifically includes the following steps:

s231, moving the first contour frame towards the interval frame edge according to a preset size in sequence, and performing confidence calculation on the moved real-time contour after each movement;

step S232, moving one of the interval frame edges according to a preset sequence, stopping moving the current interval frame edge if the confidence coefficient of the obtained first real-time outline is higher than the confidence coefficients of the real-time outlines obtained in the preset times before and after the first real-time outline, and taking the real-time outline with the maximum confidence coefficient of the interval frame edge in the moving process as the first real-time outline;

step S233, if there are two of the interval frame sides, the step S231 and the step S232 are executed with the initial position of the first outline frame as a starting point until the first outline frame completes the movement and the calculation of the corresponding confidence toward all the interval frame sides;

the step S24 specifically includes the following steps:

and taking the first real-time contour with the maximum confidence coefficient as a target contour frame.

4. The method for framing the shape of the object based on image recognition according to claim 2, wherein the step S24 specifically includes the following steps:

and carrying out equal-scale amplification or reduction on the real-time contour with the maximum confidence coefficient, and calculating the confidence coefficient in real time in the scale change process so as to take the real-time contour with the maximum confidence coefficient obtained in the scaling process as a target contour frame.

5. The method for framing the shape of the object based on image recognition according to claim 3, wherein the preset number of times is [2,4 ].

6. An object shape frame selection terminal based on image recognition, comprising a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program to realize the following steps:

s1, acquiring the shooting angle of the image to be recognized, and restoring the imaging shape of the target object to be recognized based on the shooting angle;

step S2, classifying and recognizing the image to be recognized by adopting a sliding window to obtain a detection frame with the maximum confidence as a target detection frame, and then performing secondary frame selection on the target detection frame according to the imaging shape to obtain a target contour frame;

and step S3, marking and displaying the target detection frame and/or the target outline frame.

7. The terminal of claim 6, wherein the step S2 of performing secondary framing on the target detection frame according to the imaging shape to obtain the target contour frame specifically includes the following steps:

step S21, obtaining a first contour frame which is maximally internally tangent to the target detection frame according to the imaging shape, and placing the first contour frame at the center position of the target detection frame;

step S22, determining all interval frame edges of the first contour frame, which are not vertically tangent to the target detection frame, according to the internally tangent position of the first contour frame in the target detection frame;

step S23, sequentially moving the first contour frame toward the interval frame sides according to a preset size, and performing confidence calculation on the moved real-time contour after each movement, so as to obtain a confidence of each real-time contour in the moving process of the first contour frame toward all the interval frame sides;

and step S24, taking the real-time contour with the maximum confidence coefficient as a target contour frame.

8. The terminal for framing the shape of the object based on image recognition according to claim 7, wherein the step S23 specifically includes the following steps:

s231, moving the first contour frame towards the interval frame edge according to a preset size in sequence, and performing confidence calculation on the moved real-time contour after each movement;

step S232, moving one of the interval frame edges according to a preset sequence, stopping moving the current interval frame edge if the confidence coefficient of the obtained first real-time outline is higher than the confidence coefficients of the real-time outlines obtained in the preset times before and after the first real-time outline, and taking the real-time outline with the maximum confidence coefficient of the interval frame edge in the moving process as the first real-time outline;

step S233, if there are two of the interval frame sides, the step S231 and the step S232 are executed with the initial position of the first outline frame as a starting point until the first outline frame completes the movement and the calculation of the corresponding confidence toward all the interval frame sides;

the step S24 specifically includes the following steps:

and taking the first real-time contour with the maximum confidence coefficient as a target contour frame.

9. The terminal for framing the shape of the object based on image recognition according to claim 7, wherein the step S24 specifically includes the following steps:

and carrying out equal-scale amplification or reduction on the real-time contour with the maximum confidence coefficient, and calculating the confidence coefficient in real time in the scale change process so as to take the real-time contour with the maximum confidence coefficient obtained in the scaling process as a target contour frame.

10. The terminal for framing the shape of the object based on image recognition according to claim 8, wherein the preset number of times is [2,4 ].

Background

Image recognition technology is an important field of artificial intelligence. It refers to a technique of performing object recognition on an image to recognize various different modes of objects and objects.

For the human brain, when visual information enters the brain through the retina, the visual cortex converts sensory input into coherent perceptions that can be understood as psychological representations of objects and differentiated from one another by neurons within the brain.

Therefore, in the conventional image recognition, the target object is recognized by using a square frame, and in some cases where the mapping processing is performed after the target object is recognized, the final target frame obtained based on the square frame contains elements other than the target object, so that the mapping effect is not ideal.

Disclosure of Invention

The technical problem to be solved by the invention is as follows: the method and the terminal for framing the shape of the target object based on image recognition are provided, so that the final framed target frame better conforms to the contour of the target object.

In order to solve the technical problems, the invention adopts the technical scheme that:

a target object shape framing method based on image recognition comprises the following steps:

s1, acquiring the shooting angle of the image to be recognized, and restoring the imaging shape of the target object to be recognized based on the shooting angle;

step S2, classifying and recognizing the image to be recognized by adopting a sliding window to obtain a detection frame with the maximum confidence as a target detection frame, and then performing secondary frame selection on the target detection frame according to the imaging shape to obtain a target contour frame;

and step S3, marking and displaying the target detection frame and/or the target outline frame.

In order to solve the technical problem, the invention adopts another technical scheme as follows:

an object shape frame selection terminal based on image recognition comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program to realize the following steps:

s1, acquiring the shooting angle of the image to be recognized, and restoring the imaging shape of the target object to be recognized based on the shooting angle;

step S2, classifying and recognizing the image to be recognized by adopting a sliding window to obtain a detection frame with the maximum confidence as a target detection frame, and then performing secondary frame selection on the target detection frame according to the imaging shape to obtain a target contour frame;

and step S3, marking and displaying the target detection frame and/or the target outline frame.

The invention has the beneficial effects that: a target object shape frame selection method and a terminal based on image recognition are disclosed, wherein a shooting angle of an image to be recognized is obtained, an imaging shape of the target object to be recognized is restored based on the shooting angle, and then a target detection frame is subjected to secondary frame selection according to the imaging shape to obtain a target outline frame; therefore, the shape of the target object in the image to be recognized is better restored through the shooting angle, and then secondary frame selection is carried out according to the obtained imaging shape, so that the target frame obtained through final frame selection is more in line with the outline of the target object.

Drawings

Fig. 1 is a schematic flowchart of a target object shape framing method based on image recognition according to an embodiment of the present invention;

fig. 2 is a schematic structural diagram of a target object shape framing terminal based on image recognition according to an embodiment of the present invention.

Description of reference numerals:

1. a target object shape selection terminal based on image recognition; 2. a processor; 3. a memory.

Detailed Description

In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.

Referring to fig. 1, a method for framing a shape of an object based on image recognition includes:

s1, acquiring the shooting angle of the image to be recognized, and restoring the imaging shape of the target object to be recognized based on the shooting angle;

step S2, classifying and recognizing the image to be recognized by adopting a sliding window to obtain a detection frame with the maximum confidence as a target detection frame, and then performing secondary frame selection on the target detection frame according to the imaging shape to obtain a target contour frame;

and step S3, marking and displaying the target detection frame and/or the target outline frame.

From the above description, the beneficial effects of the present invention are: the method comprises the steps of reducing the imaging shape of a target object to be identified based on a shooting angle by obtaining the shooting angle of an image to be identified, and then carrying out secondary frame selection on a target detection frame according to the imaging shape to obtain a target outline frame; therefore, the shape of the target object in the image to be recognized is better restored through the shooting angle, and then secondary frame selection is carried out according to the obtained imaging shape, so that the target frame obtained through final frame selection is more in line with the outline of the target object.

Further, the step S2 of performing secondary frame selection on the target detection frame according to the imaging shape to obtain a target contour frame specifically includes the following steps:

step S21, obtaining a first contour frame which is maximally internally tangent to the target detection frame according to the imaging shape, and placing the first contour frame at the center position of the target detection frame;

step S22, determining all interval frame edges of the first contour frame, which are not vertically tangent to the target detection frame, according to the internally tangent position of the first contour frame in the target detection frame;

step S23, sequentially moving the first contour frame toward the interval frame sides according to a preset size, and performing confidence calculation on the moved real-time contour after each movement, so as to obtain a confidence of each real-time contour in the moving process of the first contour frame toward all the interval frame sides;

and step S24, taking the real-time contour with the maximum confidence coefficient as a target contour frame.

From the above description, it can be known that, with the current sliding window recognition algorithm, the detection frame surrounding the target object can be basically selected accurately, that is, the target object is in the target detection frame, so that the movement and the calculation of the confidence degree are performed based on the first contour frame which is most internally tangent to the target contour frame, and finally the real-time contour with the maximum confidence degree is used as the target contour frame, so that the target object is also surrounded in the finally obtained target contour frame, and the contour which meets the target object can be selected accurately.

Further, the step S23 specifically includes the following steps:

s231, moving the first contour frame towards the interval frame edge according to a preset size in sequence, and performing confidence calculation on the moved real-time contour after each movement;

step S232, moving one of the interval frame edges according to a preset sequence, stopping moving the current interval frame edge if the confidence coefficient of the obtained first real-time outline is higher than the confidence coefficients of the real-time outlines obtained in the preset times before and after the first real-time outline, and taking the real-time outline with the maximum confidence coefficient of the interval frame edge in the moving process as the first real-time outline;

step S233, if there are two of the interval frame sides, the step S231 and the step S232 are executed with the initial position of the first outline frame as a starting point until the first outline frame completes the movement and the calculation of the corresponding confidence toward all the interval frame sides;

the step S24 specifically includes the following steps:

and taking the first real-time contour with the maximum confidence coefficient as a target contour frame.

As can be seen from the above description, the first real-time contour with the maximum confidence level at a plurality of times before and after is considered to be optimal in the direction of moving to the corresponding frame edge, so that the movement in the direction is stopped, and thus the calculation amount is reduced and the calculation time is shortened on the premise of ensuring the accuracy of frame selection, so as to ensure real-time image processing.

Further, the step S24 specifically includes the following steps:

and carrying out equal-scale amplification or reduction on the real-time contour with the maximum confidence coefficient, and calculating the confidence coefficient in real time in the scale change process so as to take the real-time contour with the maximum confidence coefficient obtained in the scaling process as a target contour frame.

From the above description, the real-time contour with the maximum confidence obtained based on the maximum inscribed shape is further subjected to equal-scale enlargement or reduction so as to ensure that the finally obtained target contour frame reduces useless information as much as possible and better conforms to the contour of the target object.

Further, the preset number of times is [2,4 ].

Referring to fig. 2, an object shape selection terminal based on image recognition includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the following steps when executing the computer program:

s1, acquiring the shooting angle of the image to be recognized, and restoring the imaging shape of the target object to be recognized based on the shooting angle;

step S2, classifying and recognizing the image to be recognized by adopting a sliding window to obtain a detection frame with the maximum confidence as a target detection frame, and then performing secondary frame selection on the target detection frame according to the imaging shape to obtain a target contour frame;

and step S3, marking and displaying the target detection frame and/or the target outline frame.

From the above description, the beneficial effects of the present invention are: the method comprises the steps of reducing the imaging shape of a target object to be identified based on a shooting angle by obtaining the shooting angle of an image to be identified, and then carrying out secondary frame selection on a target detection frame according to the imaging shape to obtain a target outline frame; therefore, the shape of the target object in the image to be recognized is better restored through the shooting angle, and then secondary frame selection is carried out according to the obtained imaging shape, so that the target frame obtained through final frame selection is more in line with the outline of the target object.

Further, the step S2 of performing secondary frame selection on the target detection frame according to the imaging shape to obtain a target contour frame specifically includes the following steps:

step S21, obtaining a first contour frame which is maximally internally tangent to the target detection frame according to the imaging shape, and placing the first contour frame at the center position of the target detection frame;

step S22, determining all interval frame edges of the first contour frame, which are not vertically tangent to the target detection frame, according to the internally tangent position of the first contour frame in the target detection frame;

step S23, sequentially moving the first contour frame toward the interval frame sides according to a preset size, and performing confidence calculation on the moved real-time contour after each movement, so as to obtain a confidence of each real-time contour in the moving process of the first contour frame toward all the interval frame sides;

and step S24, taking the real-time contour with the maximum confidence coefficient as a target contour frame.

From the above description, it can be known that, with the current sliding window recognition algorithm, the detection frame surrounding the target object can be basically selected accurately, that is, the target object is in the target detection frame, so that the movement and the calculation of the confidence degree are performed based on the first contour frame which is most internally tangent to the target contour frame, and finally the real-time contour with the maximum confidence degree is used as the target contour frame, so that the target object is also surrounded in the finally obtained target contour frame, and the contour which meets the target object can be selected accurately.

Further, the step S23 specifically includes the following steps:

s231, moving the first contour frame towards the interval frame edge according to a preset size in sequence, and performing confidence calculation on the moved real-time contour after each movement;

step S232, moving one of the interval frame edges according to a preset sequence, stopping moving the current interval frame edge if the confidence coefficient of the obtained first real-time outline is higher than the confidence coefficients of the real-time outlines obtained in the preset times before and after the first real-time outline, and taking the real-time outline with the maximum confidence coefficient of the interval frame edge in the moving process as the first real-time outline;

step S233, if there are two of the interval frame sides, the step S231 and the step S232 are executed with the initial position of the first outline frame as a starting point until the first outline frame completes the movement and the calculation of the corresponding confidence toward all the interval frame sides;

the step S24 specifically includes the following steps:

and taking the first real-time contour with the maximum confidence coefficient as a target contour frame.

As can be seen from the above description, the first real-time contour with the maximum confidence level at a plurality of times before and after is considered to be optimal in the direction of moving to the corresponding frame edge, so that the movement in the direction is stopped, and thus the calculation amount is reduced and the calculation time is shortened on the premise of ensuring the accuracy of frame selection, so as to ensure real-time image processing.

Further, the step S24 specifically includes the following steps:

and carrying out equal-scale amplification or reduction on the real-time contour with the maximum confidence coefficient, and calculating the confidence coefficient in real time in the scale change process so as to take the real-time contour with the maximum confidence coefficient obtained in the scaling process as a target contour frame.

From the above description, the real-time contour with the maximum confidence obtained based on the maximum inscribed shape is further subjected to equal-scale enlargement or reduction so as to ensure that the finally obtained target contour frame reduces useless information as much as possible and better conforms to the contour of the target object.

Further, the preset number of times is [2,4 ].

Referring to fig. 1, a first embodiment of the present invention is:

a target object shape framing method based on image recognition comprises the following steps:

s1, acquiring the shooting angle of the image to be recognized, and restoring the imaging shape of the target object to be recognized based on the shooting angle;

in this embodiment, for a specific target object to be recognized, angle recognition is performed through a multi-classification convolutional neural network model, which performs different angle outputs according to the source of the image to be recognized.

If the recognized object is spherical, the imaging shape obtained based on any angle is circular, and the imaging shape of the target object to be recognized can be directly obtained without acquiring a shooting angle.

Step S2, classifying and recognizing the image to be recognized by adopting a sliding window to obtain a detection frame with the maximum confidence as a target detection frame, and then performing secondary frame selection on the target detection frame according to the imaging shape to obtain a target contour frame;

in this embodiment, the step S2 of performing secondary frame selection on the target detection frame according to the imaging shape to obtain the target contour frame specifically includes the following steps:

step S21, obtaining a first contour frame which is maximally internally tangent to the target detection frame according to the imaging shape, and placing the first contour frame at the center position of the target detection frame;

that is, at least two opposite sides of the first contour frame are tangent to the target detection frame, because if only one side is tangent, the maximum inscribed shape is not yet obtained. If two adjacent sides are tangent, two pairs of opposite sides are not tangent, and the two pairs of opposite sides can be enlarged by moving towards the direction without the tangency, so that the two pairs of opposite sides are not in the maximum inscribed shape at the moment. I.e. only including the case of relative two-sided tangency, relative two-sided tangency plus adjacent one, and four-sided tangency.

Step S22, determining all interval frame edges of the first contour frame which are not vertically tangent to the target detection frame according to the internally tangent position of the first contour frame in the target detection frame;

wherein, when the two opposite sides are tangent, if the two sides are left and right, the upper and lower sides are the spacing frame sides. If the two opposite sides are tangent with the adjacent side, the lower side is a spacing frame side if the left side and the right side are tangent with the upper side. If the four sides are tangent, there is no frame edge to be separated, and step S22 is omitted.

Step S23, moving the first contour frame towards the interval frame edge according to the preset size in sequence, and performing confidence calculation on the moved real-time contour after each movement, so as to obtain the confidence of each real-time contour in the moving process of the first contour frame towards all the interval frame edges;

in this embodiment, step S23 specifically includes the following steps:

s231, sequentially moving the first contour frame towards the interval frame edge according to a preset size, and performing confidence calculation on the moved real-time contour after each movement;

taking the two-side tangency as an example, the first outline frame may move upwards, and at this time, the first outline frame moves according to the pixel density of the image to be recognized or a preset size set by the user, for example, 10 pixels. And moving once to obtain a corresponding real-time contour and performing confidence calculation in real time.

Step S232, moving one of the interval frame edges according to a preset sequence, stopping moving the current interval frame edge if the confidence coefficient of the obtained first real-time outline is higher than the confidence coefficients of the real-time outlines obtained in the preset times before and after the first real-time outline, and taking the real-time outline with the maximum confidence coefficient of the interval frame edge in the moving process as the first real-time outline;

wherein the predetermined number of times is [2,4], and in the present embodiment is 3. That is, the confidence comparison of the first and the last three times is the highest confidence of the first real-time contour, and then the first real-time contour does not need to move upwards

Step 233, if there are two spaced frame sides, then the initial position of the first outline frame is used as the starting point to execute step 231 and step 232 until the first outline frame completes the movement and the calculation of the corresponding confidence toward all the spaced frame sides;

i.e. at most two opposite spaced frame sides, and then the movement is started by the initial position of the first contour frame, so that the time delay caused by repeated movement and calculation is avoided.

And step S24, taking the first real-time contour with the maximum confidence as a target contour frame.

Namely, for two opposite spaced frame sides, two first real-time contours are respectively obtained in the process of moving to the opposite sides, and the maximum value of the two first real-time contours is taken as a target contour frame.

Wherein, step S24 specifically includes the following:

and carrying out equal-scale amplification or reduction on the real-time contour with the maximum confidence coefficient, and calculating the confidence coefficient in real time in the scale change process so as to take the proportional contour with the maximum confidence coefficient obtained in the scaling process as a target contour frame.

And step S3, marking and displaying the target detection frame and/or the target outline frame.

That is, in this embodiment, only the target detection frame or the target outline frame may be displayed, or both of them may be displayed together, and when both of them are displayed together, they are displayed in different colors or in different forms of lines, such as red and green, such as a solid line and a dotted line.

Referring to fig. 2, the second embodiment of the present invention is:

an object shape frame selection terminal 1 based on image recognition comprises a memory 3, a processor 2 and a computer program which is stored on the memory 3 and can run on the processor 2, wherein the first step of the embodiment is realized when the processor 2 executes the computer program.

In summary, according to the object shape framing method and the terminal based on image recognition provided by the invention, the shape of the object in the image to be recognized is better restored through the shooting angle, then secondary framing is performed according to the obtained imaging shape, movement and confidence calculation are performed based on the first contour frame which is most internally tangent to the object contour frame, and finally the object contour frame is selected after the real-time contour with the maximum confidence is subjected to equal-scale amplification or reduction, so that the finally framed and obtained object frame better conforms to the contour of the object. The first real-time contour with the maximum confidence coefficient for a plurality of times can be considered to be optimal in the direction of moving to the corresponding interval frame edge, so that the movement in the direction is stopped, the calculation amount is reduced on the premise of ensuring the frame selection accuracy, the calculation time is shortened, and the real-time picture processing can be ensured.

The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:一种基于多特征提取的药品标签数字识别方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!