A method, device, electronic device and storage medium for generating verification code images

By segmenting the pending pictures into rectangular blocks and using random arrays to generate target graphics and tiles, the problem of high labor and time cost when generating verification code pictures is solved, and efficient and diversified verification code picture generation is achieved, supporting automation Automated verification of tests.

CN114386011BActive Publication Date: 2024-11-19BEIJING YUNCE INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111508991.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-10
Publication Date
2024-11-19
Estimated Expiration
2041-12-10

AI Technical Summary

Technical Problem

During the automated testing process, it takes a lot of labor and time to generate a large number of verification code pictures. The existing technology relies on manual collection of verification code picture data samples, which is inefficient.

Method used

By dividing the images to be processed into rectangular blocks, a random array of each rectangular block is obtained, the target graphics and target tiles are generated, and the verification code pictures are generated, the random and diversified verification code pictures are achieved.

Benefits of technology

It effectively solves the labor and time cost problems when generating a large number of verification code pictures, improves efficiency, ensures the diversity and number of verification code pictures, and supports automated verification of automated testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114386011B_ABST
    Figure CN114386011B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, electronic device and storage medium for generating a verification code image, which belongs to the field of data processing and is used to solve the problem in the related art that a large amount of manpower and time costs are consumed when generating a large number of verification code images. The method comprises: dividing the image to be processed into at least one rectangular block; for a target rectangular block in the at least one rectangular block, obtaining a random array corresponding to the target rectangular block, wherein the target rectangular block is any one of the at least one rectangular block; based on the random array, generating a target graphic corresponding to the target rectangular block; based on the target rectangular block and the target graphic, generating a target tile corresponding to the target rectangular block; based on the target tile, generating a verification code image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of data processing, and specifically relates to a method, device, electronic device and storage medium for generating a verification code image. Background Art

[0002] When encountering a scenario where a slider verification code needs to be verified during the automated testing process, the automated process is often interrupted and manual verification of the slider verification code is required, which consumes a lot of manpower and time. To solve this problem, an object detection model can be used to detect the position of the slider verification code to verify the slider verification code.

[0003] Normally, training a certain target detection model requires manually collecting a large number of verification code image data samples. If you want to generate tens of thousands of data, this process will consume a lot of manpower and time costs. Summary of the invention

[0004] The embodiments of the present application provide a method, device, electronic device and storage medium for generating a verification code image, which can solve the problem in the related art that a large amount of manpower and time costs are consumed when generating a large number of verification code images.

[0005] In a first aspect, an embodiment of the present application provides a method for generating a verification code image, the method comprising: dividing a to-be-processed image into at least one rectangular block; for a target rectangular block in the at least one rectangular block, obtaining a random array corresponding to the target rectangular block, wherein the target rectangular block is any one of the at least one rectangular block; based on the random array, generating a target graphic corresponding to the target rectangular block; based on the target rectangular block and the target graphic, generating a target tile corresponding to the target rectangular block; and based on the target tile, generating a verification code image.

[0006] In a second aspect, an embodiment of the present application provides a device for generating a verification code image, the device comprising: a segmentation module, used to segment a to-be-processed image into at least one rectangular block; an acquisition module, used to acquire a random array corresponding to a target rectangular block in the at least one rectangular block, wherein the target rectangular block is any one of the at least one rectangular block; a first generation module, used to generate a target graphic corresponding to the target rectangular block based on the random array; a second generation module, used to generate a target tile corresponding to the target rectangular block based on the target rectangular block and the target tile; a verification code module, used to generate a verification code image based on the target tile.

[0007] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.

[0008] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0009] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.

[0010] In an embodiment of the present application, a to-be-processed image is divided into at least one rectangular block; for a target rectangular block in the at least one rectangular block, a random array corresponding to the target rectangular block is obtained, wherein the target rectangular block is any one of the at least one rectangular block; based on the random array, a target graphic corresponding to the target rectangular block is generated; based on the target rectangular block and the target graphic, a target tile corresponding to the target rectangular block is generated; based on the target tile, a verification code image is generated, so that the target tile is generated after bitwise operation is performed between the rectangular blocks divided into the to-be-processed image and the target tile randomly generated based on the random array, so that each to-be-processed image can randomly generate a number of target tiles, and these target tiles are bitwise combined with the to-be-processed image to generate a number of verification code images. On this basis, if a large number of to-be-processed images are divided, a large number of randomly generated verification code images can be obtained, which solves the problem in the related art that a large amount of manpower and time costs are consumed when generating a large number of verification code images. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Figure 1 It is a flowchart of a method for generating a verification code image provided by an embodiment of the present application;

[0012] Figure 2 It is a schematic diagram of a picture provided in an embodiment of the present application;

[0013] Figure 3 is a schematic diagram of another picture provided in an embodiment of the present application;

[0014] Figure 4 It is a schematic diagram of a verification code picture provided in an embodiment of the present application;

[0015] Figure 5 It is a schematic diagram of another verification code picture provided in an embodiment of the present application;

[0016] Figure 6 It is a flowchart of another method for generating a verification code image provided by an embodiment of the present application;

[0017] Figure 7 It is a structural schematic diagram of a device for generating a verification code image according to an embodiment of the present application;

[0018] Figure 8 is a schematic structural diagram of an electronic device according to another embodiment of the present application. DETAILED DESCRIPTION

[0019] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0020] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0021] In conjunction with the accompanying drawings, a method, device, electronic device and storage medium for generating a verification code image provided by an embodiment of the present application are described in detail through specific embodiments and their application scenarios.

[0022] Figure 1 A method for generating a verification code image provided by an embodiment of the present invention is shown. The method can be executed by an electronic device, and the electronic device may include: a server and / or a terminal device, wherein the terminal device may be, for example, a vehicle-mounted terminal or a mobile phone terminal. In other words, the method can be executed by software or hardware installed in the electronic device, and the method includes the following steps:

[0023] Step 101: Divide the image to be processed into at least one rectangular block.

[0024] In this step, the image to be processed may be divided into a number of rectangular blocks.

[0025] Optionally, the image to be processed may be segmented according to a preset number of rows and columns to obtain at least one rectangular block.

[0026] For example, the image to be processed is randomly divided into x rows and y columns, so that x*y rectangular blocks can be generated.

[0027] Of course, the image to be processed may also be segmented in other ways, for example, the image to be processed may be segmented according to a preset number of segmentation blocks or a preset rectangular block size.

[0028] It should be noted that the sizes of the above-mentioned rectangular blocks may be the same or different.

[0029] In addition, the image to be processed can be any image and is not specifically limited here.

[0030] Step 102: For a target rectangular block in the at least one rectangular block, obtain a random array corresponding to the target rectangular block, wherein the target rectangular block is any one of the at least one rectangular block.

[0031] Specifically, for any one rectangular block among the at least one rectangular block, a random array corresponding to the rectangular block is obtained.

[0032] Specifically, the random number array may include at least one random number, and the number of the random number array may also be at least one, that is, it may be one, or may be two, three, or four.

[0033] Step 103: Based on the random array, generate a target graphic corresponding to the target rectangular block.

[0034] In this step, based on the random array corresponding to any target rectangular block, a target graphic corresponding to the target rectangular block is generated. At this time, due to the randomness of the random numbers in the random array, the target graphic can be randomly generated, thereby ensuring the diversity of the generated target graphic.

[0035] Step 104: Based on the target rectangular block and the target graphic, generate a target graphic block corresponding to the target rectangular block.

[0036] Specifically, when generating a target block corresponding to the target rectangular block based on the target rectangular block and the target graphic corresponding to the target rectangular block, the target rectangular block and the target graphic corresponding to the target rectangular block may be merged or the target rectangular block and the target graphic may be spliced.

[0037] The target rectangular block and the target graphic may be combined by performing a bit operation on the target rectangular block and its corresponding target graphic.

[0038] In addition, specifically, the target block can be a convex slider or a concave slider. Of course, it is understandable that the target block can also be a block of other shapes.

[0039] The convex slider and the concave slider can be distinguished based on whether there is an internal shadow effect inside the slider. Specifically, from the perspective of human visual effect, the concave slider has an internal shadow effect, while the convex slider does not have an internal shadow effect.

[0040] For example, Figure 2 The target rectangular block N shown in Figure 3 The circle Y shown in FIG. 1 is bitwise ANDed in the image P to be processed to obtain the following Figure 4 In the first block S1 shown in FIG, if there is no shadow inside the first block S1, the first block S1 is a convex slider. On the contrary, if there is a shadow inside the first block S1, the first block S1 is a concave slider.

[0041] Step 105: Generate a verification code image based on the target image block.

[0042] Specifically, in this step, the target image block can be combined with the image to be processed to generate a verification code image.

[0043] Specifically, for example, if the image to be processed is divided into 7 rows and 10 columns, the image to be processed can be divided into 70 (i.e., 7*10) rectangular blocks. On this basis, if each rectangular block is operated according to the above steps, a target graphic corresponding to each rectangular block can be generated according to the random array corresponding to each rectangular block, and then each rectangular block can be combined with its corresponding target graphic to generate a target block. In this way, by processing each rectangular block in the image to be processed, 70 randomly generated target blocks can be obtained, and then by combining the target blocks with the image to be processed, 70 randomly generated verification code images can be generated, which ensures the diversity of the verification code images generated by one image, and then ensures the number of verification code images generated. Continuing, if multiple images to be processed are processed in this way, a large number of randomly generated slider verification code images can be obtained, which avoids the problem that a large number of slider verification codes need to be manually collected in the related art to obtain more verification code images, which solves the problem that a large number of slider verification codes need to be manually collected when generating a large number of slider verification codes in the related art, which leads to a large amount of labor cost and time cost.

[0044] Thus, in this embodiment, the image to be processed is divided into a number of rectangular blocks, and a target graphic corresponding to the random array is randomly generated according to the random array corresponding to the rectangular block, and then the rectangular block is combined with the corresponding target graphic to generate a target tile, and the target tile is combined with the image to be processed to generate the same number of slider verification code images as the rectangular block. In this way, due to the randomness of the random numbers in the random array, the target graphics can be randomly generated, and the diversity of the generated target graphics is achieved, thereby achieving the diversity of the target tiles generated by the target graphics and the diversity of the slider verification codes obtained by the target tiles, so that one image can generate a large number of different verification code images, solving the problem of consuming a lot of time and manpower costs when generating a large number of verification code images in the related art.

[0045] In an optional implementation, generating a target graphic corresponding to the target rectangular block based on the random array may include the following steps:

[0046] Based on the preset correspondence between random numbers and graphic elements, a target graphic element corresponding to each random number in the random array is generated, and based on the target graphic element, the target graphic is obtained.

[0047] The graphic element includes at least one of a graphic shape, a positional relationship between the target graphic and the target rectangular block, and a graphic shadow effect, and the positional relationship includes that the target graphic overlaps with a graphic on at least one side of the target rectangular block.

[0048] In this implementation, based on the obtained random array, a target graphic corresponding to the random array can be generated. The target graphic includes elements such as the graphic shape, the positional relationship between the target graphic and the target rectangular block, and the graphic shadow effect; wherein the graphic shape can include a circle, a square, or an irregular quadrilateral, etc.

[0049] Specifically, the random array may include 3 random numbers. The first random number is used to generate the shape of the target graphic, such as a circle, a square or an irregular quadrilateral, where the shape may depend on the value of the random number; the second random number is used to generate the positional relationship between the target graphic and the target rectangular block, such as the positional relationship may be that the target graphic and at least one side of the target rectangular block coincide, or the center of the target graphic coincides with the midpoint of the left side of the target rectangle, where the positional relationship may depend on the value of the random number; the third random number is used to generate the internal shadow effect of the target graphic, where the internal shadow effect may be that there is a shadow or no shadow inside the target graphic.

[0050] In addition, it should be noted that the target pattern corresponding to the random array can be generated on at least one side of the target rectangular block corresponding to the random array. The number of random arrays can be the same as the number of target patterns, and the target patterns generated by the random arrays can be distributed on the respective sides of the target rectangular block. For example, a random array can generate a target pattern corresponding to the random array on one side of the target rectangular block, and two random arrays can generate target patterns corresponding to the two random arrays on both sides of the target rectangular block.

[0051] As a specific example, Figure 3 As shown, in the image P to be processed, the target image generated by the random array can be a circle Y without a shadow effect, and the center of the circle is Figure 2 The midpoint of the lower side of the target rectangular block N coincides.

[0052] In this way, by changing the random numbers in the random array, various target graphics can be generated accordingly, and then in the subsequent steps, the target graphics can be combined with their corresponding target rectangular blocks to generate various slider verification codes, which greatly enriches the diversity of slider verification codes. In this way, the form of slider verification code images generated based on slider verification codes is also fully enriched, ensuring the number of slider verification codes generated by one image, making the target detection model trained based on slider verification code images more reliable.

[0053] In an optional implementation, generating a target image block corresponding to the target rectangular block based on the target rectangular block and the target graphic may include: obtaining a first binarized image corresponding to the target rectangular block and a second binarized image corresponding to the target graphic; performing a bit operation on the first binarized image and the second binarized image to generate a target binarized image, wherein the target image block is represented by the target binarized image.

[0054] In this implementation, specifically, the target rectangular block and the target graphic binary image can be obtained, and the target rectangular block and the target graphic binary image can be bitwise operated to generate the target graphic block binary image. Optionally, the bitwise operation can include a bitwise AND operation, a bitwise OR operation, and a negation operation.

[0055] For example, Figure 2 The binary image of the target rectangular block N in can be Figure 3 The binary image of the circle Y in the figure is bitwise ORed to obtain Figure 4 The binarized image of the first image block S1 is shown. Figure 3 The binary image of the circle Y shown can also be bitwise inverted and compared with Figure 2 The binary image of the target rectangular block N shown in the figure is bitwise ANDed to obtain Figure 5The binarized image of the second image block S2 is shown.

[0056] In this way, by performing various bit operations on the target rectangular block and the binary image of the target graphic, various forms of target blocks can be generated, enriching the diversity of the slider verification code image data finally generated, making the target detection model based on the slider verification code image training more reliable.

[0057] In an optional implementation, the target block may be a convex slider or a concave slider; when the target graphic has a graphic shadow effect, the target block is a concave slider; when the target graphic has no graphic shadow effect, the target block is a convex slider.

[0058] Specifically, when the random numbers in the random array correspond to the shadow effect generated inside the target graphic, the target block generated by the bitwise operation of the target graphic and the target rectangular block is a concave slider; when there is no shadow effect inside the corresponding target graphic generated in the random array, the target block generated by the bitwise operation of the target graphic and the target rectangular block is a convex slider.

[0059] For example, as a specific example, Figure 4 The first block S1 in the image P to be processed and Figure 5 There is no shadow inside the second block S2 in the to-be-processed image P, so the first block S1 and the second block S2 are both convex sliders. Of course, if there are shadows inside the first block S1 and the second block S2, the first block S1 and the second block S2 are concave sliders.

[0060] In this way, by generating a shadow effect inside the target graphic, a large number of concave and convex sliders can be generated, which enriches the properties of the sliders, and further enriches the diversity of the slider verification code image data finally generated, making the target detection model based on the slider verification code image training more reliable.

[0061] In an optional implementation, generating a verification code image based on the target image block may include: generating a mask image of the target image block; performing a bitwise inversion operation on the mask image, and performing a bitwise AND operation on the mask image after the bitwise inversion operation and the image to be processed to obtain the verification code image.

[0062] In this implementation, based on the binary image of the target block, the mask image of the target slider can be generated. Then, the mask image is bitwise inverted to obtain the image form of the target block. On this basis, the mask image after bitwise inversion is bitwise ANDed with the image to be processed, so that the image of the target block is bitwise combined with the image to be processed to obtain a verification code image. In addition, if the target block is a convex slider, the slider verification code image corresponding to the convex slider can be obtained, and if the target block is a concave slider, the slider verification code image corresponding to the concave slider can be obtained.

[0063] In this way, through the above steps, a mask image corresponding to the target block can be generated based on the binary image of the target block, and the image mode of the target block can be obtained after the mask image is inverted. The image mode of the target block can be bitwise ANDed with the image to be processed to generate a slider verification code image. On this basis, if many images to be processed are segmented, and each image to be processed generates several rectangular blocks, a large number of rectangular blocks can be generated, and these rectangular blocks can generate a large number of different slider verification code images, which solves the problem of consuming a lot of manpower and time costs when generating a large number of verification code images in the related art.

[0064] In an optional implementation, after generating the target tile corresponding to the target rectangular block based on the target rectangular block and the target graphic, it may also include: generating a label file of the image to be processed, wherein the label file records the position of the target tile in the image to be processed and the slider attributes of the target tile, wherein the slider attributes include convex slider attributes or concave slider attributes.

[0065] In this implementation, specifically, after a target tile corresponding to a target rectangular block is generated, contour search can be used to save the position information of the target slider in the image to be processed and the slider attributes of the target tile in the label file, wherein the slider attributes may include the convex slider attribute or the concave slider attribute of the target slider. In this way, in the process of training the target detection model based on a large number of slider verification code images generated, the label file can be used to find the position of the target tile in the image to be processed and determine whether the target tile is a convex slider or a concave slider, so that the training of the target detection model is more efficient.

[0066] Optional, combine the following Figure 6 , an embodiment of the present application is described, and the embodiment includes the following steps:

[0067] Step 601: Divide the image to be processed into at least one rectangular block.

[0068] Specifically, any image can be used as a to-be-processed image, and the to-be-processed image can be randomly divided into x rows and y columns to obtain x*y rectangular blocks. For example, the to-be-processed image can be randomly divided into 7 rows and 10 columns to obtain 70 (7*10) rectangular blocks.

[0069] Step 602: For a target rectangular block in the at least one rectangular block, obtain a random array corresponding to the target rectangular block.

[0070] Specifically, for the 70 rectangular blocks formed by segmentation, a random array corresponding to the target rectangular block in at least one of the rectangular blocks can be obtained. The number of the random arrays can be at least one, for example, the number of the random arrays can be the same as the number of edges of the target rectangular block.

[0071] Step 603: Based on the preset correspondence between random numbers and graphic elements, a target graphic element corresponding to each random number in the random array is generated, and based on the target graphic element, the target graphic is obtained.

[0072] Specifically, the target graphic element may include at least one of a graphic shape, a positional relationship between the target graphic and the target rectangular block, and a graphic shadow effect, wherein the positional relationship includes the target graphic overlapping with a graphic on at least one side of the target rectangular block.

[0073] For example, the random array may include three random numbers, which can be used to generate the shape of the target graphic, the positional relationship between the target graphic and the rectangular block corresponding to the random array, and the shadow effect inside the graphic. In this way, different element sets of target graphics corresponding to the random arrays can be generated according to different random arrays input, and the target graphic can be generated according to the element sets.

[0074] As a specific example, for example, the target graphic elements generated by the three random numbers in the random array can be respectively that the shape of the target graphic is a circle, the center of the target graphic is located at the midpoint of the lower side of the corresponding rectangular block, and there is no shadow inside the target graphic. On this basis, the above target graphic elements are combined to obtain the following: Figure 3 The circular Y shown.

[0075] Step 604: performing a bitwise operation on the first binarized image of the target rectangular block and the second binarized image of the target graphic to generate a target binarized image.

[0076] Specifically, for example, Figure 2 The binary image of the rectangular block N in Figure 3 The binary image of the circle Y shown in the figure is bitwise ORed to generate Figure 4 The binary image of the first block S1 in Figure 3 The binary image of the circle Y in is bitwise inverted, and the inverted result is compared with Figure 2 The binary image of the rectangular block N in the bitwise AND operation is generated Figure 5 Binarized image of the second block S2 in .

[0077] In addition, it should be noted that the target block can be a convex slider or a concave slider. When there is a shadow inside the target graphic, the target block is a concave slider; when there is no shadow inside the target graphic, the target block is a convex slider. For example, if there is no shadow inside the first block S1 and the second block S2, the first block S1 and the second block S2 are convex sliders; if there is a shadow inside the first block S1 and the second block S2, the first block S1 and the second block S2 are concave sliders.

[0078] Step 605: Generate a label file for the image to be processed.

[0079] Specifically, after generating the above-mentioned convex slider or concave slider, contour search can be used to save the position information of the convex slider or concave slider in the image to be processed in the label file, and save the slider attributes of the slider in the label file, that is, save whether the slider attribute is a convex slider or a concave slider, so that when the target detection model is subsequently trained based on the verification code image, the position of the slider can be found and the slider attributes of the slider can be determined.

[0080] Step 606: Generate a mask image of the target image block; perform a bitwise inversion operation on the mask image, and perform a bitwise AND operation on the mask image after the bitwise inversion operation and the image to be processed to obtain the verification code image.

[0081] Specifically, based on the binary image of the convex slider or the concave slider, a mask image of the convex slider or the concave slider can be generated, and the mask image can be bitwise inverted to obtain the image form of the convex slider or the concave slider. In this way, the image form of the convex slider or the concave slider can be bitwise ANDed with the image to be processed to obtain the slider verification code image of the convex slider or the concave slider.

[0082] In this embodiment, the image to be processed is divided into a plurality of rectangular blocks, and then different graphic elements are generated by using the random array corresponding to the rectangular blocks, and the graphic elements are combined to generate a target graphic, and then the above target graphic and its corresponding rectangular block are bitwise operated, so that the target graphic and its corresponding rectangular block are bitwise combined to generate a convex slider or a concave slider, and then the convex slider or the concave slider is bitwise combined with the image to be processed to generate a slider verification code image. In this way, by traversing each rectangular block of the image to be processed according to the above steps, several different target blocks can be generated, and then several different slider verification code images can be generated. If a large number of images to be processed are divided in this way, a large number of different slider verification code images can be obtained, thereby solving the problem of consuming a lot of time and manpower costs when obtaining a large number of verification code images in the related art.

[0083] It should be noted that the execution subject of the method for generating a verification code image provided in the embodiment of the present application may be a device for generating a verification code image, or a control module in the device for generating a verification code image for executing a method for generating a verification code image. In the embodiment of the present application, a device for generating a verification code image executing a method for generating a verification code image is taken as an example to illustrate a device for generating a verification code image provided in the embodiment of the present application.

[0084] Figure 7 is a schematic diagram of the structure of a device for generating a verification code image according to an embodiment of the present invention. Figure 7 As shown, a device 700 for generating a verification code image includes: a segmentation module 710 , an acquisition module 720 , a first generation module 730 , a second generation module 740 , and a verification code module 750 .

[0085] A segmentation module 710 is used to segment the image to be processed into at least one rectangular block; an acquisition module 720 is used to acquire a random array corresponding to a target rectangular block in the at least one rectangular block, wherein the target rectangular block is any one of the at least one rectangular block; a first generation module 730 is used to generate a target graphic corresponding to the target rectangular block based on the random array; a second generation module 740 is used to generate a target image block corresponding to the target rectangular block based on the target rectangular block and the target image; a verification code module 750 is used to generate a verification code image based on the target image block.

[0086] In one implementation, the first generation module 730 is specifically used to: generate a target graphic element corresponding to each random number in the random array based on a correspondence between pre-set random numbers and graphic elements, wherein the graphic element includes at least one of a graphic shape, a positional relationship between the target graphic and the target rectangular block, and a graphic shadow effect, and the positional relationship includes the target graphic overlapping with the graphic on at least one side of the target rectangular block; and obtain the target graphic based on the target graphic element.

[0087] In one implementation, the second generation module 740 is specifically used to: obtain a first binarized image corresponding to the target rectangular block and a second binarized image corresponding to the target graphic; perform bit operations on the first binarized image and the second binarized image to generate a target binarized image, wherein the target image block is represented by the target binarized image.

[0088] In one implementation, the target block in the second generation module 740 is a convex slider or a concave slider; when the target graphic has a graphic shadow effect, the target block is a concave slider; when the target graphic has no graphic shadow effect, the target block is a convex slider.

[0089] In one implementation, the verification code module 750 is specifically used to: generate a mask image of the target image block; perform a bitwise inversion operation on the mask image, and perform a bitwise AND operation on the mask image after the bitwise inversion operation and the image to be processed to obtain the verification code image.

[0090] In one implementation, the second generation module 740 is further used to: generate a label file for the image to be processed, wherein the label file records the position of the target tile in the image to be processed and the slider attributes of the target tile, wherein the slider attributes include convex slider attributes or concave slider attributes.

[0091] In the embodiments of the present application, a device for generating a verification code image may be a device, or a component, an integrated circuit, or a chip in a terminal. The device may be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device may be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc., and the non-mobile electronic device may be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiments of the present application.

[0092] In the embodiment of the present application, a device for generating a verification code image may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0093] The generation device of a verification code picture provided in the embodiment of the present application can realize Figures 1 to 6 To avoid repetition, the various processes implemented in the method embodiment are not described here.

[0094] Optional, such as Figure 8 As shown, an embodiment of the present application also provides an electronic device 800, including a processor 801, a memory 802, and a program or instruction stored in the memory 802 and executable on the processor 801. When the program or instruction is executed by the processor 801, each process of an embodiment of a method for generating a verification code image described above is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0095] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0096] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned embodiment of a method for generating a verification code image is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0097] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0098] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned embodiment of the method for generating a verification code image, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0099] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0100] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0101] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0102] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A method for generating a verification code image, characterized in that: include: Divide the image to be processed into at least one rectangular block; For a target rectangular block in the at least one rectangular block, obtaining a random array corresponding to the target rectangular block, wherein the target rectangular block is any one of the at least one rectangular block; Based on the random array, generating a target graphic corresponding to the target rectangular block; Based on the target rectangular block and the target graphic, generating a target graphic block corresponding to the target rectangular block; Based on the target image block, generate a verification code image; The step of generating a target graphic corresponding to the target rectangular block based on the random array includes: Based on the preset correspondence between random numbers and graphic elements, a target graphic element corresponding to each random number in the random array is generated, wherein the graphic element includes at least one of a graphic shape, a positional relationship between the target graphic and the target rectangular block, and a graphic shadow effect, and the positional relationship includes that the target graphic overlaps with a graphic on at least one side of the target rectangular block; Based on the target graphic element, obtaining the target graphic; The step of generating a target image block corresponding to the target rectangular block based on the target rectangular block and the target graphic comprises: Acquire a first binarized image corresponding to the target rectangular block and a second binarized image corresponding to the target graphic; Performing a bitwise operation on the first binarized image and the second binarized image to generate a target binarized image, wherein the target image block is represented by the target binarized image; The step of generating a verification code image based on the target image block includes: Generate a mask image of the target image block; A bitwise inversion operation is performed on the mask image, and a bitwise AND operation is performed on the mask image after the bitwise inversion operation and the image to be processed to obtain the verification code image.

2. The method according to claim 1, characterized in that The target block is a convex slider or a concave slider; In the case where the target graphic has a graphic shadow effect, the target block is a concave slider; In the case where the target graphic has no graphic shadow effect, the target block is a convex slider.

3. The method according to claim 1, characterized in that: After generating a target block corresponding to the target rectangular block based on the target rectangular block and the target graphic, the method further includes: Generate a label file of the image to be processed, wherein the label file records the position of the target image block in the image to be processed and the slider attribute of the target image block, wherein the slider attribute includes a convex slider attribute or a concave slider attribute.

4. A device for generating a verification code image, characterized in that: include: A segmentation module, used for segmenting the image to be processed into at least one rectangular block; An acquisition module, configured to acquire, for a target rectangular block in the at least one rectangular block, a random array corresponding to the target rectangular block, wherein the target rectangular block is any one of the at least one rectangular block; A first generating module, used for generating a target graphic corresponding to the target rectangular block based on the random array; A second generating module, configured to generate a target image block corresponding to the target rectangular block based on the target rectangular block and the target image; A verification code module, used to generate a verification code image based on the target image block; The first generating module is specifically used for: Based on the preset correspondence between random numbers and graphic elements, a target graphic element corresponding to each random number in the random array is generated, wherein the graphic element includes at least one of a graphic shape, a positional relationship between the target graphic and the target rectangular block, and a graphic shadow effect, and the positional relationship includes that the target graphic overlaps with a graphic on at least one side of the target rectangular block; Based on the target graphic element, obtaining the target graphic; The second generating module is specifically used for: Acquire a first binarized image corresponding to the target rectangular block and a second binarized image corresponding to the target graphic; Performing a bitwise operation on the first binarized image and the second binarized image to generate a target binarized image, wherein the target image block is represented by the target binarized image; The verification code module is specifically used for: Generate a mask image of the target image block; A bitwise inversion operation is performed on the mask image, and a bitwise AND operation is performed on the mask image after the bitwise inversion operation and the image to be processed to obtain the verification code image.

5. An electronic device, characterized in that: The invention comprises a processor, a memory and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of a method for generating a verification code image as described in any one of claims 1 to 3.

6. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of a method for generating a verification code image as described in any one of claims 1 to 3 are implemented.