Method, device, computer equipment and storage medium for verifying authenticity of certificate
Patent Information
- Application Number
- CN201811106159.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-09-21
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2038-09-21
AI Technical Summary
Existing methods for verifying the authenticity of documents are inaccurate, resulting in unreliable verification results.
The CTPN-RNN algorithm is used to locate the document image, obtain the text line area block image, and recognize the text through the OCR recognition model. It obtains the content verification rules based on the document type and location identification, performs content and data verification, and performs color difference verification at the same time. If the three verifications pass, the authenticity of the document is confirmed.
It greatly improves the accuracy and efficiency of document verification, simplifies the verification process, and ensures the reliability of document authenticity.
Smart Images

Figure CN109446900B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cryptographic technology, and in particular to a method, device, computer equipment and storage medium for verifying the authenticity of a certificate. Background Art
[0002] At present, with the rapid development of my country's economy, the flow of people is becoming more and more frequent. When people travel, go abroad, and stay in hotels, they need to verify the authenticity of their documents. The current methods for verifying the authenticity of documents are relatively simple, which leads to the problem of inaccurate verification of the authenticity of documents. Summary of the invention
[0003] The embodiments of the present invention provide a method, an apparatus, a computer device and a storage medium for verifying the authenticity of a certificate, so as to solve the problem of inaccurate verification of the authenticity of a certificate.
[0004] A method for verifying the authenticity of a certificate, comprising:
[0005] Acquire an original document image, where the original document image corresponds to a document type;
[0006] Using a CTPN-RNN algorithm to locate the original document image, obtaining at least one text line region, intercepting an image corresponding to the text line region from the original document image as a regional block image, and obtaining a position identifier corresponding to each regional block image;
[0007] Using an OCR recognition model to recognize each of the regional block images, and obtaining target text corresponding to each of the regional block images;
[0008] Based on the document type and the position identifier corresponding to each of the regional block images, a corresponding content verification rule is obtained, and the content verification rule is used to perform content verification on the target text corresponding to each of the regional block images to obtain a content verification result;
[0009] Verify the target text corresponding to each of the area block images with the standard text in the database corresponding to the certificate type to obtain a data verification result;
[0010] Performing color difference verification on the original document image to obtain a color difference verification result;
[0011] If the content verification result, the data verification result and the color difference verification result are all verified to be passed, the certificate corresponding to the original certificate image is a genuine certificate.
[0012] A device for verifying the authenticity of a certificate, comprising:
[0013] An image acquisition module, used to acquire an original document image, wherein the original document image corresponds to a document type;
[0014] A region block image acquisition module, used to locate the original document image using a CTPN-RNN algorithm, acquire at least one text line region, intercept an image corresponding to the text line region from the original document image as a region block image, and acquire a position identifier corresponding to each region block image;
[0015] A target text acquisition module, used to recognize each of the regional block images using an OCR recognition model to acquire the target text corresponding to each of the regional block images;
[0016] A first verification module is used to obtain a corresponding content verification rule based on the document type and the position identifier corresponding to each of the regional block images, and perform content verification on the target text corresponding to each of the regional block images using the content verification rule to obtain a content verification result;
[0017] A second verification module is used to verify the target text corresponding to each of the regional block images with the standard text in the database corresponding to the certificate type to obtain a data verification result;
[0018] A third verification module is used to perform color difference verification on the original document image to obtain a color difference verification result;
[0019] The result determination module is used to determine that if the content verification result, the data verification result and the color difference verification result are all verified to be passed, the certificate corresponding to the original certificate image is a genuine certificate.
[0020] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned steps of document authenticity verification when executing the computer program.
[0021] A computer-readable storage medium stores a computer program, which implements the steps of the above-mentioned document authenticity verification method when executed by a processor.
[0022] In the above-mentioned certificate authenticity verification method, device, computer equipment and storage medium, the CTPN-RNN algorithm is used to locate the acquired original certificate image, obtain at least one text line area, and intercept the image corresponding to the text line area from the original certificate image as a regional block image to achieve the positioning of each area in the original certificate image, and the OCR recognition model is used to recognize each regional block image, and the target text corresponding to each regional block image is obtained to achieve the acquisition of the text in the certificate from the original certificate image. Based on the certificate type and the position identifier corresponding to each regional block image, the corresponding content verification rule is obtained, and the content verification rule is used to perform content verification on the target text corresponding to each regional block image, and the content verification result is obtained to achieve the verification of the target text in the original certificate image according to the preset content verification rule. The target text corresponding to each regional block image is verified with the standard text in the database corresponding to the certificate type, and the data verification result is obtained to achieve the data verification of the target text in the original certificate image. The original certificate image is subjected to color difference verification, and the color difference verification result is obtained to achieve the color difference verification of the original certificate image. If the content verification results, data verification results and color difference verification results are all verified and passed, the document corresponding to the original document image is a genuine document, so that the authenticity of the document can be judged based on the content verification results, data verification results and color difference verification results, which greatly improves the accuracy of document verification and the document verification process is simple and fast. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0024] Figure 1 Schematic diagram of an application environment of a method for verifying the authenticity of a certificate in an embodiment of the present invention;
[0025] Figure 2 is a flow chart of a method for verifying the authenticity of a certificate in one embodiment of the present invention;
[0026] Figure 3 is a flow chart of a method for verifying the authenticity of a certificate in one embodiment of the present invention;
[0027] Figure 4 is a flow chart of a method for verifying the authenticity of a certificate in one embodiment of the present invention;
[0028] Figure 5 is a flow chart of a method for verifying the authenticity of a certificate in one embodiment of the present invention;
[0029] Figure 6 is a flow chart of a method for verifying the authenticity of a certificate in one embodiment of the present invention;
[0030] Figure 7 is a flow chart of a method for verifying the authenticity of a certificate in one embodiment of the present invention;
[0031] Figure 8 is a flow chart of a method for verifying the authenticity of a certificate in one embodiment of the present invention;
[0032] Fig. 9 It is a principle block diagram of a device for verifying the authenticity of a certificate in one embodiment of the present invention;
[0033] Fig.10 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0035] The method for verifying the authenticity of a certificate provided by the embodiment of the present invention can be applied in the following aspects: Figure 1 In an application environment, the user terminal communicates with the server terminal through a network, which can be a wired network or a wireless network. The server terminal obtains the original document image, and verifies the original document image to determine whether the original document image is a genuine document, so as to solve the problem of inaccurate document authenticity verification. The server terminal and the user terminal are connected through a network, and the user terminal can be, but is not limited to, a personal computer, a laptop computer, a smart phone, and a tablet computer. The server terminal can be implemented by an independent server terminal or a server terminal cluster composed of multiple servers.
[0036] In one embodiment, if Figure 2 As shown, a method for verifying the authenticity of a certificate is provided, and the method is applied in Figure 1 The server in the example is used as an example to illustrate the following steps:
[0037] S10: Acquire an original document image, where the original document image corresponds to a document type.
[0038] Among them, the document type refers to the type corresponding to the original document image, and the document type can be a second-generation identity card, a Hong Kong identity card, a Hong Kong and Macau Pass, and a passport, etc.
[0039] Specifically, the server obtains a certificate authenticity verification request sent by the user, and obtains the original certificate image based on the authenticity verification request. The original certificate image can be uploaded to the server by the user, and the certificate type corresponding to the original certificate image can be the certificate type determined by the user when uploading the original certificate image.
[0040] S20: Using the CTPN-RNN algorithm to locate the original document image, obtain at least one text line region, intercept an image corresponding to the text line region from the original document image as a regional block image, and obtain a position identifier corresponding to each regional block image.
[0041] Among them, the text line area refers to the positioning of the original document image into several meaningful areas according to certain rules, and there is no intersection between the areas. The regional block image refers to the image captured from the text line area. The position identifier refers to the identifier corresponding to the regional block image, and the corresponding regional block image can be found through the position identifier. For example, the position identifier of a certain ID number is 1, and the regional block image can be determined to be the image of the ID number through the position identifier 1.
[0042] Specifically, CTPN (Connectionist Text Proposal Network, hereinafter referred to as CTPN) is a model for accurately locating text lines in images. The main purpose of RNN (Recurrent Neural Networks) is to process and predict sequence data. The nodes between the hidden layers of RNN are connected, and the input of the hidden layer includes not only the output of the input layer, but also the output of the hidden layer at the previous moment. By seamlessly integrating CTPN into the RNN convolutional network, it can accurately locate the text line area in the original document image. For original document images of different document types, each text line area has a different position in the original document image. At least one text line area is located from the original document image through the CTPN-RNN algorithm, so that the at least one text line area obtained is more accurate. The text line area in the original document image is intercepted by a cropping tool to obtain a regional block image, and each regional block image corresponds to a position identifier. Among them, when the original document image is positioned by the CTPN-RNN algorithm, each original document image can be mapped into a feature vector of size W×H×C, and the coordinates of the four corners of each text line are obtained by regression filtering and other operations. The coordinates of the upper left corner of the text line are the coordinates of the upper left corner of the regional block image. The corresponding position identifier is configured in advance according to the coordinates of the upper left corner of the regional block image corresponding to each document type, and the position identifier corresponding to the regional block image is determined by the coordinates of the upper left corner of each regional block image. In this embodiment, the text line area in the original document image can be intercepted by OpenCV, wherein OpenCV (Open Source Computer Vision Library) is a cross-platform computer vision library issued based on the BSD license (open source), which can run on Linux, Windows, Android and Mac OS operating systems. In this embodiment, the coordinates of the four corners of each text line area are intercepted by OpenCV to obtain the corresponding regional block image. The interception operation is performed by OpenCV, which is simple in calculation, high in computational efficiency and stable in performance.
[0043] S30: using an OCR recognition model to recognize each region block image, and obtaining target text corresponding to each region block image.
[0044] The target text refers to the text recognized from the regional block image using the OCR recognition model, and the target text may include Chinese, numbers, and English.
[0045] Specifically, the process of recognizing each region block image through a pre-trained OCR recognition model is text feature extraction, which extracts text features from the region block image and finds the word with the most similar features from the OCR recognition model to obtain the target text corresponding to each region block image.
[0046] Among them, the pre-trained OCR recognition model stores various features of the text, such as the structure of the text and the strokes of the text. When the OCR recognition model is trained, it is mainly through defining a network (which can be an improved version of LeNet), adding batchnormalization deep learning, selecting a suitable loss function, the loss function can be sparse_softmax_cross_entropy_with_logits cross entropy, adding an optimizer, and the optimizer can be Adam (the learning rate is set to 0.1), and training the model on the training text to obtain the OCR recognition model.
[0047] S40: Based on the document type and the position identifier corresponding to each regional block image, a corresponding content verification rule is obtained, and the content verification rule is used to perform content verification on the target text corresponding to each regional block image to obtain a content verification result.
[0048] The content verification rule refers to a pre-set rule for verifying the target text. In this embodiment, the content verification rule can be a code pre-written according to the certificate standard rule, and the target text is verified by executing the code. The certificate standard rule is a rule formulated by the state on the certificate standard.
[0049] Specifically, based on the document type of the original document image, the server can obtain a database corresponding to the document type, which includes pre-set content verification rules. Based on the position identifier corresponding to the regional block image, the corresponding content verification rule is obtained, and the target text corresponding to the regional block image is verified using the content verification rule to obtain the content verification result, which can be a verification pass or a verification fail.
[0050] Furthermore, the content verification rules corresponding to different types of certificates are different. For example, when the certificate type is a second-generation ID card, the database corresponding to the second-generation ID card is searched. The database corresponding to the second-generation ID card contains content verification rules for verifying the second-generation ID card that are pre-written according to the certificate standard rules. For example, the second-generation ID card number includes 1 to 6 digits for the area code (where 1 and 2 digits are the codes of the provincial governments, 3 and 4 digits are the codes of the prefecture and city governments, and 5 to 6 digits are the codes of the county and district governments), 7 to 14 digits for the date of birth, 15 to 17 digits for the sequence number (where odd numbers are male allocation codes and even numbers are female allocation codes), and 18 digits for the verification code. The verification rules for the second-generation ID card number are: (1) Multiply the first 17 digits by different coefficients respectively. The coefficients from the first to the 17th digits are (7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2). (2) Multiply the first 17 digits by the corresponding coefficients and add the results. (3) Subtract the result of addition from 11 to obtain the remainder. (4) The possibilities of the remainder are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. The corresponding check codes are 1, 0, X, 9, 8, 7, 6, 5, 4, 3, 2. For another example, when the document type is a Hong Kong identity card, the database corresponding to the Hong Kong identity card is searched. The database corresponding to the Hong Kong identity card contains the content check rules for checking the Hong Kong identity card that are pre-written according to the document standard rules. For example, the check rule for the Hong Kong identity card number is determined by the first 7 digits of the Hong Kong identity card number, and the first letter is replaced by a number, that is, A is represented by 1, B is represented by 2... Z is represented by 26, and 8 digits can be obtained. The check code in the brackets of the Hong Kong identity card number is used to check whether the previous digits are correct. It may be a number or the letter A. By multiplying the first number by 8, the second number by 7, and so on, multiplying the seventh number by 2, and the sixth number by 1, and then adding all the above products together, you get a number, and then divide this number by 11 to get the remainder. If it is an integer, the check code is 0; if the remainder is 1, the check code is A; if the remainder is 2 to 10, subtract the remainder from 11 to get the check code.
[0051] Furthermore, different positions of the document correspond to different content verification rules. For example, the Hong Kong identity card contains regional block images such as Chinese telegraph code, Chinese name, date of issue, marking symbol, first issue date, English name, date of birth, gender and identity ID. Each regional block image corresponds to a position identifier, and the corresponding content verification rules can be found in the database corresponding to the document type through the position identifier. For example, in the database corresponding to the Hong Kong identity card, the content verification rules corresponding to the Chinese telegraph code can be found through the position identifier of the Chinese telegraph code.
[0052] S50: Verify the target text corresponding to each area block image with the standard text in the database corresponding to the document type to obtain a data verification result.
[0053] Specifically, the server stores a database corresponding to each certificate type, and the database contains standard texts corresponding to all users. The server searches the database by certificate type to obtain the database corresponding to the certificate type, searches the database corresponding to the certificate type according to the target text corresponding to each regional block image, obtains the standard text corresponding to the target text, matches the target text with the standard text, and obtains the data verification result, wherein the data verification result can be verification passed or verification failed.
[0054] Furthermore, each original document image corresponds to an identity id, and a unique user can be determined by the identity id. The identity id in the target text corresponding to the regional block image is obtained, and the database corresponding to the document type is searched through the identity id. If the database contains standard text corresponding to the identity id (i.e., text that is the same as the identity id), the standard text corresponding to each regional block image corresponding to the current identity id is obtained, and the target text is matched with the standard text. If both are matched successfully, the data verification result is verification passed. If any target text is not matched successfully, the data verification result is verification failed. For example, a certain document type is a second-generation ID card, and the identity id can be an ID card number. For example, if the identity id is xxxx1, the database corresponding to the second-generation ID card is searched through xxxx1. If the database contains standard text that matches xxxx1, the target text of each regional block image corresponding to xxxx1 and the standard text associated with xxxx1 in the database are obtained. The associated standard text can be name, age, address, etc. The target text is matched with the standard text to obtain the data verification result.
[0055] S60: Perform color difference verification on the original document image to obtain a color difference verification result.
[0056] Specifically, the server obtains the original document image, which includes a front image and at least two side images of the document taken at different angles. The color difference between each side image and the front image is calculated, and the color difference is compared with a preset color difference threshold to obtain a color difference verification result. The color difference verification result may be a verification pass or a verification fail. Usually, the original document image obtained at different angles of the document refracts different light. For example, for a Hong Kong identity card, the light refracted by the original document image obtained at different angles may be different colors such as gold and green. In this embodiment, the accuracy of document authenticity verification is improved by performing color difference verification on the original document image.
[0057] S70: If the content verification result, the data verification result and the color difference verification result are all verified to be passed, the document corresponding to the original document image is a genuine document.
[0058] Specifically, the server obtains the content verification result, the data verification result and the color difference verification result. If the content verification result, the data verification result and the color difference verification result are all verified, the certificate corresponding to the original certificate image is a genuine certificate; conversely, if any one of the content verification result, the data verification result and the color difference verification result fails to verify, then the certificate corresponding to the original certificate image is a fake certificate.
[0059] In steps S10-S70, the acquired original document image is positioned by using the CTPN-RNN algorithm to obtain at least one text line area, and the image corresponding to the text line area is intercepted from the original document image as a regional block image to achieve positioning of each area in the original document image, and each regional block image is recognized by using the OCR recognition model to obtain the target text corresponding to each regional block image, so as to achieve obtaining the text in the document from the original document image. Based on the document type and the position identifier corresponding to each regional block image, the corresponding content verification rule is obtained, and the content verification rule is used to perform content verification on the target text corresponding to each regional block image, and the content verification result is obtained, so as to achieve verification of the target text in the original document image according to the preset content verification rule. The target text corresponding to each regional block image is verified with the standard text in the database corresponding to the document type, and the data verification result is obtained, so as to achieve data verification of the target text in the original document image. The original document image is subjected to color difference verification, and the color difference verification result is obtained, so as to achieve color difference verification of the original document image. If the content verification results, data verification results and color difference verification results are all verified, the document corresponding to the original document image is a genuine document, so that the authenticity of the document can be judged based on the content verification results, data verification results and color difference verification results, which greatly improves the accuracy of document verification and the verification process is simple and fast.
[0060] In one embodiment, if Figure 3 As shown, in step S30, each region block image is recognized by using an OCR recognition model to obtain a target text corresponding to each region block image, including:
[0061] S31: using an OCR recognition model to recognize each region block image, and obtaining target recognition content, wherein the target recognition content includes recognition text corresponding to the region block image and recognition probability corresponding to the recognition text.
[0062] Specifically, the server inputs the regional block image into the OCR recognition model. First, the regional block image is cut into single-font images through a text cutting algorithm. Then, the cut single-font images are sequentially input into the OCR recognition model for recognition according to the cutting order to obtain the target recognition content corresponding to each single-font image. The target recognition content includes the recognition text corresponding to the regional block image and the recognition probability corresponding to the recognition text. Among them, the text cutting algorithm can be a projection-based text cutting algorithm. For example, for a certain type of certificate, which is a second-generation ID card, the regional block image corresponding to the name in the second-generation ID card is input into the OCR recognition model. If the name in the regional block image is "Li Da", the regional block image is first segmented into two single-font images, "Li" and "Da". The OCR recognition model is used to recognize the single-font images to obtain the recognition text corresponding to the single-font images and the recognition probability corresponding to the recognition text. The recognition text and the recognition probability corresponding to the recognition text can be "Li" 95% and "Ji" 73%; "Da" 98% and "Ren" 80%.
[0063] S32: Use the recognition text corresponding to the maximum recognition probability as the target text corresponding to the regional block image.
[0064] Specifically, the server obtains the recognition text corresponding to each single-font image in the regional block image and the recognition probability corresponding to the recognition text, and extracts the recognition text corresponding to the maximum recognition probability of each single-font image as the target text. For example, in step S31, the recognition text and the recognition probability corresponding to the recognition text can be "Li" 95% and "Ji" 73%; "Da" 98% and "Ren" 80%. The "Li" corresponding to the maximum recognition probability of 95% and the "Da" corresponding to 98% are used as the target text.
[0065] In steps S31 - S32, the OCR recognition model is used to recognize each regional block image to obtain the target recognition content. The target recognition content includes the recognition text corresponding to the regional block image and the recognition probability corresponding to the recognition text. The recognition text corresponding to the maximum recognition probability is used as the target text corresponding to the regional block image, so as to realize the recognition of the content in the regional block image through the pre-trained OCR recognition model, quickly obtain the target text corresponding to the regional block image, the recognition process is fast, and the OCR recognition model can be reused.
[0066] In one embodiment, the OCR recognition model includes a dedicated OCR recognition model and a general OCR recognition model.
[0067] Among them, the pre-trained OCR recognition model may include a dedicated OCR recognition model and a general OCR recognition model, wherein the general OCR recognition model can recognize the target recognition content of the combination of Chinese, numbers and English in the regional block image, while the dedicated OCR recognition model can only recognize one of the target recognition content of Chinese, numbers and English in the regional block image. The dedicated OCR recognition model is to split the general OCR recognition model into three different models of Chinese, English and numbers. Compared with the general OCR recognition model, the recognition rate is higher. The training process of the two is the same, but the training images are classified on the training library. For example, the digital dedicated OCR recognition model is trained with training images containing only numbers and marked text.
[0068] like Figure 4 As shown, in step S31, each region block image is recognized by using an OCR recognition model to obtain target recognition content, which specifically includes the following steps:
[0069] S311: Based on the document type corresponding to the original document image and the position identifier corresponding to each regional block image, the attributes corresponding to each regional block image are obtained, where the attributes include special attributes and general attributes.
[0070] The attributes of each text line area in the original document image of each document type are preset, and the attributes are used to distinguish whether the special attributes only contain Chinese, numbers and English and the general attributes formed by the combination of Chinese, numbers and English. The special attributes correspond to the special OCR recognition model, and the general attributes correspond to the general OCR recognition model.
[0071] Specifically, a database corresponding to the document type is obtained through the document type corresponding to the original document image, and the database stores attributes corresponding to each text line area. The attributes corresponding to the regional block image of the intercepted text line area are determined through the position identifier corresponding to the regional block image, and the attributes include special attributes and general attributes.
[0072] S312: If the attribute corresponding to the region block image is a dedicated attribute, a dedicated OCR recognition model is used to recognize the region block image to obtain target recognition content corresponding to the region block image.
[0073] Specifically, when the server determines that the attribute corresponding to the regional block image is a dedicated attribute based on the document type corresponding to the original document image and the position identifier corresponding to the regional block image, the server adopts a dedicated OCR recognition model to recognize the regional block image to obtain the target recognition content corresponding to the regional block image, so that the target recognition content is more accurate.
[0074] For example, the document type is a Hong Kong identity card, and the first text line area in the Hong Kong identity card image is "Hong Kong Permanent Resident Identity Card". Since it only contains Chinese, the attribute corresponding to the first text line area is pre-set as a dedicated attribute. The location identifier of the regional block image can be used to determine that the corresponding attribute is a dedicated attribute. The regional block image is recognized by a dedicated OCR recognition model to obtain the target recognition content corresponding to the regional block image. In this step, the dedicated recognition model is a Chinese-specific OCR recognition model.
[0075] S313: If the attribute corresponding to the region block image is a general attribute, a general OCR recognition model is used to recognize the region block image to obtain target recognition content corresponding to the region block image.
[0076] Specifically, when the server determines that the attribute corresponding to the regional block image is a common attribute based on the document type corresponding to the original document image and the position identifier corresponding to the regional block image, the server uses a common OCR recognition model to recognize the regional block image to obtain the target recognition content corresponding to the regional block image.
[0077] For example, the document type is a second-generation ID card, and the third text line area in the second-generation ID card is "Birth Year X Month X Day", and the third text line area contains Chinese characters and numbers. The attribute corresponding to the third text line area is preset as a universal attribute. The corresponding attribute can be determined as a universal attribute through the position identifier corresponding to the regional block image, and the regional block image is recognized through the universal OCR recognition model to obtain the target recognition content corresponding to the regional block image.
[0078] In steps S311-S313, based on the document type corresponding to the original document image and the position identifier corresponding to each regional block image, the attributes corresponding to each regional block image are obtained, and the attributes include special attributes and general attributes, so that the recognition model can be determined according to the attributes later. If the attribute corresponding to the regional block image is a special attribute, the special OCR recognition model is used to recognize the regional block image, and the target recognition content corresponding to the regional block image is obtained, so as to realize the recognition of the regional block image through the special OCR recognition model, so as to improve the recognition efficiency and accuracy. If the attribute corresponding to the regional block image is a general attribute, the general OCR recognition model is used to recognize the regional block image, and the target recognition content corresponding to the regional block image is obtained, so as to realize the recognition of the regional block model through the general OCR recognition model, so as to improve the recognition efficiency.
[0079] In one embodiment, if Figure 5 As shown, in step S40, based on the document type and the position identifier corresponding to each area block image, the corresponding content verification rule is obtained, and the content verification rule is used to perform content verification on the target text corresponding to each area block image to obtain the content verification result, which specifically includes the following steps:
[0080] S41: Based on the certificate type, at least one content verification rule corresponding to the certificate type is obtained, and each content verification rule corresponds to an identification of an area to be verified.
[0081] Specifically, the server obtains a database corresponding to the document type according to the document type, and a content verification rule is stored in the database corresponding to each document type. Among them, the content verification rule is a rule for verifying the target text corresponding to the specific area block image in the original document image. Each content verification rule corresponds to an identification of the area to be verified. For example, if the document type is a Hong Kong identity card, the database contains content verification rules corresponding to the identification of the area to be verified, such as Chinese telegraph number, Chinese name, symbol mark, date of birth and identity card number. Each content verification rule corresponds to an identification of the area to be verified, and the corresponding content verification rule can be obtained according to the identification.
[0082] Furthermore, based on the document type, the corresponding relationship between the identification of the area to be verified and the content verification rule is stored in the database corresponding to the document type, which can be a one-to-one relationship or a many-to-one relationship. For example, if the document type is a Hong Kong identity card, the identification of the area to be verified is the identity card number, which corresponds to a content verification rule, it is a one-to-one relationship; if the identification of the area to be verified is a Chinese name and the identification of the area to be verified is a Chinese telegraph code, it corresponds to a content verification rule, which is a many-to-one relationship, that is, the identification of the area to be verified as a Chinese name and the identification of the area to be verified as a Chinese telegraph code correspond to the same content verification rule, and the identification of the area to be verified corresponding to the same verification rule is associated. For example, the identification of the area to be verified as a Chinese name and the identification of the area to be verified as a Chinese telegraph code correspond to the same content verification rule, and the same content verification rule is that the Chinese characters, letters and symbols corresponding to the Chinese telegraph code area identified by the Chinese telegraph code rule are compared with the Chinese characters, letters and symbols and the Chinese name. When they are consistent, the content verification result is determined to be passed.
[0083] S42: Acquire a target region block image whose position identifier matches the identifier of the region to be verified.
[0084] Specifically, the server obtains the location identifier, matches the location identifier with the area identifier to be verified, obtains the area block image corresponding to the successfully matched location identifier, and uses the area block image as the target area block image. For example, if the location identifier is a Chinese name, the location identifier is matched with the area identifier to be verified. If the database corresponding to the document type contains the area identifier to be verified as a Chinese name, the area block image corresponding to the location identifier is used as the target area block image.
[0085] Further, if the position identifier matches the area identifier to be verified, it is determined whether there is an area identifier to be verified associated with the area identifier to be verified. If there is an associated area identifier to be verified, the remaining position identifiers in the original document image are matched with the associated area identifier to be verified to obtain each matched target area block image. For example, in step S41, the database contains the same content verification rule corresponding to the area identifier to be verified as a Chinese name and the area identifier to be verified as a Chinese telegraph code. If the position identifier as a Chinese name matches the area identifier to be verified as a Chinese name successfully, it is determined whether there is an area identifier to be verified associated with the area identifier to be verified as a Chinese telegraph code, and the area identifier to be verified as a Chinese name is associated with the area identifier to be verified as a Chinese telegraph code, then the remaining position identifiers in the original document image are matched with the area identifier to be verified as a Chinese telegraph code. If they match, the area block images corresponding to the position identifier as a Chinese name and the position identifier as a Chinese telegraph code are obtained as the target area block images.
[0086] S43: Using content verification rules, perform content verification on the target text corresponding to the target area block image to obtain a content verification result.
[0087] Specifically, the identification of the area to be verified that successfully matches the position identification is obtained, and the corresponding content verification rule is obtained according to the identification of the area to be verified, and the target text corresponding to the target area block image is subjected to content verification according to the content verification rule to obtain the content verification result. For example, in step S42, the content verification rule corresponding to the Chinese name of the area to be verified is obtained, and the target text corresponding to the target area block image is subjected to content verification according to the content verification rule to obtain the content verification result.
[0088] Furthermore, if the identification of the area to be verified and the content verification rule are in a many-to-one relationship, the target text corresponding to the target area block image associated with the identification of the area to be verified is input into the same content verification rule to obtain the content verification result. For example, the identification of the area to be verified as a Chinese name and the identification of the area to be verified as a Chinese telegraph code correspond to the same content verification rule. In step S42, the area block image corresponding to the position identification as the Chinese name and the position identification as the Chinese telegraph code is used as the target area block image, and the Chinese name and the Chinese telegraph code are both input into the same content verification rule. The Chinese characters, letters and symbols corresponding to the Chinese telegraph code are first identified, and the Chinese characters, letters and symbols are compared with the Chinese name. When they are consistent, the content verification result is determined to be passed. Among them, the Chinese characters, letters and symbols corresponding to the recognized Chinese telegraph codes are mainly identified based on the Chinese telegraph code table. The Chinese telegraph code table uses four-digit Arabic numerals as codes, referred to as the "four-code telegraph", arranged in four-digit sequence from 0001 to 9999. Four digits are used to represent up to 10,000 Chinese characters, letters and symbols, that is, each four-digit number corresponds to a Chinese character, and Chinese characters, letters and symbols are recognized.
[0089] In steps S41-S43, based on the certificate type, at least one content verification rule corresponding to the certificate type is obtained, so that the corresponding content verification rule can be found through the location identifier later, so that the corresponding verification rule can be found faster. The target area block image whose location identifier matches the area identifier to be verified is obtained, and the content verification rule is used to perform content verification on the target text corresponding to the target area block image, and the content verification result is obtained to realize content verification of the target text.
[0090] In one embodiment, the original document image includes a front image of the document and at least two side images of the document, wherein the front image refers to an image taken perpendicular to the document, and the side image refers to a photo taken at a preset angle based on the front image, and the preset angle may be 30-40 degrees.
[0091] like Figure 6 As shown, in step S60, color difference verification is performed on the original document image to obtain the color difference verification result, including:
[0092] S61: Performing spatial transformation on the original document images to obtain image parameters corresponding to each original document image, where the image parameters include hue, saturation and brightness.
[0093] The original document image is spatially transformed so as to obtain the corresponding image parameters. In this embodiment, the original document image is converted into the HSI color space to obtain the image parameters corresponding to the original document image. The image parameters may be specifically hue, saturation and brightness. In the HSI color space, the original document image is described by hue, saturation and brightness. Hue refers to the overall tendency of the color in the original document image, which is determined by which wavelength is dominant in the light reflected by the document. Different wavelengths produce different color sensations. Hue is an important feature of color, which determines the fundamental characteristics of the color nature. Saturation refers to the vividness of the color in the original document image, also known as the purity of the color. Saturation depends on the ratio of the color component and the achromatic component (gray) in the color. Brightness refers to the brightness of the original document image, and the unit is candela per square meter (cd / m2) or nits, that is, candlelight per square meter.
[0094] S62: Based on the hue, saturation and brightness corresponding to each original document image, the color difference between each side image and the front image of the document is calculated using a color difference formula; the color difference formula is: 1 is the front image, 2 is the side image, D is the image color difference between the front image and the side image, i1 is the brightness of the front image, i2 is the brightness of the side image, s1 is the saturation of the front image, s2 is the saturation of the side image, h1 is the hue of the front image, and h2 is the hue of the side image.
[0095] Specifically, the image parameters of each side image and front image are obtained, and the color difference between each side image and the front image is calculated by the color difference calculation formula, which is mainly calculated by the hue, saturation and brightness corresponding to the side image and the front image. The color difference formula is: Substitute the hue, saturation and brightness of the front image into the formula h1, s1 and i1 respectively, and substitute the hue, saturation and brightness of the side image into the formula h2, s2 and i2 respectively, and calculate the image color difference between the side image and the front image using the color difference formula.
[0096] S63: Compare the color difference of each image with the color difference threshold corresponding to the document type. If the color difference of the image is greater than or equal to the color difference threshold, the color difference verification result is verification passed.
[0097] The color difference threshold refers to a preset value, and each document type has a preset color difference threshold. The calculated image color difference between each side image and the front image is compared with the color difference threshold corresponding to the document type. When the color difference between each side image and the front image is greater than or equal to the color difference threshold, the color difference verification result is verification passed. If the color difference between any side image and the front image is less than the color difference threshold, the color difference verification result is verification failed.
[0098] In steps S61-S63, the original document image is spatially transformed to obtain the image parameters corresponding to each original document image. Based on the image parameters corresponding to each original document image, the color difference formula is used to calculate the image color difference between each document side image and the document front image, and each image color difference is compared with the color difference threshold corresponding to the document type. If the image color difference is greater than or equal to the color difference threshold, the color difference verification result is verification passed, and the color difference verification of the original document image is achieved. The image color difference corresponding to each side image is compared with the color difference threshold, so that the authenticity verification of the document is more accurate.
[0099] In one embodiment, if Figure 7 As shown, in step S61, the original document image is spatially transformed to obtain image parameters corresponding to each original document image, which specifically includes the following steps:
[0100] S611: Determine whether the original document image is an RGB color space image.
[0101] Specifically, the properties of the original document image can be used to determine whether it is an RGB image. Usually, the bit depth in the RGB color space image properties is 24. The bit depth is used to specify the amount of color information that can be used for each pixel in the image. The RGB color space image is composed of three color channels. An RGB image with 8 bits per channel (bpc) is called a 24-bit image (8 bits x 3 channels = 24 bits of data per pixel), that is, the bit depth is 24. The RGB color space is a color standard in the industry. Various colors are obtained by changing the three color channels of red, green and blue and superimposing them with each other. RGB represents the colors of the three channels of red, green and blue. For each RGB (red, green and blue) component in the color image, an intensity value between 0 (black) and 255 (white) is assigned to each pixel.
[0102] S612: If the original document image is an RGB color space image, obtain the color value of the RGB color space, where the color value includes the intensity of the red component, the intensity of the green component, and the intensity of the blue component.
[0103] Specifically, if the original document image is an RGB color space image, the color value of the RGB color space can be obtained through tools such as Photoshop. The color value refers to the red component intensity, green component intensity and blue component intensity of the RGB color space. Each pixel in the original document image can be represented by the red component intensity, green component intensity and blue component intensity.
[0104] S613: If the original document image is not an RGB color space image, convert the original document image into an RGB color space image to obtain a color value in the RGB color space.
[0105] Specifically, if the original document image is not an RGB color space image, the original document image can be converted into an RGB color space image through tools such as Photoshop, and then the color value of the RGB color space is obtained.
[0106] S614: Convert the color values in the RGB color space into image values in the HSI color space by means of a geometric deduction method, and use the image values in the HSI color space as image parameters corresponding to the original document image.
[0107] Among them, the HSI color space is based on the human visual system and uses hue, saturation and brightness to describe color. The HSI color space can be described by a cone space model.
[0108] Specifically, after obtaining the color value of the RGB color space of the original document image, the color value of the RGB color space is converted into the image value of the HSI color space through the geometric deduction method. The image value of the HSI color space includes hue, saturation and brightness. Among them, the geometric deduction method mainly separates the brightness from the RGB color space first, reduces the three-dimensional space to two-dimensional, and uses the vector dot product formula of analytic geometry in the two-dimensional plane to calculate the hue and saturation of the HSI model.
[0109] In steps S611-S614, it is determined whether the original document image is an RGB color space image to determine whether the original document image needs to be spatially converted. If the original document image is an RGB color space image, the color value of the RGB color space is obtained to quickly obtain the RGB color space corresponding to the original document image. If the original document image is not an RGB color space image, the original document image is converted into an RGB color space image, and the color value of the RGB color space is obtained to achieve spatial conversion of the original document image and obtain the RGB color space corresponding to the original document image. The color value of the RGB color space is converted into the image value of the HSI color space by geometric deduction, and the image value of the HSI color space is used as the image parameter corresponding to the original document image to quickly obtain the image parameter, and the acquisition process is simple.
[0110] In one embodiment, the image value includes brightness, saturation and hue. Figure 8 As shown, in step S614, the color value of the RGB color space is converted into the image value of the HSI color space by a geometric derivation method, which specifically includes the following steps:
[0111] S6141: Based on the intensity of the red component, the intensity of the green component, and the intensity of the blue component, the brightness of the HSI color space is obtained according to the brightness formula. The brightness formula is: r is the intensity of the red component, g is the intensity of the green component, b is the intensity of the blue component, and i is the brightness.
[0112] Specifically, the color value of the RGB color space corresponding to the original document image is obtained, and the red component intensity, green component intensity, and blue component intensity in the color value of the RGB color space are respectively substituted into the brightness formula to obtain the brightness of the image value converted into the HSI color space, that is, the brightness corresponding to the original document image.
[0113] S6142: Based on the red component intensity, green component intensity, and blue component intensity, the saturation of the HSI color space is obtained according to the saturation formula. The saturation formula is: s is the saturation, and min(r, g, b) is the minimum value of the red component intensity, the green component intensity, and the blue component intensity.
[0114] Specifically, the server obtains the minimum value of the red component intensity, the green component intensity and the blue component intensity based on the red component intensity, the green component intensity and the blue component intensity, and substitutes the red component intensity, the green component intensity and the blue component intensity and the minimum value into the saturation formula to obtain the saturation of the image value converted into the HSI color space, that is, the saturation corresponding to the original document image.
[0115] S6143: Based on the intensity of the red component, the intensity of the green component, and the intensity of the blue component, the hue of the HSI color space is obtained according to the hue formula. The hue formula is: h is the hue.
[0116] Specifically, the server uses the formula based on the red component intensity, green component intensity and blue component intensity Calculate the value of θ. If the intensity of the green component is greater than or equal to the intensity of the blue component, the hue is equal to the value of θ. If the intensity of the green component is less than the intensity of the blue component, the hue is equal to 2π-θ. This is to obtain the hue in the image value converted into the HSI color space, that is, the hue corresponding to the original document image.
[0117] In steps S6141-S6143, based on the intensity of the red component, the intensity of the green component and the intensity of the blue component, the brightness of the HSI color space is obtained according to the brightness formula, the saturation of the HSI color space is obtained according to the saturation formula, and the hue of the HSI color space is obtained according to the hue formula, so as to quickly obtain the brightness, saturation and hue of the HSI color space, and use the brightness, saturation and hue of the HSI color space as image parameters corresponding to the original document image, so as to subsequently calculate the image color difference between the side image and the front image according to the image parameters.
[0118] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0119] In one embodiment, a device for verifying the authenticity of a certificate is provided, and the device for verifying the authenticity of a certificate corresponds one-to-one to the method for verifying the authenticity of a certificate in the above embodiment. Fig. 9 As shown, the document authenticity verification device includes an image acquisition module 10, a region block image acquisition module 20, a target text acquisition module 30, a first verification module 40, a second verification module 50, a third verification module 60 and a result determination module 70. The functional modules are described in detail as follows:
[0120] The image acquisition module 10 is used to acquire an original document image, where the original document image corresponds to a document type.
[0121] The region block image acquisition module 20 is used to locate the original document image using the CTPN-RNN algorithm, obtain at least one text line region, intercept the image corresponding to the text line region from the original document image as the region block image, and obtain the position identifier corresponding to each region block image.
[0122] The target text acquisition module 30 is used to recognize each region block image by using an OCR recognition model to acquire the target text corresponding to each region block image.
[0123] The first verification module 40 is used to obtain corresponding content verification rules based on the document type and the position identifier corresponding to each regional block image, and perform content verification on the target text corresponding to each regional block image using the content verification rules to obtain content verification results.
[0124] The second verification module 50 is used to verify the target text corresponding to each area block image with the standard text in the database corresponding to the document type to obtain a data verification result.
[0125] The third verification module 60 is used to perform color difference verification on the original document image and obtain a color difference verification result.
[0126] The result determination module 70 is used to determine that the document corresponding to the original document image is a genuine document if the content verification result, the data verification result and the color difference verification result are all verified to be passed.
[0127] In one embodiment, the target text acquisition module 30 includes a target recognition content acquisition unit and a target text acquisition unit.
[0128] The target recognition content acquisition unit is used to recognize each region block image using an OCR recognition model to obtain target recognition content, wherein the target recognition content includes recognition text corresponding to the region block image and recognition probability corresponding to the recognition text.
[0129] The target text acquisition unit is used to use the recognized text corresponding to the maximum recognition probability as the target text corresponding to the regional block image.
[0130] In one embodiment, the OCR recognition model includes a dedicated OCR recognition model and a general OCR recognition model.
[0131] The target recognition content acquisition unit includes an attribute acquisition subunit, a first recognition subunit and a second recognition subunit.
[0132] The attribute acquisition subunit is used to acquire the attributes corresponding to each area block image based on the document type corresponding to the original document image and the position identifier corresponding to each area block image, and the attributes include special attributes and general attributes.
[0133] The first recognition subunit is used to recognize the region block image by using a dedicated OCR recognition model if the attribute corresponding to the region block image is a dedicated attribute, so as to obtain target recognition content corresponding to the region block image.
[0134] The second recognition subunit is used to recognize the region block image by using a universal OCR recognition model if the attribute corresponding to the region block image is a universal attribute, so as to obtain target recognition content corresponding to the region block image.
[0135] In one embodiment, the first verification module 40 includes a content verification rule acquisition unit, a target region block image acquisition unit, and a content verification result acquisition unit.
[0136] The content verification rule acquisition unit is used to acquire at least one content verification rule corresponding to the certificate type based on the certificate type, and each content verification rule corresponds to an identification of an area to be verified.
[0137] The target area block image acquisition unit is used to acquire the target area block image whose position identifier matches the identifier of the area to be verified.
[0138] The content verification result acquisition unit is used to perform content verification on the target text corresponding to the target area block image by using the content verification rule to obtain the content verification result.
[0139] In one embodiment, the original document image includes a front document image and at least two side document images.
[0140] The third verification module 60 includes an image parameter acquisition submodule, an image color difference calculation submodule and a color difference verification result acquisition submodule.
[0141] The image parameter acquisition submodule is used to perform spatial transformation on the original document image and obtain the image parameters corresponding to each original document image. The image parameters include hue, saturation and brightness.
[0142] The image color difference calculation submodule is used to calculate the image color difference between each side image and the front image of the document using the color difference formula based on the hue, saturation and brightness corresponding to each original document image. The color difference formula is 1 is the front image, 2 is the side image, D is the color difference between the front image and the side image, i1 is the brightness of the front image, i2 is the brightness of the side image, s1 is the saturation of the front image, s2 is the saturation of the side image, h1 is the hue of the front image, and h2 is the hue of the side image.
[0143] The color difference verification result acquisition submodule is used to compare the color difference of each image with the color difference threshold corresponding to the document type. If the image color difference is greater than or equal to the color difference threshold, the color difference verification result is verification passed.
[0144] In one embodiment, the image parameter acquisition submodule includes a determination unit, a first determination unit, a second determination unit and an image parameter acquisition unit.
[0145] The judging unit is used to judge whether the original document image is an RGB color space image.
[0146] The first determination unit is used to obtain the color value of the RGB color space if the original document image is an RGB color space image, where the color value includes the intensity of the red component, the intensity of the green component and the intensity of the blue component.
[0147] The second determination unit is configured to convert the original document image into an RGB color space image if the original document image is not an RGB color space image, and obtain a color value in the RGB color space.
[0148] The image parameter acquisition unit is used to convert the color value of the RGB color space into the image value of the HSI color space through a geometric deduction method, and use the image value of the HSI color space as the image parameter corresponding to the original document image.
[0149] In one embodiment, the image value includes brightness, saturation and hue. The image parameter acquisition unit includes a brightness acquisition subunit, a saturation acquisition subunit and a hue acquisition subunit.
[0150] The brightness acquisition subunit is used to obtain the brightness of the HSI color space based on the red component intensity, the green component intensity and the blue component intensity according to the brightness formula. The brightness formula is: r is the intensity of the red component, g is the intensity of the green component, b is the intensity of the blue component, and i is the brightness.
[0151] The saturation acquisition subunit is used to obtain the saturation of the HSI color space based on the red component intensity, the green component intensity, and the blue component intensity according to the saturation formula. The saturation formula is: s is the saturation, and min(r, g, b) is the minimum value of the red component intensity, the green component intensity, and the blue component intensity.
[0152] The hue acquisition subunit is used to obtain the hue of the HSI color space based on the red component intensity, the green component intensity and the blue component intensity according to the hue formula. The hue formula is: h is the hue.
[0153] The specific definition of the document authenticity verification device can be found in the definition of the document authenticity verification method above, which will not be repeated here. Each module in the above-mentioned document authenticity verification device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0154] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.10 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the user's standard text, etc. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for verifying the authenticity of a certificate is implemented.
[0155] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the document authenticity verification method in the above embodiment are implemented, for example, Figure 2 Steps S10 to S70 shown, or the processor executes the computer program to implement the functions of each module / submodule / unit / subunit in the document authenticity verification device in the above embodiment, for example, Fig. 9 The functions of the modules 10 to 70 are shown in Figure 1. To avoid repetition, they will not be described in detail here.
[0156] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the document authenticity verification method in the above method embodiment are implemented, for example, Figure 2 Steps S10 to S70 shown, or when the computer program is executed by a processor, implement the functions of each module / submodule / unit / subunit in the document authenticity verification device in the above device, for example, Fig. 9 The functions of the modules 10 to 70 are shown in Figure 1. To avoid repetition, they will not be described in detail here.
[0157] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0158] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0159] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.
Claims
1. A method for verifying the authenticity of a certificate, characterized in that: include: Acquire an original document image, where the original document image corresponds to a document type; Using a CTPN-RNN algorithm to locate the original document image, obtaining at least one text line region, intercepting an image corresponding to the text line region from the original document image as a regional block image, and obtaining a position identifier corresponding to each regional block image; Using an OCR recognition model to recognize each of the regional block images, and obtaining target text corresponding to each of the regional block images; Based on the document type and the position identifier corresponding to each of the regional block images, a corresponding content verification rule is obtained, and the content verification rule is used to perform content verification on the target text corresponding to each of the regional block images to obtain a content verification result; Verify the target text corresponding to each of the area block images with the standard text in the database corresponding to the certificate type to obtain a data verification result; Performing spatial transformation on the original document images to obtain image parameters corresponding to each of the original document images, the image parameters including hue, saturation and brightness; the original document images include a front document image and at least two side document images; Based on the hue, saturation and brightness corresponding to each of the original document images, a color difference formula is used to calculate the image color difference between each of the side document images and the front document image; The color difference formula is , 1 is the front image, 2 is the side image, D is the color difference between the front image and the side image, is the brightness of the front image, is the brightness of the side image, is the saturation of the front image, is the saturation of the side image, is the hue of the front image, is the hue of the side image; Compare the color difference of each image with the color difference threshold corresponding to the document type, and if the color difference of the image is greater than or equal to the color difference threshold, the color difference verification result is verification passed; If the content verification result, the data verification result and the color difference verification result are all verified to be passed, the certificate corresponding to the original certificate image is a genuine certificate.
2. The method for verifying the authenticity of a certificate as claimed in claim 1, characterized in that: The adopting of the OCR recognition model to recognize each of the regional block images to obtain the target text corresponding to each of the regional block images includes: Using an OCR recognition model to recognize each of the region block images, and obtaining target recognition content, wherein the target recognition content includes recognition text corresponding to the region block image and recognition probability corresponding to the recognition text; The recognized text corresponding to the maximum recognition probability is used as the target text corresponding to the regional block image.
3. The method for verifying the authenticity of a certificate as claimed in claim 2, characterized in that: The OCR recognition model includes a dedicated OCR recognition model and a general OCR recognition model; The adopting of the OCR recognition model to recognize each of the region block images to obtain target recognition content includes: Based on the document type corresponding to the original document image and the position identifier corresponding to each of the regional block images, acquiring attributes corresponding to each of the regional block images, the attributes including dedicated attributes and general attributes; If the attribute corresponding to the region block image is a dedicated attribute, the dedicated OCR recognition model is used to recognize the region block image to obtain target recognition content corresponding to the region block image; If the attribute corresponding to the region block image is a general attribute, the general OCR recognition model is used to recognize the region block image to obtain target recognition content corresponding to the region block image.
4. The method for verifying the authenticity of a certificate as claimed in claim 1, characterized in that: The step of obtaining a corresponding content verification rule based on the document type and the position identifier corresponding to each of the regional block images, performing content verification on the target text corresponding to each of the regional block images using the content verification rule, and obtaining a content verification result includes: Based on the certificate type, obtaining at least one content verification rule corresponding to the certificate type, each of the content verification rules corresponding to a to-be-verified area identifier; Acquire a target area block image whose position identifier matches the area identifier to be verified; The content verification rule is adopted to perform content verification on the target text corresponding to the target area block image to obtain a content verification result.
5. The method for verifying the authenticity of a certificate as claimed in claim 1, characterized in that: The performing spatial transformation on the original document images to obtain image parameters corresponding to each of the original document images includes: Determining whether the original document image is an RGB color space image; If the original document image is an RGB color space image, then obtaining a color value in the RGB color space, wherein the color value includes a red component intensity, a green component intensity, and a blue component intensity; If the original document image is not an RGB color space image, converting the original document image into an RGB color space image to obtain a color value in the RGB color space; The color values in the RGB color space are converted into image values in the HSI color space by a geometric deduction method, and the image values in the HSI color space are used as image parameters corresponding to the original document image.
6. The method for verifying the authenticity of a certificate as claimed in claim 5, characterized in that: The image values include brightness, saturation and hue; The converting the color value of the RGB color space into the image value of the HSI color space by a geometric derivation method comprises: Based on the intensity of the red component, the intensity of the green component, and the intensity of the blue component, the brightness of the HSI color space is obtained according to a brightness formula, where the brightness formula is: , r is the intensity of the red component, g is the intensity of the green component, b is the intensity of the blue component, and i is the brightness; Based on the intensity of the red component, the intensity of the green component, and the intensity of the blue component, the saturation of the HSI color space is obtained according to a saturation formula, where the saturation formula is: , s is saturation, is the minimum value among the intensity of the red component, the intensity of the green component, and the intensity of the blue component; Based on the intensity of the red component, the intensity of the green component, and the intensity of the blue component, the hue of the HSI color space is obtained according to a hue formula, where the hue formula is: , , h is the hue.
7. A device for verifying the authenticity of a certificate, characterized in that: include: An image acquisition module, used to acquire an original document image, wherein the original document image corresponds to a document type; A region block image acquisition module, used to locate the original document image using a CTPN-RNN algorithm, acquire at least one text line region, intercept an image corresponding to the text line region from the original document image as a region block image, and acquire a position identifier corresponding to each region block image; A target text acquisition module, used to recognize each of the regional block images using an OCR recognition model to acquire the target text corresponding to each of the regional block images; A first verification module is used to obtain a corresponding content verification rule based on the document type and the position identifier corresponding to each of the regional block images, and perform content verification on the target text corresponding to each of the regional block images using the content verification rule to obtain a content verification result; A second verification module is used to verify the target text corresponding to each of the regional block images with the standard text in the database corresponding to the certificate type to obtain a data verification result; A third verification module is used to perform spatial transformation on the original document images to obtain image parameters corresponding to each of the original document images, wherein the image parameters include hue, saturation and brightness; the original document images include a front document image and at least two side document images; Based on the hue, saturation and brightness corresponding to each of the original document images, a color difference formula is used to calculate the image color difference between each of the side document images and the front document image; The color difference formula is , 1 is the front image, 2 is the side image, D is the color difference between the front image and the side image, is the brightness of the front image, is the brightness of the side image, is the saturation of the front image, is the saturation of the side image, is the hue of the front image, is the hue of the side image; comparing the color difference of each image with the color difference threshold corresponding to the document type, if the color difference of the image is greater than or equal to the color difference threshold, the color difference verification result is verification passed; The result determination module is used to determine that if the content verification result, the data verification result and the color difference verification result are all verified to be passed, the certificate corresponding to the original certificate image is a genuine certificate.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the document authenticity verification method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the document authenticity verification method as claimed in any one of claims 1 to 6 are implemented.
