{"id":382,"date":"2015-03-31T10:30:35","date_gmt":"2015-03-31T02:30:35","guid":{"rendered":"http:\/\/www.woria.cn\/blogs\/?p=382"},"modified":"2015-03-31T10:30:35","modified_gmt":"2015-03-31T02:30:35","slug":"qrcode-read-php-python-flash","status":"publish","type":"post","link":"https:\/\/blogs.woria.cn\/?p=382","title":{"rendered":"\u4f7f\u7528\u7ec4\u5408\u6280\u6765\u89e3\u6790\u4e8c\u7ef4\u7801"},"content":{"rendered":"<p>\u6709\u670b\u53cb\u63d0\u51fa\u8fd9\u4e2a\u9700\u6c42\u3002<br \/>\n\u5e0c\u671b\u533a\u5206\u7528\u6237\u4e0a\u4f20\u7684\u4e8c\u7ef4\u7801\u662f\u7fa4\u4e8c\u7ef4\u7801\uff0c\u8fd8\u662f\u4e2a\u4eba\u4e8c\u7ef4\u7801\u6216\u8005\u8bf4\u662f\u516c\u5171\u5e10\u53f7\u3002<\/p>\n<p>\u8fd9\u91cc\u4f1a\u6d89\u53ca\u5230\u4e8c\u7ef4\u7801\u7684\u89e3\u8bfb\u3002<br \/>\n\u672c\u6765flash\u4e2d\u6709\u7c7b\u5e93\uff0c\u53ef\u4ee5\u751f\u6210\u53ca\u89e3\u6790\u4e8c\u7ef4\u7801\u3002<br \/>\n\u5982\u679c\u662fpc\u7f51\u7ad9\u7684\u8bdd\uff0c\u76f4\u63a5\u5728flash\u4e0a\u4f20\u7ec4\u4ef6\u4e2d\u505a\u624b\u811a\u3002\u4e0a\u4f20\u540c\u65f6\u8bfb\u53d6\u5230\u5185\u5b58\u4e2d\u8fdb\u884c\u4e8c\u7ef4\u7801\u89e3\u8bfb\u3002<br \/>\n\u4f46\u662f\u8fd9\u4e2a\u670b\u53cb\u662f\u4e00\u4e2a\u624b\u673a\u7ad9\u70b9\u3002<br \/>\n\u65e0\u6cd5\u4f7f\u7528flash\u7ec4\u4ef6\u3002<br \/>\n\u53ea\u597d\u53e6\u60f3\u4ed6\u6cd5\u3002<\/p>\n<p>php\u4e2d\u4e5f\u6709\u4e8c\u7ef4\u7801\u76f8\u5173\u7684\u64cd\u4f5c\u7c7b\u5e93\u3002libqrencode ,PHP QR Code\u7b49\u7b49\u3002\u4e5f\u6709\u5927\u8c37\u6b4c\u63d0\u4f9b\u7684\u4e8c\u7ef4\u7801api\uff08\u53ef\u60dc\u5899\u6389\u4e86\uff0c\u614e\u7528\uff09\u3002<br \/>\n\u8fd9\u4e9b\u8c8c\u4f3c\u6bd4\u8f83\u96be\u64cd\u4f5c\u3002\u591a\u6570\u90fd\u662f\u5982\u4f55\u751f\u6210\uff0c\u4f46\u662f\u5982\u4f55\u8bfb\u53d6\u53c2\u8003\u6587\u7ae0\u5c11\u4e4b\u53c8\u5c11\u3002<br \/>\n\u4e3b\u8981\u6709\u4e00\u70b9\uff0c\u7528\u6237\u4e0a\u4f20\u7684\u4e8c\u7ef4\u7801\u9c7c\u9f99\u6df7\u6742\uff0c\u5e76\u975e\u662f\u5355\u7eaf\u89c4\u8303\u7684\u4e8c\u7ef4\u7801\u3002\u6240\u4ee5\u5bf9\u8bfb\u53d6\u548c\u89e3\u6790\u8981\u6c42\u80fd\u529b\u6781\u9ad8\u3002<\/p>\n<p>\u7ecf\u8fc7\u4e00\u756a\u8003\u8651\u3002\u51b3\u5b9a\u91c7\u7528\u5982\u4e0b\u6a21\u5f0f\uff1a<\/p>\n<p>1\u3001\u7f16\u5199python\u811a\u672c\u6765\u89e3\u6790\u4e8c\u7ef4\u7801\u3002<br \/>\n2\u3001\u4f7f\u7528php\u505a\u4e2d\u4ecb\u3002<br \/>\n<!--more--><\/p>\n<p>\u9996\u5148\u5728\u670d\u52a1\u5668\u4e0a\u68c0\u67e5python\u4ee5\u53ca\u7ec4\u4ef6\u652f\u6301\u60c5\u51b5<br \/>\n1\u3001\u9700\u8981\u5b89\u88c5python-qrcode #yum install python-qrcode*<br \/>\n2\u3001\u9700\u8981\u5b89\u88c5zbar #yum install zbar-dev* zbar-pygt*<br \/>\n3\u3001\u9700\u8981\u5b89\u88c5cStringIO #yum install cStringIO<br \/>\n4\u3001\u4e0a\u8ff0\u4e09\u4e2a\u7ec4\u4ef6\u5206\u522b\u662f\u7528\u6765\u751f\u6210\u8bfb\u53d6\u4e8c\u7ef4\u7801\u7684qrcode\u3001\u89e3\u6790\u56fe\u7247\u7684zbar\u3001\u628a\u8fdc\u7a0b\u6587\u4ef6\u8bfb\u53d6\u9053\u5185\u5b58\u4e2d\u7684cStringIO\u3002<\/p>\n<p>\u5b8c\u6210\u4e0a\u8ff0\u5de5\u4f5c\u540e\u5c31\u5f00\u641e\u5427\uff01<\/p>\n<p>\u7f16\u5199python\u811a\u672c<br \/>\n#vi rc.py<\/p>\n<blockquote><p>\n#!\/usr\/bin\/python<br \/>\nfrom sys import argv<br \/>\nimport zbar<br \/>\nimport Image<br \/>\nimport cStringIO<br \/>\nimport urllib2<br \/>\n#\u4e0a\u8fb9\u662f\u52a0\u8f7d\u6a21\u5757<br \/>\nif len(argv) < 2: exit(1)\n#\u521b\u5efa\u56fe\u7247\u8bfb\u53d6\u5668\nscanner = zbar.ImageScanner()\n# configure the reader\nscanner.parse_config('enable')\n#\u8fdc\u7a0b\u8bfb\u53d6\u56fe\u7247\u5230\u5185\u5b58\u4e2d\nurl = argv[1]\nfile = urllib2.urlopen(url)\ntmpIm = cStringIO.StringIO(file.read())\n#\u8fd9\u4e2a\u662f\u8bfb\u53d6\u672c\u5730\u6587\u4ef6\n#pil = Image.open(argv[1]).convert('L')\n#\u8bfb\u53d6\u6587\u4ef6\npil = Image.open(tmpIm).convert('L')\nwidth, height = pil.size\nraw = pil.tostring()\n# wrap image data\nimage = zbar.Image(width, height, 'Y800', raw)\n# scan the image for barcodes\n#\u626b\u63cf\u56fe\u7247\nscanner.scan(image)\n# extract results\nfor symbol in image:\n    # \u8fd4\u56de\u6570\u636e\uff0c\u5305\u542b\u4e8c\u7ef4\u7801\u7f16\u7801\u683c\u5f0f\u4ee5\u53ca\u6570\u636e\n    print 'decoded', symbol.type, 'symbol', '\"%s\"' % symbol.data\n\n# clean up\n#\u6e05\u7406\u5185\u5b58\ndel(image)\n<\/p><\/blockquote>\n<p>\u7f16\u5199php\u8c03\u7528python<br \/>\n#vi index.php<\/p>\n<blockquote><p>\n<?php\n$k = $_REQUEST['k'];\/\/\u627e\u5230url\u4e2d\u5305\u542b\u56fe\u7247\u8def\u5f84\u7684\u53c2\u6570\nif (!empty($k))\n{\n        $k = trim($k);\/\/\u83b7\u5f97\u8fdc\u7a0b\u56fe\u7247\u8def\u5f84\n        passthru('python .\/rc.py '.$k);\/\/\u6267\u884c\u5e76\u8fd4\u56depython\u7ed3\u679c\n}else{\n        echo 'no,pic!';\/\/\u5982\u679c\u6ca1\u6709\u53c2\u6570\u5219\u6253\u4e2a\u62db\u547c\uff01\n}\n?><\/p>\n<\/blockquote>\n<p>ok\u4e86\uff0c\u6253\u5b8c\u6536\u5de5\u3002\u505a\u51e0\u4e2a\u6d4b\u8bd5\u3002<\/p>\n<p>\u5f88\u5feb\u53d1\u73b0\u89c4\u5f8b\u3002<br \/>\nhttp:\/\/weixin.qq.com\/q\/ \u5f00\u5934\u7684\u90fd\u4e3a\u516c\u5171\u53f7<br \/>\nhttp:\/\/weixin.qq.com\/r\/ \u5f00\u5934\u7684\u90fd\u4e3a\u4e2a\u4eba\u53f7<br \/>\nhttp:\/\/weixin.qq.com\/g\/ \u5f00\u5934\u7684\u90fd\u4e3a\u5fae\u4fe1\u7fa4<\/p>\n<p>http:\/\/www.woria.cn\/qc\/index.php?k=pic<\/p>\n<p>\u8fd9\u662f\u6211\u7684\u6f14\u793a\u5730\u5740\u3002\u8bf7\u66ff\u6362pic\u4e3a\u4f60\u60f3\u89e3\u6790\u7684\u4e8c\u7ef4\u7801\u3002\uff08\u94fe\u63a5\u540e\u671f\u53ef\u80fd\u4f1a\u5931\u6548\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u670b\u53cb\u63d0\u51fa\u8fd9\u4e2a\u9700\u6c42\u3002 \u5e0c\u671b\u533a\u5206\u7528\u6237\u4e0a\u4f20\u7684\u4e8c\u7ef4\u7801\u662f\u7fa4\u4e8c\u7ef4\u7801\uff0c\u8fd8\u662f\u4e2a\u4eba\u4e8c\u7ef4\u7801\u6216\u8005\u8bf4\u662f\u516c\u5171\u5e10\u53f7\u3002 \u8fd9\u91cc\u4f1a\u6d89\u53ca\u5230\u4e8c\u7ef4\u7801&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,10,5],"tags":[],"class_list":["post-382","post","type-post","status-publish","format-standard","hentry","category-technique","category-ued","category-magician"],"_links":{"self":[{"href":"https:\/\/blogs.woria.cn\/index.php?rest_route=\/wp\/v2\/posts\/382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.woria.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.woria.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.woria.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.woria.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=382"}],"version-history":[{"count":0,"href":"https:\/\/blogs.woria.cn\/index.php?rest_route=\/wp\/v2\/posts\/382\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.woria.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.woria.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.woria.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}