{"id":938,"date":"2019-12-06T20:36:42","date_gmt":"2019-12-06T17:06:42","guid":{"rendered":"https:\/\/behnudi.ir\/?p=938"},"modified":"2024-08-25T21:52:43","modified_gmt":"2024-08-25T18:22:43","slug":"barcode-scanner","status":"publish","type":"post","link":"https:\/\/behnudi.ir\/?p=938","title":{"rendered":"\u0628\u0627\u0631\u06a9\u062f \u0627\u0633\u06a9\u0646\u0631"},"content":{"rendered":"<p>\u0628\u0627\u0631\u06a9\u062f \u0627\u0633\u06a9\u0646\u0631 \u06cc\u0627 \u0628\u0627\u0631\u06a9\u062f\u062e\u0648\u0627\u0646 \u0628\u0647 \u062f\u0633\u062a\u06af\u0627\u0647\u06cc \u0645\u06cc\u200c\u06af\u0648\u06cc\u0646\u062f \u06a9\u0647\u00a0 \u0628\u0627\u0631\u06a9\u062f \u0686\u0627\u067e \u0634\u062f\u0647 \u0631\u0627 \u0645\u06cc\u200c\u062e\u0648\u0627\u0646\u062f\u060c \u0648 \u062f\u06cc\u062a\u0627\u06cc \u0645\u0648\u062c\u0648\u062f \u062f\u0631 \u0622\u0646 \u0631\u0627 \u0631\u0645\u0632\u06af\u0634\u0627\u06cc\u06cc \u0645\u06cc\u200c\u06a9\u0646\u062f.<!--more--><\/p>\n<p>\u0645\u0627\u0646\u0646\u062f \u06cc\u06a9 \u0627\u0633\u06a9\u0646\u0631 \u0645\u0639\u0645\u0648\u0644\u06cc\u060c \u0627\u0632 \u06cc\u06a9 \u0645\u0646\u0628\u0639 \u0646\u0648\u0631\u060c \u06cc\u06a9 \u0644\u0646\u0632 \u0648 \u06cc\u06a9 \u0633\u0646\u0633\u0648\u0631 \u0646\u0648\u0631 \u062a\u0634\u06a9\u06cc\u0644 \u0634\u062f\u0647 \u0627\u0633\u062a. \u0647\u0645\u0686\u0646\u06cc\u0646\u060c \u062a\u0642\u0631\u06cc\u0628\u0627\u064b \u0647\u0645\u0647 \u0628\u0627\u0631\u06a9\u062f\u062e\u0648\u0627\u0646\u200c\u0647\u0627 \u062f\u0627\u0631\u0627\u06cc \u0645\u062f\u0627\u0631 \u0631\u0645\u0632\u06af\u0634\u0627\u06cc\u06cc \u0647\u0633\u062a\u0646\u062f \u06a9\u0647 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u062f \u062f\u06cc\u062a\u0627\u06cc \u062a\u0635\u0648\u06cc\u0631 \u0628\u0627\u0631\u06a9\u062f \u0627\u0631\u0627\u0626\u0647 \u0634\u062f\u0647 \u062a\u0648\u0633\u0637 \u0633\u0646\u0633\u0648\u0631 \u0631\u0627 \u0622\u0646\u0627\u0644\u06cc\u0632 \u06a9\u0631\u062f\u0647 \u0648 \u0645\u062d\u062a\u0648\u0627\u06cc \u0622\u0646 \u0631\u0627 \u0628\u0627\u0632\u06cc\u0627\u0628\u06cc \u06a9\u0646\u062f.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-942 size-full\" src=\"https:\/\/behnudi.ir\/wp-content\/uploads\/2019\/12\/barcode_scanner.jpg\" alt=\"\" width=\"1280\" height=\"720\" srcset=\"https:\/\/behnudi.ir\/wp-content\/uploads\/2019\/12\/barcode_scanner.jpg 1280w, https:\/\/behnudi.ir\/wp-content\/uploads\/2019\/12\/barcode_scanner-300x169.jpg 300w, https:\/\/behnudi.ir\/wp-content\/uploads\/2019\/12\/barcode_scanner-1024x576.jpg 1024w, https:\/\/behnudi.ir\/wp-content\/uploads\/2019\/12\/barcode_scanner-768x432.jpg 768w, https:\/\/behnudi.ir\/wp-content\/uploads\/2019\/12\/barcode_scanner-640x360.jpg 640w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p>\u0647\u0645\u0686\u0646\u06cc\u0646 \u0646\u0631\u0645 \u0627\u0641\u0632\u0627\u0631\u0647\u0627\u06cc\u06cc \u0633\u0627\u062e\u062a\u0647 \u0634\u062f\u0647 \u06a9\u0647 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u062f \u0647\u0645\u06cc\u0646 \u06a9\u0627\u0631 \u0631\u0627 \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u062f. \u0628\u0631\u062e\u06cc \u0644\u0648\u06a9\u0627\u0644 \u0628\u0631 \u0631\u0648\u06cc \u062f\u0633\u062a\u06af\u0627\u0647 \u0634\u0645\u0627 \u0648 \u0628\u0631\u062e\u06cc \u0622\u0646\u0644\u0627\u06cc\u0646 \u06a9\u0627\u0631 \u0645\u06cc\u200c\u06a9\u0646\u0646\u062f.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright wp-image-944 size-full\" src=\"https:\/\/behnudi.ir\/wp-content\/uploads\/2019\/12\/zebra\u0640crossing.png\" alt=\"\" width=\"100\" height=\"100\" \/><\/p>\n<p><a href=\"https:\/\/github.com\/zxing-js\/library\" target=\"_blank\" rel=\"noopener\"><strong>ZXing<\/strong><\/a> (\u06a9\u0648\u062a\u0627\u0647\u200c\u0634\u062f\u0647\u0654 <strong>Zebra Crossing<\/strong> \u0628\u0647 \u0641\u0627\u0631\u0633\u06cc: \u062e\u0637\u200c\u06a9\u0634\u06cc \u0639\u0627\u0628\u0631 \u067e\u06cc\u0627\u062f\u0647) \u0646\u0627\u0645 \u06cc\u06a9 \u06a9\u062a\u0627\u0628\u062e\u0627\u0646\u0647 \u067e\u0631\u062f\u0627\u0632\u0634 \u062a\u0635\u0648\u06cc\u0631 \u0628\u0627\u0631\u06a9\u062f \u06cc\u06a9\u200c\u0628\u0639\u062f\u06cc \u0648 \u062f\u0648\u0628\u0639\u062f\u06cc \u0627\u0633\u062a. \u0627\u06cc\u0646 \u067e\u0631\u0648\u0698\u0647 \u0627\u067e\u0646 \u0633\u0648\u0631\u0633 \u0648 \u0622\u0632\u0627\u062f \u0627\u0633\u062a. \u0628\u0627 \u0627\u06cc\u0646\u06a9\u0647 \u0628\u0647 \u0632\u0628\u0627\u0646 \u062c\u0627\u0648\u0627 \u067e\u06cc\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0634\u062f\u0647\u060c \u0627\u0645\u06a9\u0627\u0646 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u062f\u0631 \u0628\u0631\u062e\u06cc \u0632\u0628\u0627\u0646\u200c\u0647\u0627\u06cc \u062f\u06cc\u06af\u0631 \u0631\u0627 \u0646\u06cc\u0632 \u062f\u0627\u0631\u062f.<\/p>\n<hr \/>\n<p>\u062f\u0631 \u0645\u062b\u0627\u0644 \u0632\u06cc\u0631 \u0627\u0632 \u06a9\u062a\u0627\u0628\u062e\u0627\u0646\u0647 <strong>ZXing<\/strong> \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a. \u0627\u06cc\u0646 \u0645\u062b\u0627\u0644 \u0646\u062d\u0648\u0647 \u0627\u0633\u06a9\u0646 \u0628\u0627\u0631\u06a9\u062f \u06cc\u06a9\u200c\u0628\u0639\u062f\u06cc \u0648 \u062f\u0648\u0628\u0639\u062f\u06cc \u0631\u0627 \u0627\u0632 \u062f\u0648\u0631\u0628\u06cc\u0646 \u0641\u06cc\u0644\u0645 \u0628\u0631\u062f\u0627\u0631\u06cc \u0646\u0634\u0627\u0646 \u0645\u06cc\u200c\u062f\u0647\u062f. \u0627\u06af\u0631 \u0628\u06cc\u0634 \u0627\u0632 \u06cc\u06a9 \u062f\u0648\u0631\u0628\u06cc\u0646 \u062f\u0631 \u062f\u0633\u062a\u0631\u0633 \u0628\u0627\u0634\u062f (\u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u0645\u062b\u0627\u0644 \u062f\u0648\u0631\u0628\u06cc\u0646 \u062c\u0644\u0648 \u0648 \u067e\u0634\u062a) \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0622\u0646 \u0631\u0627 \u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0646\u06cc\u062f.<\/p>\n<p><iframe class=\"w-100\" src=\"https:\/\/behnudi.ir\/f\/iframe\/zxing\/\" height=\"600\"><\/iframe><\/p>\n<div dir=\"ltr\">HTML<\/div>\n<pre><code class=\"html\">\r\n&lt;button id=\"start-btn\"&gt;Start&lt;\/button&gt;\r\n&lt;button id=\"stop-btn\"&gt;Stop&lt;\/button&gt;\r\n&lt;video id=\"video\" width=\"320\" height=\"180\"&gt;&lt;\/video&gt;\r\n&lt;select id=\"src-select\"&gt;&lt;\/select&gt;\r\n&lt;pre id=\"out-box\"&gt;&lt;\/pre&gt;\r\n\r\n<\/code><\/pre>\n<div dir=\"ltr\">JS<\/div>\n<pre><code class=\"javascript\">\r\nwindow.addEventListener('load', function () {\r\n  const startBtn = document.getElementById('start-btn');\r\n  const stopBtn = document.getElementById('stop-btn');\r\n  const srcSelect = document.getElementById('src-select');\r\n  const outBox = document.getElementById('out-box');\r\n\r\n  let selectedDeviceId;\r\n  const codeReader = new ZXing.BrowserMultiFormatReader();\r\n  codeReader.listVideoInputDevices()\r\n    .then((videoInputDevices) =&gt; {\r\n      selectedDeviceId = videoInputDevices[0].deviceId;\r\n      if (videoInputDevices.length &gt;= 1) {\r\n        videoInputDevices.forEach((element) =&gt; {\r\n          const srcOption = document.createElement('option');\r\n          srcOption.text = element.label;\r\n          srcOption.value = element.deviceId;\r\n          srcSelect.appendChild(srcOption);\r\n        })\r\n\r\n        srcSelect.onchange = () =&gt; {\r\n          selectedDeviceId = srcSelect.value;\r\n        };\r\n      }\r\n\r\n      startBtn.addEventListener('click', () =&gt; {\r\n        codeReader.decodeFromVideoDevice(selectedDeviceId, 'video', (result, err) =&gt; {\r\n          if (result) {\r\n            outBox.textContent = result.text;\r\n          }\r\n          if (err &amp;&amp; !(err instanceof ZXing.NotFoundException)) {\r\n            outBox.textContent = err;\r\n          }\r\n        })\r\n      })\r\n\r\n      stopBtn.addEventListener('click', () =&gt; {\r\n        codeReader.reset();\r\n        outBox.textContent = '';\r\n      })\r\n\r\n    })\r\n    .catch((err) =&gt; {\r\n      console.error(err);\r\n    })\r\n})\r\n\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0628\u0627\u0631\u06a9\u062f \u0627\u0633\u06a9\u0646\u0631 \u06cc\u0627 \u0628\u0627\u0631\u06a9\u062f\u062e\u0648\u0627\u0646 \u0628\u0647 \u062f\u0633\u062a\u06af\u0627\u0647\u06cc \u0645\u06cc\u200c\u06af\u0648\u06cc\u0646\u062f \u06a9\u0647\u00a0 \u0628\u0627\u0631\u06a9\u062f \u0686\u0627\u067e \u0634\u062f\u0647 \u0631\u0627 \u0645\u06cc\u200c\u062e\u0648\u0627\u0646\u062f\u060c \u0648 \u062f\u06cc\u062a\u0627\u06cc \u0645\u0648\u062c\u0648\u062f \u062f\u0631 \u0622\u0646 \u0631\u0627 \u0631\u0645\u0632\u06af\u0634\u0627\u06cc\u06cc \u0645\u06cc\u200c\u06a9\u0646\u062f.<\/p>\n","protected":false},"author":1,"featured_media":939,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[53],"class_list":["post-938","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computer-science","tag-barcode"],"_links":{"self":[{"href":"https:\/\/behnudi.ir\/index.php?rest_route=\/wp\/v2\/posts\/938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/behnudi.ir\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/behnudi.ir\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/behnudi.ir\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/behnudi.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=938"}],"version-history":[{"count":0,"href":"https:\/\/behnudi.ir\/index.php?rest_route=\/wp\/v2\/posts\/938\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/behnudi.ir\/index.php?rest_route=\/wp\/v2\/media\/939"}],"wp:attachment":[{"href":"https:\/\/behnudi.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/behnudi.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/behnudi.ir\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}