Text area segmentation method, device, electronic device and storage medium

By extracting the pixel feature values ​​and gradient peak positions in the frame image, the segmentation position of the text area is filtered out, which solves the problem of difficult segmentation of text areas in video content and improves the efficiency and effect of text filtering.

CN114140798BActive Publication Date: 2024-09-27BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111470610.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-03
Publication Date
2024-09-27
Estimated Expiration
2041-12-03

AI Technical Summary

Technical Problem

The existing technology is difficult to effectively segment text areas in video content, resulting in indistinguishability and low filtering efficiency before text filtering.

Method used

By extracting the pixel feature values ​​in the frame image, calculating the gradient and identifying the gradient peak position, and counting the number of pixels, the segmentation position of the text area is screened out, and the text area is segmented along the segmentation position.

Benefits of technology

It achieves accurate segmentation of text areas, provides a basis for subsequent text filtering, reduces the calculation amount of text filtering, and optimizes the filtering effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114140798B
    Figure CN114140798B
Patent Text Reader

Abstract

The embodiment of the present invention provides a method and device for segmenting a text area, wherein the method includes: obtaining a frame image containing a text area; extracting the characteristic value of each pixel in the frame image; calculating the gradient of each pixel according to the characteristic value, and identifying the frame image position from the frame image; counting the number of pixels corresponding to the gradient peak in the frame image position; filtering the segmentation position of the text area from the frame image position according to the number of pixels; and segmenting the text area along the segmentation position. The embodiment of the present invention realizes the preliminary determination of the row position or column position of the text area based on the characteristic value of the pixel in the frame image, and then filtering the segmentation position from the preliminary determined row position or column position, and segmenting the text area along the segmentation position, providing a filtering basis for subsequent filtering of the text in the text area, so as to filter the segmented text area in a targeted manner, reduce the calculation amount of text filtering, and optimize the effect of text filtering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a text area segmentation method and device, as well as an electronic device and a computer-readable storage medium. Background Art

[0002] With the rapid development of the Internet and computer technology, there are a lot of video content on traditional TV stations and the Internet. In order to help users understand the video content, corresponding texts can usually be set for the video content, for example, displaying dialogue text and non-dialogue text in variety shows.

[0003] However, when there are a lot of texts in the video content, the texts may interfere with each other. For example, the non-dialogue texts in variety shows will interfere with the dialogue texts. Therefore, it is necessary to filter the texts in the video content to display more valuable texts. Before text filtering, each text needs to be segmented. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to provide a method and device for segmenting a text region, as well as an electronic device and a computer-readable storage medium, which solve the problem of how to segment a text region. The specific technical solution is as follows:

[0005] In the first aspect of the implementation of the present invention, a method for segmenting a text area is first provided, comprising: obtaining a frame image to be identified, the frame image containing a text area; extracting feature values ​​of each pixel in the frame image; calculating the gradient of each pixel based on the feature values, and identifying the frame image position corresponding to the gradient peak in each gradient from the frame image; counting the number of pixels corresponding to the gradient peak in the frame image position; filtering out the segmentation position of the text area from the frame image position based on the number of pixels; and segmenting the text area along the segmentation position.

[0006] Optionally, filtering out the segmentation position of the text area from the frame image position according to the number of pixel points includes: determining whether there are at least two frame image positions whose numbers of pixel points are greater than a preset threshold and both are located on the same side of the central axis of the text area; if there are at least two frame image positions whose numbers of pixel points are greater than a preset threshold and both are located on the same side of the central axis of the text area, then using the frame image position closer to the central axis among the at least two frame image positions as the segmentation position.

[0007] Optionally, identifying from the frame image the frame image positions corresponding to the gradient peaks in each of the gradients, includes: when the frame image contains at least one of the text areas, for at least one of the text areas whose text display direction is horizontal, identifying at least one row position corresponding to the gradient peaks in each of the gradients; when the frame image contains at least one of the text areas, for at least one of the text areas whose text display direction is vertical, identifying at least one column position corresponding to the gradient peaks in each of the gradients.

[0008] Optionally, the identifying of at least one row position corresponding to a gradient peak in each of the gradients includes: when the gradient peak is a positive gradient peak, identifying the upper boundary of the text area with a horizontal text display direction; when the gradient peak is a negative gradient peak, identifying the lower boundary of the text area with a horizontal text display direction; the identifying of at least one column position corresponding to a gradient peak in each of the gradients includes: when the gradient peak is a positive gradient peak, identifying the right boundary of the text area with a vertical text display direction; when the gradient peak is a negative gradient peak, identifying the left boundary of the text area with a vertical text display direction.

[0009] Optionally, counting the number of pixel points corresponding to the gradient peak value in the frame image position includes: counting the number of pixel points in a preset surrounding area of ​​the pixel point corresponding to the gradient peak value.

[0010] Optionally, the preset threshold is an empirical value, or the preset threshold is the difference between the current number of pixel points and the previous or first number of pixel points after the plurality of pixel point numbers are sorted.

[0011] Optionally, extracting the characteristic value of each pixel in the frame image includes: extracting the grayscale characteristic value of each pixel in the frame image.

[0012] In the second aspect of the implementation of the present invention, there is also provided a device for segmenting a text area, comprising: an image acquisition module, used to acquire a frame image to be identified, the frame image containing a text area; a feature extraction module, used to extract feature values ​​of each pixel in the frame image; a position identification module, used to calculate the gradient of each pixel based on the feature value, and identify the frame image position corresponding to the gradient peak in each gradient from the frame image; a quantity counting module, used to count the number of pixels corresponding to the gradient peak in the frame image position; a position screening module, used to screen out the segmentation position of the text area from the frame image position based on the pixel point; and a region segmentation module, used to segment the text area along the segmentation position.

[0013] Optionally, the position screening module includes: a position judgment module, used to judge whether there are at least two frame image positions whose number of pixel points is greater than a preset threshold and both are located on the same side of the central axis of the text area; a position confirmation module, used to use the frame image position closer to the central axis among the at least two frame image positions as the segmentation position if there are at least two frame image positions whose number of pixel points is greater than a preset threshold and both are located on the same side of the central axis of the text area.

[0014] Optionally, the position identification module is used to, when the frame image contains at least one text area, identify at least one row position corresponding to a gradient peak in each of the gradients for at least one text area whose text display direction is horizontal; when the frame image contains at least one text area, identify at least one column position corresponding to a gradient peak in each of the gradients for at least one text area whose text display direction is vertical.

[0015] Optionally, the position identification module is used to identify the upper boundary of the text area with a horizontal text display direction when the gradient peak is a positive gradient peak; and to identify the lower boundary of the text area with a horizontal text display direction when the gradient peak is a negative gradient peak. The position identification module is also used to identify the right boundary of the text area with a vertical text display direction when the gradient peak is a positive gradient peak; and to identify the left boundary of the text area with a vertical text display direction when the gradient peak is a negative gradient peak.

[0016] Optionally, the quantity counting module is used to count the number of pixel points in a preset surrounding area of ​​the pixel point corresponding to the gradient peak.

[0017] Optionally, the preset threshold is an empirical value, or the preset threshold is the difference between the current number of pixel points and the previous or first number of pixel points after the plurality of pixel point numbers are sorted.

[0018] Optionally, the feature extraction module is used to extract the grayscale feature value of each pixel in the frame image.

[0019] In another aspect of the present invention, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes any of the above-mentioned methods for segmenting a text region.

[0020] In yet another aspect of the present invention, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute any of the above-mentioned methods for segmenting a text region.

[0021] The text area segmentation scheme provided by the embodiment of the present invention extracts the characteristic value of each pixel point from the frame image containing the text area, calculates the gradient of each pixel point according to the characteristic value, identifies the frame image position corresponding to the gradient peak value in each gradient from the frame image, counts the number of pixels points corresponding to the gradient peak value in the frame image position, and then screens the segmentation position of the text area from the frame image position according to the number of pixels points, and finally segments the text area along the segmentation position. The text area is segmented along the segmentation position by preliminarily determining the row position or column position of the text area based on the characteristic value of the pixel point in the frame image, and then screening the segmentation position from the preliminarily determined row position or column position, and segmenting the text area along the segmentation position, which can provide a filtering basis for subsequent filtering of the text in the text area, and can solve the technical problem that the text area cannot be segmented before the existing text filtering, so as to filter the segmented text area in a targeted manner, reduce the calculation amount of text filtering, and optimize the effect of text filtering. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0023] Figure 1 The present invention is a flowchart of a method for segmenting a text region according to an embodiment of the present invention.

[0024] Figure 2 The present invention is a flowchart of a method for preprocessing dialogue filtering in variety show video data according to an embodiment of the present invention.

[0025] Figure 3 It is a schematic diagram of segmentation results of a horizontal text area according to an embodiment of the present invention.

[0026] Figure 4 It is a schematic diagram of another segmentation result of a horizontal text area according to an embodiment of the present invention.

[0027] Figure 5 The figure is a schematic diagram of a segmentation result of a vertical text area according to an embodiment of the present invention.

[0028] Figure 6 It is a schematic diagram of another segmentation result of a vertical text area according to an embodiment of the present invention.

[0029] Figure 7 The figure is a schematic diagram of the structure of a text region segmentation device according to an embodiment of the present invention.

[0030] Figure 8 The figure is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention.

[0031] Fig. 9The present invention is a schematic diagram of the working process of a system for recognizing subtitles of lines in audio and video files according to an embodiment of the present invention. DETAILED DESCRIPTION

[0032] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0033] An embodiment of the present invention proposes a text area segmentation scheme. First, the feature value of each pixel point in a frame image containing a text area is extracted, and then the gradient of each pixel point is calculated based on the feature value, and the frame image position corresponding to the gradient peak is identified from the frame image, and then the number of pixel points corresponding to the gradient peak in the frame image is counted, and the segmentation position of the text area is screened out from the frame image position according to the number of pixel points. Finally, the text area is segmented along the segmentation position to provide a filtering basis for subsequent filtering of text in the text area.

[0034] like Figure 1 As shown, a flowchart of a method for segmenting a text area according to an embodiment of the present invention is shown. The method for segmenting a text area can be applied to a terminal or a server. The method for segmenting a text area can specifically include the following steps.

[0035] Step 101: Obtain a frame image to be recognized.

[0036] In an embodiment of the present invention, the frame image may be derived from video data or audio and video data. In practical applications, the frame image may be a frame image of video data or audio and video data. Moreover, the frame image may include a text area. The text area may be understood as an area where text content in a frame image is located. In one embodiment, the frame image may include one text area or multiple text areas.

[0037] Step 102: extracting the feature value of each pixel in the frame image.

[0038] In an embodiment of the present invention, the frame image may be input into a pre-trained network model, and then the network model may be used to extract the feature value of each pixel in the frame image.

[0039] Step 103, calculating the gradient of each pixel point according to the characteristic value, and identifying the frame image position corresponding to the gradient peak in each gradient from the frame image.

[0040] In an embodiment of the present invention, the gradient of each pixel point in the positive direction and the gradient in the negative direction can be calculated based on the characteristic value of each pixel point, and then the gradient in the positive direction and the gradient in the negative direction determine the gradient peak in each direction, and then the frame image position corresponding to the gradient peak is identified from the frame image.

[0041] Step 104: Count the number of pixels corresponding to the gradient peak in the frame image position.

[0042] In the embodiment of the present invention, the number of pixel points in a preset surrounding area may be counted with the pixel point corresponding to the gradient peak value as the center in the frame image position.

[0043] Step 105 , filtering out the segmentation position of the text area from the frame image position according to the number of pixels.

[0044] In the embodiment of the present invention, the segmentation position can be screened out from the frame image position according to the number of pixels, a preset threshold, and the positional relationship between the frame image position and the central axis of the text area.

[0045] Step 106, segment the text area along the segmentation position.

[0046] In the embodiment of the present invention, the text region may be divided left and right or up and down along the division position, that is, one text region may be divided into two left and right text regions or two up and down text regions along the division position.

[0047] The text area segmentation scheme provided by the embodiment of the present invention extracts the characteristic value of each pixel point from the frame image containing the text area, calculates the gradient of each pixel point according to the characteristic value, identifies the frame image position corresponding to the gradient peak value in each gradient from the frame image, counts the number of pixels points corresponding to the gradient peak value in the frame image position, and then screens the segmentation position of the text area from the frame image position according to the number of pixels points, and finally segments the text area along the segmentation position. The text area is segmented along the segmentation position by preliminarily determining the row position or column position of the text area based on the characteristic value of the pixel point in the frame image, and then screening the segmentation position from the preliminarily determined row position or column position, and segmenting the text area along the segmentation position, which can provide a filtering basis for subsequent filtering of the text in the text area, and can solve the technical problem that the text area cannot be segmented before the existing text filtering, so as to filter the segmented text area in a targeted manner, reduce the calculation amount of text filtering, and optimize the effect of text filtering.

[0048] In an exemplary embodiment of the present invention, an implementation method of selecting the segmentation position of the text area from the frame image position according to the number of pixels is to determine whether there are at least two frame image positions whose number of pixels is greater than a preset threshold and both are located on the same side of the central axis of the text area; if there are at least two frame image positions whose number of pixels is greater than the preset threshold and both are located on the same side of the central axis of the text area, then the frame image position close to the central axis of the at least two frame image positions is used as the segmentation position. For example, there are frame image positions U1, U2, U3, U4 and U5. If the number of pixels of frame image positions U1 and U2 is greater than the preset threshold, and frame image positions U1 and U2 are located on the same side of the central axis of the text area. Among frame image positions U1 and U2, frame image position U1 is closer to the central axis of the text area, then frame image position U1 is used as the segmentation position of the text area. The above-mentioned preset threshold value can be a pre-set empirical value, or the above-mentioned preset threshold value can be the difference between the number of pixels corresponding to the gradient peak values ​​in the current frame image position after sorting the number of pixels corresponding to the gradient peak values ​​in each frame image position and the number of pixels in the first position or the number of pixels in the previous position.

[0049] In an exemplary embodiment of the present invention, the frame image may include at least one text area, and the text display direction in the text area can generally be divided into two directions: horizontal and vertical. Therefore, one implementation method of identifying the frame image position corresponding to the gradient peak in each gradient from the frame image is that when the frame image includes at least one text area, for at least one text area with a horizontal text display direction, at least one row position corresponding to the gradient peak in each gradient is identified. It should be noted that the row position in this implementation method can be a horizontal row position, or a row position at a certain angle to the horizontal row position. Another implementation method of identifying the frame image position corresponding to the gradient peak in each gradient from the frame image is that when the frame image includes at least one text area, for at least one text area with a vertical text display direction, at least one column position corresponding to the gradient peak in each gradient is identified. It should be noted that the column position in this implementation method can be a vertical column position, or a column position at a certain angle to the vertical column position.

[0050] In an exemplary embodiment of the present invention, since the gradient is a vector, it includes a gradient in a positive direction and a gradient in a negative direction. In practical applications, if the text display direction in the text area is horizontal, then one implementation method for identifying at least one row position corresponding to the gradient peak in each gradient is, when the gradient peak is a positive gradient peak, the upper boundary of the text area with a horizontal text display direction is identified; when the gradient peak is a negative gradient peak, the lower boundary of the text area with a horizontal text display direction is identified. If the text display direction in the text area is vertical, then one implementation method for identifying at least one column position corresponding to the gradient peak in each gradient is, when the gradient peak is a positive gradient peak, the right boundary of the text area with a vertical text display direction is identified; when the gradient peak is a negative gradient peak, the left boundary of the text area with a vertical text display direction is identified.

[0051] In an exemplary embodiment of the present invention, one implementation method of counting the number of pixels corresponding to the gradient peak value in the frame image position is to count the number of pixels in a preset surrounding area of ​​the pixel corresponding to the gradient peak value in the frame image position. As can be seen from the above, the frame image position can be the upper boundary, lower boundary, left boundary or right boundary of the text area. For example, the frame image position U is the upper boundary of the text area. For the pixel point d corresponding to the gradient peak value of the frame image position U, in the preset surrounding area [d xy -dis,d xy +dis] to obtain the number of pixels UX. xy represents the horizontal coordinate value and the vertical coordinate value of the pixel point d, and dis represents the preset coordinate threshold.

[0052] In an exemplary embodiment of the present invention, one implementation method of extracting the feature value of each pixel in the frame image is to extract the gray feature value of each pixel in the frame image. In practical applications, the frame image can be a gray image or an RGB image. If the frame image is an RGB image, the RGB image can be further converted into a gray image, and then the gray feature value of each pixel in the frame image is extracted.

[0053] Based on the above description of the text area segmentation method embodiment, a method for preprocessing dialogue filtering in variety show video data is introduced below. Figure 2 As shown, Figure 2 A flowchart of the steps of a method for preprocessing dialogue filtering in variety show video data is shown.

[0054] A text detection image containing a text area is obtained. The text detection image may be a frame image in the above embodiment. The text detection image contains a text area, and the text area may contain a line text content and a non-line text content, or the text area contains a line text content and does not contain a non-line text content. The purpose of the line filtering preprocessing method is to identify the approximate range of the line text content and the approximate range of the non-line text content in the text detection image, and provide a filtering basis for subsequent line filtering. The grayscale feature value of each pixel in the text detection image is obtained, and the gradient of each pixel is calculated according to the grayscale feature value, and then a plurality of frame image positions are identified from the text detection image. Specifically, the plurality of frame image positions may correspond to the left boundary, the right boundary, the middle column and other positions of the text area. If the above identification obtains the frame image positions B1, B2, and B3, the number of pixels Bs1, Bs2, and Bs3 corresponding to the gradient peak in the frame image positions B1, B2, and B3 are respectively counted. According to the number of pixels Bs1, Bs2, Bs3 and the preset threshold BM, a segmentation position is selected from the frame image positions B1, B2, B3, and the segmentation position is the frame image position B1. Then, the text area is segmented along the segmentation position B1 to obtain a first text area and a second text area.

[0055] It should be noted that the text display direction in the text area in the text detection image can be horizontal or vertical. When the text display direction is horizontal, the segmentation position can be a segmentation column, and the number of segmentation positions can be one or more. Figure 3 , shows a schematic diagram of a segmentation result of a horizontal text area according to an embodiment of the present invention. Figure 3 In the example, the text area is divided into a group name text area, a person name text area, and a dialogue text area by segmentation columns L1 and L2. The group name text area contains group text content, the person name text area contains the person name text content, and the dialogue text area contains the dialogue text content. Figure 4 , shows another schematic diagram of the segmentation result of the horizontal text area according to an embodiment of the present invention. Figure 4 In the example, the text area is divided into a name text area and a line text area by a segmentation column L3. The name text area contains name text content, and the line text area contains line text content. When the text display direction is vertical, the segmentation position can be a segmentation line, and the number of segmentation positions can be one or more. Figure 5 , which shows a schematic diagram of a segmentation result of a vertical text area according to an embodiment of the present invention. Figure 5 In FIG. 1 , the text area is divided into a group name text area, a person name text area, and a dialogue text area by dividing lines L4 and L5. The group name text area contains group text content, the person name text area contains the person name text content, and the dialogue text area contains the dialogue text content. Figure 6 , shows another schematic diagram of the segmentation result of the vertical text area according to an embodiment of the present invention. Figure 6 In FIG. 1 , the text area is divided into a name text area and a dialogue text area by a segmentation line L6 . The name text area contains the name text content, and the dialogue text area contains the dialogue text content.

[0056] When a heatmap is subsequently generated for the dialogue text content of the first text region or the second text region, several pixel points (eg, 10 pixel points) near the segmentation position may not be included in the heatmap statistics.

[0057] like Figure 7 FIG. 2 is a schematic diagram showing a structure of a text region segmentation device according to an embodiment of the present invention. The text region segmentation device may include the following modules.

[0058] An image acquisition module 71 is used to acquire a frame image to be recognized, wherein the frame image contains a text area;

[0059] A feature extraction module 72, used to extract the feature value of each pixel in the frame image;

[0060] A position identification module 73, used for calculating the gradient of each pixel point according to the characteristic value, and identifying the frame image position corresponding to the gradient peak value in each gradient from the frame image;

[0061] A quantity counting module 74, used for counting the number of pixel points corresponding to the gradient peak value in the frame image position;

[0062] A position screening module 75, configured to screen out the segmentation position of the text area from the frame image position according to the pixel points;

[0063] The region segmentation module 76 is used to segment the text region along the segmentation position.

[0064] In a preferred embodiment of the present invention, the position screening module 75 includes:

[0065] A position determination module, used to determine whether there are at least two positions of the frame image whose number of pixels is greater than a preset threshold and both are located on the same side of the central axis of the text area;

[0066] A position confirmation module is used to use the frame image position closer to the central axis among the at least two frame image positions as the segmentation position if there are at least two frame image positions whose number of pixel points is greater than a preset threshold and both are located on the same side of the central axis of the text area.

[0067] In a preferred embodiment of the present invention, the position identification module 73 is used to, when the frame image contains at least one text area, identify at least one row position corresponding to a gradient peak in each of the gradients for at least one text area with a horizontal text display direction; when the frame image contains at least one text area, identify at least one column position corresponding to a gradient peak in each of the gradients for at least one text area with a vertical text display direction.

[0068] In a preferred embodiment of the present invention, the position identification module 73 is used to identify the upper boundary of the text area whose text display direction is horizontal when the gradient peak is a positive gradient peak; and to identify the lower boundary of the text area whose text display direction is horizontal when the gradient peak is a negative gradient peak;

[0069] The position identification module 73 is also used to identify the right boundary of the text area with a vertical text display direction when the gradient peak is a positive gradient peak; and to identify the left boundary of the text area with a vertical text display direction when the gradient peak is a negative gradient peak.

[0070] In a preferred embodiment of the present invention, the quantity counting module 74 is used to count the number of pixel points in a preset surrounding area of ​​the pixel point corresponding to the gradient peak value.

[0071] In a preferred embodiment of the present invention, the preset threshold is an empirical value, or the preset threshold is the difference between the current number of pixel points and the previous or first number of pixel points after sorting the plurality of pixel point numbers.

[0072] In a preferred embodiment of the present invention, the feature extraction module 72 is used to extract the grayscale feature value of each pixel in the frame image.

[0073] The embodiment of the present invention further provides an electronic device, such as Figure 8 As shown, it includes a processor 81, a communication interface 82, a memory 83 and a communication bus 84, wherein the processor 81, the communication interface 82, and the memory 83 communicate with each other through the communication bus 84.

[0074] A memory 83, for storing computer programs;

[0075] The processor 81 is used to execute the program stored in the memory 83 to implement the following steps:

[0076] Acquire a frame image to be recognized, wherein the frame image contains a text area;

[0077] Extracting feature values ​​of each pixel in the frame image;

[0078] Calculate the gradient of each pixel point according to the characteristic value, and identify the frame image position corresponding to the gradient peak value in each gradient from the frame image;

[0079] Counting the number of pixel points corresponding to the gradient peak in the frame image position;

[0080] Filtering the segmentation position of the text area from the frame image position according to the number of pixels;

[0081] The text area is segmented along the segmentation position.

[0082] The step of selecting the segmentation position of the text area from the frame image position according to the number of pixels includes:

[0083] Determine whether there are at least two positions of the frame image whose number of pixel points is greater than a preset threshold and both are located on the same side of the central axis of the text area;

[0084] If there are at least two frame image positions whose number of pixels is greater than a preset threshold and both are located on the same side of the central axis of the text area, the frame image position close to the central axis among the at least two frame image positions is used as the segmentation position.

[0085] The step of identifying, from the frame image, a frame image position corresponding to a gradient peak value in each gradient, comprises:

[0086] When the frame image includes at least one text area, for at least one text area in which the text display direction is horizontal, identifying at least one row position corresponding to a gradient peak value in each of the gradients;

[0087] When the frame image includes at least one text area, for at least one text area in which the text display direction is vertical, at least one column position corresponding to a gradient peak value in each gradient is identified.

[0088] The identifying at least one row position corresponding to a gradient peak in each of the gradients comprises:

[0089] When the gradient peak is a positive gradient peak, identifying an upper boundary of a text area whose text display direction is horizontal;

[0090] When the gradient peak is a negative gradient peak, identifying a lower boundary of a text area in which the text display direction is horizontal;

[0091] The identifying at least one column position corresponding to a gradient peak in each of the gradients comprises:

[0092] When the gradient peak is a positive gradient peak, identifying a right boundary of a text area whose text display direction is vertical;

[0093] When the gradient peak is a negative gradient peak, a left boundary of a text area whose text display direction is vertical is identified.

[0094] The counting of the number of pixel points corresponding to the gradient peak value in the frame image position includes:

[0095] The number of pixels in a preset surrounding area of ​​the pixel corresponding to the gradient peak is counted.

[0096] The preset threshold is an empirical value, or the preset threshold is the difference between the current number of pixel points and the previous or first number of pixel points after the plurality of numbers of pixel points are sorted.

[0097] The extracting the characteristic value of each pixel in the frame image includes:

[0098] Extract the grayscale feature value of each pixel in the frame image.

[0099] Based on the description of the above-mentioned text region segmentation method and device and other embodiments, a system for recognizing subtitles in audio and video files is introduced below. The recognition system can be composed of hardware devices such as a personal computer or a server, a server cluster, etc. A subtitle detection framework is deployed in the recognition system, and the subtitle detection framework mainly includes a subtitle detection model, a subtitle filtering model, a subtitle tracking model, and a text classification model.

[0100] Reference Fig. 9 , shows a schematic diagram of the workflow of a system for recognizing lines and subtitles in an audio and video file according to an embodiment of the present invention. In actual application, a complete audio and video file is input into the recognition system, and a graphics processing unit (GPU) of a hardware device is used to extract video frame results from the audio and video file. The specific video frame results may be partial frame images and full frame images. Among them, the partial frame images may be three frames of images extracted from a 1-second time period of the audio and video file. In order to reduce the amount of computation required for extracting the video frame results, extraction processing may be performed on partial video frame images of the audio and video file, for example, only the lower 1 / 3 of the video frame image may be extracted. The extracted partial frame images may be continuously written into a memory queue. The extracted full frame images may be stored in a hard disk.

[0101] Based on multi-threading, multiple dialogue subtitle detection models are started, partial frame images are continuously read from the memory queue, and the read partial frame images are spliced. For example, three consecutive partial frame images are spliced ​​into one frame image. The dialogue subtitle detection model locates the positions of all text boxes from the spliced ​​frame images.

[0102] The dialogue subtitle filtering model counts the frequency of all text boxes appearing in the time draw, determines a high-frequency heat map area based on the frequency, and then uses the high-frequency heat map area as the filtering standard area for dialogue subtitles and non-dialogue subtitles, and uses the filtering standard area to filter all text boxes into dialogue subtitle text boxes and non-dialogue subtitle text boxes. Among them, non-dialogue subtitle text boxes are discarded and do not participate in subsequent processing.

[0103] The dialogue and subtitle tracking model extracts the deep features of optical character recognition (OCR) from the dialogue and subtitle text boxes, and performs tracking processing based on the full frame images stored in the hard disk to obtain the start and end time information of each dialogue and subtitle text box in the audio and video files.

[0104] The text classification model determines the language information corresponding to each subtitle text box, and transmits the deep features to the corresponding OCR prediction network according to the language information. The OCR prediction network uses its own text recognition algorithm to recognize the subtitles in the subtitle text box to obtain the subtitle results. For example, the language information can be Chinese or English. The Chinese language corresponds to the Chinese OCR prediction network, and the English language corresponds to the English OCR prediction network.

[0105] The recognition system provided by the embodiment of the present invention constructs a software development kit (SDK) for line and subtitle frame-level recognition. For the same audio and video file, the ratio of the time for line and subtitle recognition on the GPU to the time for line and subtitle recognition through the SDK is about 1:0.11, which greatly improves the speed and accuracy of line and subtitle recognition. Based on the line results obtained by recognition, external subtitles of audio and video files can be generated, and embedded subtitles of audio and video files can be quickly converted into external subtitles.

[0106] The recognition system provided by the embodiment of the present invention uses the time domain information of the text box to filter the text box into a line subtitle text box and a non-line subtitle text box when filtering the text box, and the accuracy of text box filtering is very high. When the audio and video file is a film and television work, the filtering accuracy exceeds 99%; when the audio and video file is a variety show, the filtering accuracy exceeds 98.5%.

[0107] The recognition system provided by the embodiment of the present invention can also extract video frames for designated areas such as name strips, lyric boards and lyrics in variety shows, and then perform processes such as positioning, filtering, tracking, classification and recognition of names, lyrics, etc., thereby realizing text recognition of names, lyrics, etc.

[0108] The recognition system provided by the embodiment of the present invention can not only recognize the lines and subtitles in Chinese and English, but also realize the intelligent recognition of the lines and subtitles in Chinese and English, Chinese and Japanese, Chinese and Korean, etc. in dual-audio and video files, and supports the recognition of lines and subtitles in multi-language audio and video files.

[0109] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0110] The communication interface is used for communication between the above terminal and other devices.

[0111] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0112] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0113] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions. When the instructions are executed on a computer, the computer executes the text region segmentation method described in any of the above embodiments.

[0114] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the text region segmentation method described in any one of the above embodiments.

[0115] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0116] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants 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, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0117] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system 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.

[0118] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A text region segmentation method, characterized in that: include: Acquire a frame image to be recognized, wherein the frame image contains a text area; Extracting feature values ​​of each pixel in the frame image; Calculating the gradient of each pixel point according to the characteristic value, when the frame image includes at least one text area, for at least one text area whose text display direction is horizontal, identifying at least one row position corresponding to a gradient peak value in each gradient; when the frame image includes at least one text area, for at least one text area whose text display direction is vertical, identifying at least one column position corresponding to a gradient peak value in each gradient; Counting the number of pixel points corresponding to the gradient peak in the frame image position; Determine whether there are at least two frame image positions whose numbers of pixel points corresponding to the gradient peaks are greater than a preset threshold and both are located on the same side of the central axis of the text area; if there are at least two frame image positions whose numbers of pixel points corresponding to the gradient peaks are greater than the preset threshold and both are located on the same side of the central axis of the text area, use the frame image position close to the central axis among the at least two frame image positions as the segmentation position; The text area is segmented along the segmentation position.

2. The method according to claim 1, characterized in that: The identifying at least one row position corresponding to a gradient peak in each of the gradients comprises: When the gradient peak is a positive gradient peak, identifying an upper boundary of a text area whose text display direction is horizontal; When the gradient peak is a negative gradient peak, identifying a lower boundary of a text area in which the text display direction is horizontal; The identifying at least one column position corresponding to a gradient peak in each of the gradients comprises: When the gradient peak is a positive gradient peak, identifying a right boundary of a text area whose text display direction is vertical; When the gradient peak is a negative gradient peak, a left boundary of a text area whose text display direction is vertical is identified.

3. The method according to claim 1, characterized in that The counting of the number of pixel points corresponding to the gradient peak value in the frame image position includes: The number of pixels in a preset surrounding area of ​​the pixel corresponding to the gradient peak is counted.

4. The method according to claim 1, characterized in that: The preset threshold is an empirical value, or the preset threshold is the difference between the current number of pixel points and the previous or first number of pixel points after the plurality of numbers of pixel points are sorted.

5. The method according to claim 1, characterized in that The extracting the characteristic value of each pixel in the frame image includes: Extract the grayscale feature value of each pixel in the frame image.

6. A text region segmentation device, characterized in that: include: An image acquisition module, used for acquiring a frame image to be recognized, wherein the frame image contains a text area; A feature extraction module, used to extract the feature value of each pixel in the frame image; a position identification module, configured to calculate the gradient of each pixel point according to the feature value, and when the frame image includes at least one text area, for at least one text area with a horizontal text display direction, identify at least one row position corresponding to a gradient peak value in each gradient; when the frame image includes at least one text area, for at least one text area with a vertical text display direction, identify at least one column position corresponding to a gradient peak value in each gradient; A quantity statistics module, used for counting the number of pixel points corresponding to the gradient peak value in the frame image position; a position screening module, used to determine whether there are at least two frame image positions whose numbers of pixel points corresponding to the gradient peaks are greater than a preset threshold and both are located on the same side of the central axis of the text area; if there are at least two frame image positions whose numbers of pixel points corresponding to the gradient peaks are greater than the preset threshold and both are located on the same side of the central axis of the text area, then the frame image position of the at least two frame image positions close to the central axis is used as the segmentation position; A region segmentation module is used to segment the text region along the segmentation position.

7. 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; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 5 when executing a program stored in a memory.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.