1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
cout << "Content-Type:image/jpeg\r\n\r\n";
unsigned char *frame;
char px[2];
int x, y, w;
QRcode *qrcode;
QRtools tools;
qrcode = QRcode_encodeString("http://www.lequipe.fr", 4, QR_ECLEVEL_H, QR_MODE_8, 1);
//S'il n'y a pas d'erreur, alors on traite le qrcode
if(tools.checkQrcodeError(qrcode)){
tools.binarize(qrcode,true);
Mat qrMat (tools.width, tools.width, CV_8UC1);
//On rempli la matrice avec le tableau d'int du qrcode
for(int y=0;y<tools.width;y++){
for(int x=0;x<tools.width;x++){
if(tools.binQrCode[y*tools.width+x] > 0)
qrMat.at<uchar> (y, x) = 0;
else
qrMat.at<uchar> (y, x) = 255;
}
}
//On encode l'image en jpeg
std::vector<uchar>outbuf;
std::vector<int> params;
params.push_back(CV_IMWRITE_JPEG_QUALITY);
params.push_back(100);
imencode(".jpg", qrMat, outbuf, params);
//cout<<outbuf;
} |
Partager