这几天在玩这个,发一下关于QR码的程序吧。
题目如下:
题目标题说明是QR码,看来是需要用程序来把上面的数字来生成QR码。代码如下:(基于OPENCV来实现的)
//由于图片太小,这里把图片放大了十倍
#include <stdio.h>
#include <stdlib.h>
#include "cv.h"
#include "cvaux.h"
#include "cxcore.h"
#include "highgui.h"
int main()
{
int t[]={1,1,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,1,1,1,1,1,1,
1,0,0,0,0,0,1,0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,
1,0,1,1,1,0,1,0,0,0,1,0,1,0,0,1,1,0,1,0,1,1,1,0,1,
1,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,
1,0,1,1,1,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,0,1,
1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,
1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,1,0,1,1,0,1,0,1,1,0,0,0,0,0,0,0,0,
1,1,0,1,1,0,1,0,0,1,1,1,0,1,0,0,0,0,1,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,1,0,1,1,1,0,1,1,
0,1,1,1,1,0,1,0,0,0,1,1,0,1,0,1,0,1,1,1,1,0,1,0,1,
0,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,0,
1,0,0,0,0,1,1,0,0,1,0,1,1,1,0,0,1,0,1,0,0,1,0,1,1,
1,0,1,1,0,1,0,0,1,1,0,0,0,1,1,1,1,1,1,1,1,0,0,1,0,
1,1,1,0,1,1,1,1,0,0,0,1,1,1,0,1,0,1,0,0,1,0,0,1,1,
1,0,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,1,1,1,
1,0,1,0,1,0,1,0,1,1,0,0,0,0,1,0,1,1,1,1,1,0,1,1,1,
0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,0,1,0,0,0,1,0,1,0,1,
1,1,1,1,1,1,1,0,0,0,1,1,0,0,0,0,1,0,1,0,1,1,1,0,1,
1,0,0,0,0,0,1,0,0,1,0,0,1,0,1,1,1,0,0,0,1,1,0,1,1,
1,0,1,1,1,0,1,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,1,
1,0,1,1,1,0,1,0,1,0,1,0,0,0,1,0,1,1,1,1,1,1,1,1,1,
1,0,1,1,1,0,1,0,0,0,1,0,1,0,1,1,0,1,0,1,1,1,0,1,1,
1,0,0,0,0,0,1,0,1,0,1,0,0,0,1,1,0,1,1,1,0,1,1,1,1,
1,1,1,1,1,1,1,0,1,0,0,0,0,1,1,1,1,0,0,0,1,1,0,0,1};
cvNamedWindow("a");
IplImage* img=cvCreateImage(cvSize(250,250),IPL_DEPTH_8U,1);
int m,n;
for(int i=0;i<250;++i)
{
for(int j=0;j<250;++j)
{
m=i/10;
n=j/10;
if(t[n*25+m]==0)
((uchar*)(img->imageData+img->widthStep*j))[i]=(char)(255);
else
((uchar*)(img->imageData+img->widthStep*j))[i]=(char)(0);
}
}
cvShowImage("a",img);
cvWaitKey(0);
//system("pause");
return 0;
}
效果如下:
百度上传扫一下就出来了。