Image recognition methods, devices, electronic devices and readable media
By extracting the outline edge lines and color distribution of the target image, the screenshot image is automatically recognized, which solves the problems of low efficiency and high cost of screenshot image recognition in the prior art, and improves the review efficiency and accuracy of posts in the application.
Patent Information
- Application Number
- CN202210301397.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-25
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-03-25
AI Technical Summary
In the prior art, relying on manual review and recognition of screenshot images is inefficient and costly, and it is impossible to deal with screenshot images of a large number of posts in the application in a timely manner, affecting the user experience.
By acquiring the target image, extracting the outline edge lines, determining the color distribution of the edge area. If the preset conditions are met, it will be recognized as a screenshot image. Computer vision technology is used to automatically identify whether the edge area meets the color distribution conditions, and improve the recognition efficiency of the screenshot image.
It realizes efficient recognition of screenshot images, reduces manual review costs, improves user experience, and ensures the accuracy and security of posts in the application.
Smart Images

Figure CN114693629B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of Internet technology, and in particular, to an image recognition method, an image recognition device, an electronic device, and a computer-readable medium. Background Art
[0002] With the development of Internet technology, users can use applications (APPs) installed in terminal devices such as smartphones and computers to shop online, trade houses, and find jobs, which not only greatly improves the convenience of people's lives, but also enriches the diversity of life.
[0003] When users use the services provided by the application, they can use images to determine whether to conduct online shopping or house transactions, etc. However, there are a large number of posts in the application, and there may be posts that steal images of legitimate users. Currently, one of the common ways to steal images is screenshots, and the images obtained by screenshots are screenshot images.
[0004] Currently, manual review is used to identify whether images uploaded by users are screenshots. However, relying solely on manual review has the disadvantage of high cost. In addition, due to the low efficiency of manual recognition, it is impossible to conduct timely review of all images uploaded by users in the face of the huge number of posts in the application. Therefore, there is a risk of a large number of screenshots appearing online, which in turn affects the user experience. Summary of the invention
[0005] The embodiments of the present invention provide an image recognition method, device, electronic device and computer-readable storage medium to solve the problem of being unable to review screenshot images in a timely manner.
[0006] An embodiment of the present invention discloses an image recognition method, the method comprising:
[0007] Get the target image submitted to the application;
[0008] Extracting a contour edge line from the target image;
[0009] Based on the contour edge line, determining an edge region in the target image;
[0010] Determining the color distribution of the edge area;
[0011] When the color distribution meets a preset color distribution condition, the target image is identified as a screenshot image; wherein the color distribution condition is based on a background corresponding setting when viewing the image in the application.
[0012] Optionally, determining an edge region in the target image based on the contour edge line includes:
[0013] Respectively acquiring at least two pixel coordinates of the contour edge line and the distance between the contour edge line and the edge of the target image;
[0014] Determine the angle of the contour edge line according to the pixel coordinates;
[0015] Determine a preset number of contour edge lines whose angles are preset angles and whose distances from the edges of the target image are the smallest as target contour edge lines;
[0016] The target image between the target contour edge line and the edge of the target image is determined as an edge area.
[0017] Optionally, after determining the angle of the contour edge line according to the pixel coordinates, the method further comprises:
[0018] When the contour edge line having the preset angle does not exist, the target image is identified as a non-screenshot image.
[0019] Optionally, determining the color distribution of the edge area includes:
[0020] Obtaining pixel values of pixels in the edge area;
[0021] The pixel values are used to calculate the mean and variance of the edge area; the mean and variance are used to characterize the color distribution of the edge area.
[0022] Optionally, when the color distribution condition satisfies a preset color distribution condition, identifying the target image as a screenshot image includes:
[0023] When the mean and the variance satisfy a preset color distribution condition corresponding to a background of a specified color, and the target image is not a floor plan, the target image is identified as a screenshot image.
[0024] Optionally, whether the target image is a floor plan is determined by:
[0025] Acquire image information of the target image submitted in the application;
[0026] It is determined whether the target image is a floor plan based on the image information.
[0027] Optionally, after determining the color distribution of the edge area, the method further includes:
[0028] When the color distribution condition does not satisfy a preset color distribution condition, the target image is identified as a non-screenshot image.
[0029] Optionally, when the color distribution condition satisfies a preset color distribution condition, after identifying the target image as a screenshot image, the method further includes:
[0030] If the target image is identified as a screenshot image, posting a post containing the target image in the application is prohibited.
[0031] The embodiment of the present invention further discloses an image recognition device, the device comprising:
[0032] A target image acquisition module is used to acquire a target image submitted to the application;
[0033] A contour edge line extraction module, used to extract contour edge lines from the target image;
[0034] An edge region determining module, configured to determine an edge region in the target image based on the contour edge line;
[0035] A color distribution determination module, used to determine the color distribution of the edge area;
[0036] An image recognition module is used to recognize the target image as a screenshot image when the color distribution meets a preset color distribution condition; wherein the color distribution condition is based on a background corresponding setting when viewing the image in the application.
[0037] Optionally, the edge area determination module is used to respectively obtain at least two pixel coordinates of the contour edge line and the distance between the contour edge line and the edge of the target image; determine the angle of the contour edge line according to the pixel coordinates; determine a preset number of contour edge lines whose angle is a preset angle and whose distance from the edge of the target image is the smallest as target contour edge lines; and determine the target image between the target contour edge line and the edge of the target image as an edge area.
[0038] Optionally, the edge region determining module is configured to identify the target image as a non-screenshot image when the contour edge line having the preset angle does not exist.
[0039] Optionally, the color distribution determination module is used to obtain pixel values of pixels in the edge area; use the pixel values to calculate the mean and variance of the edge area; the mean and the variance are used to characterize the color distribution of the edge area.
[0040] Optionally, the image recognition module is used to identify the target image as a screenshot image when the mean and the variance meet a preset color distribution condition set corresponding to a background of a specified color, and the target image is not a floor plan.
[0041] Optionally, the image recognition module is used to obtain image information of the target image submitted in the application; and determine whether the target image is a floor plan based on the image information.
[0042] Optionally, the image recognition module is used to recognize the target image as a non-screenshot image when the color distribution does not meet a preset color distribution condition.
[0043] Optionally, the device further comprises a publishing prohibition module, configured to prohibit publishing a post containing the target image in the application if the target image is identified as a screenshot image.
[0044] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0045] The memory is used to store computer programs;
[0046] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0047] The embodiment of the present invention further discloses one or more computer-readable media on which instructions are stored. When executed by one or more processors, the processors are enabled to execute the method described in the embodiment of the present invention.
[0048] The embodiment of the present invention further discloses a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the embodiment of the present invention.
[0049] The embodiments of the present invention include the following advantages:
[0050] In an embodiment of the present invention, a target image submitted to an application is obtained, and a contour edge line is extracted from the target image. After an edge area is determined in the target image based on the contour edge line, the color distribution of the edge area is determined. If the color distribution meets a preset color distribution condition, the target image can be identified as a screenshot image, wherein the color distribution condition is based on the corresponding setting of the background when viewing the image in the application. If the color distribution of the edge area meets the preset color distribution condition, it means that the target image may be a screenshot image that has captured the background. The embodiment of the present invention determines whether the target image is a screenshot image by automatically identifying whether the edge area of the target image meets the color distribution condition, thereby improving the recognition efficiency of the screenshot image. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 is a schematic diagram of an application environment provided in an embodiment of the present invention;
[0052] Figure 2 is a flowchart of the steps of an image recognition method provided in an embodiment of the present invention;
[0053] Figure 3 is one of the screenshot images of a house image provided in an embodiment of the present invention;
[0054] Figure 4 This is a second screenshot image of a house image provided in an embodiment of the present invention;
[0055] Figure 5 This is a third screenshot image of a house image provided in an embodiment of the present invention;
[0056] Figure 6 is a schematic diagram of a contour edge line of a house image provided in an embodiment of the present invention;
[0057] Figure 7 is a schematic diagram of a floor plan provided in an embodiment of the present invention;
[0058] Figure 8 is a flowchart of image recognition provided in an embodiment of the present invention;
[0059] Fig. 9 It is a structural block diagram of an image recognition device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0060] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0061] The image recognition method provided by the embodiment of the present invention can be applied to Figure 1In the application environment shown. The terminal devices 102 communicate with the server 104 through the network. Specifically, the server 104 obtains the target image submitted to the application by the user through the terminal device 102, extracts the contour edge line from the target image, determines the edge area in the target image based on the contour edge line, determines the color distribution of the edge area, and identifies the target image as a screenshot image when the color distribution meets the preset color distribution condition; wherein the color distribution condition is based on the background corresponding setting when viewing the image in the application.
[0062] In actual applications, the terminal device 102 can be but is not limited to various personal computers, laptops, smart phones, tablet computers, robots, vehicle-mounted terminals and portable wearable devices, and the server 104 can be implemented as an independent server or a server cluster consisting of multiple servers.
[0063] Reference Figure 2 , shows a flowchart of an image recognition method provided in an embodiment of the present invention, which may specifically include the following steps:
[0064] Step 202: Obtain the target image submitted to the application.
[0065] In a specific implementation, an application program, such as a life application program, can be run on the terminal device. The life application program can provide users with functions such as house transaction, vehicle sale and purchase, housekeeping service, and leisure.
[0066] The target image may be an image containing a specified object, for example, a house image containing a house, a vehicle image containing a vehicle, an object image containing an object, etc.
[0067] For example, a landlord user or a broker user can upload a post about a house transaction in a life application. In order to allow the tenant user who browses the post to better understand the situation of the house, the post usually contains a house image, such as a photo of the house environment. If the post is allowed to be published on the application, the tenant user can determine whether to further communicate with the user who posted the post after browsing the post. In an embodiment of the present invention, if it is detected that a user uploads a post about a house transaction in a life application, and the post about the house transaction contains a house image, the house image in the post can be used as the target image.
[0068] Step 204: extracting contour edge lines from the target image.
[0069] Among them, the contour edge line, also called the "external line", refers to the outer edge boundary of an individual, group or scene in an image. It is the dividing line between one object and another, and between an object and the background.
[0070] For example, if the target image is a house image, and the target image includes house-related contents such as chandeliers, beds, tables, windows, curtains, and stairs, then the contour edge lines of the chandeliers, beds, tables, windows, curtains, and stairs can be extracted from the target image. As an optional embodiment, edge detection algorithms such as Canny, Sobel, Prewitt, Roberts, and Marr-Hildreth can be used to extract the contour edge lines of all contents in the target image.
[0071] In a specific implementation, the target image may be a screenshot image stolen by screenshot. Specifically, the screenshot image is usually obtained by a user taking a screenshot of an image displayed in an application. When an image is displayed in an application, in order not to affect the user's normal browsing of the image, the image is usually displayed on a background pre-set in the application, wherein the background is usually a solid color, such as a black background or a white background. Therefore, the screenshot image contains not only the screenshot image itself, but also the background when the screenshot image is displayed in the application.
[0072] The following are some specific examples to illustrate the screenshots: Figure 3 , is one of the screenshot images of a house image of the present invention, and the image includes not only the screenshot image 302 but also the background 304; refer to Figure 4 , which is a second screenshot image of a house image of the present invention, and in addition to the screenshot image 402, the image also includes a background 404; refer to Figure 5 , which is a third screenshot image of a house image of the present invention, and in addition to the screenshot image 502 , the image also includes a background 504 .
[0073] Based on the above characteristics that the screenshot image contains the background, if the target image is a screenshot image, then the contour edge lines extracted from the target image include not only the content of the screenshot image itself, but also the background of the application. Taking a house image as an example, the contour edge lines extracted from the house image, in addition to the chandelier, bed, table, window, curtain, staircase, etc. in the house image, will also include the contour edge lines corresponding to the background when the application displays the house image. For example, referring to Figure 6 , is a schematic diagram of a contour edge line of a house image of the present invention, which includes a contour edge line 602 corresponding to the background and contour edge lines of other contents in the house image.
[0074] Step 206: Determine an edge region in the target image based on the contour edge line.
[0075] The edge region refers to an image region in the target image determined based on the contour edge line.
[0076] In an embodiment of the present invention, after all the contour edge lines in the target image are obtained, one or more edge regions can be determined in the target image based on the contour edge lines. Figure 6 The white image areas 604 in the figure all belong to the edge areas in the target image determined based on the contour edge lines 602.
[0077] Step 208: Determine the color distribution of the edge area.
[0078] Step 210: When the color distribution meets a preset color distribution condition, identify the target image as a screenshot image; wherein the color distribution condition is based on a background corresponding setting when viewing the image in the application.
[0079] The color distribution is used to represent the overall distribution of the color values of the pixels in the edge region, for example, a color to which the color values of the pixels in the edge region tend to be, for example, towards black, or towards white.
[0080] Among them, the color distribution condition is a setting corresponding to the background when viewing the image in the application. Therefore, in the embodiment of the present invention, after determining one or more edge areas in the target image based on the contour edge line, the color distribution of each edge area is further determined. If the color distribution of the edge area meets the preset color distribution condition, it can be explained that the target image includes the background when the image is displayed in the application, and the target image can be identified as a screenshot image. Optionally, computer vision technology can be used to set the color distribution condition based on the background when viewing the image in the application.
[0081] In the above-mentioned image recognition method, a target image submitted to an application is obtained, and contour edge lines are extracted from the target image. After the edge area is determined in the target image based on the contour edge lines, the color distribution of the edge area is determined. If the color distribution meets the preset color distribution condition, the target image can be identified as a screenshot image, wherein the color distribution condition is based on the corresponding setting of the background when viewing the image in the application. If the color distribution of the edge area meets the preset color distribution condition, it means that the target image may be a screenshot image that has captured the background. The embodiment of the present invention improves the recognition efficiency of screenshot images by automatically identifying whether the edge area of the target image meets the color distribution condition to determine whether the target image is a screenshot image.
[0082] Based on the above embodiment, a variant embodiment of the above embodiment is proposed. It should be noted that in order to make the description concise, only the differences from the above embodiment are described in the variant embodiment.
[0083] In an exemplary embodiment, the step 206 of determining the edge region in the target image based on the contour edge line may include the following steps:
[0084] Respectively acquiring at least two pixel coordinates of the contour edge line and the distance between the contour edge line and the edge of the target image;
[0085] Determine the angle of the contour edge line according to the pixel coordinates;
[0086] Determine a preset number of contour edge lines whose angles are preset angles and whose distances from the edges of the target image are the smallest as target contour edge lines;
[0087] The target image between the target contour edge line and the edge of the target image is determined as an edge area.
[0088] In a specific implementation, the image displayed in the application is usually rectangular, so if a screenshot is taken of the image displayed in the application, the contour edge line corresponding to the background in the obtained screenshot image should be a straight line with an angle of 90 degrees or 0 degrees if the horizontal line is used as a reference. Therefore, in an optional example of the present invention, the preset angle can be set to 90 degrees or 0 degrees. In addition, the background part in the screenshot image is located at the position closest to the edge of the image in the screenshot image, more specifically, at the top, bottom, left, and right positions of the screenshot image close to the edge of the screenshot image. This is because when the screenshot image is displayed in the application, it is usually displayed in the middle of the background. Therefore, in an optional example of the present invention, the preset number can be set to 4.
[0089] In an embodiment of the present invention, when extracting the contour edge line from the target image, at least two pixel coordinates of the contour edge line are obtained respectively. If the two pixel coordinates are both on the horizontal axis or the vertical axis of the coordinate system, it can be determined that the angle of the contour edge line is 90 degrees or 0 degrees, that is, it satisfies the preset angle, and the contour edge line is a straight line. If the angle of the contour edge line is the preset angle, the distance between these contour edge lines and the edge of the target image is further determined, and a preset number of contour edge lines with the smallest distance to the edge of the target image, for example, the 4 contour edge lines with the smallest distance to the edge of the target image, are determined as the target contour edge lines. Then, the target image in the rectangular frame formed by the combination of the target contour edge line and the edge of the target image can be determined as the edge area.
[0090] It should be noted that the preset angle and the preset number can be set according to the actual situation when the image is displayed in the application. For example, if the target image is displayed at an angle in the application, the preset angle can be adjusted according to the angle of inclination. If the background on the left and right sides of the application is completely covered by the target image, the preset number can be set to 2, and the embodiment of the present invention does not limit this.
[0091] For example, refer to Figure 6 , Figure 6 The four dotted lines in the upper, lower, left, and right middle are the edges of the target image. Figure 6 The contour edge line 602 in is the target contour edge line, then the target contour edge line 602 is combined with the dotted line (ie, the edge of the target image) to obtain a rectangular frame, and the target image within the rectangular frame is the edge region 604 .
[0092] In the above exemplary embodiment, after the contour edge lines are extracted from the target image, a preset number of contour edge lines with a preset angle and a minimum distance from the edge of the target image are further determined from the contour edge lines, and then combined with the edge of the target image to determine the edge area, which is used for subsequent determination of whether the target image is a screenshot image based on the color distribution of the edge area, thereby reducing the number of edge areas that need to be determined and reducing the consumption of computing resources.
[0093] It should be noted that the embodiment of the present invention extracts contour edge lines from the target image through an edge detection algorithm. If the edge detection algorithm is not accurate, the extracted contour edge lines will not be accurate enough. The background in the screenshot image has a large color contrast with the screenshot image. Therefore, the contour edge lines corresponding to the background in the screenshot image are very easy to be detected by the edge detection algorithm. In view of the above characteristics, the embodiment of the present invention does not need to use a very high-precision edge detection algorithm. Even if some details in the target image cannot be accurately detected, it will not affect the recognition of the target image.
[0094] In an exemplary embodiment, after determining the angle of the contour edge line according to the pixel coordinates, the method may further include the following steps:
[0095] When the contour edge line having the preset angle does not exist, the target image is identified as a non-screenshot image.
[0096] In an embodiment of the present invention, if at least two pixel coordinates of the contour edge line are not both on the horizontal axis or the vertical axis of the coordinate system, it can be determined that the angle of the contour edge line is not 90 degrees or 0 degrees, that is, it does not meet the preset angle, indicating that there is no contour edge line corresponding to the background in the target image, and it is not a straight line. The target image can be identified as a non-screenshot image, that is, a compliant image.
[0097] In the above exemplary embodiment, when there is no contour edge line with a preset angle among the contour edge lines of the target image, the target image can be directly identified as a non-screenshot image without determining a preset number of contour edge lines with the smallest distance from the edge of the target image from the contour edge lines, thereby improving the recognition efficiency of the target image.
[0098] In an exemplary embodiment, the step 208 of determining the color distribution of the edge area may include the following steps:
[0099] Obtaining pixel values of pixels in the edge area;
[0100] The pixel values are used to calculate the mean and variance of the edge area; the mean and variance are used to characterize the color distribution of the edge area.
[0101] The mean is the average value of the color values of the pixels in the image. Based on the mean, the color that the image tends to be, for example, black or white, can be determined. The variance reflects the degree of deviation of the color values of the pixels in the image from the mean.
[0102] In the embodiment of the present invention, the pixel values of the pixels in each edge region of the target image are obtained to calculate the mean and variance of the edge region based on the pixel values, so that the color distribution of the edge region can be determined based on the mean and variance. Of course, in addition to determining the color distribution of the edge region based on the mean and variance, the color distribution of the edge region can also be determined based on the mean square value, mean square deviation, and standard deviation of the edge region, and the embodiment of the present invention does not need to be limited to this.
[0103] In the above exemplary embodiment, the color distribution of the edge area is determined based on the mean and variance calculated from the pixel values of the pixels in the edge area, which is simple, accurate and efficient.
[0104] Specifically, the preset color distribution condition may be to satisfy a specified color, where the specified color is the color of a specified image. At this time, when the color distribution condition satisfies the specified color and the target image is not the specified image, the target image is identified as a screenshot image.
[0105] In an exemplary embodiment, the designated image may be a floor plan, and the designated color is the color of the floor plan. Step 210, when the color distribution meets a preset color distribution condition, identifying the target image as a screenshot image, may include the following steps:
[0106] When the mean and the variance satisfy a preset color distribution condition corresponding to a background of a specified color, and the target image is not a floor plan, the target image is identified as a screenshot image.
[0107] Among them, the preset color distribution condition includes a preset mean and a preset variance corresponding to the background when the application views the image. Therefore, if the mean and the variance meet the preset mean and the preset variance, the target image can be identified as a screenshot image. Exemplarily, if the target image is in RGB color mode, each pixel in the target image will be assigned a pixel value in the range of 0 to 255, where 0 represents black and 255 represents white. Assuming that the mean mean and the variance std are calculated based on the pixels in the edge area, when mean>220 and std<10, it means that the edge area tends to be white, and the deviation of the overall pixel value is small, then the edge area can be determined as a white area, and when mean<5 and std<10, it means that the edge area tends to be black, and the deviation of the overall pixel value is small, then the edge area can be determined as a black area. In an embodiment of the present invention, if it is determined that the edge area is a white area or a black area, the target image can be identified as a screenshot image.
[0108] Of course, if the target image is in CMYK color mode, HSB color mode, YUV color mode, etc., the edge area can also be converted into RGB color mode and then the mean and variance can be calculated to determine whether the target image is a screenshot image. The embodiment of the present invention is not limited to this.
[0109] In a specific implementation, the target image may be a house image, and the house image may include a house photo and a floor plan. Figure 7 , is a schematic diagram of a floor plan provided in an embodiment of the present invention. The floor plan refers to a planar spatial layout diagram of a house, that is, a diagram describing the use function, corresponding position, and size of each independent space of the house. In practical applications, in order to more intuitively see the direction and layout of the house, most floor plans are in white or off-white.
[0110] In an optional embodiment, the designated image is a floor plan, and the designated color is the color of the floor plan. For example, if the color of the floor plan is white, the designated color is white. In the embodiment of the present invention, considering that the target image may be a floor plan, if the mean and variance in the edge area meet the color distribution condition set for the background of a non-designated color (e.g., black), the target image can be identified as a screenshot image. If the mean and variance in the edge area meet the color distribution condition set for the background of a designated color (e.g., white), it will be further determined whether the target image is a floor plan. Specifically, if the target image meets the color distribution condition set for the background of the designated color and is not a floor plan, the target image can be identified as a screenshot image.
[0111] In the above exemplary embodiment, if the mean and variance of the edge area satisfy the color distribution conditions set corresponding to the background of the specified color, it means that the target image may be a special image, such as a floor plan. In this case, it can be determined whether the target image is a floor plan to further identify whether the target image is a screenshot image, avoid misidentification, and improve recognition accuracy.
[0112] In an exemplary embodiment, whether the target image is a floor plan is determined in the following manner:
[0113] Acquire image information of the target image submitted in the application;
[0114] It is determined whether the target image is a floor plan based on the image information.
[0115] In a specific implementation, when a user submits an image in an application, the user may also submit image information about the image. For example, if the image is a floor plan, image information indicating that the image is a floor plan may be submitted in the application.
[0116] In an embodiment of the present invention, if the mean and variance of the edge area satisfy the color distribution conditions set for a background of a specified color, for example, the color distribution conditions set for a white background, it indicates that the image may be a floor plan. Image information of the target image is then acquired to determine whether the target image is a floor plan based on the image information. If it is determined based on the image information that the target image is indeed a floor plan, the target image can be identified as a non-screenshot image, that is, a compliant image. If it is determined based on the image information that the target image is not a floor plan, the target image can be identified as a screenshot image, that is, a non-compliant image.
[0117] In the above exemplary embodiment, the image information of the target image submitted by the user is obtained to identify whether the target image is a screenshot image in combination with the preset color distribution condition and the image information, which can improve the recognition accuracy of the target image.
[0118] In an exemplary embodiment, after determining the color distribution of the edge area, the method may further include the following steps:
[0119] When the color distribution condition does not satisfy a preset color distribution condition, the target image is identified as a non-screenshot image.
[0120] In an embodiment of the present invention, after determining one or more edge areas in the target image, the color distribution of each edge area is further determined. If the color distribution of the edge area does not meet the preset color distribution conditions, it can be explained that the target image does not include the background when the image is displayed in the application. Then the target image can be identified as a non-screenshot image, that is, a compliant image.
[0121] Exemplarily, assuming that the mean mean and variance std are calculated based on the pixels in the edge area, that is, if mean>220 and std<10, and mean<5 and std<10 are not satisfied, it means that the color distribution of the edge area does not meet the preset color distribution conditions, and the target image can be identified as a non-screenshot image.
[0122] In the above exemplary embodiment, when it is identified that the edge area of the target image does not meet the color distribution condition, it is indicated that the target image is not a screenshot image, and the target image can be identified as a non-screenshot image, thereby improving the recognition efficiency of the target image.
[0123] In an exemplary embodiment, after identifying the target image as a screenshot image when the color distribution condition satisfies a preset color distribution condition, the method may further include the following steps:
[0124] If the target image is identified as a screenshot image, posting a post containing the target image in the application is prohibited.
[0125] In a specific implementation, the target image may be an image in a post submitted by a user to the application, for example, an image of a house in a post about a house transaction. If the target image is identified as a screenshot image, it means that the image in the post may be an illegal secondary use of an existing image. In order to ensure the property and life safety of all users in the application, posts containing screenshot images will not be allowed to be published in the application.
[0126] In the above exemplary embodiment, if the image in the post submitted by the user to the application is identified as a screenshot image, the post will be prohibited from being published in the application, thereby improving the efficiency of post review, especially when the number of posts is large. It can effectively reduce the posting of false information on the application, improve the accuracy of the posts displayed in the application, avoid unnecessary trouble to users caused by posts of false information, and users can use the application with confidence, thereby improving user trust.
[0127] In order to enable those skilled in the art to better understand the embodiments of the present invention, a specific example is used below for illustration. Figure 8 , is a flowchart of an image recognition provided by an embodiment of the present invention, comprising the following steps:
[0128] Step 802: Acquire a target image.
[0129] Step 804: Use the Canny edge detection algorithm to extract all contour edge lines in the target image;
[0130] Step 806: Extract the contour edge lines (straight lines) with angles of 0 or 90 degrees through the pixel coordinates on the same contour edge line, and further select the contour edge lines closest to the edge of the target image, that is, the four contour edge lines closest to the upper, lower, left, and right edges of the target image. If the target image includes a target contour edge line whose angle and distance meet the conditions, execute step 808; if the target image does not include a target contour edge line whose angle and distance meet the conditions, execute step 816.
[0131] Step 808: Combine the target contour edge line and the target image edge into a rectangular frame, the target image in the rectangular frame is the edge region, and calculate the mean and variance std of the pixels in the edge region.
[0132] Step 810: When mean>220 and std<10, the edge area is determined as a white area; when mean<5 and std<10, the edge area is determined as a black area; if the edge area is a white area, step 812 is executed; if the edge area is a black area, step 814 is executed. If the mean and variance std of the edge area do not meet the color distribution conditions of mean>220 and std<10, or mean<5 and std<10, that is, the edge area is neither a black area nor a white area, step 816 is executed.
[0133] Step 812: Considering that if the target image is a floor plan, the edge area may be identified as a white area, which may cause a false call. Therefore, when extracting the edge area of the white area from the target image, it is necessary to further obtain the image information provided by the user to determine whether the target image is a floor plan. If so, execute step 816; if not, execute step 814.
[0134] Step 814: Determine the image as a screenshot.
[0135] Step 816: Determine that the image is not a screenshot image.
[0136] By applying the embodiments of the present invention, when a user posts a post in an application, an image in the post can be identified as a target image, and it can be determined whether it is a screenshot image stolen by screenshotting. This can ensure high recall of screenshot images that are illegally used for a second time with very little deployment resource consumption. It has the characteristics of stable features, high recognition accuracy, and high robustness, and effectively saves manpower review costs.
[0137] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0138] Reference Fig. 9 , shows a structural block diagram of an image recognition device provided in an embodiment of the present invention, which may specifically include the following modules:
[0139] The target image acquisition module 902 is used to acquire the target image submitted to the application;
[0140] A contour edge line extraction module 904 is used to extract contour edge lines from the target image;
[0141] An edge region determining module 906, configured to determine an edge region in the target image based on the contour edge line;
[0142] A color distribution determination module 908, configured to determine the color distribution of the edge area;
[0143] The image recognition module 910 is used to recognize the target image as a screenshot image when the color distribution meets a preset color distribution condition; wherein the color distribution condition is based on the background corresponding setting when viewing the image in the application.
[0144] In an exemplary embodiment, the edge area determination module 906 is used to respectively obtain at least two pixel coordinates of the contour edge line and the distance between the contour edge line and the edge of the target image; determine the angle of the contour edge line according to the pixel coordinates; determine a preset number of contour edge lines with a preset angle and a minimum distance from the edge of the target image as target contour edge lines; and determine the target image between the target contour edge line and the edge of the target image as an edge area.
[0145] In an exemplary embodiment, the edge region determining module 906 is configured to identify the target image as a non-screenshot image when the contour edge line having the preset angle does not exist.
[0146] In an exemplary embodiment, the color distribution determination module 908 is used to obtain pixel values of pixels in the edge area; use the pixel values to calculate the mean and variance of the edge area; the mean and the variance are used to characterize the color distribution of the edge area.
[0147] In an exemplary embodiment, the image recognition module 910 is used to recognize the target image as a screenshot image when the mean and the variance meet a preset color distribution condition set corresponding to a background of a specified color and the target image is not a floor plan.
[0148] In an exemplary embodiment, the image recognition module 910 is used to obtain image information of the target image submitted in the application; and determine whether the target image is a floor plan based on the image information.
[0149] In an exemplary embodiment, the image recognition module 910 is configured to recognize the target image as a non-screenshot image when the color distribution does not satisfy a preset color distribution condition.
[0150] In an exemplary embodiment, the device further includes a publishing prohibition module, which is used to prohibit publishing a post containing the target image in the application if the target image is identified as a screenshot image.
[0151] In an embodiment of the present invention, a target image submitted to an application is obtained, and a contour edge line is extracted from the target image. After an edge area is determined in the target image based on the contour edge line, the color distribution of the edge area is determined. If the color distribution meets a preset color distribution condition, the target image can be identified as a screenshot image, wherein the color distribution condition is based on the corresponding setting of the background when viewing the image in the application. If the color distribution of the edge area meets the preset color distribution condition, it means that the target image may be a screenshot image that has captured the background. The embodiment of the present invention determines whether the target image is a screenshot image by automatically identifying whether the edge area of the target image meets the color distribution condition, thereby improving the recognition efficiency of the screenshot image.
[0152] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0153] Preferably, an embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned image recognition method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0154] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned image recognition method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0155] An embodiment of the present invention provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned image recognition method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0156] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0157] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0158] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
[0159] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0160] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0161] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0162] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0163] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0164] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0165] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. An image recognition method, characterized in that: The method comprises: Get the target image submitted to the application; Extracting a contour edge line from the target image; Based on the contour edge line, determining an edge region in the target image; Determining the color distribution of the edge area; When the color distribution meets a preset color distribution condition, identifying the target image as a screenshot image; wherein the color distribution condition is based on a background corresponding setting when viewing the image in the application; The step of determining an edge region in the target image based on the contour edge line comprises: Respectively acquiring at least two pixel coordinates of the contour edge line and the distance between the contour edge line and the edge of the target image; Determine the angle of the contour edge line according to the pixel coordinates; Determine a preset number of contour edge lines whose angles are preset angles and whose distances from the edges of the target image are the smallest as target contour edge lines; The target image between the target contour edge line and the edge of the target image is determined as an edge area.
2. The method according to claim 1, characterized in that: After determining the angle of the contour edge line according to the pixel coordinates, the method further includes: When the contour edge line having the preset angle does not exist, the target image is identified as a non-screenshot image.
3. The method according to claim 1, characterized in that The determining the color distribution of the edge area includes: Obtaining pixel values of pixels in the edge area; The pixel values are used to calculate the mean and variance of the edge area; the mean and variance are used to characterize the color distribution of the edge area.
4. The method according to claim 3, characterized in that When the color distribution condition satisfies a preset color distribution condition, identifying the target image as a screenshot image includes: When the mean and the variance satisfy a preset color distribution condition corresponding to a background of a specified color, and the target image is not a floor plan, the target image is identified as a screenshot image.
5. The method according to claim 4, characterized in that Determine whether the target image is a floor plan by: Acquire image information of the target image submitted in the application; It is determined whether the target image is a floor plan based on the image information.
6. The method according to claim 1, characterized in that After determining the color distribution of the edge area, the method further includes: When the color distribution condition does not satisfy a preset color distribution condition, the target image is identified as a non-screenshot image.
7. The method according to claim 1, characterized in that After identifying the target image as a screenshot image when the color distribution condition satisfies a preset color distribution condition, the method further includes: If the target image is identified as a screenshot image, posting a post containing the target image in the application is prohibited.
8. An image recognition device, characterized in that: The device comprises: A target image acquisition module is used to acquire a target image submitted to the application; A contour edge line extraction module, used to extract contour edge lines from the target image; An edge region determining module, configured to determine an edge region in the target image based on the contour edge line; A color distribution determination module, used to determine the color distribution of the edge area; An image recognition module, configured to recognize the target image as a screenshot image when the color distribution condition satisfies a preset color distribution condition; wherein the color distribution condition is based on a background corresponding setting when viewing the image in the application; The edge area determination module includes: Respectively acquiring at least two pixel coordinates of the contour edge line and the distance between the contour edge line and the edge of the target image; Determine the angle of the contour edge line according to the pixel coordinates; Determine a preset number of contour edge lines whose angles are preset angles and whose distances from the edges of the target image are the smallest as target contour edge lines; The target image between the target contour edge line and the edge of the target image is determined as an edge area.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 7 when executing the program stored in the memory.
10. One or more computer readable media having instructions stored thereon, which when executed by one or more processors cause the processors to perform the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Image recognition method and apparatus, and equipment
CN108256530A
Door face photo copying detection method
CN112258481A