[go: up one dir, main page]

CN109918890A - Method for generating picture verification codes, server and storage medium - Google Patents

Method for generating picture verification codes, server and storage medium Download PDF

Info

Publication number
CN109918890A
CN109918890A CN201910040608.XA CN201910040608A CN109918890A CN 109918890 A CN109918890 A CN 109918890A CN 201910040608 A CN201910040608 A CN 201910040608A CN 109918890 A CN109918890 A CN 109918890A
Authority
CN
China
Prior art keywords
picture
user
validation code
color
color value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910040608.XA
Other languages
Chinese (zh)
Inventor
陈少昀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
OneConnect Smart Technology Co Ltd
Original Assignee
OneConnect Smart Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by OneConnect Smart Technology Co Ltd filed Critical OneConnect Smart Technology Co Ltd
Priority to CN201910040608.XA priority Critical patent/CN109918890A/en
Publication of CN109918890A publication Critical patent/CN109918890A/en
Pending legal-status Critical Current

Links

Landscapes

  • Color Image Communication Systems (AREA)

Abstract

The present invention relates to artificial intelligence, disclose a kind of method for generating picture verification codes, after this method receives picture validation code generation instruction, it is random to obtain the first picture validation code, if user is colour blindness, then the first picture validation code is handled according to default picture processing rule, generates second picture identifying code, and second picture identifying code is sent to user;If user is not colour blindness, the first picture validation code is directly sent to user.The present invention is also disclosed that a kind of server and computer storage medium.Using the present invention, different user is improved to the identification of picture validation code, promotes the usage experience of colour blindness user.

Description

Method for generating picture verification codes, server and storage medium
Technical field
The present invention relates to technical field of data processing more particularly to a kind of method for generating picture verification codes, server and meter Calculation machine readable storage medium storing program for executing.
Background technique
Identifying code plays more next in terms of preventing Brute Force, malicious registration and login attempt and preventing network brush Bigger effect, exactly because the significant effect of this special role of identifying code, some illegal businessmans or hacker have been opened Some programs are issued, i.e., so-called robot program is capable of the identifying code of the easy identification of automatic identification naked eyes.
Therefore, in order to more preferably play the specifically functional of identifying code, present verification code technology, it is intended to increase human eye The difficulty of identification, for example, the color and figure etc. to picture validation code are much handled, to prevent robot from identifying, thus Achieve the purpose that utilize the specifically functional progress network security protection of identifying code.
However, not accounting for the use of colour blindness anomalous trichromatism user when increasing the color complexity of picture validation code, this can be led The blind anomalous trichromatism user of coloring is not easy to differentiate the text or figure in picture, reduces user experience.
Summary of the invention
In view of the foregoing, the present invention provides a kind of method for generating picture verification codes, server and computer-readable storage Medium, main purpose be by handling picture validation code, improves different user to the identification of picture validation code, Promote the usage experience of colour blindness user.
To achieve the above object, the present invention provides a kind of method for generating picture verification codes, this method comprises:
S1, detecting simultaneously receive the identifying code acquisition instruction that user is issued by client, from default picture validation code library The first picture validation code is transferred at random;
S2, the user information that the user is read from the identifying code acquisition instruction, being determined according to the user information should The class of subscriber of user, and judge whether to need to handle first picture validation code according to the class of subscriber;
S3, when needing to handle first picture validation code, handled according to preset class of subscriber and picture The mapping relations of rule, call the processing of corresponding with the class of subscriber of user picture regular to first picture validation code into Row processing, generates second picture identifying code, and the second picture identifying code is sent to client;Or
S4, when not needing to handle first picture validation code, first picture validation code is sent to Client.
In addition, the server includes: memory, processor the present invention also provides a kind of server, deposited on the memory The picture validation code that contain to run on the processor generates program, and the picture validation code generates program by the processing , it can be achieved that arbitrary steps in method for generating picture verification codes as described above when device executes.
In addition, to achieve the above object, it is described computer-readable the present invention also provides a kind of computer readable storage medium Include that picture validation code generates program in storage medium, the picture validation code generate when program is executed by processor, it can be achieved that Arbitrary steps in method for generating picture verification codes as described above.
Method for generating picture verification codes, server and computer readable storage medium proposed by the present invention receive picture and test Demonstrate,prove after code generates instruction, it is random to obtain the first picture validation code, according to user information judge whether to need to the first identifying code into The processing of row picture handles the first picture validation code according to picture processing rule is preset, generates the if user is colour blindness Two picture validation codes, and second picture identifying code is sent to user;If user is not colour blindness, directly the first picture is verified Code is sent to user.It is handled by the picture validation code to different user, and to the picture validation code of different colour blindness users Different processing is carried out, different colour blindness users is improved to the identification of picture validation code, promotes the usage experience of colour blindness user.
Detailed description of the invention
Fig. 1 is the flow chart of method for generating picture verification codes preferred embodiment of the present invention;
Fig. 2 is the schematic diagram of server preferred embodiment of the present invention;
Fig. 3 is picture validation code generator routine module diagram in Fig. 2.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
The present invention provides a kind of verification code generation method.Referring to Fig.1 shown in, be method for generating picture verification codes of the present invention compared with The flow chart of good embodiment.This method can be executed by a server, which can be by software and or hardware realization.
In the present embodiment, the method for generating picture verification codes is applied to server, the method comprising the steps of S1-S4.
S1, detecting simultaneously receive the identifying code acquisition instruction that user is issued by client, from default picture validation code library The first picture validation code is transferred at random.
Before this step, this method further include: establish and save the picture validation code library including plurality of pictures identifying code. Initially set up the picture validation code library including N picture identifying code, wherein N is the natural number more than or equal to 2, for example, N Equal to 1000.
The identifying code acquisition instruction generates operation for triggering picture validation code, for example, identifying code acquisition instruction is not only Be limited to: the acquisition identifying code request that user issues, identifying code acquisition request may also is that identifying code obtains the website that user issues The ticket purchasing request etc. that log-in instruction, user issue in booking website.
After triggering picture validation code and generating operation, the picture validation code library pre-established is obtained, and from picture validation code One or more picture validation code is transferred in library at random.
S2, the user information that the user is read from the identifying code acquisition instruction, being determined according to the user information should The class of subscriber of user, and judge whether to need to handle first picture validation code according to the class of subscriber.
Wherein, the user information of user is carried in the identifying code acquisition instruction, for example, user is registering or logging in When not only need to input the identity informations such as account, password, it is also necessary to input the privacy information of preset kind, for example, protanopia anerythrochloropsia, Monochromasia, non-colour blindness.
Specifically, which includes: reading preset kind data (privacy information of preset kind, the example from user information Such as, protanopia anerythrochloropsia, monochromasia, non-colour blindness), classified according to the preset kind data to the user;When user is first Class user (protanopia anerythrochloropsia) or when the second class user (monochromasia), judges to need to first picture validation code Reason;When user is third class user (non-colour blindness), judgement does not need to handle first picture validation code.
S3, when needing to handle first picture validation code, handled according to preset class of subscriber and picture The mapping relations of rule, call the processing of corresponding with the class of subscriber of user picture regular to first picture validation code into Row processing, generates second picture identifying code, and the second picture identifying code is sent to client.
Preferably, described in the present embodiment " calls the processing of corresponding with the class of subscriber of user picture regular to institute The first picture validation code is stated to be handled " include:
When user be the first kind user when, call the first picture processing rule to first picture validation code at Reason;
When user be the second class user when, call second picture processing rule to first picture validation code at Reason.
Corresponding different picture processing rule is determined previously according to different class of subscribers, generates class of subscriber and picture Handle the mapping relations of rule.For example, calling the first picture to handle the first figure of rule process when judging user for protanopia anerythrochloropsia Piece identifying code calls second picture to handle the first picture validation code of rule process when user is monochromasia.
Preferably, first picture processing rule in the present embodiment includes: a1-a4.
A1, first picture is determined according to the original color value of each pixel of first picture validation code respectively All red areas and green area in identifying code.
It should be noted that the picture being shown on client screen before submitting to Gpu or Cpu be typically all with What pixel-color value format saved.That is, the color of each pixel in the first picture validation code can be directly obtained It is worth (RGB or ARGB, wherein rgb value is a hexadecimal numerical value).
Specifically, described " to determine described respectively according to the color value of each pixel of first picture validation code All red areas and green area in one picture validation code " include:
Each pixel for scanning first picture validation code, by the original color value of each pixel respectively with One color value section and the second color value section are compared;
If the original color value of all pixels point belongs to the first color value section in a region, judge the region for red color area Domain;Or
If the original color value of all pixels point belongs to the second color value section in a region, judge the region for green area Domain.
What can not be differentiated due to protanopia anerythrochloropsia is red and green within the scope of certain color value, it need to predefine red The boundary of color and green, and be color value by boundary transition, that is, red and green respectively corresponds a color value range, the first color value Section is red corresponding color value range, and the second color value section is the corresponding color value range of green.By the first determining color value area Between and the second color value section stored according to default store path.
When determining the red area or green area of the first picture validation code, all pixels point is scanned, if adjacent pixel The original color value of point is all in the color value range of red or the original color value of adjacent pixel all in green color value model It is just same region if enclosing.According to this logic, all red green regions are collected, are saved according to scanning sequency Into data structure (for example, array).
A2, it is filtered out from all red areas and green area of first picture validation code and meets preset condition Target red area and target green region.
Above-mentioned preset condition can illustrate are as follows: each individual red area or green area area account for screen area ratio Example is more than preset threshold (for example, 1/100).Preset threshold can be adjusted according to screen size and screen resolution (pixel quantity) It is whole.
For being unsatisfactory for red area/green area of preset condition (area accounting is less than 1/100), it is defaulted as influencing not Greatly, it does not deal with.
A3, average color around each target red area and each target green region is calculated separately, respectively The color value opposite with the average color color around each target red area and each target green region is determined, as each The replacement color value in target red area and each target green region, and with each target red area and each target green area The replacement color value in domain replaces corresponding original color value.
It is understood that the pixel on screen can be understood as a piece of thickly dotted point arranged vertically and horizontally, with one The adjacent pixel of a pixel is exactly 8 pixels being centered around around the pixel.
There is a boundary in each target red area and target green region, and borderline pixel is boundary pixel Point.
8 pictures by taking target red area R as an example, first around each boundary pixel point of collection target red area R In vegetarian refreshments, the color value of the pixel outside target red area R;Then the average value of all color values is taken;Then the average value is taken Inverse value, and with the original color value of all pixels point in inverse value update area R, which is in order to by red area and green Color region is substituted for protanopia anerythrochloropsia and can recognize and have the color centainly compared with ambient color.
The calculation formula for the color value for taking color opposite are as follows: newColor=0xFFFFFF-oldColor.For example, red Rgb value is 0xFF0000, and negating is exactly 0xFFFFFF-0xFF0000.
A4, default profile is added by the replaced target red area of color value and target green region to be each, generated The second picture identifying code.
The purpose of addition profile is to make to become apparent from by the range of the replaced red area of color value and green area, increases Identification of the blind user of additive color to picture validation code.For example, addition black silhouette.Specifically, the addition in step a4 is black Colour wheel is wide, comprising:
It determines respectively each by the replaced target red area of color value and the boundary pixel point in target green region;
The neighbor pixel for determining each boundary pixel point respectively, by the neighbor pixel not in the process The color value of the replaced target red area of color value and the neighbor pixel in target green region replaces with default color value.
By taking target red area R as an example, to add default profile (for example, black) for region R, first according to determining area All neighbor pixels outside the R of domain, the step of determining neighbor pixel, are similar with above-mentioned steps, do not repeat here.Then, The color value of all neighbor pixels is assigned a value of 0x000000, that is, all replace with black.
It should be noted that after carrying out color value replacement to the pixel of target red area and target green region, it may It is partially red or partially green that there are replaced colors, and protanopia anerythrochloropsia patient still can not identify.In other embodiments, red in order to improve Identification of the deuteranope to picture validation code, the step a3 further include:
Find out target red area or target green of the replacement color value in third color value section or the 4th color value section When section, deviated according to replacement color value of the default bias rule to the target red area and target green region found out; And it is utilized respectively the original color that the replacement color value after each offset replaces corresponding target red area or target green region Value.
Wherein, third color value section is pre-set partially red color value range, and the 4th color value section is pre-set Partially green color value range, boundary value need to be determined by professional.In addition, third color value section may include the first color value area Between, the 4th color value section may include the second color value section.
When the replacement color value of target red area or target green region is fallen in third color value section, judge to replace The corresponding color of color value is partially red, when the replacement color value in target red area or target green region is fallen in the 4th color value section When, judge that the corresponding color of replacement color value is partially green, partially red or inclined Green City is that protanopia anerythrochloropsia can not recognize, it is therefore desirable to be carried out Offset adjustment.
The default bias rule in the present embodiment includes:
When replacing color value in third color value section, to the algorithm that is deviated of replacement color value are as follows:
NewColor2=newColor+K;
When replacing color value in the 4th color value section, to the algorithm that is deviated of replacement color value are as follows:
NewColor2=newColor-K;
Wherein, newColor indicates the replacement color value of a target red area or a green area, newColor2 table Replacement color value after showing a target red area or a green area offset, K is the offset for replacing color value, for example, 0x0000FF。
That is, if the corresponding color of replacement color value is partially red, newColor2=newColor+0x0000FF;If replacement The corresponding color of color value is partially green, newColor2=newColor-0x0000FF.Replacing after guaranteeing offset using above-mentioned steps Colour changing value is not in preset red and green fields.
Preferably, the second picture processing rule in the present embodiment includes: b1-b3.
B1, determine that first picture is verified according to the original color value of each pixel of first picture validation code Multiple color regions of code, and the multiple color region is divided to the section of preset quantity.
Specifically, step b1 includes:
The all colours region in first picture validation code is determined according to pre-set color region division rule;
It, respectively will be described every according to the mapping relations of the color value range of each color region and the section of the preset quantity A color region is divided in the section of the preset quantity (for example, 50 or 100).
The corresponding preset color value section of each color region, the determination of specific color region and above-mentioned red area And the determination step of green area is identical, does not repeat here.
The section of above-mentioned preset quantity refers to according to color value, and all color value ranges are divided.
By taking rgb value as an example, RGB is a hexadecimal numerical value.All color value ranges are as follows: 0x000000-0xFFFFFF, If being divided into uniform 50 sections, the siding-to-siding block length in each section is 0xFFFFFF/50, if being divided into 100 sections, each The value siding-to-siding block length in section is 0xFFFFFF/100.
For example, first section is 0x000000 to 0x051EB8, as color value maximum value < 0x051EB8 of color region M, And when color value minimum value > 0x000000, color region M just belongs to first section.
It should be noted that may include multiple and different color regions in a section, it is also possible to not include any color Region.
B2, the corresponding default gray value in each section, respectively each section pair are determined according to the determination of section quantity respectively The color region answered assigns corresponding default gray value, generates the gray level image of first picture validation code.
The range of gray value is 0-255.The corresponding default gray value in each section is related with section quantity.
For example, the default gray value that first section corresponds to all colours region is 2, second section if 100 sections Corresponding default gray value is 4 ..., and the corresponding default gray value in the 50th section is 100 ....If there is 50 sections, first The corresponding default gray value in a section is 0, and the corresponding gray scale in second section is the 50th corresponding gray scale in section of degree 5 ... It is 250.
It should be noted that above-mentioned steps are not that directly to convert gray level image for picture (be not to convert color value to The corresponding gray value of color value), but corresponding gray value is distributed by section.
B3, the color region for meeting preset condition, and the color region to find out are found out from the multiple color region Profile is added, the second picture identifying code is generated.
Above-mentioned preset condition can illustrate are as follows: it is more than default that each individual color region area, which accounts for screen area ratio, Threshold value (for example, 1/100).Preset threshold can be adjusted according to screen size and screen resolution (pixel quantity).For not The color region for meeting preset condition (ratio is less than 1/100) is defaulted as influencing less, not dealing with.
Optionally, by taking 50 sections as an example, in step b3 it is described " according to presupposition analysis rule be these regions addition wheel It is wide ", comprising: when the color region found out is divided in the first class interval (for example, preceding 25 sections), then outline color is black Color;When the color region found out is divided in the second class interval (for example, rear 25 sections), then outline color is white.
Preceding 25 sections are exactly color value range in fact in the section of 0x7FFFFF-0xFFFFFF, and color is partially white, therefore profile Dark color should be taken, i.e. profile color value takes 0x000000, gray value 0;Color value range is in the section of 0x000000-0x7FFFFF, color Partially black, profile should take light color, i.e. profile color value takes 0xFFFFFF, gray value 255.Profile and regional correlation in this way becomes apparent from.
The second picture identifying code generated after picture is handled is sent to client, is tested for user according to second picture Card code identifies correct identifying code.
S4, when not needing to handle first picture validation code, first picture validation code is sent to Client.
When user be third class user (non-colour blindness), the first picture validation code is directly sent to client, for user's root Correct identifying code is identified according to the first picture validation code.
The method for generating picture verification codes that above-described embodiment proposes, it is random to obtain after receiving picture validation code generation instruction First picture validation code judges whether to need to carry out picture processing to the first identifying code according to user information, if user is colour blindness, Then the first picture validation code is handled according to presetting picture processing rule, generates second picture identifying code, and by the second figure Piece identifying code is sent to user;If user is not colour blindness, the first picture validation code is directly sent to user.By to difference The picture validation code of user is handled, and carries out different processing to the picture validation code of different colour blindness users, is improved not With colour blindness user to the identification of picture validation code, the usage experience of colour blindness user is promoted.
The present invention also provides a kind of servers.
It is the schematic diagram of 1 preferred embodiment of server of the present invention referring to shown in Fig. 2.
In the present embodiment, server 1 can be smart phone, tablet computer, portable computer, desktop PC etc. Terminal device having data processing function, the server 1 can also be rack-mount server, blade server, tower Server or Cabinet-type server.
The server 1 includes memory 11, processor 12 and network interface 13.
Wherein, memory 11 include at least a type of readable storage medium storing program for executing, the readable storage medium storing program for executing include flash memory, Hard disk, multimedia card, card-type memory (for example, SD or DX memory etc.), magnetic storage, disk, CD etc..Memory 11 It can be the internal storage unit of the server 1, such as the hard disk of the server 1 in some embodiments.Memory 11 exists It is hard to be also possible to the plug-in type being equipped on the External memory equipment of the server 1, such as the server 1 in other embodiments Disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card) etc..Further, memory 11 can also both including the server 1 internal storage unit and also including outside Store equipment.
Memory 11 can be not only used for the application software and Various types of data that storage is installed on the server 1, such as picture Identifying code generates program 10 etc., can be also used for temporarily storing the data that has exported or will export.
Processor 12 can be in some embodiments a central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor or other data processing chips, the program for being stored in run memory 11 Code or processing data, for example, picture validation code generates program 10 etc..
Network interface 13 optionally may include standard wireline interface and wireless interface (such as WI-FI interface), be commonly used in Communication connection is established between the server 1 and other electronic equipments.For example, carrying out data biography with client (being not marked in figure) It is defeated.
Fig. 2 illustrates only the server 1 with component 11-13, it will be appreciated by persons skilled in the art that Fig. 2 shows Structure do not constitute the restriction to server 1, may include than illustrating less perhaps more components or the certain portions of combination Part or different component layouts.
Optionally, which can also include user interface, and user interface may include display (Display), defeated Enter unit such as keyboard (Keyboard), optional user interface can also include standard wireline interface and wireless interface.
Optionally, in some embodiments, display can be light-emitting diode display, liquid crystal display, touch control type LCD and show Device and Organic Light Emitting Diode (Organic Light-Emitting Diode, OLED) touch device etc..Wherein, display It is properly termed as display screen or display unit, for showing the information handled in the server 1 and for showing visual use Family interface.
In 1 embodiment of server shown in Fig. 2, as storing picture in a kind of memory 11 of computer storage medium Identifying code generates the program code of program 10 and realizes when processor 12 executes the program code of picture validation code generation program 10 Step: A1-A4.
A1, detecting simultaneously receive the identifying code acquisition instruction that user is issued by client, from default picture validation code library The first picture validation code is transferred at random.
Before this step, it need to pre-establish and save the picture validation code library including plurality of pictures identifying code.It builds first The vertical picture validation code library including N picture identifying code, wherein N is the natural number more than or equal to 2, for example, N is equal to 1000。
The identifying code acquisition instruction generates operation for triggering picture validation code, for example, identifying code acquisition instruction is not only Be limited to: the acquisition identifying code request that user issues, identifying code acquisition request may also is that identifying code obtains the website that user issues The ticket purchasing request etc. that log-in instruction, user issue in booking website.
After triggering picture validation code and generating operation, the picture validation code library pre-established is obtained, and from picture validation code One or more picture validation code is transferred in library at random.
A2, the user information that the user is read from the identifying code acquisition instruction, being determined according to the user information should The class of subscriber of user, and judge whether to need to handle first picture validation code according to the class of subscriber.
Wherein, the user information of user is carried in the identifying code acquisition instruction, for example, user is registering or logging in When not only need to input the identity informations such as account, password, it is also necessary to input the privacy information of preset kind, for example, protanopia anerythrochloropsia, Monochromasia, non-colour blindness.
Specifically, which includes: reading preset kind data (privacy information of preset kind, the example from user information Such as, protanopia anerythrochloropsia, monochromasia, non-colour blindness), classified according to the preset kind data to the user;When user is first Class user (protanopia anerythrochloropsia) or when the second class user (monochromasia), judges to need to first picture validation code Reason;When user is third class user (non-colour blindness), judgement does not need to handle first picture validation code.
A3, when needing to handle first picture validation code, handled according to preset class of subscriber and picture The mapping relations of rule, call the processing of corresponding with the class of subscriber of user picture regular to first picture validation code into Row processing, generates second picture identifying code, and the second picture identifying code is sent to client.
Preferably, described in the present embodiment " calls the processing of corresponding with the class of subscriber of user picture regular to institute The first picture validation code is stated to be handled " include:
When user be the first kind user when, call the first picture processing rule to first picture validation code at Reason;
When user be the second class user when, call second picture processing rule to first picture validation code at Reason.
Corresponding different picture processing rule is determined previously according to different class of subscribers, generates class of subscriber and picture Handle the mapping relations of rule.For example, calling the first picture to handle the first figure of rule process when judging user for protanopia anerythrochloropsia Piece identifying code calls second picture to handle the first picture validation code of rule process when user is monochromasia.
Preferably, first picture processing rule in the present embodiment includes: a1-a4.
A1, first picture is determined according to the original color value of each pixel of first picture validation code respectively All red areas and green area in identifying code.
It should be noted that the picture being shown on client screen before submitting to Gpu or Cpu be typically all with What pixel-color value format saved.That is, the color of each pixel in the first picture validation code can be directly obtained It is worth (RGB or ARGB, wherein rgb value is a hexadecimal numerical value).
Specifically, described " to determine described respectively according to the color value of each pixel of first picture validation code All red areas and green area in one picture validation code " include:
Each pixel for scanning first picture validation code, by the original color value of each pixel respectively with One color value section and the second color value section are compared;
If the original color value of all pixels point belongs to the first color value section in a region, judge the region for red color area Domain;Or
If the original color value of all pixels point belongs to the second color value section in a region, judge the region for green area Domain.
What can not be differentiated due to protanopia anerythrochloropsia is red and green within the scope of certain color value, it need to predefine red The boundary of color and green, and be color value by boundary transition, that is, red and green respectively corresponds a color value range, the first color value Section is red corresponding color value range, and the second color value section is the corresponding color value range of green.By the first determining color value area Between and the second color value section stored according to default store path.
When determining the red area or green area of the first picture validation code, all pixels point is scanned, if adjacent pixel The original color value of point is all in the color value range of red or the original color value of adjacent pixel all in green color value model It is just same region if enclosing.According to this logic, all red green regions are collected, are saved according to scanning sequency Into data structure (for example, array).
A2, it is filtered out from all red areas and green area of first picture validation code and meets preset condition Target red area and target green region.
Above-mentioned preset condition can illustrate are as follows: each individual red area or green area area account for screen area ratio Example is more than preset threshold (for example, 1/100).Preset threshold can be adjusted according to screen size and screen resolution (pixel quantity) It is whole.
For being unsatisfactory for red area/green area of preset condition (area accounting is less than 1/100), it is defaulted as influencing not Greatly, it does not deal with.
A3, average color around each target red area and each target green region is calculated separately, respectively The color value opposite with the average color color around each target red area and each target green region is determined, as each The replacement color value in target red area and each target green region, and with each target red area and each target green area The replacement color value in domain replaces corresponding original color value.
It is understood that the pixel on screen can be understood as a piece of thickly dotted point arranged vertically and horizontally, with one The adjacent pixel of a pixel is exactly 8 pixels being centered around around the pixel.
There is a boundary in each target red area and target green region, and borderline pixel is boundary pixel Point.
8 pictures by taking target red area R as an example, first around each boundary pixel point of collection target red area R In vegetarian refreshments, the color value of the pixel outside target red area R;Then the average value of all color values is taken;Then the average value is taken Inverse value, and with the original color value of all pixels point in inverse value update area R, which is in order to by red area and green Color region is substituted for protanopia anerythrochloropsia and can recognize and have the color centainly compared with ambient color.
The calculation formula for the color value for taking color opposite are as follows: newColor=0xFFFFFF-oldColor.For example, red Rgb value is 0xFF0000, and negating is exactly 0xFFFFFF-0xFF0000.
A4, default profile is added by the replaced target red area of color value and target green region to be each, generated The second picture identifying code.
The purpose of addition profile is to make to become apparent from by the range of the replaced red area of color value and green area, increases Identification of the blind user of additive color to picture validation code.For example, addition black silhouette.Specifically, the addition in step a4 is black Colour wheel is wide, comprising:
It determines respectively each by the replaced target red area of color value and the boundary pixel point in target green region; And the neighbor pixel of each boundary pixel point is determined respectively, color value will not be passed through described in the neighbor pixel The color value of replaced target red area and the neighbor pixel in target green region replaces with default color value.
By taking target red area R as an example, to add default profile (for example, black) for region R, first according to determining area All neighbor pixels outside the R of domain, the step of determining neighbor pixel, are similar with above-mentioned steps, do not repeat here.Then, The color value of all neighbor pixels is assigned a value of 0x000000, that is, all replace with black.
It should be noted that after carrying out color value replacement to the pixel of target red area and target green region, it may It is partially red or partially green that there are replaced colors, and protanopia anerythrochloropsia patient still can not identify.In other embodiments, red in order to improve Identification of the deuteranope to picture validation code, step a3 further include:
Find out target red area or target green of the replacement color value in third color value section or the 4th color value section When section, deviated according to replacement color value of the default bias rule to the target red area and target green region found out;
Replacement color value after being utilized respectively each offset replaces the original in corresponding target red area or target green region Beginning color value.
Wherein, third color value section is pre-set partially red color value range, and the 4th color value section is pre-set Partially green color value range, boundary value need to be determined by professional.In addition, third color value section may include the first color value area Between, the 4th color value section may include the second color value section.
When the replacement color value of target red area or target green region is fallen in third color value section, judge to replace The corresponding color of color value is partially red, when the replacement color value in target red area or target green region is fallen in the 4th color value section When, judge that the corresponding color of replacement color value is partially green, partially red or inclined Green City is that protanopia anerythrochloropsia can not recognize, it is therefore desirable to be carried out Offset adjustment.
The default bias rule in the present embodiment includes:
When replacing color value in third color value section, to the algorithm that is deviated of replacement color value are as follows:
NewColor2=newColor+K;
When replacing color value in the 4th color value section, to the algorithm that is deviated of replacement color value are as follows:
NewColor2=newColor-K;
Wherein, newColor indicates the replacement color value of a target red area or a green area, newColor2 table Replacement color value after showing a target red area or a green area offset, K is the offset for replacing color value, for example, 0x0000FF。
That is, if the corresponding color of replacement color value is partially red, newColor2=newColor+0x0000FF;If replacement The corresponding color of color value is partially green, newColor2=newColor-0x0000FF.Replacing after guaranteeing offset using above-mentioned steps Colour changing value is not in preset red and green fields.
Preferably, the second picture processing rule in the present embodiment includes: b1-b3.
B1, determine that first picture is verified according to the original color value of each pixel of first picture validation code Multiple color regions of code, and the multiple color region is divided to the section of preset quantity.
Specifically, step b1 includes:
The all colours region in first picture validation code is determined according to pre-set color region division rule;
It, respectively will be described every according to the mapping relations of the color value range of each color region and the section of the preset quantity A color region is divided in the section of the preset quantity (for example, 50 or 100).
The corresponding preset color value section of each color region, the determination of specific color region and above-mentioned red area And the determination step of green area is identical, does not repeat here.
The section of above-mentioned preset quantity refers to according to color value, and all color value ranges are divided.
By taking rgb value as an example, RGB is a hexadecimal numerical value.All color value ranges are as follows: 0x000000-0xFFFFFF, If being divided into uniform 50 sections, the siding-to-siding block length in each section is 0xFFFFFF/50, if being divided into 100 sections, each The value siding-to-siding block length in section is 0xFFFFFF/100.
For example, first section is 0x000000 to 0x051EB8, as color value maximum value < 0x051EB8 of color region M, And when color value minimum value > 0x000000, color region M just belongs to first section.
It should be noted that may include multiple and different color regions in a section, it is also possible to not include any color Region.
B2, the corresponding default gray value in each section, respectively each section pair are determined according to the determination of section quantity respectively The color region answered assigns corresponding default gray value, generates the gray level image of first picture validation code.
The range of gray value is 0-255.The corresponding default gray value in each section is related with section quantity.
For example, the default gray value that first section corresponds to all colours region is 2, second section if 100 sections Corresponding default gray value is 4 ..., and the corresponding default gray value in the 50th section is 100 ....If there is 50 sections, first The corresponding default gray value in a section is 0, and the corresponding gray scale in second section is the 50th corresponding gray scale in section of degree 5 ... It is 250.
It should be noted that above-mentioned steps are not that directly to convert gray level image for picture (be not to convert color value to The corresponding gray value of color value), but corresponding gray value is distributed by section.
B3, the color region for meeting preset condition, and the color region to find out are found out from the multiple color region Profile is added, the second picture identifying code is generated.
Above-mentioned preset condition can illustrate are as follows: it is more than default that each individual color region area, which accounts for screen area ratio, Threshold value (for example, 1/100).Preset threshold can be adjusted according to screen size and screen resolution (pixel quantity).For not The color region for meeting preset condition (ratio is less than 1/100) is defaulted as influencing less, not dealing with.
Optionally, by taking 50 sections as an example, in step b3 it is described " according to presupposition analysis rule be these regions addition wheel It is wide ", comprising: when the color region found out is divided in the first class interval (for example, preceding 25 sections), then outline color is black Color;When the color region found out is divided in the second class interval (for example, rear 25 sections), then outline color is white.
Preceding 25 sections are exactly color value range in fact in the section of 0x7FFFFF-0xFFFFFF, and color is partially white, therefore profile Dark color should be taken, i.e. profile color value takes 0x000000, gray value 0;Color value range is in the section of 0x000000-0x7FFFFF, color Partially black, profile should take light color, i.e. profile color value takes 0xFFFFFF, gray value 255.Profile and regional correlation in this way becomes apparent from.
The second picture identifying code generated after picture is handled is sent to client, is tested for user according to second picture Card code identifies correct identifying code.
A4, when not needing to handle first picture validation code, first picture validation code is sent to Client.
When user be third class user (non-colour blindness), the first picture validation code is directly sent to client, for user's root Correct identifying code is identified according to the first picture validation code.
The server 1 that above-described embodiment proposes, it is random to obtain the verifying of the first picture after receiving picture validation code generation instruction Code judges whether to need to carry out picture processing to the first identifying code according to user information, if user is colour blindness, according to default figure Piece processing rule handles the first picture validation code, generates second picture identifying code, and second picture identifying code is sent To user;If user is not colour blindness, the first picture validation code is directly sent to user.It is tested by the picture to different user Card code is handled, and carries out different processing to the picture validation code of different colour blindness users, improves different colour blindness users couple The identification of picture validation code promotes the usage experience of colour blindness user.
Optionally, in other examples, picture validation code, which generates program 10, can also be divided into one or more A module, one or more module are stored in memory 11, and (the present embodiment is processing by one or more processors Device 12) it is performed, to complete the present invention, the so-called module of the present invention is the series of computation machine journey for referring to complete specific function Sequence instruction segment.
It is the module diagram that picture validation code generates program 10 in Fig. 2 for example, referring to shown in Fig. 3, in the embodiment, Picture validation code, which generates program 10, can be divided into receiving module 110, judgment module 120, picture processing module 130 and feedback Module 140, the functions or operations step that the module 110-140 is realized is similar as above, and and will not be described here in detail, exemplary Ground, such as wherein:
Receiving module 110, the identifying code acquisition instruction issued for detecting and receiving user by client, from default figure Piece identifying code transfers the first picture validation code in library at random;
Judgment module 120, for reading the user information of the user from the identifying code acquisition instruction, according to the use Family information determines the class of subscriber of the user, and judges whether to need to first picture validation code according to the class of subscriber It is handled;
Picture processing module 130, for when need first picture validation code is handled when, according to preset use The mapping relations of family classification and picture processing rule call picture processing rule corresponding with the class of subscriber of the user to described First picture validation code is handled, and generates second picture identifying code, and the second picture identifying code is sent to client; And
Feedback module 140, for when not needing to handle first picture validation code, by first picture Identifying code is sent to client.
In addition, the embodiment of the present invention also proposes a kind of computer readable storage medium, the computer readable storage medium In include that picture validation code generates program 10, the picture validation code, which generates, realizes following behaviour when program 10 is executed by processor Make:
A1, detecting simultaneously receive the identifying code acquisition instruction that user is issued by client, from default picture validation code library The first picture validation code is transferred at random;
A2, the user information that the user is read from the identifying code acquisition instruction, being determined according to the user information should The class of subscriber of user, and judge whether to need to handle first picture validation code according to the class of subscriber;
A3, when needing to handle first picture validation code, handled according to preset class of subscriber and picture The mapping relations of rule, call the processing of corresponding with the class of subscriber of user picture regular to first picture validation code into Row processing, generates second picture identifying code, and the second picture identifying code is sent to client;Or
A4, when not needing to handle first picture validation code, first picture validation code is sent to Client.
The tool of the specific embodiment of the computer readable storage medium of the present invention and above-mentioned method for generating picture verification codes Body embodiment is roughly the same, and details are not described herein.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, device, article or the method that include a series of elements not only include those elements, and And further include other elements that are not explicitly listed, or further include for this process, device, article or method institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do There is also other identical elements in the process, device of element, article or method.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art The part contributed out can be embodied in the form of software products, which is stored in one as described above In storage medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that terminal device (it can be mobile phone, Computer, server or network equipment etc.) execute method described in each embodiment of the present invention.
The above is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair Equivalent structure or equivalent flow shift made by bright specification and accompanying drawing content is applied directly or indirectly in other relevant skills Art field, is included within the scope of the present invention.

Claims (10)

1. a kind of method for generating picture verification codes is applied to server, which is characterized in that the described method includes:
S1, detecting simultaneously receive the identifying code acquisition instruction that user is issued by client, random from default picture validation code library Transfer the first picture validation code;
S2, the user information that the user is read from the identifying code acquisition instruction, determine the user according to the user information Class of subscriber, and according to the class of subscriber judge whether need first picture validation code is handled;
S3, when needing to handle first picture validation code, rule is handled according to preset class of subscriber and picture Mapping relations, call the processing of corresponding with the class of subscriber of user picture it is regular to first picture validation code at Reason generates second picture identifying code, and the second picture identifying code is sent to client;Or
S4, when not needing to handle first picture validation code, first picture validation code is sent to client End.
2. method for generating picture verification codes according to claim 1, which is characterized in that step S2 includes:
Preset kind data are read from the user information, are classified according to the preset kind data to the user;
When user is first kind user or the second class user, judge to need to handle first picture validation code; Or
When user is third class user, judgement does not need to handle first picture validation code.
3. method for generating picture verification codes according to claim 1, which is characterized in that the class of subscriber includes: first Class user, the second class user and third class user, it is described " to call picture processing rule corresponding with the class of subscriber of the user right First picture validation code is handled " include:
When user is first kind user, the first picture processing rule is called to handle first picture validation code;When When user is the second class user, second picture processing rule is called to handle first picture validation code.
4. method for generating picture verification codes according to claim 3, which is characterized in that the first picture processing rule packet It includes:
A1, determine that first picture is verified respectively according to the original color value of each pixel of first picture validation code All red areas and green area in code;
A2, the target for meeting preset condition is filtered out from all red areas and green area of first picture validation code Red area and target green region;
A3, average color around each target red area and each target green region is calculated separately, determined respectively The color value opposite with the average color color around each target red area and each target green region, as each target The replacement color value in red area and each target green region, and with each target red area and each target green region It replaces color value and replaces corresponding original color value;And
A4, profile is preset for each add by the replaced target red area of color value and target green region, described in generation Second picture identifying code.
5. method for generating picture verification codes according to claim 4, which is characterized in that step a3 further include:
Find out target red area or target green section of the replacement color value in third color value section or the 4th color value section When, it is deviated according to replacement color value of the default bias rule to the target red area and target green region found out;And
Replacement color value after being utilized respectively each offset replaces the original color in corresponding target red area or target green region Value.
6. method for generating picture verification codes according to claim 3, which is characterized in that the second picture processing rule packet It includes:
B1, first picture validation code is determined according to the original color value of each pixel of first picture validation code Multiple color regions, and the multiple color region is divided to the section of preset quantity;
B2, the corresponding default gray value in each section is determined according to the determination of section quantity respectively, respectively each section is corresponding Color region assigns corresponding default gray value, generates the gray level image of first picture validation code;And
B3, the color region for meeting preset condition, and the color region addition to find out are found out from the multiple color region Profile generates the second picture identifying code.
7. method for generating picture verification codes according to claim 6, which is characterized in that step b1 includes:
The all colours region in first picture validation code is determined according to pre-set color region division rule;
According to the mapping relations of the color value range of each color region and the section of the preset quantity, respectively by each face Color region division is into the section of the preset quantity.
8. a kind of server, which is characterized in that the server includes: memory, processor, and being stored on the memory can be The picture validation code run on the processor generates program, and the picture validation code generates program and executed by the processor When, it can be achieved that following steps:
A1, detecting simultaneously receive the identifying code acquisition instruction that user is issued by client, random from default picture validation code library Transfer the first picture validation code;
A2, the user information that the user is read from the identifying code acquisition instruction, determine the user according to the user information Class of subscriber, and according to the class of subscriber judge whether need first picture validation code is handled;
A3, when needing to handle first picture validation code, rule is handled according to preset class of subscriber and picture Mapping relations, call the processing of corresponding with the class of subscriber of user picture it is regular to first picture validation code at Reason generates second picture identifying code, and the second picture identifying code is sent to client;Or
A4, when not needing to handle first picture validation code, first picture validation code is sent to client End.
9. server according to claim 8, which is characterized in that the picture validation code generates program by the processor When execution, the step of also realizing method for generating picture verification codes as described in any one of claim 2 to 7.
10. a kind of computer readable storage medium, which is characterized in that include that picture is verified in the computer readable storage medium Code generates program, and the picture validation code generates when program is executed by processor, it can be achieved that as any one in claim 1 to 7 The step of method for generating picture verification codes described in item.
CN201910040608.XA 2019-01-16 2019-01-16 Method for generating picture verification codes, server and storage medium Pending CN109918890A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910040608.XA CN109918890A (en) 2019-01-16 2019-01-16 Method for generating picture verification codes, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910040608.XA CN109918890A (en) 2019-01-16 2019-01-16 Method for generating picture verification codes, server and storage medium

Publications (1)

Publication Number Publication Date
CN109918890A true CN109918890A (en) 2019-06-21

Family

ID=66960390

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910040608.XA Pending CN109918890A (en) 2019-01-16 2019-01-16 Method for generating picture verification codes, server and storage medium

Country Status (1)

Country Link
CN (1) CN109918890A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113191776A (en) * 2021-04-30 2021-07-30 中国银行股份有限公司 User classification method and device based on mobile banking
CN113868620A (en) * 2021-10-14 2021-12-31 咪咕文化科技有限公司 A verification method, device and device for verification code

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160164882A1 (en) * 2014-12-05 2016-06-09 Inventec (Pudong) Technology Corporation Verification Code Generating System And Method
WO2016124066A1 (en) * 2015-02-05 2016-08-11 北京京东尚科信息技术有限公司 Image verification code generation method and system
CN106203058A (en) * 2016-06-30 2016-12-07 北京奇艺世纪科技有限公司 Verification code generation method and device
US20170187725A1 (en) * 2015-12-29 2017-06-29 Yahoo!, Inc. User verification
CN106920266A (en) * 2015-12-28 2017-07-04 腾讯科技(深圳)有限公司 The Background Generation Method and device of identifying code
CN107493274A (en) * 2017-08-08 2017-12-19 芜湖通全科技有限公司 A kind of identifying code Prevention-Security device
WO2018036274A1 (en) * 2016-08-22 2018-03-01 上海壹账通金融科技有限公司 Page colour adjustment method, terminal device, server, and storage medium
CN107888553A (en) * 2016-09-30 2018-04-06 华为技术有限公司 A kind of verification method, server and system

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160164882A1 (en) * 2014-12-05 2016-06-09 Inventec (Pudong) Technology Corporation Verification Code Generating System And Method
WO2016124066A1 (en) * 2015-02-05 2016-08-11 北京京东尚科信息技术有限公司 Image verification code generation method and system
CN106920266A (en) * 2015-12-28 2017-07-04 腾讯科技(深圳)有限公司 The Background Generation Method and device of identifying code
US20170187725A1 (en) * 2015-12-29 2017-06-29 Yahoo!, Inc. User verification
CN106203058A (en) * 2016-06-30 2016-12-07 北京奇艺世纪科技有限公司 Verification code generation method and device
WO2018036274A1 (en) * 2016-08-22 2018-03-01 上海壹账通金融科技有限公司 Page colour adjustment method, terminal device, server, and storage medium
CN107888553A (en) * 2016-09-30 2018-04-06 华为技术有限公司 A kind of verification method, server and system
CN107493274A (en) * 2017-08-08 2017-12-19 芜湖通全科技有限公司 A kind of identifying code Prevention-Security device

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
冯杰;李旭伟;: "网上银行验证码研究与安全性分析", 计算机技术与发展, no. 11, 28 August 2013 (2013-08-28) *
汪成亮;张玉维;: "基于共振峰合成和韵律调整的语音验证码方法研究", 计算机应用研究, no. 07, 15 July 2011 (2011-07-15) *
贾默然;高永兵;: "PHP图片验证码的实现", 包钢科技, no. 01, 25 February 2010 (2010-02-25) *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113191776A (en) * 2021-04-30 2021-07-30 中国银行股份有限公司 User classification method and device based on mobile banking
CN113868620A (en) * 2021-10-14 2021-12-31 咪咕文化科技有限公司 A verification method, device and device for verification code

Similar Documents

Publication Publication Date Title
US11816807B2 (en) Augmented reality system with color-based fiducial marker
US11487979B2 (en) Matrix barcode having a plurality of colors and an infrared layer for conveying spatial information
US12255646B2 (en) System and method using a histogram and colospaces to generate a matrix barcode having a plurality of colors and an ultraviolent layer
US10496911B1 (en) Detection of images in relation to targets based on colorspace transformation techniques and utilizing ultraviolet and infrared light
AU2016201723B2 (en) Method of Host-Directed Illumination and System for Conducting Host-Directed Illumination
US20200402476A1 (en) Adaptive image display based on colorspace conversions
CN106529512B (en) Living body faces verification method and device
CN102193962B (en) Matching device, digital image processing system, and matching device control method
CN108255555B (en) A kind of system language switching method and terminal device
CN110135262A (en) The anti-peeping processing method of sensitive data, device, equipment and storage medium
EP2557507A3 (en) User verification method and user verification system
EP2541492A1 (en) Authentication device, authentication program, and authentication method
CN111898538B (en) Certificate authentication method and device, electronic equipment and storage medium
CN109862401A (en) Real name register method, device, television set and the readable storage medium storing program for executing of account
US8601552B1 (en) Personal identification pairs
CN113869219B (en) Face living body detection method, device, equipment and storage medium
CN110704104A (en) Application counterfeit detection method, intelligent terminal and storage medium
CN109918890A (en) Method for generating picture verification codes, server and storage medium
CN115311167B (en) Color gamut control method, device and equipment based on multicolor light and storage medium
CN109684945A (en) Biopsy method, device, server and storage medium based on pupil
CN113989548B (en) Certificate classification model training method and device, electronic equipment and storage medium
JP2014116033A (en) Personal authentication device, personal authentication method, camera, program, and storage medium
CN114723400B (en) Service authorization management method, device, equipment and storage medium
CN113518993A (en) Information code reading system
CN109784454A (en) A kind of information concealing method based on two dimensional code, device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination