A method, system and computer storage medium for detecting text in non-commodity images

By performing channel extraction and pixel segmentation detection on images uploaded by sellers, the problem of low manual review efficiency is solved, efficient text detection is achieved, manpower and financial resources are saved, and detection accuracy and recall rate are improved.

CN114973288BActive Publication Date: 2024-08-30CHENGDU SETH INTELLIGENT TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210595852.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-30
Publication Date
2024-08-30
Estimated Expiration
2042-05-30

AI Technical Summary

Technical Problem

In the existing technology, manual review is used to detect whether pictures uploaded by sellers have descriptive text, which results in a lot of waste of manpower and time costs, and is inefficient. No effective solution has yet been proposed.

Method used

Provide a non-commercial image text detection method. By obtaining the original image for channel extraction, synthesizing the white background image and grayscale image, performing text detection and contour detection based on pixel segmentation, calculating the area intersection ratio and proportion, and determining whether there is Unqualified text area to determine whether the image is qualified.

Benefits of technology

It effectively improves the efficiency of manual review, saves manpower and financial resources, can accurately locate text areas of any shape, distinguish the text of the product itself from descriptive text, and achieves an accuracy rate of 99% and a recall rate of 98%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114973288B
    Figure CN114973288B
Patent Text Reader

Abstract

The present invention discloses a method, system and computer storage medium for detecting text in non-commodity images. The method includes: 100, obtaining an original image and performing channel extraction; 200, synthesizing the extracted R, G and B channels into a white background image, and synthesizing the extracted Alpha channel into a grayscale image; 300, performing text detection on the grayscale image, and when no text is detected, entering 400; otherwise, entering 800; 400, performing contour detection on the grayscale image, obtaining the contour area on the grayscale image and calculating the circumscribed rectangular frame of the contour area; 500, performing text detection based on pixel segmentation on the white background image, obtaining the text rectangular frame of the text on the white background image; mapping the circumscribed rectangular frame onto the white background image, and calculating the area intersection and union ratio of the text rectangular frame on the white background image and the circumscribed rectangular frame; when the area intersection and union ratio is not less than a first preset threshold, entering 800; 800, determining that the original image is an unqualified image. The method greatly improves the efficiency of manual review and saves manpower and financial resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision technology, and in particular to a non-commodity image text detection method, system and computer storage medium. Background Art

[0002] With the development of the Internet, online shopping has become a lifestyle for people, and the competition among e-commerce companies is becoming increasingly fierce. Digital consumption has played a positive role in promoting the vigorous development of my country's consumer market and expanding domestic demand.

[0003] Nowadays, you can open online shopping malls such as Taobao, JD.com, Suning, and Amazon, select the products you like, pay online, and wait for two or three days for the courier to deliver the products to your door. This online shopping experience has become a daily routine for quite a number of people. In recent years, the increase in mobile Internet users and the development of mobile payments have made online shopping something that can be done anytime, anywhere. In the era of online shopping, a large number of companies and individuals have taken the "express train" of online shopping and shared the "cake" of online shopping.

[0004] However, each e-commerce company will recruit sellers of various products. The sellers upload pictures of the products they sell to display on various e-commerce platforms, so that buyers can decide whether to buy based on the physical pictures of the products. However, the uploaded pictures are of varying quality. Some are taken at random, and some are arbitrarily added with a large amount of descriptive text about the products, which seriously affects the user's shopping experience. Some descriptive text will also conflict with the platform's unified holiday promotion. Therefore, the e-commerce platform will have certain requirements for the pictures uploaded by merchants, such as uploading four-channel pictures and only showing the main part of the product, without adding descriptive text unrelated to the product, so that the platform can unify and synthesize the pictures of the products with a festive atmosphere. In order to avoid such situations, manual review is usually used to review the pictures uploaded by sellers. The picture review team uses manual review to conduct inspections, which consumes a lot of manpower and time costs, and the efficiency of manual review is difficult to meet the growing demand for picture review.

[0005] Currently, no effective solution has been proposed to address the problem of waste of manpower and time costs and low efficiency caused by using manual review in the existing technology to detect whether the pictures uploaded by sellers have descriptive texts. Summary of the invention

[0006] The embodiments of the present invention provide a non-product image text detection method, system and computer storage medium to solve the problem of waste of manpower and time costs and low efficiency caused by using manual review in the prior art to detect whether the images uploaded by sellers have descriptive text.

[0007] To achieve the above-mentioned purpose, on the one hand, the present invention provides a method for detecting text in a non-commodity image, the method comprising: step 100, obtaining an original image and performing channel extraction on the original image; step 200, synthesizing the extracted R channel, G channel, and B channel into a white background image, and synthesizing the extracted Alpha channel into a grayscale image; step 300, performing pixel segmentation-based text detection on the grayscale image, and when no text is detected, proceeding to step 400; otherwise, proceeding to step 800; step 400, performing contour detection on the grayscale image, obtaining a contour area on the grayscale image and calculating a circumscribed rectangular frame of the contour area; step 500, performing pixel segmentation-based text detection on the white background image, and obtaining a contour area on the grayscale image; and calculating a circumscribed rectangular frame of the contour area. The image is subjected to pixel segmentation-based text detection to obtain a text rectangular frame of the text on the white background image; the circumscribed rectangular frame is mapped to the white background image, and the area intersection and union ratio of the text rectangular frame on the white background image and the circumscribed rectangular frame is calculated; when the area intersection and union ratio is less than a first preset threshold, the process proceeds to step 600; otherwise, the process proceeds to step 800; in step 600, the areas of all text rectangular frames in the current circumscribed rectangular frame are summed up and the proportion of the summed area to the area of ​​the current circumscribed rectangular frame is calculated; in step 700, it is determined whether the area proportion is greater than a second preset threshold, and if so, the process proceeds to step 800; in step 800, it is determined that the original image is an unqualified image.

[0008] Optionally, when it is determined that the area ratio is not greater than the second preset threshold, enter step 900; in step 900, calculate the width and height of the white background image and calculate the width and height of each of the text rectangular boxes; based on the width and height of the text rectangular box and the width and height of the white background image, determine whether there is a text rectangular box whose proportion in the white background image is greater than the third preset threshold; if so, enter step 800.

[0009] Optionally, the obtaining of the original image and performing channel extraction on the original image includes: obtaining the original image; determining whether the original image is a four-channel transparent image; and if so, performing channel extraction on the original image.

[0010] Optionally, the calculating and obtaining the circumscribed rectangular frame of the contour area includes: calculating the area of ​​the contour area and filtering out the contour area whose area is smaller than a third preset threshold; and calculating and obtaining the circumscribed rectangular frame of the filtered contour area.

[0011] Optionally, the calculation formula for the intersection and union ratio of the areas of the text rectangular frame and the circumscribed rectangular frame on the white background image is:

[0012] x 1 =max(x a1 ,x b1 );

[0013] y 1 =max(ya1 ,y b1 );

[0014] x 2 =max(x a2 ,x b2 );

[0015] y 2 =max(y a2 ,y b2 );

[0016] intersection=max(x 2 -x 1 +1.0,0)*max(y 2 -y 1 +1.0,0);

[0017] SA=(x a2 -x a1 +1.0)*(y a2 -y a1 +1.0);

[0018] SB=(x b2 -x b1 +1.0)*(y b2 -y b1 +1.0);

[0019] Union=SA+SB-intersection;

[0020] iou=intersection / Union;

[0021] The coordinates of the text rectangle are [x a1 ,y a1 ,x a2 ,y a2 ], the coordinates of the circumscribed rectangular frame are [x b1 ,y b1 ,x b2 ,y b2 ], x 1 ,y 1 x is the coordinate of the upper left corner of the intersection of the text rectangle and the circumscribed rectangle; 2 ,y 2 is the coordinate of the lower right corner of the intersection of the text rectangular box and the circumscribed rectangular box; intersection is the area of ​​the intersection of the text rectangular box and the circumscribed rectangular box; SA is the area of ​​the text rectangular box; SB is the area of ​​the circumscribed rectangular box; Union is the total area of ​​the text rectangular box and the circumscribed rectangular box; iou is the intersection-union ratio of the areas of the text rectangular box and the circumscribed rectangular box.

[0022] Optionally, performing pixel segmentation-based text detection on the grayscale image includes: scaling the grayscale image; and inputting the scaled grayscale image into a pre-trained text detection model to perform pixel segmentation-based text detection.

[0023] On the other hand, the present invention provides a non-commodity image text detection system, which includes: an acquisition unit, used to acquire an original image and perform channel extraction on the original image; a synthesis unit, used to synthesize the extracted R channel, G channel, and B channel into a white background image, and synthesize the extracted Alpha channel into a grayscale image; a first judgment unit, used to perform pixel segmentation-based text detection on the grayscale image, and when no text is detected, enter the contour detection unit; otherwise, enter the judgment unit; the contour detection unit, used to perform contour detection on the grayscale image, obtain the contour area on the grayscale image and calculate the circumscribed rectangular frame of the contour area; the second judgment unit, used to perform pixel segmentation on the white background image, and enter the grayscale image. Based on the pixel segmentation text detection, the text rectangular frame of the text on the white background image is obtained; the circumscribed rectangular frame is mapped to the white background image, and the area intersection and union ratio of the text rectangular frame on the white background image and the circumscribed rectangular frame is calculated; when the area intersection and union ratio is less than a first preset threshold, it enters the area ratio calculation unit; otherwise, it enters the judgment unit; the area ratio calculation unit is used to sum the areas of all the text rectangular frames in the current circumscribed rectangular frame and calculate the area ratio of the summed area to the area of ​​the current circumscribed rectangular frame; a third judgment unit is used to judge whether the area ratio is greater than a second preset threshold, and if so, it enters the judgment unit; the judgment unit is used to judge whether the original image is an unqualified image.

[0024] Optionally, when it is determined that the area ratio is not greater than the second preset threshold, enter the fourth judgment unit; the fourth judgment unit is used to calculate the width and height of the white background image and calculate the width and height of each of the text rectangular boxes; based on the width and height of the text rectangular box and the width and height of the white background image, determine whether there is a text rectangular box in the white background image that accounts for a ratio greater than the third preset threshold, and if so, enter the judgment unit.

[0025] Optionally, the acquisition unit includes: an acquisition subunit, used to acquire the original image; and a judgment subunit, used to judge whether the original image is a four-channel transparent image; if so, performing channel extraction on the original image.

[0026] On the other hand, the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the above-mentioned non-commodity image text detection method.

[0027] Beneficial effects of the present invention:

[0028] The present invention provides a method, system and computer storage medium for detecting text in non-commodity images, wherein the method performs contour detection through a grayscale image, obtains a contour area on the grayscale image and calculates a circumscribed rectangular frame of the contour area; performs pixel segmentation-based text detection through a white background image, obtains a text rectangular frame of the text on the white background image; and maps the circumscribed rectangular frame to the white background image. The above method is used to locate the text on the original image, effectively solving the problem of directly using a text detection algorithm to detect the commodity image, which causes the commodity image itself to be detected and mistakenly judged as an unqualified image, greatly improving the efficiency of manual review and saving manpower and financial resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 is a flow chart of a non-commodity image text detection method provided by an embodiment of the present invention;

[0030] Figure 2 It is a structural schematic diagram of a non-commodity image text detection system provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0031] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0032] In online shopping malls such as Taobao, JD.com, Suning, and Amazon, each e-commerce company will recruit sellers of various products. The sellers upload pictures of the products they sell to display on various e-commerce platforms, so that buyers can decide whether to buy them based on the physical pictures of the products. However, the uploaded pictures are of varying quality. Some are taken at random, and some are arbitrarily added with a large amount of descriptive text about the products, which seriously affects the user's shopping experience. Some descriptive text will also conflict with the platform's unified holiday promotion. Therefore, the e-commerce platform will have certain requirements for the pictures uploaded by merchants, such as uploading four-channel pictures and only showing the main part of the product, without adding descriptive text unrelated to the product, so that the platform can unify and synthesize the product pictures with a festive atmosphere. In order to avoid such situations, manual review is usually used to review the pictures uploaded by sellers. The picture review team uses manual review to conduct inspections, which consumes a lot of manpower and time costs, and the efficiency of manual review is difficult to meet the growing demand for picture review.

[0033] Therefore, the present invention provides a method for detecting text in non-commodity images. Figure 1is a flowchart of a non-commodity image text detection method provided by an embodiment of the present invention. Figure 1 As shown, the method includes:

[0034] Step 100, obtaining an original image and performing channel extraction on the original image;

[0035] In an optional implementation, step 100 includes:

[0036] Step 1001, obtaining an original image;

[0037] Step 1002, determining whether the original image is a four-channel transparent image; if so, performing channel extraction on the original image.

[0038] Specifically, in an uncompressed 32-bit RGB image, each pixel is composed of four parts: an Alpha channel and three R, G, and B channels. When the Alpha value is 0, the pixel is completely transparent, and when the Alpha value is 255, the pixel is completely opaque. When merchants upload pictures to e-commerce platforms, in order to uniformly manage the display effects of various festival activities, e-commerce platforms generally require merchants to upload four-channel 32-bit transparent images with an Alpha value of 0. Therefore, the channel judgment will be first performed on the pictures uploaded by the merchants (original pictures). If it is not a four-channel picture, it will be directly rejected and the merchant will be asked to upload it again; if it is a four-channel transparent picture, the channels will be further separated and extracted. That is, the R channel, G channel, B channel, and Alpha channel are extracted.

[0039] Step 200, synthesizing the extracted R channel, G channel, and B channel into a white background image, and synthesizing the extracted Alpha channel into a grayscale image;

[0040] Step 300, performing text detection based on pixel segmentation on the grayscale image, if no text is detected, proceed to step 400; otherwise, proceed to step 800;

[0041] In an optional implementation, traditional text detection methods generally use manual feature extraction to detect text, such as SWT, MSER and other methods, and then use template matching or model training methods to recognize the detected text. Traditional methods have many limitations in implementation, but this patent uses a text detection method based on pixel segmentation, which can not only detect horizontal text and vertical text, but also accurately locate text of any shape and irregular text instances. It greatly improves the robustness and detection performance of text detection.

[0042] The performing pixel-based segmentation text detection on the grayscale image comprises:

[0043] Performing image scaling on the grayscale image;

[0044] Specifically, in order to prevent the pixels of individual images from being too large, which will cause the graphics card memory to be full when the images are input into the network, the grayscale images need to be resized, that is, the grayscale images with a width and height greater than 1080 pixels are resized, the largest side is resized to 1080 pixels, and the small sides are resized proportionally by the same multiple. Grayscale images with a width and height less than 1080 pixels are not processed.

[0045] The scaled grayscale image is input into a pre-trained text detection model to perform text detection based on pixel segmentation.

[0046] Specifically, first read in the pre-trained text detection model, input the scaled grayscale image into the text detection model, extract features from the grayscale image through the backbone network, output features of four dimensions, and then fuse the high-level features with the low-level features to obtain four feature layers (P2, P3, P4, P5), where the number of channels in each feature layer is 256. Then concat the four feature layers to obtain F, send F to the Conv(3,3)-BN-ReLU layer, and change the number of channels in the feature layer to 256. Then send F to multiple Conv(1,1)-Up-Sigmod layers to obtain n segmentation results S1, S2, ... Sn (actually obtained through 1*1*n1*1*n1*1*n convolution).

[0047] In the above, F=C(P2, P3, P4, P5)=P2||Upx2(P3)||Upx4(P4)||Upx8(P5); wherein || represents concat; Up represents upsampling; Upx2, Upx4, and Upx8 represent upsampling of 2 times, 4 times, and 8 times, respectively.

[0048] Now the network outputs S1, S2, ... Sn. Assume n = 3. Now there are S1, S2, S3. S1 represents the segmentation result of the smallest kernel (convolution). It has four connected domains C = {c1, c2, c3, c4}. The CC operation obtains four connected domains in S1 (small scale, large spaces between different text lines, easy to distinguish). We know that the kernel (convolution) in S2 is larger than the kernel (convolution) in S1, which means that the kernel in S2 contains the kernel in S1. Then, the pixels that belong to the kernel in S2 but not in S1 are allocated. Each pixel of the found connected domain is expanded one by one up, down, left, and right in a BFS manner, which is equivalent to gradually widening the area of ​​the predicted text line in S1 (or in other words: for each pixel of the kernel in S2, assign them to a connected domain in S1). The same is true for the subsequent S3. Finally, we extract the connected area after S3 as the final text line detection result (that is, the result is whether the text is detected).

[0049] When no text is detected, the process proceeds to step 400 , otherwise, the original image is determined to be an unqualified image (ie, the image uploaded by the merchant has descriptive text).

[0050] Step 400, performing contour detection on the grayscale image to obtain a contour area on the grayscale image and calculating a circumscribed rectangular frame of the contour area;

[0051] In an optional implementation, the calculating the circumscribed rectangular frame of the contour area includes:

[0052] Calculating the area of ​​the contour region and filtering out the contour region whose area is smaller than a third preset threshold;

[0053] The circumscribed rectangular frame of the filtered contour area is calculated.

[0054] For example, some text is not written outside the product image alone, but only one line of text (3000W) is written outside the product image and in a small circular area. At this time, the text cannot be detected by directly performing pixel segmentation-based text detection on the grayscale image. Therefore, further detection is required, that is, contour detection is performed on the grayscale image to obtain the contour area on the grayscale image; the area of ​​the contour area is calculated and the contour area whose area is less than the third preset threshold is filtered out; at this time, the contour area of ​​the product image and the small circular area are retained; the circumscribed rectangular frame of the two contour areas is calculated.

[0055] Step 500, performing pixel segmentation-based text detection on the white background image to obtain a text rectangular frame of the text on the white background image; mapping the circumscribed rectangular frame onto the white background image, and calculating the area intersection-and-union ratio of the text rectangular frame on the white background image and the circumscribed rectangular frame; when the area intersection-and-union ratio is less than a first preset threshold, proceeding to step 600; otherwise, proceeding to step 800;

[0056] In an optional implementation, the white background image is scaled;

[0057] Specifically, in order to prevent the pixels of individual images from being too large, which will cause the graphics card memory to be full when the images are input into the network, the white background image needs to be resized, that is, the grayscale image with a width and height greater than 1080 pixels is resized, the largest side is resized to 1080 pixels, and the small side is resized proportionally by the same multiple. The white background image with a width and height less than 1080 pixels is not processed.

[0058] Input the scaled white background image into a pre-trained text detection model (psenet) to perform text detection based on pixel segmentation, and obtain a text rectangular frame of the text on the white background image; map the circumscribed rectangular frame onto the white background image, and calculate the intersection-and-union ratio of the areas of the text rectangular frame on the white background image and the circumscribed rectangular frame;

[0059] The calculation formula for the intersection and union ratio of the area of ​​the text rectangular frame and the circumscribed rectangular frame on the white background image is:

[0060] x 1 =max(x a1 ,x b1 );

[0061] y 1 =max(y a1 ,y b1 );

[0062] x 2 =max(x a2 ,x b2 );

[0063] y 2 =max(y a2 ,y b2 );

[0064] intersection=max(x 2 -x 1 +1.0,0)*max(y 2 -y 1 +1.0,0);

[0065] SA=(x a2 -xa1 +1.0)*(y a2 -y a1 +1.0);

[0066] SB=(x b2 -x b1 +1.0)*(y b2 -y b1 +1.0);

[0067] Union=SA+SB-intersection;

[0068] iou=intersection / Union;

[0069] The coordinates of the text rectangle are [x a1 ,y a1 ,x a2 ,y a2 ], the coordinates of the circumscribed rectangular frame are [x b1 ,y b1 ,x b2 ,y b2 ], x 1 ,y 1 x is the coordinate of the upper left corner of the intersection of the text rectangle and the circumscribed rectangle; 2 ,y 2 is the coordinate of the lower right corner of the intersection of the text rectangular box and the circumscribed rectangular box; intersection is the area of ​​the intersection of the text rectangular box and the circumscribed rectangular box; SA is the area of ​​the text rectangular box; SB is the area of ​​the circumscribed rectangular box; Union is the total area of ​​the text rectangular box and the circumscribed rectangular box; iou is the intersection-union ratio of the areas of the text rectangular box and the circumscribed rectangular box.

[0070] When the area intersection-to-union ratio is less than the first preset threshold, the process proceeds to step 600 . Otherwise, the original image is determined to be an unqualified image (ie, the image uploaded by the merchant has descriptive text).

[0071] Step 600, summing up the areas of all text rectangular frames within the current circumscribed rectangular frame and calculating the proportion of the summed area to the area of ​​the current circumscribed rectangular frame;

[0072] In an optional implementation, there may be two, three, ... rows of text rectangular frames in a small circular area; some of the text rectangular frames may be missed by the above method, therefore, based on the above method, it is necessary to sum up the areas of the text rectangular frames of all rows in the small circular area to obtain Sc, and calculate the area ratio A of the circumscribed rectangular frame of Sc in the small circular area;

[0073] Step 700, determining whether the area ratio is greater than a second preset threshold, if so, proceeding to step 800;

[0074] It is determined whether the area ratio A is greater than a second preset threshold value. If so, it is considered that the text area detected on the white background image is the text added by the merchant, which is an irregular text area, and the image will be rejected, and the merchant is asked to upload it again. Otherwise, it goes to step 900.

[0075] Step 800: determine whether the original image is an unqualified image.

[0076] Step 900, calculate the width and height of the white background image and the width and height of each of the text rectangular boxes; determine whether there is a text rectangular box whose proportion in the white background image is greater than a third preset threshold based on the width and height of the text rectangular box and the width and height of the white background image, and if so, proceed to step 800.

[0077] In an optional implementation, for example: a picture, the product image occupies 2 / 3 of the original picture, the text area occupies 1 / 3 of the original picture, and the text area is connected to the product image, and the text area is in a small rectangular frame. At this time, the above method cannot filter out the picture. That is, if the text detection based on pixel segmentation is directly performed on the grayscale image, what is detected is a full white area, and no text is detected; if the contour detection is performed on the grayscale image, the circumscribed rectangular frame obtained is the total frame of the product image and the text area combined (because the two are connected, what is detected is one area, and then the circumscribed rectangular frame is also one). At this time, the white background image is subjected to pixel segmentation-based text detection to obtain a text rectangular frame of the text on the white background image, but the area intersection ratio of the text rectangular frame and the circumscribed rectangular frame is less than the first preset threshold; and the area of ​​all text rectangular frames in the circumscribed rectangular frame and the ratio of the area of ​​the circumscribed rectangular frame are still less than the second preset threshold, so the above method cannot filter out the picture.

[0078] Therefore, the present invention also involves a judgment rule, that is, calculating the width and height of the white background image and calculating the width and height of each text rectangular box; judging whether the proportion of the text rectangular box in the white background image is greater than the third preset threshold according to the width and height of the text rectangular box and the width and height of the white background image, if so, it is considered that the merchant has self-Photoshopped descriptive text on the picture uploaded, and the picture will be rejected, and the merchant is asked to upload it again. Otherwise, the original picture is considered to be a transparent picture that meets the platform requirements (qualified picture).

[0079] In the present invention, the above method can effectively detect text on product images uploaded by merchants, and can locate and detect text areas of any shape (including curved, inclined, horizontal, and vertical). On the other hand, the method can also effectively distinguish between the text of the product itself and the text that is not the product itself (descriptive text added by the merchant), thereby effectively avoiding false detection caused by direct use of text detection, and can also achieve 99% accuracy and 98% recall rate of e-commerce images in this scenario.

[0080] Figure 2 is a structural diagram of a non-commodity image text detection system provided by an embodiment of the present invention, such as Figure 2 As shown, the system includes:

[0081] An acquisition unit 201 is used to acquire an original image and perform channel extraction on the original image;

[0082] In an optional implementation, the acquiring unit 201 includes:

[0083] The acquisition subunit 2011 is used to acquire the original image;

[0084] The judging subunit 2012 is used to judge whether the original image is a four-channel transparent image; if so, perform channel extraction on the original image.

[0085] Specifically, in an uncompressed 32-bit RGB image, each pixel is composed of four parts: an Alpha channel and three R, G, and B channels. When the Alpha value is 0, the pixel is completely transparent, and when the Alpha value is 255, the pixel is completely opaque. When merchants upload pictures to e-commerce platforms, in order to uniformly manage the display effects of various festival activities, e-commerce platforms generally require merchants to upload four-channel 32-bit transparent images with an Alpha value of 0. Therefore, the channel judgment will be first performed on the pictures uploaded by the merchants (original pictures). If it is not a four-channel picture, it will be directly rejected and the merchant will be asked to upload it again; if it is a four-channel transparent picture, the channels will be further separated and extracted. That is, the R channel, G channel, B channel, and Alpha channel are extracted.

[0086] A synthesis unit 202 is used to synthesize the extracted R channel, G channel, and B channel into a white background image, and synthesize the extracted Alpha channel into a grayscale image;

[0087] The first judgment unit 203 is used to perform text detection based on pixel segmentation on the grayscale image. When no text is detected, it enters the contour detection unit; otherwise, it enters the judgment unit;

[0088] In an optional implementation, traditional text detection methods generally use manual feature extraction to detect text, such as SWT, MSER and other methods, and then use template matching or model training methods to recognize the detected text. Traditional methods have many limitations in implementation, but this patent uses a text detection method based on pixel segmentation, which can not only detect horizontal text and vertical text, but also accurately locate text of any shape and irregular text instances. It greatly improves the robustness and detection performance of text detection.

[0089] The performing pixel-based segmentation text detection on the grayscale image comprises:

[0090] Performing image scaling on the grayscale image;

[0091] Specifically, in order to prevent the pixels of individual images from being too large, which will cause the graphics card memory to be full when the images are input into the network, the grayscale images need to be resized, that is, the grayscale images with a width and height greater than 1080 pixels are resized, the largest side is resized to 1080 pixels, and the small sides are resized proportionally by the same multiple. Grayscale images with a width and height less than 1080 pixels are not processed.

[0092] The scaled grayscale image is input into a pre-trained text detection model to perform text detection based on pixel segmentation.

[0093] Specifically, first read in the pre-trained text detection model, input the scaled grayscale image into the text detection model, extract features from the grayscale image through the backbone network, output features of four dimensions, and then fuse the high-level features with the low-level features to obtain four feature layers (P2, P3, P4, P5), where the number of channels in each feature layer is 256. Then concat the four feature layers to obtain F, send F to the Conv(3,3)-BN-ReLU layer, and change the number of channels in the feature layer to 256. Then send F to multiple Conv(1,1)-Up-Sigmod layers to obtain n segmentation results S1, S2, ... Sn (actually obtained through 1*1*n 1*1*n1*1*n convolution).

[0094] In the above, F=C(P2, P3, P4, P5)=P2||Upx2(P3)||Upx4(P4)||Upx8(P5); wherein || represents concat; Up represents upsampling; Upx2, Upx4, and Upx8 represent upsampling of 2 times, 4 times, and 8 times, respectively.

[0095] Now the network outputs S1, S2, ... Sn. Assume n = 3. Now there are S1, S2, S3. S1 represents the segmentation result of the smallest kernel (convolution). It has four connected domains C = {c1, c2, c3, c4}. The CC operation obtains four connected domains in S1 (small scale, large spaces between different text lines, easy to distinguish). We know that the kernel (convolution) in S2 is larger than the kernel (convolution) in S1, which means that the kernel in S2 contains the kernel in S1. Then, the pixels that belong to the kernel in S2 but not in S1 are allocated. Each pixel of the found connected domain is expanded one by one up, down, left, and right in a BFS manner, which is equivalent to gradually widening the area of ​​the predicted text line in S1 (or in other words: for each pixel of the kernel in S2, assign them to a connected domain in S1). The same is true for the subsequent S3. Finally, we extract the connected area after S3 as the final text line detection result (that is, the result is whether the text is detected).

[0096] When no text is detected, the process enters the contour detection unit 204, otherwise, the original image is determined to be an unqualified image (ie, the image uploaded by the merchant has descriptive text).

[0097] A contour detection unit 204 is used to perform contour detection on the grayscale image, obtain a contour area on the grayscale image, and calculate a circumscribed rectangular frame of the contour area;

[0098] In an optional implementation, the calculating the circumscribed rectangular frame of the contour area includes:

[0099] Calculating the area of ​​the contour region and filtering out the contour region whose area is smaller than a third preset threshold;

[0100] The circumscribed rectangular frame of the filtered contour area is calculated.

[0101] For example, some text is not written outside the product image alone, but only one line of text (3000W) is written outside the product image and in a small circular area. At this time, the text cannot be detected by directly performing pixel segmentation-based text detection on the grayscale image. Therefore, further detection is required, that is, contour detection is performed on the grayscale image to obtain the contour area on the grayscale image; the area of ​​the contour area is calculated and the contour area whose area is less than the third preset threshold is filtered out; at this time, the contour area of ​​the product image and the small circular area are retained; the circumscribed rectangular frame of the two contour areas is calculated.

[0102] The second judgment unit 205 is used to perform pixel segmentation-based text detection on the white background image to obtain a text rectangular frame of the text on the white background image; map the circumscribed rectangular frame onto the white background image, and calculate the area intersection and union ratio of the text rectangular frame on the white background image and the circumscribed rectangular frame; when the area intersection and union ratio is less than a first preset threshold, enter the area proportion calculation unit; otherwise, enter the judgment unit;

[0103] In an optional implementation, the white background image is scaled;

[0104] Specifically, in order to prevent the pixels of individual images from being too large, which will cause the graphics card memory to be full when the images are input into the network, the white background image needs to be resized, that is, the grayscale image with a width and height greater than 1080 pixels is resized, the largest side is resized to 1080 pixels, and the small side is resized proportionally by the same multiple. The white background image with a width and height less than 1080 pixels is not processed.

[0105] Input the scaled white background image into a pre-trained text detection model (psenet) to perform text detection based on pixel segmentation, and obtain a text rectangular frame of the text on the white background image; map the circumscribed rectangular frame onto the white background image, and calculate the intersection-and-union ratio of the areas of the text rectangular frame on the white background image and the circumscribed rectangular frame;

[0106] The calculation formula for the intersection and union ratio of the area of ​​the text rectangular frame and the circumscribed rectangular frame on the white background image is:

[0107] x 1 =max(x a1 ,x b1 );

[0108] y 1 =max(y a1 ,y b1 );

[0109] x 2 =max(x a2 ,x b2 );

[0110] y 2 =max(y a2 ,y b2 );

[0111] intersection=max(x 2 -x 1 +1.0,0)*max(y 2 -y 1 +1.0,0);

[0112] SA=(xa2 -x a1 +1.0)*(y a2 -y a1 +1.0);

[0113] SB=(x b2 -x b1 +1.0)*(y b2 -y b1 +1.0);

[0114] Union = SA + SB-intersection;

[0115] iou=intersection / Union;

[0116] The coordinates of the text rectangle are [x a1 ,y a1 ,x a2 ,y a2 ], the coordinates of the circumscribed rectangular frame are [x b1 ,y b1 ,x b2 ,y b2 ], x 1 ,y 1 x is the coordinate of the upper left corner of the intersection of the text rectangle and the circumscribed rectangle; 2 ,y 2 is the coordinate of the lower right corner of the intersection of the text rectangular box and the circumscribed rectangular box; intersection is the area of ​​the intersection of the text rectangular box and the circumscribed rectangular box; SA is the area of ​​the text rectangular box; SB is the area of ​​the circumscribed rectangular box; Union is the total area of ​​the text rectangular box and the circumscribed rectangular box; iou is the intersection-union ratio of the areas of the text rectangular box and the circumscribed rectangular box.

[0117] When the area intersection-to-union ratio is less than the first preset threshold, it enters the area proportion calculation unit 206, otherwise, it is determined that the original image is an unqualified image (that is, the image uploaded by the merchant has descriptive text).

[0118] An area ratio calculation unit 206, used for summing up the areas of all the text rectangular frames within the current circumscribed rectangular frame and calculating the ratio of the summed area to the area of ​​the current circumscribed rectangular frame;

[0119] In an optional implementation, there may be two, three, ... rows of text rectangular frames in a small circular area; some of the text rectangular frames may be missed by the above method, therefore, based on the above method, it is necessary to sum up the areas of the text rectangular frames of all rows in the small circular area to obtain Sc, and calculate the area ratio A of the circumscribed rectangular frame of Sc in the small circular area;

[0120] The third judgment unit 207 is used to judge whether the area ratio is greater than the second preset threshold value, and if so, enter the judgment unit; when it is determined that the area ratio is not greater than the second preset threshold value, enter the fourth judgment unit;

[0121] It is determined whether the area ratio A is greater than a second preset threshold value. If so, it is considered that the text area detected on the white background image is text added by the merchant and is an irregular text area, and the image will be rejected, and the merchant is asked to upload it again. Otherwise, the process proceeds to the fourth determination unit 209.

[0122] The determination unit 208 is configured to determine whether the original image is an unqualified image.

[0123] The fourth judgment unit 209 is used to calculate the width and height of the white background image and the width and height of each of the text rectangular boxes; based on the width and height of the text rectangular boxes and the width and height of the white background image, it is judged whether there is a text rectangular box whose proportion in the white background image is greater than a third preset threshold value, and if so, it enters the judgment unit.

[0124] In an optional implementation, for example: a picture, the product image occupies 2 / 3 of the original picture, the text area occupies 1 / 3 of the original picture, and the text area is connected to the product image, and the text area is in a small rectangular frame. At this time, the above method cannot filter out the picture. That is, if the text detection based on pixel segmentation is directly performed on the grayscale image, what is detected is a full white area, and no text is detected; if the contour detection is performed on the grayscale image, the circumscribed rectangular frame obtained is the total frame of the product image and the text area combined (because the two are connected, what is detected is one area, and then the circumscribed rectangular frame is also one). At this time, the white background image is subjected to pixel segmentation-based text detection to obtain a text rectangular frame of the text on the white background image, but the area intersection ratio of the text rectangular frame and the circumscribed rectangular frame is less than the first preset threshold; and the area of ​​all text rectangular frames in the circumscribed rectangular frame and the ratio of the area of ​​the circumscribed rectangular frame are still less than the second preset threshold, so the above method cannot filter out the picture.

[0125] Therefore, the present invention also involves a judgment rule, that is, calculating the width and height of the white background image and calculating the width and height of each text rectangular box; judging whether the proportion of the text rectangular box in the white background image is greater than the third preset threshold according to the width and height of the text rectangular box and the width and height of the white background image, if so, it is considered that the merchant has self-Photoshopped descriptive text on the picture uploaded, and the picture will be rejected, and the merchant is asked to upload it again. Otherwise, the original picture is considered to be a transparent picture that meets the platform requirements (qualified picture).

[0126] In the present invention, the above method can effectively detect text on product images uploaded by merchants, and can locate and detect text areas of any shape (including curved, inclined, horizontal, and vertical). On the other hand, the method can also effectively distinguish between the text of the product itself and the text that is not the product itself (descriptive text added by the merchant), thereby effectively avoiding false detection caused by direct use of text detection, and can also achieve 99% accuracy and 98% recall rate of e-commerce images in this scenario.

[0127] The present invention also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned non-commodity image text detection method is implemented.

[0128] The above-mentioned software is stored in the above-mentioned storage medium, which includes but is not limited to: a CD, a floppy disk, a hard disk, an erasable memory, etc.

[0129] Beneficial effects of the present invention:

[0130] The present invention provides a method, system and computer storage medium for detecting text in non-commodity images, wherein the method performs contour detection through a grayscale image, obtains a contour area on the grayscale image and calculates a circumscribed rectangular frame of the contour area; performs pixel segmentation-based text detection through a white background image, obtains a text rectangular frame of the text on the white background image; and maps the circumscribed rectangular frame to the white background image. The above method is used to locate the text on the original image, effectively solving the problem of directly using a text detection algorithm to detect the commodity image, which causes the commodity image itself to be detected and mistakenly judged as an unqualified image, greatly improving the efficiency of manual review and saving manpower and financial resources.

[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for detecting text in non-commodity images, characterized in that: include: Step 100, obtaining an original image and performing channel extraction on the original image; Step 200, synthesizing the extracted R channel, G channel, and B channel into a white background image, and synthesizing the extracted Alpha channel into a grayscale image; Step 300, performing text detection based on pixel segmentation on the grayscale image, and when no text is detected, proceeding to step 400; Otherwise, proceed to step 800; Step 400, performing contour detection on the grayscale image to obtain a contour area on the grayscale image and calculating a circumscribed rectangular frame of the contour area; Step 500, performing pixel segmentation-based text detection on the white background image to obtain a text rectangular frame of the text on the white background image; mapping the circumscribed rectangular frame onto the white background image, and calculating the area intersection-and-union ratio of the text rectangular frame on the white background image and the circumscribed rectangular frame; when the area intersection-and-union ratio is less than a first preset threshold, proceeding to step 600; Otherwise, proceed to step 800; Step 600, summing up the areas of all text rectangular frames within the current circumscribed rectangular frame and calculating the proportion of the summed area to the area of ​​the current circumscribed rectangular frame; Step 700, determining whether the area ratio is greater than a second preset threshold, if so, proceeding to step 800; Step 800: determine whether the original image is an unqualified image.

2. The method according to claim 1, characterized in that When it is determined that the area ratio is not greater than the second preset threshold, proceed to step 900; Step 900, calculate the width and height of the white background image and the width and height of each of the text rectangular boxes; determine whether there is a text rectangular box whose proportion in the white background image is greater than a third preset threshold based on the width and height of the text rectangular box and the width and height of the white background image, and if so, proceed to step 800.

3. The method according to claim 1, characterized in that: The obtaining of the original image and performing channel extraction on the original image comprises: Get the original image; Determine whether the original image is a four-channel transparent image; if so, perform channel extraction on the original image.

4. The method according to claim 1, characterized in that: The calculation to obtain the circumscribed rectangular frame of the contour area includes: Calculating the area of ​​the contour region and filtering out the contour region whose area is smaller than a third preset threshold; The circumscribed rectangular frame of the filtered contour area is calculated.

5. The method according to claim 1, characterized in that The calculation formula for the intersection and union ratio of the area of ​​the text rectangular frame and the circumscribed rectangular frame on the white background image is: x1=max(x a1 ,x b1 ); y1=max(y a1 ,and b1 ); x2=max(x a2 ,x b2 ); y2=max(y a2 ,and b2 ); intersection=max(x2-x1+1.0,0)*max(y2-y1+1.0,0); AT=(x a2 -x a1 +1.0*(y a2 -y a1 +1.0); SB=(x b2 -x b1 +1.0)*(and b2 -and b1 +1.0); Union = SA + SB-intersection; iou=intersection / Union; The coordinates of the text rectangle are [x a1 ,y a1 ,x a2 ,y a2 ], the coordinates of the circumscribed rectangular frame are [x b1 ,y b1 ,x b2 ,y b2 ], x1, y1 are the coordinates of the upper left corner of the intersection of the text rectangular box and the outer rectangular box; x2, y2 are the coordinates of the lower right corner of the intersection of the text rectangular box and the outer rectangular box; intersection is the area of ​​the intersection of the text rectangular box and the outer rectangular box; SA is the area of ​​the text rectangular box; SB is the area of ​​the outer rectangular box; Union is the total area of ​​the text rectangular box and the outer rectangular box; iou is the intersection-union ratio of the areas of the text rectangular box and the outer rectangular box.

6. The method according to claim 1, characterized in that The step of performing pixel-based segmentation text detection on the grayscale image comprises: Performing image scaling on the grayscale image; The scaled grayscale image is input into a pre-trained text detection model to perform text detection based on pixel segmentation.

7. A non-commodity image text detection system, characterized in that: include: An acquisition unit, used for acquiring an original image and performing channel extraction on the original image; A synthesis unit, used for synthesizing the extracted R channel, G channel, and B channel into a white background image, and synthesizing the extracted Alpha channel into a grayscale image; A first judgment unit is used to perform text detection based on pixel segmentation on the grayscale image, and enter the contour detection unit when no text is detected; Otherwise, it enters the judgment unit; A contour detection unit, used to perform contour detection on the grayscale image, obtain a contour area on the grayscale image and calculate a circumscribed rectangular frame of the contour area; The second judgment unit is used to perform pixel segmentation-based text detection on the white background image to obtain a text rectangular frame of the text on the white background image; map the circumscribed rectangular frame onto the white background image, and calculate the area intersection and union ratio of the text rectangular frame on the white background image and the circumscribed rectangular frame; when the area intersection and union ratio is less than a first preset threshold, enter the area proportion calculation unit; otherwise, enter the judgment unit; An area ratio calculation unit, used for summing up the areas of all text rectangular frames within a current circumscribed rectangular frame and calculating the ratio of the summed area to the area of ​​the current circumscribed rectangular frame; A third judging unit is used to judge whether the area ratio is greater than a second preset threshold, and if so, enter the judging unit; A determination unit is used to determine whether the original image is an unqualified image.

8. The system according to claim 7, characterized in that When it is determined that the area ratio is not greater than the second preset threshold, entering the fourth judgment unit; A fourth judgment unit, used to calculate the width and height of the white background image and the width and height of each of the character rectangular frames; According to the width and height of the text rectangular frame and the width and height of the white background image, it is determined whether the proportion of the text rectangular frame in the white background image is greater than a third preset threshold. If so, the determination unit is entered.

9. The system according to claim 7, characterized in that The acquisition unit comprises: The acquisition subunit is used to acquire the original image; The judging subunit is used to judge whether the original image is a four-channel transparent image; if so, perform channel extraction on the original image.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the non-commodity image text detection method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Conference video mosaic detection method based on circumscribed rectangles

    CN106780529A

  • Commodity price tag character accurate detection positioning system and positioning method

    CN111027554A