{"id":56320,"date":"2022-07-05T03:01:01","date_gmt":"2022-07-04T17:01:01","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=56320"},"modified":"2022-07-06T15:51:49","modified_gmt":"2022-07-06T05:51:49","slug":"barcode-detection-api-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/barcode-detection-api-primer-tutorial\/","title":{"rendered":"Barcode Detection API Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/barcode_check.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Barcode Detection API Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/barcode_check.jpg\" title=\"Barcode Detection API Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Barcode Detection API Primer Tutorial<\/p><\/div>\n<p>We&#8217;re visiting another experimental Javascript API again today.  Today&#8217;s exploration takes us to the <a target=_blank title='Barcode information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Barcode'>Barcode<\/a> <a target=_blank href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Barcode_Detection_API' title='Barcode Detection API'>Detection API<\/a> &#8230;<\/p>\n<blockquote cite='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Barcode_Detection_API'><p>\nSupport for barcode recognition within web apps unlocks a variety of use cases through supported barcode formats. QR codes can be used for online payments, web navigation or establishing social media connections, Aztec codes can be used to scan boarding passes and shopping apps can use EAN or UPC barcodes to compare prices of physical items.<br \/>\n<br \/>\nDetection is achieved through the detect() method, which takes an image object; it can be one of these objects: an SVGImageElement, an HTMLVideoElement, an HTMLCanvasElement, an ImageBitmap, an OffscreenCanvas, a VideoFrame, a Blob, or an ImageData. Optional parameters can be passed to the BarcodeDetector constructor to provide hints on which barcode formats to detect.\n<\/p><\/blockquote>\n<p><a target=_blank href='https:\/\/en.wikipedia.org\/wiki\/Point_of_sale' title='Point of sale information from Wikipedia ... thanks'>Point of sale<\/a> is a huge concept in retail, often powered by the automation barcodes can offer.  That, alone, makes this API quite interesting, as far as practicalities go, making use of API code such as &#8230;<\/p>\n<p><code><br \/>\n\/\/ check supported types<br \/>\nBarcodeDetector.getSupportedFormats()<br \/>\n  .then(supportedFormats =&gt; {<br \/>\n    supportedFormats.forEach(format =&gt; prespa.push(format));<br \/>\n  });<br \/>\n<br \/>\n  if (prespa.length == 0) { prespa=spa; }<br \/>\n<br \/>\n  \/\/ create new detector<br \/>\n  barcodeDetector = new BarcodeDetector({formats: prespa});<br \/>\n  console.log('Barcode Detector supported ... yes!');<br \/>\n}<br \/>\n<br \/>\n  barcodeDetector.detect(imageEl)<br \/>\n    .then(barcodes =&gt; {<br \/>\n      barcodes.forEach(barcode =&gt; ouralert(barcode.rawData||barcode.rawValue));<br \/>\n    })<br \/>\n    .catch(err =&gt; {<br \/>\n      console.log(err);<br \/>\n    });<br \/>\n<\/code><\/p>\n<p>This leaves today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/barcode_check.html_GETME\" title=\"barcode_check.html\">barcode_check.html<\/a>&#8216;s <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/barcode_check.html\" title=\"Click picture\">proof of concept web application<\/a>, as also usable below, more useful as a &#8220;child iframe&#8221; tool used by <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/imagecapture.html---------------GETME\">the changed<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/imagecapture.html---------------GETME\">imagecapture.htm<\/a> example of a <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/imagecapture.htm\">user of the Barcode Detection API tool<\/a> web application you can also try.<\/p>\n<p><iframe src=\"\/\/www.rjmprogramming.com.au\/HTMLCSS\/barcode_check.html?parentwp=y\" style=\"width:100%;height:620px;\"><\/iframe><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d56320' onclick='var dv=document.getElementById(\"d56320\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/barcode\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d56320' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re visiting another experimental Javascript API again today. Today&#8217;s exploration takes us to the Barcode Detection API &#8230; Support for barcode recognition within web apps unlocks a variety of use cases through supported barcode formats. QR codes can be used &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/barcode-detection-api-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[88,1977,4018,375,576,652,4022,4021,4019,2976,997,1114,1319],"class_list":["post-56320","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-api","tag-barcode","tag-barcode-detection-api","tag-ecommerce","tag-html","tag-javascript","tag-permission","tag-permissions","tag-point-of-sale","tag-privacy","tag-programming","tag-security","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/56320"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=56320"}],"version-history":[{"count":9,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/56320\/revisions"}],"predecessor-version":[{"id":56329,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/56320\/revisions\/56329"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=56320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=56320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=56320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}