Subject identification method, device, and computer-readable storage medium
Through the deep learning target detection method, pre-trained models are used to detect object attribute characteristics in pictures, which solves the problem of subject recognition relying on artificially set thresholds in the existing technology, and achieves flexible subject recognition and multi-foreground separation in complex backgrounds.
Patent Information
- Application Number
- CN202010440237.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-22
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2040-05-22
AI Technical Summary
In the existing technology, the recognition of the subject in the picture requires artificially setting a threshold, which cannot be automatically recognized, and it is difficult to effectively separate the subject when the background is complex or there are multiple foregrounds.
Using a target detection method based on deep learning, through a pre-trained target detection model, the object in the picture and its attribute characteristics, such as the center point position, size parameters and confidence level, are determined based on these characteristics, and the target subject is determined by setting the weight To specify different categories of objects as target subjects.
It achieves flexible subject recognition in complex backgrounds and multiple foreground situations, avoids the limitations of artificially set thresholds, and can be applied to a variety of scenes and specify different categories of objects as target subjects.
Smart Images

Figure CN113705285B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to computer technology, and more particularly to a subject identification method, device, and computer-readable storage medium. Background Art
[0002] In the prior art, the subject in the picture is mostly segmented by thresholding by manually observing the image features, and the foreground and background are roughly distinguished. For example, a black-and-white binary image is obtained by binarization, and the noise is removed by dilation processing to retain the main part of the original image; or the image color space RGB is converted into HSV, and the H vector is stripped to obtain a grayscale vector, and then a histogram or binarization algorithm is used to distinguish the background from the foreground to obtain the main part. This type of method requires manual setting of thresholds for each image, and cannot automatically identify the type of subject, and cannot effectively separate the subject when the background is complex or there are multiple foregrounds. Summary of the invention
[0003] The present application provides a subject recognition method, device, and computer-readable storage medium, which can achieve the purpose of flexibly identifying a target subject in a picture.
[0004] The present application provides a subject recognition method, which includes obtaining a picture to be recognized; inputting the obtained picture to be recognized into a pre-trained target detection model to detect objects in the picture and attribute characteristics of each object in the picture; the attribute characteristics of each object include the center point position of the object, the size parameters of the object and the confidence of the object; and determining the object in the picture as the target subject based on the detected attribute characteristics of each object in the picture.
[0005] Compared with the related technology, the subject recognition method based on deep learning target detection in the embodiment of the present application uses target detection technology to replace the method of manually setting thresholds, binarization, dilation and other methods to segment the foreground and background. It can flexibly identify the target subject in the picture and is suitable for complex backgrounds and situations with multiple foregrounds.
[0006] In an exemplary embodiment, the embodiment of the present application can specify objects of different categories as target subjects by setting weights corresponding to the attribute features.
[0007] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by implementing the present application. Other advantages of the present application can be realized and obtained by the schemes described in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] The accompanying drawings are used to provide an understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0009] Figure 1 This is a flow chart of the subject identification method of the embodiment of the present application;
[0010] Figure 2 A schematic diagram of a target subject identified in a picture according to an embodiment of the present application;
[0011] Figure 3 This is a schematic diagram of the subject identification device module of an embodiment of the present application. DETAILED DESCRIPTION
[0012] The present application describes multiple embodiments, but the description is exemplary rather than restrictive, and it is obvious to those skilled in the art that there may be more embodiments and implementations within the scope of the embodiments described in the present application. Although many possible feature combinations are shown in the drawings and discussed in the specific embodiments, many other combinations of the disclosed features are also possible. Unless specifically limited, any feature or element of any embodiment may be used in combination with any other feature or element in any other embodiment, or may replace any other feature or element in any other embodiment.
[0013] The present application includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The embodiments, features and elements disclosed in the present application may also be combined with any conventional features or elements to form a unique invention scheme defined by the claims. Any features or elements of any embodiment may also be combined with features or elements from other invention schemes to form another unique invention scheme defined by the claims. Therefore, it should be understood that any feature shown and / or discussed in the present application may be implemented individually or in any appropriate combination. Therefore, except for the limitations made according to the attached claims and their equivalents, the embodiments are not subject to other restrictions. In addition, various modifications and changes may be made within the scope of protection of the attached claims.
[0014] In addition, when describing representative embodiments, the specification may have presented the method and / or process as a specific sequence of steps. However, to the extent that the method or process does not rely on the specific order of the steps described herein, the method or process should not be limited to the steps of the specific order described. As will be understood by those of ordinary skill in the art, other sequences of steps are also possible. Therefore, the specific sequence of the steps set forth in the specification should not be interpreted as a limitation to the claims. In addition, the claims for the method and / or process should not be limited to the steps of performing them in the order written, and those skilled in the art can easily understand that these sequences can be changed and still remain within the spirit and scope of the embodiments of the present application.
[0015] like Figure 1 As shown, the subject identification method of the embodiment of the present application includes the following operations:
[0016] S1, obtain the picture to be identified;
[0017] S2, inputting the acquired image to be identified into a pre-trained target detection model to detect objects in the image and attribute features of each object in the image;
[0018] The attribute characteristics of each object include the center point position of the object, the size parameters of the object, the confidence level of the object, etc. In other implementations, the attribute characteristics of the object may not be limited to the aforementioned types, and may be increased according to specific circumstances.
[0019] The above confidence level refers to the probability of the object type predicted by the target detection model, such as the probability that the target object belongs to a person, an animal, or an object.
[0020] S3. Determine the object serving as the target subject in the image according to the detected attribute features of each object in the image.
[0021] The embodiment of the present application can more flexibly identify the target subject in the image.
[0022] In an exemplary embodiment, the above-mentioned pre-trained target detection model is implemented using a deep learning-based target detection algorithm, and can detect the location information of objects and people contained in a picture, etc. Detection models such as FasterRCNN, Mask RCNN, SSD, or YOLOv3 can be used, and rectangular coordinate frames are used to frame objects corresponding to various categories (people, tables, computers, etc.) in the picture.
[0023] In an exemplary embodiment, in the above operation S3, determining the object in the picture as the target subject according to the attribute features of each object detected in the picture includes: determining the object in the picture as the target subject according to the attribute features of each object detected in the picture and the preset weight corresponding to each attribute feature of the object.
[0024] By setting weights in the embodiments of the present application, objects of different categories can be specified as target subject objects for region recognition, that is, after setting the requirements for the target subject, the target subject is extracted. The requirements for the preset subject object may include: First, the area of a single subject in the picture; Second, the position of a single subject in the picture; Third, the confidence level, that is, the probability that a single subject belongs to a certain category.
[0025] In an exemplary embodiment, in the above operation S3, determining the object in the picture as the target subject according to the attribute features of each object detected in the picture and the preset weight corresponding to each attribute feature of the object includes the following operations:
[0026] S31. Determine the area ratio of each object in the picture according to the size parameters of each object, and determine the distance between the center point of each object and the center point of the picture according to the center point position of each object; wherein, the attribute parameters of the picture can be obtained before this step.
[0027] S32. Determine the object in the picture as the target subject according to the area ratio of each object and the weight of the preset size parameter, the distance between the center point of each object and the center point of the picture and the weight of the preset center point position, and the confidence level and the weight of the confidence level.
[0028] In an exemplary embodiment, a pre-trained target detection neural network detects N single objects of various types in the picture, and extracts the attribute features of the picture and the attribute features of each object. Among them, the attribute features of each object include size parameter attribute features, expressed as [xi, yi, wi, hi, pi], 0 <= i < N; xi and yi represent the center points of each object; wi and hi represent the width and height of each object; the confidence level attribute feature is expressed as pi. Among them, the attribute features of the picture include size parameter attribute features, expressed as [X, Y, W, H]; X and Y represent the center points of the picture, and W and H represent the width and height of the picture.
[0029] In an exemplary embodiment, the area ratio A of each object in the picture can be obtained by the following formula:
[0030]
[0031] In an exemplary embodiment, the distance B between the center point of each object and the center point of the image can be obtained using the following formula:
[0032]
[0033] The above calculation of the area ratio of each object and the distance between the center point and the center point of the image is not limited to the above calculation form, and other calculation formulas can be used, which are not limited here.
[0034] In an exemplary embodiment, the operation S32 described above determines the object as the target subject in the picture according to the area ratio of each object and the weight of the preset size parameter, the distance between the center point of each object and the center point of the picture and the weight of the preset center point position, and the confidence and the weight of the confidence, including the following operations:
[0035] S321, determining the score of each object as the target subject according to the area ratio of each object and the weight of the preset size parameter, the distance between the center point of each object and the center point of the image and the weight of the preset center point position, and the confidence and the weight of the confidence;
[0036] S322: Determine an object with a score greater than a predetermined threshold as a target subject.
[0037] In an exemplary embodiment, the operation S321 described above determines the score of each object as the target subject according to the area ratio of each object and the weight of the preset size parameter, the distance between the center point of each object and the center point of the picture and the weight of the preset center point position, and the confidence and the weight of the confidence, including:
[0038] For each object in the image, perform the following operations:
[0039] S3211, multiplying and summing the area ratio of the object and the weight of the preset size parameter, the distance between the center point and the center point of the image and the weight of the preset center point position, and the confidence and the weight of the confidence;
[0040] S3212. Obtain a score value of the object as the target subject according to the summation result.
[0041] In an exemplary embodiment, the score value of each object as a target subject can be obtained in the following manner:
[0042] Calculate the N detected target objects one by one:
[0043]
[0044] Wherein α represents the weight of the preset size parameter, which is the area ratio weight in this embodiment. β represents the weight of the preset center point position. φ represents the confidence weight. The size of each weight can be set according to actual needs. For example, if it is necessary to detect the target object with the largest area as the target subject, the α value weight is increased. Finally, the object i with the largest Obj among the detected single objects N objects is selected as the target subject to complete the subject detection and identification.
[0045] In an exemplary embodiment, after determining the object as the target subject in the picture in the above operation S3, the step further includes: separately capturing the determined object as the target subject from the picture.
[0046] like Figure 2 As shown in the figure, the above method is described in detail by taking an actual picture as an example. Figure 2 The image in is input into the pre-trained object detection model and identifies:
[0047] Image attributes:
[0048] [302,212,604,424].
[0049] Properties of a single target,
[0050] Dog: [131,307,144,86,0.96];
[0051] People: [224 222 84 275 0.92];
[0052] Ma: [523 234 194 214 0.85].
[0053] Calculate the score for each object as a target subject:
[0054]
[0055]
[0056] Where Obj1 represents the score of the dog as the target subject; Obj2 represents the score of the person as the target subject; Obj3 represents the score of the horse as the target subject.
[0057] When α=0,β=0.1φ=0.9:
[0058]
[0059] Therefore, obj1 is the largest, so the subject selects the dog target with confidence priority as the target subject.
[0060] When α=0, β=0.5φ=0.1:
[0061]
[0062] According to the value of obj, select the person obj2 closest to the center point as the target subject.
[0063] When α=0.8,β=0.1φ=0.1:
[0064]
[0065] According to the value of obj, select obj3 horse as the main body, because the weight setting focuses on the area occupied by the main body.
[0066] The embodiment of the present application can specify objects of different categories as target subjects by setting weights corresponding to the attribute features.
[0067] In an example embodiment, the above operation S3 describes determining the object as the target subject in the image based on the detected attribute features of each object in the image, and can determine the area ratio of each object in the image according to the size parameters of the object, and determine the distance between the center point of each object and the center point of the image according to the position of the center point of each object; determine the object as the target subject in the image based on the area ratio of each object, the distance between the center point of each object and the center point of the image, and the confidence level. The only difference in the calculation method is that the above-mentioned weights are removed, which will not be repeated here.
[0068] This application uses target detection technology to replace the method of manually setting thresholds, binarization, dilation and other methods to segment the foreground and background. It can be applied to complex backgrounds and situations with multiple foregrounds, and can specify different categories of objects as target subjects for regional recognition. And according to the required subject, the subject can be extracted by the area size of all detected targets, the proximity to the center position and the category of objects.
[0069] like Figure 3 As shown, the subject identification device of the embodiment of the present application includes the following modules:
[0070] The acquisition module 10 is used to acquire the image to be identified; the detection module 20 is used to input the acquired image to be identified into a pre-trained target detection model to detect the objects in the image and the attribute characteristics of each object in the image; the attribute characteristics of each object include the center point position of the object, the size parameters of the object and the confidence of the object; the determination module 30 is used to determine the object as the target subject in the image based on the attribute characteristics of each object detected in the image.
[0071] An embodiment of the present application provides a subject identification device, including a processor and a memory, characterized in that a program for subject identification is stored in the memory; the processor is used to read the program for subject identification and execute any of the methods described above.
[0072] An embodiment of the present application provides a computer-readable medium for storing a program for subject identification, wherein the program performs any of the above methods when executed.
[0073] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
Claims
1. A subject identification method, comprising: Get the picture to be identified; Input the acquired image to be identified into a pre-trained target detection model to detect the objects in the image and the attribute features of each object in the image; The attribute characteristics of each object include the center point position of the object, the size parameters of the object and the confidence of the object; According to the detected attribute characteristics of each object in the picture, determine the object as the target subject in the picture, and use a rectangular coordinate frame to frame the objects of each category in the picture; Separately intercepting the object determined as the target subject from the picture; Wherein, determining the object as the target subject in the image according to the detected attribute features of each object in the image includes: The score of each object as the target subject is determined according to the following formula: Among them, α represents the area proportion weight, β represents the weight of the preset center point position, φ represents the confidence weight, and w i Indicates the width of each object, h i Indicates the height of each object, W indicates the width of the image, H indicates the height of the image, x i Represents the horizontal coordinate of the center point of each object, y i represents the ordinate of the center point of each object, X represents the abscissa of the center point of the image, Y represents the ordinate of the center point of the image, and p i Represents the confidence attribute feature; Determine an object with a score value greater than a predetermined threshold as a target subject; Among them, when it is necessary to detect the target object with the largest area as the target body, the weight of the α value is increased.
2. The subject identification method according to claim 1, characterized in that: The pre-trained target detection model is a model such as Faster RCNN, Mask RCNN, SSD, or YOLOv3.
3. A subject identification device, characterized in that: include: An acquisition module is used to acquire the image to be identified; A detection module is used to input the acquired image to be identified into a pre-trained target detection model to detect the objects in the image and the attribute characteristics of each object in the image; The attribute characteristics of each object include the center point position of the object, the size parameters of the object and the confidence of the object; A determination module, used to determine the object as the target subject in the image according to the detected attribute characteristics of each object in the image, and frame the objects corresponding to each category in the image using a rectangular coordinate frame; Separately intercepting the object determined as the target subject from the picture; Wherein, determining the object as the target subject in the image according to the detected attribute features of each object in the image includes: The score of each object as the target subject is determined according to the following formula: Among them, α represents the area proportion weight, β represents the weight of the preset center point position, φ represents the confidence weight, and w i Indicates the width of each object, h i Indicates the height of each object, W indicates the width of the image, H indicates the height of the image, x i Represents the horizontal coordinate of the center point of each object, y i represents the ordinate of the center point of each object, X represents the abscissa of the center point of the image, Y represents the ordinate of the center point of the image, and p i Represents the confidence attribute feature; Determine an object with a score value greater than a predetermined threshold as a target subject; Among them, when it is necessary to detect the target object with the largest area as the target body, the weight of the α value is increased.
4. A subject identification device, comprising a processor and a memory, characterized in that: The memory stores a program for subject identification; the processor is used to read the program for subject identification and execute the method described in any one of claims 1-2.
5. A computer-readable medium for storing a program for subject identification, wherein the program, when executed, performs the method according to any one of claims 1 to 2.
Citation Information
Patent Citations
Image processing method and device, electronic equipment and computer readable storage medium
CN110473185A
