Text detection method and device, storage medium and electronic device
By combining image verification and feature extraction in document tamper detection, using ResNeXt and DenseNet models, the problem of low accuracy of document tamper detection in the prior art is solved, and high accuracy detection of text content is achieved, especially in complex and In the case of low quality images.
Patent Information
- Application Number
- CN202411561589.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-01-10
AI Technical Summary
Existing document tamper detection technology is prone to false alarms when the image complexity or compression rate is high, and cannot effectively detect image-based text tampering, especially when the image quality is low or the font is unconventional.
By performing image verification and text type recognition on the initial image, the region of interest is determined, and the feature extraction method combined with ResNeXt and DenseNet models is used to fuse different levels of features, generate target features, predict text detection results, and improve detection accuracy with EXIF data. sex.
The accuracy and reliability of text detection are improved, and it can accurately identify whether the text content has been tampered with when the detection conditions are met, especially in the case of complex images and low-quality images.
Smart Images

Figure CN119296109A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a text detection method and device, a storage medium, and an electronic device. Background Art
[0002] The integrity and authenticity of documents are of vital importance, especially for key documents such as contracts, agreements, and identification documents, which carry important legal and business information. With the popularization of digital image processing technology, document tampering has become increasingly easy, and the traces of tampering may be so subtle that they are difficult to detect with the naked eye. Tampering behavior may focus on sensitive information such as digital amounts, names, and times, but these modified areas are often very small, and the image types are diverse, resulting in data imbalance, which poses a huge challenge to tampering detection.
[0003] Among traditional technologies, tampering detection technologies have their own limitations in different scenarios, and the detection effects are not very ideal. For example, error level analysis may produce false positives when the image complexity is high or the compression rate is large; discrete cosine transform (DCT) analysis has difficulty in providing evidence when detecting subtle tampering, and has limited effect on tampering with edge consistency; edge analysis may produce false positives due to complex images and the attacker's sophisticated technology; although optical character recognition (OCR) can effectively extract text, it relies on the authenticity and integrity of the text, cannot detect image-based text tampering, and its effect decreases when the image quality is low or the font is unconventional.
[0004] Therefore, there is an urgent need for a document detection method to overcome the above problems, improve the accuracy of detection, and meet the needs of practical applications. Summary of the invention
[0005] The embodiment of the present application provides a text detection method to at least solve the problem of low text detection accuracy in the related art.
[0006] According to an embodiment of the embodiments of the present application, a text detection method is provided, including: determining an image verification result obtained by performing image verification on the initial image when the initial image meets the detection conditions; determining a region of interest of the initial image based on the text type to which the initial image belongs, and obtaining a target image based on the region of interest; performing feature extraction processing based on the target image to obtain target features of the target image, and predicting an initial text detection result according to the target features; and obtaining a text target detection result based on the image verification result and the initial text detection result.
[0007] In an exemplary embodiment, the feature extraction processing is performed based on the target image to obtain the target feature of the target image, and the initial text detection result is predicted according to the target feature, including: determining a first initial feature of the target image, performing a preset number of feature extraction processing based on the first initial feature, and determining a second initial feature of the target image according to an output obtained from the last feature extraction processing; fusing the first initial feature and the second initial feature to obtain the target feature of the target image, and predicting the initial text detection result according to the target feature.
[0008] In an exemplary embodiment, the text detection result also includes that the text content has not been tampered with; the method also includes: when the image verification result indicates that the initial image does not have the risk of tampering, and the text initial detection result indicates that the initial image does not have the risk of tampering, determining that the text content has not been tampered with.
[0009] In an exemplary embodiment, any feature extraction processing includes: determining the input features of the feature extraction processing based on the first initial features; performing convolution processing on the input features to obtain convolution processing results; dividing the convolution processing results to obtain a first convolution processing result and a second convolution processing result; dividing based on the first convolution processing result to obtain a first sub-processing result and a second sub-processing result; dividing based on the second convolution processing result to obtain a third sub-processing result and a fourth sub-processing result; performing convolution on the third sub-processing result to obtain a third convolution sub-processing result, and performing convolution on the fourth sub-processing result to obtain a fourth convolution sub-processing result; obtaining the output of the feature extraction processing based on the first convolution processing result, the second convolution processing result, the third convolution sub-processing result and the fourth convolution sub-processing result.
[0010] In an exemplary embodiment, the output of the feature extraction processing is obtained based on the first convolution processing result, the second convolution processing result, the third convolution sub-processing result and the fourth convolution sub-processing result, including: concatenating the sum of the first convolution processing result and the third convolution sub-processing result, and the sum of the second convolution processing result and the fourth convolution sub-processing result to obtain the output of the feature extraction processing.
[0011] In an exemplary embodiment, determining whether the initial image satisfies a detection condition includes: extracting a first light and dark value and a second light and dark value in the initial image; the first light and dark value is greater than the second light and dark value; determining pixel brightness of the initial image based on the first light and dark value and the second light and dark value; and determining whether the initial image satisfies a detection condition based on the pixel brightness.
[0012] According to another embodiment of the embodiments of the present application, a text detection device is also provided, including: an acquisition module, used to acquire an initial image to be detected; the initial image is an image used to record text content; a first determination module, used to determine an image verification result obtained by performing image verification on the initial image when the initial image meets the detection conditions; a second determination module, used to determine the area of interest of the initial image based on the text type to which the initial image belongs, and obtain a target image based on the area of interest; an extraction module, used to perform feature extraction processing based on the target image, obtain target features of the target image, and predict the initial text detection result according to the target features; a detection module, used to obtain a text target detection result based on the image verification result and the initial text detection result.
[0013] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above method when running.
[0014] According to another aspect of the embodiments of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method through the computer program.
[0015] According to another aspect of the embodiments of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0016] In an embodiment of the present application, an initial image to be detected is obtained; the initial image is an image for recording text content; when the initial image meets the detection conditions, an image verification result obtained by performing image verification on the initial image is determined; based on the text type to which the initial image belongs, an area of interest of the initial image is determined, and a target image is obtained based on the area of interest; feature extraction processing is performed based on the target image to obtain target features of the target image, and an initial text detection result is predicted according to the target features; a text target detection result is obtained based on the image verification result and the initial text detection result. In the text detection process, the image verification result is determined only when the detection conditions are met, and the area of interest is further determined according to the text type to which the initial image belongs, and the target image is determined based on the area of interest. This process utilizes the features of different text types to locate key areas of the initial image, so that the initial text detection result obtained by the subsequent feature extraction process is more accurate. Finally, the image verification result and the initial text detection result are comprehensively considered to ensure the reliability of the text target detection result and improve the accuracy of text detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0018] Figure 1 It is a hardware structure block diagram of a computer terminal of a text detection method according to an embodiment of the present application;
[0019] Figure 2 is a flowchart of a text detection method according to an embodiment of the present application;
[0020] Figure 3 is a flowchart of a text detection method according to an embodiment of the present application;
[0021] Figure 4 is a flowchart of feature extraction processing according to an embodiment of the present application;
[0022] Figure 5 It is a structural block diagram of a text detection device according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices; "plurality" means two or more.
[0025] The method embodiments provided in the embodiments of the present application can be executed in a computer terminal or similar computing device or cloud platform or independent physical server or software platform, wherein the above software platform is run through one or more servers. Taking running on a computer terminal as an example, Figure 1 is a hardware structure block diagram of a text detection method according to an embodiment of the present application. Figure 1 As shown, the computer terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 and memory 104 for storing data. In an exemplary embodiment, the computer terminal may also include a transmission device 106 for communication functions and an input and output device 108, wherein the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. A person skilled in the art can understand that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer terminal. Figure 1 More or fewer components as shown, or with Figure 1 Equivalent functions or comparisons shown Figure 1 A different configuration with more features is shown.
[0026] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as computer programs corresponding to the methods in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, that is, the above-mentioned methods are implemented. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0027] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0028] In this embodiment, a text detection method is provided, which is applied to the above-mentioned computer terminal. Figure 2 : is a flowchart of a text detection method according to an embodiment of the present application, the process includes the following steps:
[0029] Step S202, obtaining an initial image to be detected; the initial image is an image used to record text content.
[0030] Among them, obtaining the initial image to be detected refers to the computer terminal receiving or actively obtaining the image files submitted by the user at the initial stage of the document tampering detection process. These image files are used to record text content, including but not limited to contracts, agreements, financial statements, identity documents, legal documents, medical records, academic papers, and any other information carriers containing text, numbers, tables or charts.
[0031] In some embodiments, the initial image may come from different channels, such as scanners, mobile phone cameras, network downloads, etc. The image format should be a common digital image format, such as JPEG, PNG or TIFF, etc., to facilitate computer terminal processing and analysis. The user or system should ensure the integrity of the image file to avoid damage or format errors during transmission or storage that affect subsequent detection results.
[0032] Step S204, when the initial image meets the detection condition, determining an image verification result obtained by performing image verification on the initial image;
[0033] Among them, the detection conditions are the conditions set to determine whether the initial image meets the quality standards, such as image resolution, clarity, brightness contrast, etc. This is usually achieved by calculating the pixel brightness contrast and size threshold of the initial image to ensure that the image has enough details and information for accurate analysis. Of course, it can also include checking whether the image is complete, without damage or cropping, to avoid missing key information or introducing unnecessary errors.
[0034] In some embodiments, when it is determined that the initial image does not meet the detection condition, the subsequent text detection process may be terminated.
[0035] In an exemplary embodiment, determining whether the initial image satisfies the detection conditions includes: extracting a first light and dark value and a second light and dark value in the initial image; the first light and dark value is greater than the second light and dark value; based on the first light and dark value and the second light and dark value, determining the pixel brightness of the initial image; based on the pixel brightness, determining whether the initial image satisfies the detection conditions.
[0036] Among them, the initial image that is too dark or too small (not clear enough) is eliminated by detecting the brightness contrast and size of the image pixels. Specifically, the first brightness value and the second brightness value can be obtained, the first brightness value is the highest brightness value in the initial image, and the second brightness value is the lowest brightness value in the initial image. The pixel brightness can be calculated based on the first brightness value and the second brightness value, and the pixel brightness is compared with the brightness threshold to determine whether the initial image meets the detection conditions. The brightness threshold can be set to 0.2, that is, when the pixel brightness is less than 0.2, it is judged that the initial image does not meet the detection conditions. The initial image that does not meet the detection conditions will directly enter the final stage of the algorithm, and the algorithm will not perform detection processing. The pixel brightness calculation formula is as follows:
[0037]
[0038] Among them, I max is the first brightness value in the initial image, I min is the second light and dark value in the initial image, C M is the pixel brightness.
[0039] It is understandable that the minimum threshold of the size of a single initial image is set to 300Kb. The brightness threshold and the minimum image size threshold are both adjustable parameters of this application. Different parameters can be selected according to actual conditions to adjust the screening conditions of the subsequent detection algorithm and expand or reduce the detectable image range.
[0040] In some embodiments, image verification may refer to the process of verifying the initial image through EXIF (Exchangeable Image FileFormat) to determine whether the image has been edited. When verifying the initial image through EXIF, metadata may be embedded in the initial image, and the metadata includes shooting date and time, camera brand and model, image resolution, color space information, exposure time, aperture value, ISO sensitivity, focal length, shutter speed, flash status, etc. These metadata provide detailed information about the initial image generation environment and process, which can be used to assist in detecting whether the initial image has been edited or tampered with.
[0041] Step S206, determining a region of interest of the initial image based on the text type to which the initial image belongs, and obtaining a target image based on the region of interest;
[0042] The region of interest is a key area set in advance according to the text type. Subsequent feature extraction based on the key area can obtain more accurate text features. The text type can be the type of text content in the initial image, such as text, table, contract, etc. When the text content in the initial image is text, Arabic numerals and Chinese capital letters are used as key points to determine the region of interest; when the initial image is a table, the entire image is used as the key point to determine the region of interest. After obtaining the region of interest, the initial image and the region of interest of the initial image, the two contents, can be integrated into a new target image as input for the subsequent feature extraction processing step.
[0043] Step S208, performing feature extraction processing based on the target image to obtain target features of the target image, and predicting initial text detection results according to the target features.
[0044] In some exemplary embodiments, the feature extraction processing is performed based on the target image to obtain the target feature of the target image, and the initial text detection result is predicted according to the target feature, including: determining a first initial feature of the target image, performing a preset number of feature extraction processing based on the first initial feature, and determining a second initial feature of the target image according to an output obtained from the last feature extraction processing; fusing the first initial feature and the second initial feature to obtain the target feature of the target image, and predicting the initial text detection result according to the target feature.
[0045] It should be noted that in the feature extraction process, a neural network model combining ResNeXt (deep learning model) and DenseNet (deep learning model) can be used.
[0046] Among them, the first initial feature is the feature extracted from the target image. The first initial feature is extracted through the convolution layer and the maximum pooling layer of the neural network model. Specifically, an initial feature map can be obtained after the target image passes through the convolution layer. The initial feature map is further processed according to the maximum pooling layer to reduce the size of the feature map and obtain the first initial feature. These features may include edges, textures, shapes, etc. This stage is mainly achieved through the initial convolution layer and the maximum pooling layer of the ResNeXt model, laying the foundation for subsequent more in-depth feature learning. It can reduce the amount of calculation and increase robustness.
[0047] Based on the first initial features, the model performs multiple cycles of feature extraction processing, and each cycle or stage contains a specific number of convolutional layers and pooling layers to further refine and enhance feature representation. In this process, the Cardinality mechanism in the ResNeXt model and the dense connection strategy in the DenseNet model are fully utilized to increase the diversity of features and the expressive power of the deep learning model. At the end of each stage, the model generates a new feature map as input for the next stage.
[0048] The output of the last feature extraction process contains the deepest image information, which may cover subtle clues and complex patterns of document tampering. These deep features are defined as the second initial features, which represent the model's final understanding of the image structure and content. The first initial features and the second initial features are fused to generate the target features of the target image. This step is completed by using a feature fusion mechanism that combines the concepts of ResNeXt and DenseNet. For example, feature maps at different stages are connected together through the concat operation, or features at different levels are comprehensively considered using methods such as weighted sum to form a more comprehensive and richer feature representation. This fusion mechanism can make full use of the information of shallow and deep features to improve the model's identification and generalization performance.
[0049] The fused target features are fed into the output layer of the model for final decision analysis. Based on the target features, the model predicts whether the text has been tampered with and the possibility of tampering. This process may involve multi-classification or binary classification predictions, and the output may include "not tampered with", "tampered with", or "suspected tampering" results, depending on the design and training objectives of the model. The prediction results are not only based on deep features, but also integrate the results of other detection methods such as EXIF data to improve the accuracy and reliability of the entire tampering detection system.
[0050] In an exemplary embodiment, any feature extraction processing includes: determining the input feature of the feature extraction processing based on the first initial feature; performing convolution processing on the input feature to obtain a convolution processing result; dividing the convolution processing result to obtain a first convolution processing result and a second convolution processing result; dividing based on the first convolution processing result to obtain a first sub-processing result and a second sub-processing result; dividing based on the second convolution processing result to obtain a third sub-processing result and a fourth sub-processing result; performing convolution on the third sub-processing result to obtain a third convolution sub-processing result, and performing convolution on the fourth sub-processing result to obtain a fourth convolution sub-processing result; obtaining the output of the feature extraction processing based on the first convolution processing result, the second convolution processing result, the third convolution sub-processing result and the fourth convolution sub-processing result.
[0051] It should be noted that during the feature extraction process, if the feature extraction process is performed for the first time, the input feature is the first initial feature. Except for the first time, the input features of other feature extraction processes are the first initial feature and the output obtained from the previous feature extraction process.
[0052] Specifically, the input features are convolved to obtain the convolution results, the convolution results are divided into the first convolution results and the second convolution results, and the first convolution results are divided to obtain the first sub-processing results and the second sub-processing results, and the second convolution results are divided to obtain the third sub-processing results and the fourth sub-processing results, so that the first sub-processing results, the second sub-processing results, the third sub-processing results and the fourth sub-processing results are consistent in data format. The reason for performing convolution after the third sub-processing results and the fourth sub-processing results are divided is that putting a smaller feature map into the convolution layer can consume less computing resources when the feature extraction effect is the same. The reason for retaining the first sub-processing results and the second sub-processing results instead of directly using the third sub-processing results and the fourth sub-processing results for concat is that the feature information can always retain part of the original data, assist in feature fusion, and play a role in data enhancement.
[0053] In some exemplary embodiments, the output of the feature extraction processing is obtained based on the first convolution processing result, the second convolution processing result, the third convolution sub-processing result and the fourth convolution sub-processing result, including: concatenating the sum of the first convolution processing result and the third convolution sub-processing result, and the sum of the second convolution processing result and the fourth convolution sub-processing result to obtain the output of the feature extraction processing.
[0054] It should be noted that the first convolution processing result is added to the third convolution sub-processing result, and the second convolution processing result is added to the fourth convolution sub-processing result, and then combined to obtain the output of the feature extraction processing of the time.
[0055] Step S210, obtaining a text target detection result based on the image verification result and the text initial detection result.
[0056] In some exemplary embodiments, the text detection result includes that the text content has been tampered with; and obtaining the text target detection result based on the image verification result and the text initial detection result includes: when the image verification result indicates that the initial image has a risk of tampering, and the text initial detection result indicates that the initial image has a risk of tampering, determining that the text content has been tampered with.
[0057] In some exemplary embodiments, the text detection result also includes that the text content has not been tampered with; the method also includes: when the image verification result indicates that the initial image does not have the risk of tampering, and the text initial detection result indicates that the initial image does not have the risk of tampering, determining that the text content has not been tampered with.
[0058] It is understandable that when both the image verification result and the text initial detection result indicate that the initial image is at risk of tampering, the file detection result is that the text content has been tampered with. When both the image verification result and the text initial detection result indicate that the initial image is not at risk of tampering, the file detection result is that the text content has not been tampered with. When the image verification result and the text initial detection result are inconsistent, such as when the image verification result indicates that the initial image is at risk of tampering and the text initial detection result indicates that the initial image is not at risk of tampering, or when the image verification result indicates that the initial image is not at risk of tampering and the text initial detection result indicates that the initial image is at risk of tampering, the file detection result is that the text content is suspected of being tampered with.
[0059] Through the above steps S202-S210, an initial image to be detected is obtained; the initial image is an image for recording text content; when the initial image meets the detection conditions, the image verification result obtained by performing image verification on the initial image is determined; based on the text type to which the initial image belongs, the region of interest of the initial image is determined, and the target image is obtained based on the region of interest; feature extraction processing is performed based on the target image to obtain the target feature of the target image, and the initial text detection result is predicted according to the target feature; based on the image verification result and the initial text detection result, the text target detection result is obtained. In the text detection process, the image verification result is determined only when the detection conditions are met, and the region of interest is further determined according to the text type to which the initial image belongs, and the target image is determined based on the region of interest. This process utilizes the features of different text types to locate the key areas of the initial image, so that the initial text detection result obtained by the subsequent feature extraction process is more accurate. Finally, the image verification result and the initial text detection result are comprehensively considered to ensure the reliability of the text target detection result and improve the accuracy of text detection.
[0060] In order to better understand the process of the above-mentioned text detection method, the above-mentioned text detection method is described below in combination with an optional embodiment, but it is not used to limit the technical solution of the embodiment of the present application.
[0061] Tampering of cooperation documents such as contracts is usually hidden in digital amounts, names, and times. However, the tampered area is very small, and the types of images that may encounter such situations vary greatly. There is an extreme data imbalance, and the human eye cannot tell whether the image has been tampered with or the corresponding area. In addition, auditors also need auxiliary tools to help identify tampering and various unknown adversarial attacks.
[0062] Traditional tampering detection technologies, such as ELA, EXIF, DCT, edge analysis, and OCR, have been widely studied and applied in the field of digital forensics, but these technologies also show inherent weaknesses in their applications. ELA may produce false positives in complex images or highly compressed images. EXIF data not only performs poorly in images obtained from sources other than digital cameras, but may be changed or absent in tampered images. DCT analysis may not be able to detect subtle tampering and provide conclusive evidence. Edge analysis may produce false positives due to complex images and attackers can sometimes manipulate images while maintaining edge consistency. Although traditional electronic tampering detection methods have their practicality, they are often difficult to resist complex tampering techniques. The OCR method, which has received much attention in recent years, can effectively extract text from images or documents, but relies on assumptions about the authenticity and integrity of the underlying content. However, sophisticated attackers can manipulate or change text in ways that are imperceptible to the human eye. Techniques such as font replacement, character overlay, or image-based text insertion may bypass OCR detection, resulting in false negatives or incorrect assessments of document authenticity. In addition, OCR may encounter problems with low-quality images or unconventional fonts, further reducing its reliability in accurately detecting tampering. At the same time, OCR is an extraction of text and cannot detect image tampering that may be contained in the file.
[0063] Although deep learning technology can automatically learn and adapt to various types of tampering monitoring technologies to make them more flexible to operations, there are few existing technologies in this area. Currently, traditional CNN algorithms are the mainstream, and there is still room for improvement in key dimensional indicators related to practical applications such as algorithm effects.
[0064] This application aims to detect the tampering of important documents such as contracts. It adopts, integrates and improves the ResNeXt and DenseNet models through the complementary methods of traditional methods and deep learning, and reduces the difficulty of model implementation through the innovative CNN model architecture optimization method. After the user inputs the document image, the operation can be started. After the operation is completed, the user can get the document tampering detection result. Figure 3 As shown, this is a flowchart of the text detection method:
[0065] After the text detection process begins, data is input, and the document to be detected in the image format (jpg, jpeg or png) is input, that is, the initial image. It is judged whether the document meets the detection conditions, that is, whether the initial image meets the specific detection conditions. When determining whether the detection conditions are met, EXIF detection is directly used to detect and preliminarily classify whether the initial image has been edited by image editing software. After EXIF detection, it is considered that the initial image that has not been edited by the image editing software outputs 0, and the initial image that has been edited by the image editing software outputs 1. Although the initial image with an output of 0 has not been detected as having been edited by the software at this stage, it is still possible to be tampered with; the initial image with an output of 1 has been detected as having been edited by the software, but it is still possible that it has not been tampered with. The initial images that are judged to have not been edited by the image editing software and those that have been edited by the image editing software are classified, and in the next step are put into an independent document tampering detection model for specific tampering detection.
[0066] The key areas of the initial image are located according to the document type. The special areas that reflect the key points of the document are designed according to the document types in the data set at the beginning of model training, and are considered to be the key points of documents such as contracts. For example, in the experimental process of this application, when the initial image is text, Arabic numerals and Chinese capital letters are selected as key points, and when the image is a table, the entire image is used as the key points. This application can choose the text detection method DBNet to implement text detection and positioning in this part. In this step, the two sets of data that are edited in parallel based on whether they have been edited by the image editing software share the same algorithm, that is, the images divided into two categories are kept originally stored, there is no data intersection, but the positioning content, steps and algorithms are consistent. Finally, the text key detection and positioning results are mapped to the image, and a dimension is added to the original initial image to form the target image.
[0067] The target image is further tampered with by extracting features during the tampering detection process, and tampering detection is performed based on the extracted features. The flowchart of feature extraction processing is shown in the figure. Figure 4 As shown. First, the target image is processed by RGB. Then, the model can divide the target image into two groups based on the target image and put it into two models with the same structure and different parameters for tampering detection. It consists of three parts: ① data input part (with the initial convolution layer and the maximum pooling layer; ② data convolution part, which has 4 stages, and each stage contains a different number of convolution layers and pooling layers for feature extraction at different stages; ③ global integration part. Reference Figure 4As shown in the figure, the target image through the maximum pooling layer will be divided into two identical parts after two layers of convolution. According to the ResNeXt concept, one part will keep the data as it is and the other part will undergo three layers of convolution. The two parts of data will be divided into data 1, 2 and data i, data j according to the same proportion. Data 1 is added to i, 2 is added to j, and then combined to obtain the output. The model can include multiple sub-parts for processing the target image. The output of the first sub-part can continue to input the next sub-part until the last output is determined as the second initial feature. The first initial feature and the second initial feature obtained by the convolution layer and the maximum pooling layer are fused, and then average pooling, fully connected layer, Softmax and other outputs are performed.
[0068] In terms of detection effect, multiple judgments on the same image can effectively complement each other's inherent detection weaknesses. At the same time, the deep learning model operation scheme for branch detection based on EXIF judgment results converts the original multi-classification problem into a binary classification problem, thereby improving recognition accuracy. Images that pass both EXIF detection and tampering detection are classified as "documents have not been tampered with" in the algorithm; images that fail both EXIF detection and tampering detection are classified as "documents have been tampered with" in the algorithm; images that pass only one of the two tests are classified as "documents suspected of being tampered with" in the algorithm. This application optimizes the CNN model and innovatively uses a model architecture that combines the concepts of ResNeXt and DenseNet, so that the model makes more full use of features, reduces the difficulty of model training, improves the versatility of the model, and further improves the accuracy of the algorithm.
[0069] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0070] The present application also provides a structural block diagram of a text detection device. Figure 5 is a structural block diagram of a text detection device according to an embodiment of the present application; Figure 5 As shown, including:
[0071] The acquisition module 52 is used to acquire an initial image to be detected; the initial image is an image used to record text content;
[0072] A first determination module 54 is used to determine an image verification result obtained by performing image verification on the initial image when the initial image meets the detection condition;
[0073] A second determination module 56 is used to determine a region of interest of the initial image based on the text type to which the initial image belongs, and obtain a target image based on the region of interest;
[0074] An extraction module 58, configured to perform feature extraction processing based on the target image, obtain target features of the target image, and predict an initial text detection result according to the target features;
[0075] The detection module 59 is used to obtain a text object detection result based on the image verification result and the text initial detection result.
[0076] In an exemplary embodiment, the extraction module 58 is also used to determine the first initial feature of the target image, perform a preset number of feature extraction processes based on the first initial feature, and determine the second initial feature of the target image according to the output obtained from the last feature extraction process; fuse the first initial feature and the second initial feature to obtain the target feature of the target image, and predict the initial text detection result according to the target feature.
[0077] In an exemplary embodiment, the text detection result includes that the text content has been tampered with; the detection module 59 is also used to determine that the text content has been tampered with when the image verification result indicates that the initial image has a risk of tampering and the text initial detection result indicates that the initial image has a risk of tampering.
[0078] In an exemplary embodiment, the text detection result also includes that the text content has not been tampered with; the detection module 59 is also used to determine that the text content has not been tampered with when the image verification result indicates that the initial image does not have the risk of tampering, and the text initial detection result indicates that the initial image does not have the risk of tampering.
[0079] In an exemplary embodiment, the extraction module 58 is also used to determine the input features of the feature extraction processing based on the first initial features; perform convolution processing on the input features to obtain convolution processing results; divide the convolution processing results to obtain a first convolution processing result and a second convolution processing result; divide based on the first convolution processing result to obtain a first sub-processing result and a second sub-processing result; divide based on the second convolution processing result to obtain a third sub-processing result and a fourth sub-processing result; perform convolution on the third sub-processing result to obtain a third convolution sub-processing result, and perform convolution on the fourth sub-processing result to obtain a fourth convolution sub-processing result; based on the first convolution processing result, the second convolution processing result, the third convolution sub-processing result and the fourth convolution sub-processing result, obtain the output of the feature extraction processing at that time.
[0080] In an exemplary embodiment, the extraction module 58 is also used to concatenate the sum of the first convolution processing result and the third convolution sub-processing result, and the sum of the second convolution processing result and the fourth convolution sub-processing result to obtain the output of the feature extraction processing at that time.
[0081] In an exemplary embodiment, the first determination module 54 is also used to determine whether the initial image meets the detection conditions, including: extracting a first light and dark value and a second light and dark value in the initial image; the first light and dark value is greater than the second light and dark value; based on the first light and dark value and the second light and dark value, determining the pixel brightness of the initial image; based on the pixel brightness, determining whether the initial image meets the detection conditions.
[0082] Through the above device, an initial image to be detected is obtained; the initial image is an image for recording text content; when the initial image meets the detection conditions, the image verification result obtained by performing image verification on the initial image is determined; based on the text type to which the initial image belongs, the region of interest of the initial image is determined, and the target image is obtained based on the region of interest; feature extraction processing is performed based on the target image to obtain the target feature of the target image, and the initial text detection result is predicted according to the target feature; based on the image verification result and the initial text detection result, the text target detection result is obtained. In the text detection process, the image verification result is determined only when the detection conditions are met, and the region of interest is further determined according to the text type to which the initial image belongs, and the target image is determined based on the region of interest. This process utilizes the features of different text types to locate the key areas of the initial image, so that the initial text detection result obtained by the subsequent feature extraction process is more accurate. Finally, the image verification result and the initial text detection result are comprehensively considered to ensure the reliability of the text target detection result and improve the accuracy of text detection.
[0083] An embodiment of the present application further provides a storage medium, which includes a stored program, wherein the program executes any of the above methods when it is run.
[0084] Optionally, in this embodiment, the storage medium may be configured to store program codes for executing the following steps:
[0085] S1, obtaining an initial image to be detected; the initial image is an image used to record text content;
[0086] S2, when the initial image meets the detection condition, determining an image verification result obtained by performing image verification on the initial image;
[0087] S3, determining a region of interest of the initial image based on the text type to which the initial image belongs, and obtaining a target image based on the region of interest;
[0088] S4, performing feature extraction processing based on the target image to obtain target features of the target image, and predicting an initial text detection result according to the target features;
[0089] S5, obtaining a text target detection result based on the image verification result and the text initial detection result.
[0090] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0091] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0092] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0093] S1, obtaining an initial image to be detected; the initial image is an image used to record text content;
[0094] S2, when the initial image meets the detection condition, determining an image verification result obtained by performing image verification on the initial image;
[0095] S3, determining a region of interest of the initial image based on the text type to which the initial image belongs, and obtaining a target image based on the region of interest;
[0096] S4, performing feature extraction processing based on the target image to obtain target features of the target image, and predicting an initial text detection result according to the target features;
[0097] S5, obtaining a text target detection result based on the image verification result and the text initial detection result.
[0098] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.
[0099] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0100] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0101] An embodiment of the present application also provides a computer program, which includes computer instructions stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in any one of the above method embodiments.
[0102] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0103] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0104] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A text detection method, characterized in that: include: Obtaining an initial image to be detected; The initial image is an image used to record text content; In the case where the initial image satisfies the detection condition, determining an image verification result obtained by performing image verification on the initial image; Based on the text type to which the initial image belongs, determining a region of interest of the initial image, and obtaining a target image based on the region of interest; Performing feature extraction processing based on the target image to obtain target features of the target image, and predicting initial text detection results according to the target features; Based on the image verification result and the text initial detection result, a text target detection result is obtained.
2. The method according to claim 1, characterized in that The step of performing feature extraction processing based on the target image to obtain target features of the target image, and predicting the initial text detection result according to the target features, includes: Determine a first initial feature of the target image, perform a preset number of feature extraction processes based on the first initial feature, and determine a second initial feature of the target image according to an output obtained from the last feature extraction process; The first initial feature and the second initial feature are fused to obtain a target feature of the target image, and an initial text detection result is predicted according to the target feature.
3. The method according to claim 1, characterized in that The text detection result includes that the text content has been tampered with; the text target detection result is obtained based on the image verification result and the text initial detection result, including: When the image verification result indicates that the initial image has a risk of being tampered with, and the text initial detection result indicates that the initial image has a risk of being tampered with, it is determined that the text content has been tampered with.
4. The method according to claim 1, characterized in that: The text detection result also includes that the text content has not been tampered with; the method also includes: When the image verification result indicates that the initial image has no risk of tampering, and the text initial detection result indicates that the initial image has no risk of tampering, it is determined that the text content has not been tampered with.
5. The method according to claim 2, characterized in that: Any feature extraction process includes: Determining input features for the feature extraction process based on the first initial features; Performing convolution processing on the input feature to obtain a convolution processing result; Splitting the convolution processing result to obtain a first convolution processing result and a second convolution processing result; Perform segmentation based on the first convolution processing result to obtain a first sub-processing result and a second sub-processing result; Perform segmentation based on the second convolution processing result to obtain a third sub-processing result and a fourth sub-processing result; Performing convolution on the third sub-processing result to obtain a third convolution sub-processing result, and performing convolution on the fourth sub-processing result to obtain a fourth convolution sub-processing result; Based on the first convolution processing result, the second convolution processing result, the third convolution sub-processing result and the fourth convolution sub-processing result, the output of the current feature extraction processing is obtained.
6. The method according to claim 5, characterized in that The step of obtaining the output of the feature extraction process based on the first convolution processing result, the second convolution processing result, the third convolution sub-processing result and the fourth convolution sub-processing result includes: The sum of the first convolution processing result and the third convolution sub-processing result, and the sum of the second convolution processing result and the fourth convolution sub-processing result are concatenated to obtain the output of the feature extraction processing of the time.
7. The method according to claim 1, characterized in that Determining whether the initial image satisfies a detection condition includes: Extracting a first light and dark value and a second light and dark value from the initial image; wherein the first light and dark value is greater than the second light and dark value; Determining pixel brightness of the initial image based on the first brightness value and the second brightness value; Based on the pixel brightness, it is determined whether the initial image meets a detection condition.
8. A text detection device, characterized in that: include: An acquisition module, used for acquiring an initial image to be detected; The initial image is an image used to record text content; A first determination module, configured to determine an image verification result obtained by performing image verification on the initial image when the initial image meets a detection condition; A second determination module, configured to determine a region of interest of the initial image based on the text type to which the initial image belongs, and obtain a target image based on the region of interest; An extraction module, used for performing feature extraction processing based on the target image to obtain target features of the target image, and predicting initial text detection results according to the target features; The detection module is used to obtain a text target detection result based on the image verification result and the text initial detection result.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 7 when executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.