当前位置:网站首页>I put a two-dimensional code with rainbow candy
I put a two-dimensional code with rainbow candy
2022-06-25 09:29:00 【Maoningyi】
I don't know when , QR code has become an indispensable part of our life , Pay to scan QR code , Scan QR code by bike , Even the necessary health code for our recent trip is a two-dimensional code .
The word "green" has a richer meaning , I am green , And you? …
Today, I'm going to challenge you to use rainbow candy to lay out a QR code that you can scan , But now I have no idea , Let's check whether it is feasible ~
We all know that QR code is a combination of binary arrays , The most common is this kind of two-dimensional code with black and white , Each little black square represents 1, The small white square represents 0.
But in fact, this square can not only match black and white , Red and white 、 Red and green can also be matched , Only two colors are needed to have contrast .

Even this black block is not limited to square , It can also be other shapes , Like a circle .
If the circle is colorful , That's what rainbow candy looks like .
We have to use Python Achieve it , There are wheels out there (myqr), Let's modify it a little , That's all right. .
def draw_a_black_unit(p, x, y, ul):
draw = ImageDraw.Draw(p)
font = ImageFont.truetype("/Library/Fonts/Arial Unicode.ttf", 10, encoding="utf-8")
colors = ["red","orange","green","blue","purple"]
color = random.choice(colors)
draw.text((x, y), '●', fill = color, font=font)
Then use the command line to generate , Rainbow sugar QR code appears ~
myqr https://space.bilibili.com/279911711

Try it with your mobile phone and you can successfully identify ( Wechat identification is difficult , I use a treasure sweep ), It shows that our idea is feasible ~
But now there are 691 A dot , That's what we need 691 Rainbow candy , A bag of rainbow candy is about 40 star , You can't remove the yellow ones , What can be used is about 30 star , Then I just want to buy 24 package , One pack 3 Yuan ...
Poverty makes my rusty brain work quickly . How to make these dots less and save money ?
Well, we need to know something about it first , QR codes have error correction levels .
For example, I block this one , You can still scan the contents of the QR code , It means that it is OK if the block is not blocked .
The lower the error correction level is , The less points you have left , So the first thought , Reduce the error correction level of QR code .
Now there is a lot less , But there is still 446 A dot , It's still beyond my budget ...
To further reduce the number of dots , You should know that the last step of the QR code will be handled with a mask , Avoid large areas of blank or black blocks , Affect scanning code recognition .
Now there is 8 Masks of different styles , The system will rate these masks , Select the mask with the best 2D code fragmentation .
But we just play by ourselves , There is no need to choose the best mask , Let's choose the mask with the least number of QR code points to export ~
Continue to change the code
def mask(mm, m):
mps = get_mask_patterns(mm)
scores = []
for mp in mps:
score = 0
for i in range(len(mp)):
for j in range(len(mp)):
mp[i][j] = mp[i][j] ^ m[i][j]
if mp[i][j] == 1:
score += 1
scores.append(score)
best = scores.index(min(scores))
That's it , Now we still need 414 A rainbow candy , It seems that there is not much less …
No problem , I have one last move , Is to shorten the URL , Find a website that will B The website of the home page of the station will be converted 
Let's take a look at the generation 
Obviously a lot less , Now it's just a matter of 310 A rainbow candy , With the original 691 It saves more than half of the money ~
Let's try the real thing now !
I put a two-dimensional code with rainbow candy ...
Be accomplished ~
The only regret is that the converted short link is invalid , You can't jump to B Standing on the web page .
And it's easier to identify with Taobao , Wechat is difficult , You have to find an angle …
边栏推荐
- 22 mathematical modeling contest 22 contest C
- With the QQ group file storage function of super nice, you immediately have n cloud disks that are easy to download and never expire
- Creating a binary tree (binary linked list) from a generalized table
- 使用Navicat对比多环境数据库数据差异和结构差异,以及自动DML和DDL脚本
- Notes on key words in the original English work biography of jobs (V) [chapter three]
- Flitter gets the height of the top status bar
- Notes on key words in the original English work biography of jobs (IV) [chapter two]
- (translation) the use of letter spacing to improve the readability of all capital text
- [competition -kab micro entrepreneurship competition] KAB National College Students' micro entrepreneurship action participation experience sharing (including the idea of writing the application form)
- Oracle-单行函数大全
猜你喜欢

Cassava tree disease recognition based on vgg16 image classification

Jmeter接口测试,关联接口实现步骤(token)

C # startup program loses double quotation marks for parameters passed. How to solve it?

Use Navicat to compare data differences and structure differences of multi environment databases, and automatic DML and DDL scripts

Matplotlib decision boundary drawing function plot in Matplotlib_ decision_ Boundary and plt Detailed explanation of contour function
![[competition -kab micro entrepreneurship competition] KAB National College Students' micro entrepreneurship action participation experience sharing (including the idea of writing the application form)](/img/f3/a8414635ad39ad405864f5fcf66d6d.jpg)
[competition -kab micro entrepreneurship competition] KAB National College Students' micro entrepreneurship action participation experience sharing (including the idea of writing the application form)

(translation) the use of letter spacing to improve the readability of all capital text

Data-driven anomaly detection and early warning of 21 May Day C

RMB 3000 | record "tbtools" video, make a friend and get a cash prize!
![[learn C from me and master the key to programming] insertion sort of eight sorts](/img/2c/22e065390464ed5cd1056346d46573.jpg)
[learn C from me and master the key to programming] insertion sort of eight sorts
随机推荐
六级易混词整理
Unity发布webGL的时候JsonConvert.SerializeObject()转换失败
Are the top ten securities companies at great risk of opening accounts and safe and reliable?
Voiceprint Technology (VI): other applications of voiceprint Technology
Flutter multilingual intl: ^0.17.0 cannot be imported
证券开户风险大吗,安全靠谱吗?
【OpenCV】—输入输出XML和YAML文件
Is it safe to open an account online? Who can I ask?
Numpy numpy中的meshgrid()函数
The meshgrid() function in numpy
Title B of the certification cup of the pistar cluster in the Ibagu catalog
Voiceprint Technology (II): Fundamentals of audio signal processing
Specific usage of sklearn polynomialfeatures
在指南针上面开户好不好,安不安全?
annotation lib 和 processor lib如何引用
Explanation of assertions in JMeter
Study on correlation of pumpkin price and design of price prediction model based on BP neural network
Voiceprint Technology (VII): the future of voiceprint Technology
CSV parameterization in JMeter
Atguigu---18-component