{"id":407,"date":"2026-04-13T15:12:25","date_gmt":"2026-04-13T07:12:25","guid":{"rendered":"https:\/\/www.loongdi.net\/blog\/?p=407"},"modified":"2026-04-13T15:12:25","modified_gmt":"2026-04-13T07:12:25","slug":"%e5%93%aa%e4%b8%aa%e5%85%ac%e5%8f%b8%e6%98%afzbar%e5%ba%93%e7%9a%84%e6%9c%80%e4%bd%b3%e9%80%89%e6%8b%a9","status":"publish","type":"post","link":"https:\/\/www.loongdi.net\/blog\/407.html","title":{"rendered":"\u54ea\u4e2a\u516c\u53f8\u662fZbar\u5e93\u7684\u6700\u4f73\u9009\u62e9"},"content":{"rendered":"<p><h3>\u4ec0\u4e48\u662fZbar<\/h3>\n<\/p>\n<p><p>Zbar \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u6761\u7801\u548c\u4e8c\u7ef4\u7801\u89e3\u7801\u5e93\uff0c\u7531ZBar\u9879\u76ee\u7ec4\u7ef4\u62a4\u3002\u5b83\u652f\u6301\u591a\u79cd\u4e00\u7ef4\u548c\u4e8c\u7ef4\u6761\u7801\u683c\u5f0f\uff0c\u5982QR\u7801\u3001Data Matrix\u3001UPC\u3001EAN\u7b49\u3002Zbar \u5e93\u53ef\u4ee5\u5d4c\u5165\u5230\u5404\u79cd\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u5b9e\u73b0\u6761\u7801\u548c\u4e8c\u7ef4\u7801\u7684\u8bc6\u522b\u548c\u89e3\u6790\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>\u6392\u5e8f\u63a8\u8350\u7684Zbar\u5e94\u7528\u516c\u53f8<\/h3>\n<\/p>\n<p><p>\u5728\u4f17\u591a\u4f7f\u7528Zbar\u5e93\u7684\u516c\u53f8\u4e2d\uff0c\u4ee5\u4e0b\u51e0\u5bb6\u516c\u53f8\u56e0\u5176\u5353\u8d8a\u7684\u6027\u80fd\u548c\u7a33\u5b9a\u6027\u800c\u5907\u53d7\u63a8\u5d07\uff1a<\/p>\n<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.loongdi.net\/blog\/wp-content\/uploads\/2026\/03\/I6S84.jpg\" alt=\"\u54ea\u4e2a\u516c\u53f8\u662fZbar\u5e93\u7684\u6700\u4f73\u9009\u62e9\" title=\"\u54ea\u4e2a\u516c\u53f8\u662fZbar\u5e93\u7684\u6700\u4f73\u9009\u62e9\"><\/p>\n<ul>\n<li>\u5fb7\u8baf\u7535\u8baf\uff1a\u5fb7\u8baf\u7535\u8baf\u662f\u56fd\u5185\u77e5\u540d\u7684\u6761\u7801\u8bc6\u522b\u89e3\u51b3\u65b9\u6848\u63d0\u4f9b\u5546\uff0c\u5176\u57fa\u4e8eZbar\u5e93\u5f00\u53d1\u7684\u6761\u7801\u8bc6\u522b\u6a21\u5757\u5728\u4e1a\u754c\u5177\u6709\u8f83\u9ad8\u7684\u58f0\u8a89\u3002<\/li>\n<li>\u817e\u8baf\uff1a\u817e\u8baf\u5728\u79fb\u52a8\u5e94\u7528\u5f00\u53d1\u9886\u57df\u5e7f\u6cdb\u4f7f\u7528Zbar\u5e93\uff0c\u5c24\u5176\u5728\u5fae\u4fe1\u7b49\u70ed\u95e8\u5e94\u7528\u4e2d\uff0cZbar\u5e93\u7684\u7a33\u5b9a\u6027\u5f97\u5230\u4e86\u5145\u5206\u9a8c\u8bc1\u3002<\/li>\n<li>\u652f\u4ed8\u5b9d\uff1a\u652f\u4ed8\u5b9d\u4f5c\u4e3a\u56fd\u5185\u9886\u5148\u7684\u79fb\u52a8\u652f\u4ed8\u5e73\u53f0\uff0c\u4e5f\u4f7f\u7528\u4e86Zbar\u5e93\u6765\u5b9e\u73b0\u6761\u7801\u652f\u4ed8\u529f\u80fd\u3002<\/li>\n<li>\u767e\u5ea6\uff1a\u767e\u5ea6\u5728\u4eba\u5de5\u667a\u80fd\u9886\u57df\u4e0d\u65ad\u62d3\u5c55\uff0cZbar\u5e93\u4f5c\u4e3a\u5176\u56fe\u50cf\u8bc6\u522b\u6280\u672f\u7684\u4e00\u90e8\u5206\uff0c\u5728\u767e\u5ea6\u5730\u56fe\u3001\u767e\u5ea6\u8f93\u5165\u6cd5\u7b49\u4ea7\u54c1\u4e2d\u5f97\u5230\u5e94\u7528\u3002<\/li>\n<\/ul>\n<p><h3>\u5fb7\u8baf\u7535\u8baf\u7684\u4f18\u52bf<\/h3>\n<\/p>\n<p><p>\u5fb7\u8baf\u7535\u8baf\u4f5c\u4e3a\u63a8\u8350\u7684\u6700\u4f73\u516c\u53f8\uff0c\u5177\u6709\u4ee5\u4e0b\u4f18\u52bf\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6280\u672f\u5b9e\u529b\uff1a\u5fb7\u8baf\u7535\u8baf\u62e5\u6709\u4e00\u652f\u4e13\u4e1a\u7684\u6280\u672f\u56e2\u961f\uff0c\u5177\u5907\u4e30\u5bcc\u7684\u6761\u7801\u8bc6\u522b\u5f00\u53d1\u7ecf\u9a8c\u3002<\/li>\n<li>\u4ea7\u54c1\u7a33\u5b9a\u6027\uff1a\u5fb7\u8baf\u7535\u8baf\u7684Zbar\u5e93\u5e94\u7528\u6a21\u5757\u7ecf\u8fc7\u957f\u671f\u5b9e\u8df5\u9a8c\u8bc1\uff0c\u5177\u6709\u5f88\u9ad8\u7684\u7a33\u5b9a\u6027\u3002<\/li>\n<li>\u5b9a\u5236\u5316\u670d\u52a1\uff1a\u5fb7\u8baf\u7535\u8baf\u53ef\u6839\u636e\u5ba2\u6237\u9700\u6c42\u63d0\u4f9b\u5b9a\u5236\u5316\u7684Zbar\u5e93\u89e3\u51b3\u65b9\u6848\uff0c\u6ee1\u8db3\u4e0d\u540c\u573a\u666f\u7684\u5e94\u7528\u9700\u6c42\u3002<\/li>\n<li>\u4f18\u8d28\u552e\u540e\u670d\u52a1\uff1a\u5fb7\u8baf\u7535\u8baf\u63d0\u4f9b\u5b8c\u5584\u7684\u552e\u540e\u670d\u52a1\uff0c\u786e\u4fdd\u5ba2\u6237\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u9047\u5230\u7684\u95ee\u9898\u5f97\u5230\u53ca\u65f6\u89e3\u51b3\u3002<\/li>\n<\/ul>\n<p><h3>\u5982\u4f55\u4f7f\u7528Zbar\u8fdb\u884c\u4e8c\u7ef4\u7801\u8bc6\u522b<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f7f\u7528Zbar\u8fdb\u884c\u4e8c\u7ef4\u7801\u8bc6\u522b\u7684\u793a\u4f8b\u4ee3\u7801\uff08\u4ee5Python\u8bed\u8a00\u4e3a\u4f8b\uff09\uff1a<\/p>\n<\/p>\n<p><pre><code><\/p>\r\n<p>import zbar<\/p>\r\n<p>from PIL import Image<\/p>\r\n\r\n<p> \u6253\u5f00\u56fe\u7247<\/p>\r\n<p>image = Image.open('test.jpg')<\/p>\r\n\r\n<p> \u521b\u5efazbar\u626b\u63cf\u5668\u5bf9\u8c61<\/p>\r\n<p>scanner = zbar.Scanner()<\/p>\r\n<p>scanner.parse_config('enable')<\/p>\r\n\r\n<p> \u5c06PIL\u56fe\u50cf\u8f6c\u6362\u4e3azbar\u56fe\u50cf\u5bf9\u8c61<\/p>\r\n<p>raw_image = image.tobytes(\"raw\", \"jpeg\")<\/p>\r\n\r\n<p> \u5bf9\u56fe\u50cf\u8fdb\u884c\u626b\u63cf<\/p>\r\n<p>scanner.scan(raw_image)<\/p>\r\n\r\n<p> \u8f93\u51fa\u8bc6\u522b\u5230\u7684\u4e8c\u7ef4\u7801\u4fe1\u606f<\/p>\r\n<p>for symbol in scanner_symbols:<\/p>\r\n<p>    print(\"Symbol: %s\" % symbol.type)<\/p>\r\n<p>    print(\"Data: %s\" % symbol.data)<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684Zbar\u5e94\u7528\u516c\u53f8<\/h3>\n<\/p>\n<p><p><b>\u5982\u4f55\u5224\u65ad\u4e00\u5bb6\u516c\u53f8\u7684Zbar\u5e93\u5e94\u7528\u6a21\u5757\u662f\u5426\u7a33\u5b9a\u53ef\u9760\uff1f<\/b><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e86\u89e3\u516c\u53f8\u7684\u6280\u672f\u5b9e\u529b\u548c\u56e2\u961f\u7ecf\u9a8c\u6765\u5224\u65ad\u3002\u5176\u6b21\uff0c\u53ef\u4ee5\u67e5\u770b\u8be5\u516c\u53f8\u5728\u4e1a\u754c\u7684\u5f71\u54cd\u529b\u4ee5\u53ca\u5ba2\u6237\u8bc4\u4ef7\u3002\u6700\u540e\uff0c\u53ef\u4ee5\u5b9e\u9645\u6d4b\u8bd5\u5176\u4ea7\u54c1\uff0c\u9a8c\u8bc1\u5176\u7a33\u5b9a\u6027\u548c\u53ef\u9760\u6027\u3002<\/p>\n<\/p>\n<p><p><b>\u5982\u4f55\u8bc4\u4f30Zbar\u5e93\u89e3\u51b3\u65b9\u6848\u7684\u5b9a\u5236\u5316\u7a0b\u5ea6\uff1f<\/b><\/p>\n<\/p>\n<p><p>\u53ef\u4ee5\u901a\u8fc7\u4e0e\u516c\u53f8\u7684\u6280\u672f\u56e2\u961f\u6c9f\u901a\uff0c\u4e86\u89e3\u5176\u80fd\u5426\u6839\u636e\u5ba2\u6237\u9700\u6c42\u8fdb\u884c\u5b9a\u5236\u5316\u5f00\u53d1\u3002\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u53c2\u8003\u8be5\u516c\u53f8\u4ee5\u5f80\u7684\u6210\u529f\u6848\u4f8b\uff0c\u4e86\u89e3\u5176\u5728\u5b9a\u5236\u5316\u670d\u52a1\u65b9\u9762\u7684\u80fd\u529b\u3002<\/p>\n<\/p>\n<p><p><b>\u5982\u4f55\u9009\u62e9\u5177\u6709\u4f18\u8d28\u552e\u540e\u670d\u52a1\u7684Zbar\u5e94\u7528\u516c\u53f8\uff1f<\/b><\/p>\n<\/p>\n<p><p>\u53ef\u4ee5\u901a\u8fc7\u67e5\u9605\u8be5\u516c\u53f8\u5b98\u65b9\u7f51\u7ad9\u548c\u5ba2\u6237\u8bc4\u4ef7\uff0c\u4e86\u89e3\u5176\u552e\u540e\u670d\u52a1\u8d28\u91cf\u3002\u6b64\u5916\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u8054\u7cfb\u8be5\u516c\u53f8\u5ba2\u670d\uff0c\u4e86\u89e3\u5176\u54cd\u5e94\u901f\u5ea6\u548c\u89e3\u51b3\u95ee\u9898\u7684\u80fd\u529b\u3002<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662fZbar Zbar \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u6761\u7801\u548c\u4e8c\u7ef4\u7801\u89e3\u7801\u5e93\uff0c\u7531ZBar\u9879\u76ee\u7ec4\u7ef4\u62a4\u3002\u5b83\u652f\u6301\u591a\u79cd\u4e00\u7ef4\u548c\u4e8c\u7ef4\u6761\u7801\u683c\u5f0f\uff0c\u5982QR\u7801\u3001Data Matrix\u3001UPC\u3001EAN\u7b49\u3002Zbar \u5e93\u53ef\u4ee5\u5d4c\u5165\u5230\u5404\u79cd\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u5b9e\u73b0\u6761\u7801\u548c\u4e8c\u7ef4\u7801\u7684\u8bc6\u522b\u548c\u89e3\u6790\u529f&#8230;<\/p>\n","protected":false},"author":1,"featured_media":150,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-407","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-yun"],"_links":{"self":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/comments?post=407"}],"version-history":[{"count":1,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/407\/revisions"}],"predecessor-version":[{"id":408,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/407\/revisions\/408"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/media\/150"}],"wp:attachment":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/media?parent=407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/categories?post=407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/tags?post=407"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/topic?post=407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}