Picture verification code generation method and device, terminal equipment and readable storage medium
By dynamically fine-tuning the CAPTCHA image, a CAPTCHA image that is difficult for machines to recognize is generated, which solves the problem of poor security of existing CAPTCHAs and enhances the security of manual verification by users.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN CITY TECHWIN SEMICONDUCTOR COMPANY LIMITED
- Filing Date
- 2022-08-25
- Publication Date
- 2026-05-01
AI Technical Summary
Existing CAPTCHA verification methods have poor security and are easily recognized by machine learning, allowing automated ticket-grabbing software to complete the verification automatically.
By dynamically fine-tuning the base images in the database, dynamic verification images are generated, including techniques such as 3D model projection, contour adjustment, and region filling, thereby increasing the difficulty of image CAPTCHAs.
The security of image verification codes has been improved, making it more difficult for machines to recognize them automatically, ensuring that users need to manually participate in the verification process to prevent automated ticket grabbing.
Smart Images

Figure CN115563333B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information security technology, and more specifically, to a method, apparatus, terminal device, and readable storage medium for generating image verification codes. Background Technology
[0002] CAPTCHAs can prevent malicious password cracking, vote rigging, and forum spamming. In existing technologies, for applications like 12306, users need to manually identify and click on the images appearing in the CAPTCHA. These images are pre-generated in a database and randomly selected. Although there are many types of images, such as people, animals, landscapes, and cartoons, the number of images stored in the database is limited. This makes it easy for machines to learn all the images and then identify them, such as some automatic ticket-grabbing software. Therefore, this verification method has poor security. Summary of the Invention
[0003] The purpose of this invention is to provide a method, apparatus, terminal device, and readable storage medium for generating image verification codes.
[0004] In a first aspect, the present invention provides a method for generating image verification codes, the method comprising:
[0005] Respond to the verification request and retrieve at least one basic image from the database;
[0006] The at least one base image is dynamically fine-tuned to obtain the corresponding verification image;
[0007] Generate a corresponding image verification code based on at least one verification image and display it on the verification interface.
[0008] In an optional implementation, the step of dynamically fine-tuning the at least one base image to obtain a corresponding verification image includes:
[0009] Extract the target from the base image and construct the corresponding 3D model based on the target;
[0010] The 3D model is projected using a projection angle different from the previous one to obtain a corresponding 2D image, which serves as a verification image.
[0011] In an optional implementation, the projection angle of the three-dimensional model includes a projection angle that is adjusted according to a preset step size based on the previous adjustment, or a projection angle that is randomly generated and different from the previous one.
[0012] In an optional implementation, the step of dynamically fine-tuning the at least one base image to obtain a corresponding verification image includes:
[0013] Extract the corresponding contour lines from the base image to generate a contour map;
[0014] The contour lines or regions in the contour map are dynamically fine-tuned to obtain the corresponding verification image.
[0015] In an optional implementation, the dynamic fine-tuning of the region in the contour map includes:
[0016] The contour map is divided into multiple regions based on a preset region division rule, which is to divide the region according to the region formed when the contour line is closed.
[0017] Dynamically fine-tune the segmented contour map, including one or a combination of the following operations:
[0018] Fill a portion or all of a region with color, where adjacent regions are filled with different colors;
[0019] Adjust the height and / or width of the aforementioned region.
[0020] In an optional implementation, the dynamic fine-tuning of the contour lines in the contour map includes:
[0021] Based on the outline diagram, the corresponding target object is determined, and the key features of the target object are identified.
[0022] The contour lines corresponding to the key features are extracted, and the curvature of the extracted contour lines is adjusted.
[0023] In an optional implementation, the verification interface includes a preset number of images, and the method further includes:
[0024] When the preset number is greater than the number of verification images, the number of base images to be retrieved from the database again is determined based on the preset number and the number of verification images;
[0025] Obtain the number of base images from the remaining base images in the database, and obtain the verification question corresponding to any one of the at least one verification image from the database, wherein each base image corresponds to one verification question;
[0026] The image verification code, the newly obtained base image, and the verification question are combined and displayed on the verification interface.
[0027] Secondly, the present invention provides an image verification code generation device, the device comprising:
[0028] The acquisition module is used to respond to verification requests and retrieve at least one basic image from the database;
[0029] The adjustment module is used to dynamically fine-tune the at least one base image to obtain the corresponding verification image;
[0030] The generation module is used to generate corresponding image verification codes based on at least one verification image and display them on the verification interface.
[0031] Thirdly, the present invention provides a terminal device, including a memory and a processor, wherein the memory stores a computer program, and the computer program executes the image verification code generation method when it is run on the processor.
[0032] Fourthly, the present invention provides a readable storage medium storing a computer program that executes the image verification code generation method when run on a processor.
[0033] The beneficial effects of the embodiments of the present invention are:
[0034] This application provides a method for generating image CAPTCHAs. This method, in response to a verification request, obtains at least one basic image from a database, dynamically fine-tunes the basic image to obtain a corresponding verification image, generates a corresponding image CAPTCHA based on the verification image, and displays it on a verification interface. This application not only increases the difficulty for machines to automatically recognize image CAPTCHAs but also improves their security.
[0035] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0036] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope of protection of the present invention. In the various drawings, similar components are numbered similarly.
[0037] Figure 1 This paper illustrates a first flowchart of an image verification code generation method proposed in an embodiment of this application.
[0038] Figure 2 This illustration shows a first process diagram of generating a verification image in an image verification code generation method proposed in an embodiment of this application;
[0039] Figure 3 This illustration shows a second schematic diagram of generating a verification image in an image verification code generation method according to an embodiment of this application;
[0040] Figure 4 This illustration shows a flowchart of a method for generating an image verification code according to an embodiment of this application, in which the region is dynamically fine-tuned.
[0041] Figure 5 This illustration shows a schematic diagram of region division in an image verification code generation method proposed in an embodiment of this application;
[0042] Figure 6 This paper illustrates a flowchart of a method for generating an image verification code according to an embodiment of this application, which involves dynamically fine-tuning the outline.
[0043] Figure 7 This illustration shows a schematic diagram of dynamically fine-tuning the outline in an image verification code generation method proposed in an embodiment of this application;
[0044] Figure 8 This paper illustrates a second flowchart of an image verification code generation method proposed in an embodiment of this application.
[0045] Figure 9 A schematic diagram of the structure of an image verification code generation device provided in an embodiment of this application is shown.
[0046] Explanation of key component symbols:
[0047] 10-Image verification code generation device; 11-Acquisition module; 12-Adjustment module; 13-Generation module. Detailed Implementation
[0048] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0049] The components of the embodiments of the invention described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0050] In the following, the terms “comprising,” “having,” and their cognates, which may be used in various embodiments of the invention, are intended only to indicate a particular feature, number, step, operation, element, component, or combination thereof, and should not be construed as excluding, firstly, the presence of one or more other features, numbers, steps, operations, elements, components, or combinations thereof, or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations thereof.
[0051] Furthermore, the terms "first," "second," and "third" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0052] Unless otherwise specified, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of the invention pertain. Terms (such as those defined in commonly used dictionaries) shall be interpreted as having the same meaning as in their contextual meaning in the relevant technical field and shall not be interpreted as having an idealized or overly formal meaning, unless clearly defined in the various embodiments of the invention.
[0053] Currently, some hackers and businesses have developed ticket-grabbing software that automatically recognizes CAPTCHAs pushed by applications such as 12306. This software simply needs to continuously send buy commands to continuously obtain image data. After a period of time, it can obtain all the image data in the database. During this process, the answer information corresponding to each image is simultaneously identified manually (image authentication requires users to answer questions or select areas in the image), and all images and their corresponding answer information are compiled and stored in the ticket-grabbing software's database.
[0054] During the subsequent ticket-grabbing process, the ticket-grabbing software can compare and retrieve the images pushed by the server with the image data stored in the ticket-grabbing software database, and then automatically report the saved answers to achieve an automated ticket-grabbing function without human intervention.
[0055] Therefore, existing CAPTCHA verification methods suffer from poor security. To address these issues, this invention provides a method, apparatus, terminal device, and readable storage medium for generating image CAPTCHAs.
[0056] Example 1
[0057] Please refer to Figure 1 This application provides a method for generating image verification codes. Exemplarily, the method includes steps S100 to S300.
[0058] Step S100: Respond to the verification request and obtain at least one basic image from the database.
[0059] In this embodiment of the application, the database stores at least one basic image. When a user issues a verification request, the database responds to the verification request and retrieves at least one basic image from the database. The content included in the basic image may be plants, animals, objects, etc.
[0060] Step S200: Perform dynamic fine-tuning on at least one base image to obtain the corresponding verification image.
[0061] Understandably, at least one base image is dynamically fine-tuned, and the adjusted image is used as the verification image. This dynamic fine-tuning includes, but is not limited to, 3D projection transformation, contour region and contour line adjustment, and contour region color filling.
[0062] In one implementation, such as Figure 2 As shown, step S200 includes sub-steps S210 to S220.
[0063] Sub-step S210: Extract the target from the base image and construct the corresponding 3D model based on the target.
[0064] In this embodiment, after acquiring a base image from the database, the target image is extracted from the base image, and a corresponding 3D model is constructed based on the acquired target using modeling software. The 3D modeling based on the target is within the scope of existing technology and will not be described in detail here.
[0065] Sub-step S220: Select a projection angle different from the previous adjustment to project the 3D model and obtain the corresponding 2D image, which is the verification image.
[0066] Understandably, projecting a 3D model from different angles will yield different 2D images. When projecting the constructed 3D model, a different projection angle than the previous projection will be selected to obtain a 2D image of the 3D model at the selected projection angle, which will serve as a verification image. The projection angle of the 3D model includes angles adjusted according to a preset step size based on the previous adjustment; in other words, the projection angle of the 3D model can be adjusted according to a preset step size, which can be set according to actual conditions. The projection angle of the 3D model also includes randomly generated angles different from the previous one.
[0067] In one implementation, such as Figure 3 As shown, step S200 also includes sub-steps S230 to S240.
[0068] Sub-step S230: Extract the corresponding contour lines from the base image to generate a contour map.
[0069] Understandably, the process involves extracting the corresponding contour lines from a base image and generating a corresponding contour map based on these extracted contour lines. Extracting contour lines from an image is a matter of existing technology and will not be discussed in detail here. For example, when the base image includes an animal, the animal's contour lines will be extracted, and a corresponding contour map will be generated based on these contour lines.
[0070] Sub-step S240: Dynamically fine-tune the contour lines or regions in the contour map to obtain the corresponding verification image.
[0071] After generating the contour map, the contour lines or the regions formed by the contour lines in the contour map will be dynamically fine-tuned to obtain the corresponding verification image. The dynamic fine-tuning includes one or more of the following: adjusting the curvature of some contour lines, adjusting the curvature of all contour lines, adding or removing some contour lines, adjusting the width of some regions, and adjusting the height of some regions. For example, the curvature of all contour lines in the contour map can be increased.
[0072] For example, when the extracted outline image is a flower, the outlines corresponding to the petals can be added or deleted, and the orientation of the flower can be adjusted. In other words, the overall outline of the flower can also be adjusted.
[0073] In one implementation, such as Figure 4 As shown, the region in the contour map is dynamically fine-tuned, including sub-steps S241 to S242.
[0074] Sub-step S241: Divide the contour map into multiple regions based on a preset region division rule. The preset region division rule is to divide the region according to the region formed when the contour line is closed.
[0075] Understandably, the contour map is divided into multiple regions according to a preset region division rule, where the division is based on the regions formed when the contour lines close. For example, when the contour lines in the contour map form at least one closed region, the contour map is divided according to the regions formed when the contour lines close. For instance, as... Figure 5 As shown, when there is only one circle in the contour map, the contour map is divided into two regions: the inner region A and the outer region B formed when the circle's contour line is closed.
[0076] Sub-step S242: Dynamically fine-tune the divided contour map, including one or a combination of the following operations: fill part or all of the region with color, wherein adjacent regions are filled with different colors; adjust the height and / or width of part of the region.
[0077] In this embodiment, after dividing the contour map into multiple regions, the divided contour map is dynamically fine-tuned. Exemplarily, dynamic fine-tuning can fill some or all regions of the divided contour map with color. Different colors are selected from a preset color pool to fill different regions; adjacent regions will not be filled with the same color. The color selected when filling the same region in the contour map will be different from the color selected during the initial adjustment. The preset color pool includes multiple colors. Dynamic fine-tuning can also adjust the height, width, or height and width of some regions after the contour map is divided. Furthermore, dynamic fine-tuning of the divided contour map can also involve simultaneously filling some or all regions with color and adjusting the height, width, or height and width of some regions.
[0078] For example, if the outline of the rabbit in the contour drawing is a rabbit, and the outline of the rabbit's left ear forms a closed area, then the area formed by the outline of the rabbit's left ear is one of several areas divided in the contour drawing. You can fill in the rabbit's left ear area with color, or you can adjust the height of the rabbit's left ear area before filling it with color. Furthermore, when filling in the rabbit's left ear area, you can first fill it with red, then blue, and finally green.
[0079] In one implementation, such as Figure 6 As shown, the contour lines in the contour map are dynamically fine-tuned, including sub-steps S243 to S244.
[0080] Sub-step S243: Determine the corresponding target object based on the contour map, and determine the key features of the target object.
[0081] Based on the generated contour map, the target object in the contour map can be identified, and the key features of the target object can be determined. The target object is any object contained in the contour map, such as an animal, a human figure, or a physical object. For example, if the target object in the contour map is a human figure, the key features could be facial features such as eyes and mouth; if the target object is a rabbit, the key features could be its ears and tail.
[0082] Sub-step S244: Extract the contour lines corresponding to the key features and adjust the curvature of the extracted contour lines.
[0083] After identifying the key features of the target object in the contour map, the contour lines corresponding to these key features are extracted from the contour map, and the curvature of the extracted contour lines is adjusted. For example, as shown... Figure 7As shown, when the outline in the contour diagram is a pentagram, the outline corresponding to the key features of the target object can be the outline corresponding to the pentagram. In this case, some outlines in the contour diagram can be added, and the curvature of the outlines after adding some outlines can be adjusted to increase the difficulty of being automatically recognized by the machine.
[0084] For example, when the extracted contour image is a flower, meaning the target object in the contour image is determined to be a flower, its key feature is the petal feature. After extracting the petal feature, adjustments can be made to the number of leaves, etc. In other words, the curvature of the petal contour line can be adjusted, such as increasing or decreasing the curvature. Alternatively, the petal contour line can be added or deleted. When transforming and adjusting the flower's contour line, the flower's orientation can also be adjusted; that is, the entire flower's contour line can be adjusted. When the target object included in the contour image is a rabbit, the key feature can be the rabbit's ear feature. After extracting the corresponding ear contour line from the contour image based on the rabbit's ear feature, the curvature of the rabbit's ear contour line can be adjusted, thereby adjusting the angle of the two ears.
[0085] It is understandable that when a base image is not retrieved from the database, a preset code can be retrieved from the database, and a verification image can be randomly generated using the preset code. This preset code falls within the scope of existing technology and will not be described in detail here.
[0086] Step S300: Generate a corresponding image verification code based on at least one verification image and display it on the verification interface.
[0087] After obtaining at least one verification image, generate a corresponding image verification code based on the at least one verification image, and display the generated image verification code on the verification interface.
[0088] In one implementation, such as Figure 8 As shown, the image verification code generation method also includes steps S400 to S600.
[0089] Step S400: When the preset number is greater than the number of verification images, the number of base images to be acquired again is determined based on the preset number and the number of verification images.
[0090] It is understandable that a preset number of images will be displayed on the verification interface. When the preset number to be displayed on the verification interface is greater than the number of verification images obtained after dynamic fine-tuning, the number of base images to be retrieved from the database will be determined based on the preset number and the number of verification images. The preset number will be set according to the actual situation.
[0091] Step S500: Obtain the number of basic images from the remaining basic images in the database, and obtain the verification question corresponding to any one of the verification images from the database, wherein each basic image corresponds to one verification question.
[0092] Understandably, the system will retrieve a corresponding number of base images from the remaining base images in the database based on the number of base images to be retrieved again. These remaining base images are those not selected for dynamic fine-tuning. Furthermore, each base image corresponds to a verification question, and the database stores all verification questions corresponding to all base images. Additionally, any verification image included in the image verification code will be selected to determine its corresponding base image, and the verification question for that base image will be retrieved from the database.
[0093] Step S600: Combine the image verification code, the newly obtained basic image, and the verification question, and display them on the verification interface.
[0094] After obtaining the image verification code, the base image obtained again, and the corresponding verification question, the image verification code, the base image obtained again, and the verification question are combined and displayed on the verification interface for verification. For example, the base image obtained again and the verification images included in the image verification code are arranged in an M*N format, where M and N are both positive integers greater than or equal to 1. For instance, when the preset number of images displayed on the verification interface is six, they can be arranged in a 3x2 grid. The images displayed on the verification interface can all be the adjusted verification images, i.e., the image verification code, or a combination of the image verification code and the base image obtained again.
[0095] In this embodiment, new verification code images will be dynamically generated so that machines cannot complete the automatic verification function by collecting images. This will disable the automatic verification machine, so that users can only verify manually. This not only increases the difficulty for machines to automatically recognize image verification codes, but also improves the security of image verification codes.
[0096] The image verification code generation method based on the above embodiments Figure 9 A schematic diagram of the structure of an image verification code generation device 10 provided in an embodiment of this application is shown. The image verification code generation device 10 includes:
[0097] Module 11 is used to respond to verification requests and retrieve at least one basic image from the database.
[0098] The adjustment module 12 is used to dynamically fine-tune the at least one base image to obtain the corresponding verification image.
[0099] The generation module 13 is used to generate a corresponding image verification code based on at least one verification image and display it on the verification interface.
[0100] The image verification code generation device 10 in this embodiment is used to execute the image verification code generation method of the above embodiment. The implementation schemes and beneficial effects involved in the above embodiments are also applicable in this embodiment, and will not be repeated here.
[0101] This application also provides a terminal device, including a memory and a processor. The memory stores a computer program, and the computer program executes the above-described image verification code generation method when it runs on the processor.
[0102] This application also provides a computer-readable storage medium storing a computer program that, when executed on a processor, implements the above-described image verification code generation method.
[0103] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that, as an alternative implementation, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0104] In addition, the functional modules or units in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0105] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a smartphone, personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0106] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for generating image verification codes, characterized in that, The method includes: Respond to the verification request and retrieve at least one basic image from the database; The at least one base image is dynamically fine-tuned to obtain the corresponding verification image; Generate a corresponding image verification code based on at least one verification image and display it on the verification interface; The step of dynamically fine-tuning the at least one base image to obtain a corresponding verification image includes: extracting the target from the base image and constructing a corresponding three-dimensional model based on the target; projecting the three-dimensional model using a projection angle different from the previous adjustment to obtain a corresponding two-dimensional image, which is the verification image.
2. The image verification code generation method according to claim 1, characterized in that, The projection angle of the three-dimensional model includes either a projection angle adjusted according to a preset step size based on the previous adjustment, or a projection angle generated randomly that is different from the previous one.
3. The image verification code generation method according to claim 1, characterized in that, The verification interface includes a preset number of images, and the method further includes: When the preset number is greater than the number of verification images, the number of base images to be retrieved from the database again is determined based on the preset number and the number of verification images; Obtain the number of base images from the remaining base images in the database, and obtain the verification question corresponding to any one of the at least one verification image from the database, wherein each base image corresponds to one verification question; The image verification code, the newly obtained base image, and the verification question are combined and displayed on the verification interface.
4. An image verification code generation device, characterized in that, The device includes: The acquisition module is used to respond to verification requests and retrieve at least one basic image from the database; An adjustment module is used to dynamically fine-tune the at least one base image to obtain a corresponding verification image, including: extracting the target from the base image and constructing a corresponding three-dimensional model based on the target; projecting the three-dimensional model with a projection angle different from the previous adjustment to obtain a corresponding two-dimensional image, wherein the two-dimensional image is the verification image; The generation module is used to generate corresponding image verification codes based on at least one verification image and display them on the verification interface.
5. A terminal device, characterized in that, The device includes a memory and a processor, wherein the memory stores a computer program, and the computer program, when executed on the processor, performs the image verification code generation method according to any one of claims 1 to 3.
6. A readable storage medium, characterized in that, It stores a computer program that, when run on a processor, executes the image verification code generation method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Verification method and verification device
CN104424426A
Method and device for dynamically generating verification code background image
CN114067040A