chillerlan-QRCode-Detector-GridSampler.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Documentation</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <base href="../">
  8. <link rel="icon" href="images/favicon.ico"/>
  9. <link rel="stylesheet" href="css/normalize.css">
  10. <link rel="stylesheet" href="css/base.css">
  11. <link rel="preconnect" href="https://fonts.gstatic.com">
  12. <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&display=swap" rel="stylesheet">
  13. <link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
  14. <link rel="stylesheet" href="css/template.css">
  15. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
  16. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
  17. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
  18. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
  19. <script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
  20. <script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
  21. <script src="js/search.js"></script>
  22. <script defer src="js/searchIndex.js"></script>
  23. </head>
  24. <body id="top">
  25. <header class="phpdocumentor-header phpdocumentor-section">
  26. <h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">Documentation</a></h1>
  27. <input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
  28. <label class="phpdocumentor-header__menu-icon" for="menu-button">
  29. <i class="fas fa-bars"></i>
  30. </label>
  31. <section data-search-form class="phpdocumentor-search">
  32. <label>
  33. <span class="visually-hidden">Search for</span>
  34. <svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
  35. <circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
  36. <line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
  37. </svg>
  38. <input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
  39. </label>
  40. </section>
  41. <nav class="phpdocumentor-topnav">
  42. <ul class="phpdocumentor-topnav__menu">
  43. </ul>
  44. </nav>
  45. </header>
  46. <main class="phpdocumentor">
  47. <div class="phpdocumentor-section">
  48. <input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
  49. <label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
  50. Menu
  51. </label>
  52. <aside class="phpdocumentor-column -four phpdocumentor-sidebar">
  53. <section class="phpdocumentor-sidebar__category">
  54. <h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
  55. <h4 class="phpdocumentor-sidebar__root-namespace"><a href="namespaces/chillerlan.html">chillerlan</a></h4>
  56. <ul class="phpdocumentor-list">
  57. <li>
  58. <a href="namespaces/chillerlan-qrcode.html">QRCode</a>
  59. </li>
  60. <li>
  61. <a href="namespaces/chillerlan-qrcodetest.html">QRCodeTest</a>
  62. </li>
  63. </ul>
  64. </section>
  65. <section class="phpdocumentor-sidebar__category">
  66. <h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
  67. <h4 class="phpdocumentor-sidebar__root-namespace"><a href="packages/Application.html">Application</a></h4>
  68. </section>
  69. <section class="phpdocumentor-sidebar__category">
  70. <h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
  71. <h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
  72. <h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
  73. <h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
  74. </section>
  75. <section class="phpdocumentor-sidebar__category">
  76. <h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
  77. <h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
  78. </section>
  79. </aside>
  80. <div class="phpdocumentor-column -eight phpdocumentor-content">
  81. <ul class="phpdocumentor-breadcrumbs">
  82. <li class="phpdocumentor-breadcrumb"><a href="namespaces/chillerlan.html">chillerlan</a></li>
  83. <li class="phpdocumentor-breadcrumb"><a href="namespaces/chillerlan-qrcode.html">QRCode</a></li>
  84. <li class="phpdocumentor-breadcrumb"><a href="namespaces/chillerlan-qrcode-detector.html">Detector</a></li>
  85. </ul>
  86. <article class="phpdocumentor-element -class">
  87. <h2 class="phpdocumentor-content__title">
  88. GridSampler
  89. <div class="phpdocumentor-element__package">
  90. in package
  91. <ul class="phpdocumentor-breadcrumbs">
  92. <li class="phpdocumentor-breadcrumb"><a href="packages/Application.html">Application</a></li>
  93. </ul>
  94. </div>
  95. </h2>
  96. <aside class="phpdocumentor-element-found-in">
  97. <abbr class="phpdocumentor-element-found-in__file" title="src/Detector/GridSampler.php"><a href="files/src-detector-gridsampler.html"><abbr title="src/Detector/GridSampler.php">GridSampler.php</abbr></a></abbr>
  98. :
  99. <span class="phpdocumentor-element-found-in__line">31</span>
  100. </aside>
  101. <p class="phpdocumentor-summary">Implementations of this class can, given locations of finder patterns for a QR code in an
  102. image, sample the right points in the image to reconstruct the QR code, accounting for
  103. perspective distortion. It is abstracted since it is relatively expensive and should be allowed
  104. to take advantage of platform-specific optimized implementations, like Sun&#039;s Java Advanced
  105. Imaging library, but which may not be available in other environments such as J2ME, and vice
  106. versa.</p>
  107. <section class="phpdocumentor-description"><p>The implementation used can be controlled by calling <a href="#setGridSampler(GridSampler)"></a>
  108. with an instance of a class which implements this interface.</p>
  109. </section>
  110. <h5 class="phpdocumentor-tag-list__heading" id="tags">
  111. Tags
  112. <a href="#tags" class="headerlink"><i class="fas fa-link"></i></a>
  113. </h5>
  114. <dl class="phpdocumentor-tag-list">
  115. <dt class="phpdocumentor-tag-list__entry">
  116. <span class="phpdocumentor-tag__name">author</span>
  117. </dt>
  118. <dd class="phpdocumentor-tag-list__definition">
  119. <section class="phpdocumentor-description"><p>Sean Owen</p>
  120. </section>
  121. </dd>
  122. </dl>
  123. <h3 id="toc">
  124. Table of Contents
  125. <a href="#toc" class="headerlink"><i class="fas fa-link"></i></a>
  126. </h3>
  127. <dl class="phpdocumentor-table-of-contents">
  128. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  129. <a href="classes/chillerlan-QRCode-Detector-GridSampler.html#method_sampleGrid">sampleGrid()</a>
  130. <span>
  131. &nbsp;: <a href="classes/chillerlan-QRCode-Decoder-BitMatrix.html"><abbr title="\chillerlan\QRCode\Decoder\BitMatrix">BitMatrix</abbr></a> </span>
  132. </dt>
  133. <dd>Samples an image for a rectangular matrix of bits of the given dimension. The sampling
  134. transformation is determined by the coordinates of 4 points, in the original and transformed
  135. image space.</dd>
  136. <dt class="phpdocumentor-table-of-contents__entry -method -private">
  137. <a href="classes/chillerlan-QRCode-Detector-GridSampler.html#method_checkAndNudgePoints">checkAndNudgePoints()</a>
  138. <span>
  139. &nbsp;: void </span>
  140. </dt>
  141. <dd>&lt;p&gt;Checks a set of points that have been transformed to sample points on an image against
  142. the image&#039;s dimensions to see if the point are even within the image.&lt;/p&gt;</dd>
  143. </dl>
  144. <section class="phpdocumentor-methods">
  145. <h3 class="phpdocumentor-elements__header" id="methods">
  146. Methods
  147. <a href="classes/chillerlan-QRCode-Detector-GridSampler.html#methods" class="headerlink"><i class="fas fa-link"></i></a>
  148. </h3>
  149. <article
  150. class="phpdocumentor-element
  151. -method
  152. -public
  153. "
  154. >
  155. <h4 class="phpdocumentor-element__name" id="method_sampleGrid">
  156. sampleGrid()
  157. <a href="classes/chillerlan-QRCode-Detector-GridSampler.html#method_sampleGrid" class="headerlink"><i class="fas fa-link"></i></a>
  158. </h4>
  159. <aside class="phpdocumentor-element-found-in">
  160. <abbr class="phpdocumentor-element-found-in__file" title="src/Detector/GridSampler.php"><a href="files/src-detector-gridsampler.html"><abbr title="src/Detector/GridSampler.php">GridSampler.php</abbr></a></abbr>
  161. :
  162. <span class="phpdocumentor-element-found-in__line">124</span>
  163. </aside>
  164. <p class="phpdocumentor-summary">Samples an image for a rectangular matrix of bits of the given dimension. The sampling
  165. transformation is determined by the coordinates of 4 points, in the original and transformed
  166. image space.</p>
  167. <code class="phpdocumentor-code phpdocumentor-signature ">
  168. <span class="phpdocumentor-signature__visibility">public</span>
  169. <span class="phpdocumentor-signature__name">sampleGrid</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type"><a href="classes/chillerlan-QRCode-Decoder-BitMatrix.html"><abbr title="\chillerlan\QRCode\Decoder\BitMatrix">BitMatrix</abbr></a>&nbsp;</span><span class="phpdocumentor-signature__argument__name">$image</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">int&nbsp;</span><span class="phpdocumentor-signature__argument__name">$dimension</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type"><a href="classes/chillerlan-QRCode-Detector-PerspectiveTransform.html"><abbr title="\chillerlan\QRCode\Detector\PerspectiveTransform">PerspectiveTransform</abbr></a>&nbsp;</span><span class="phpdocumentor-signature__argument__name">$transform</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type"><a href="classes/chillerlan-QRCode-Decoder-BitMatrix.html"><abbr title="\chillerlan\QRCode\Decoder\BitMatrix">BitMatrix</abbr></a></span></code>
  170. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  171. <dl class="phpdocumentor-argument-list">
  172. <dt class="phpdocumentor-argument-list__entry">
  173. <span class="phpdocumentor-signature__argument__name">$image</span>
  174. : <span class="phpdocumentor-signature__argument__return-type"><a href="classes/chillerlan-QRCode-Decoder-BitMatrix.html"><abbr title="\chillerlan\QRCode\Decoder\BitMatrix">BitMatrix</abbr></a></span>
  175. </dt>
  176. <dd class="phpdocumentor-argument-list__definition">
  177. <section class="phpdocumentor-description"></section>
  178. </dd>
  179. <dt class="phpdocumentor-argument-list__entry">
  180. <span class="phpdocumentor-signature__argument__name">$dimension</span>
  181. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  182. </dt>
  183. <dd class="phpdocumentor-argument-list__definition">
  184. <section class="phpdocumentor-description"></section>
  185. </dd>
  186. <dt class="phpdocumentor-argument-list__entry">
  187. <span class="phpdocumentor-signature__argument__name">$transform</span>
  188. : <span class="phpdocumentor-signature__argument__return-type"><a href="classes/chillerlan-QRCode-Detector-PerspectiveTransform.html"><abbr title="\chillerlan\QRCode\Detector\PerspectiveTransform">PerspectiveTransform</abbr></a></span>
  189. </dt>
  190. <dd class="phpdocumentor-argument-list__definition">
  191. <section class="phpdocumentor-description"></section>
  192. </dd>
  193. </dl>
  194. <h5 class="phpdocumentor-tag-list__heading" id="tags">
  195. Tags
  196. <a href="#tags" class="headerlink"><i class="fas fa-link"></i></a>
  197. </h5>
  198. <dl class="phpdocumentor-tag-list">
  199. <dt class="phpdocumentor-tag-list__entry">
  200. <span class="phpdocumentor-tag__name">throws</span>
  201. </dt>
  202. <dd class="phpdocumentor-tag-list__definition">
  203. <span class="phpdocumentor-tag-link"><abbr title="\RuntimeException">RuntimeException</abbr></span>
  204. <section class="phpdocumentor-description"><p>if image can't be sampled, for example, if the transformation defined
  205. by the given points is invalid or results in sampling outside the image boundaries</p>
  206. </section>
  207. </dd>
  208. </dl>
  209. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  210. <span class="phpdocumentor-signature__response_type"><a href="classes/chillerlan-QRCode-Decoder-BitMatrix.html"><abbr title="\chillerlan\QRCode\Decoder\BitMatrix">BitMatrix</abbr></a></span>
  211. &mdash;
  212. <section class="phpdocumentor-description"><p>representing a grid of points sampled from the image within a region
  213. defined by the &quot;from&quot; parameters</p>
  214. </section>
  215. </article>
  216. <article
  217. class="phpdocumentor-element
  218. -method
  219. -private
  220. "
  221. >
  222. <h4 class="phpdocumentor-element__name" id="method_checkAndNudgePoints">
  223. checkAndNudgePoints()
  224. <a href="classes/chillerlan-QRCode-Detector-GridSampler.html#method_checkAndNudgePoints" class="headerlink"><i class="fas fa-link"></i></a>
  225. </h4>
  226. <aside class="phpdocumentor-element-found-in">
  227. <abbr class="phpdocumentor-element-found-in__file" title="src/Detector/GridSampler.php"><a href="files/src-detector-gridsampler.html"><abbr title="src/Detector/GridSampler.php">GridSampler.php</abbr></a></abbr>
  228. :
  229. <span class="phpdocumentor-element-found-in__line">49</span>
  230. </aside>
  231. <p class="phpdocumentor-summary">&lt;p&gt;Checks a set of points that have been transformed to sample points on an image against
  232. the image&#039;s dimensions to see if the point are even within the image.&lt;/p&gt;</p>
  233. <code class="phpdocumentor-code phpdocumentor-signature ">
  234. <span class="phpdocumentor-signature__visibility">private</span>
  235. <span class="phpdocumentor-signature__name">checkAndNudgePoints</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type"><a href="classes/chillerlan-QRCode-Decoder-BitMatrix.html"><abbr title="\chillerlan\QRCode\Decoder\BitMatrix">BitMatrix</abbr></a>&nbsp;</span><span class="phpdocumentor-signature__argument__name">$bitMatrix</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, float&gt;&nbsp;</span><span class="phpdocumentor-signature__argument__name">$points</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">void</span></code>
  236. <section class="phpdocumentor-description"><p>This method will actually "nudge" the endpoints back onto the image if they are found to be
  237. barely (less than 1 pixel) off the image. This accounts for imperfect detection of finder
  238. patterns in an image where the QR Code runs all the way to the image border.</p>
  239. <p>For efficiency, the method will check points from either end of the line until one is found
  240. to be within the image. Because the set of points are assumed to be linear, this is valid.</p>
  241. </section>
  242. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  243. <dl class="phpdocumentor-argument-list">
  244. <dt class="phpdocumentor-argument-list__entry">
  245. <span class="phpdocumentor-signature__argument__name">$bitMatrix</span>
  246. : <span class="phpdocumentor-signature__argument__return-type"><a href="classes/chillerlan-QRCode-Decoder-BitMatrix.html"><abbr title="\chillerlan\QRCode\Decoder\BitMatrix">BitMatrix</abbr></a></span>
  247. </dt>
  248. <dd class="phpdocumentor-argument-list__definition">
  249. <section class="phpdocumentor-description"><p>image into which the points should map</p>
  250. </section>
  251. </dd>
  252. <dt class="phpdocumentor-argument-list__entry">
  253. <span class="phpdocumentor-signature__argument__name">$points</span>
  254. : <span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, float&gt;</span>
  255. </dt>
  256. <dd class="phpdocumentor-argument-list__definition">
  257. <section class="phpdocumentor-description"><p>actual points in x1,y1,...,xn,yn form</p>
  258. </section>
  259. </dd>
  260. </dl>
  261. <h5 class="phpdocumentor-tag-list__heading" id="tags">
  262. Tags
  263. <a href="#tags" class="headerlink"><i class="fas fa-link"></i></a>
  264. </h5>
  265. <dl class="phpdocumentor-tag-list">
  266. <dt class="phpdocumentor-tag-list__entry">
  267. <span class="phpdocumentor-tag__name">throws</span>
  268. </dt>
  269. <dd class="phpdocumentor-tag-list__definition">
  270. <span class="phpdocumentor-tag-link"><abbr title="\RuntimeException">RuntimeException</abbr></span>
  271. <section class="phpdocumentor-description"><p>if an endpoint is lies outside the image boundaries</p>
  272. </section>
  273. </dd>
  274. </dl>
  275. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  276. <span class="phpdocumentor-signature__response_type">void</span>
  277. &mdash;
  278. </article>
  279. </section>
  280. <script type="text/javascript">
  281. function loadExternalCodeSnippets(line) {
  282. Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach((pre) => {
  283. var src = pre.getAttribute('data-src').replace( /\\/g, '/');
  284. var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
  285. var language = 'php';
  286. var code = document.createElement('code');
  287. code.className = 'language-' + language;
  288. pre.textContent = '';
  289. pre.setAttribute('data-line', line)
  290. code.textContent = 'Loading…';
  291. pre.appendChild(code);
  292. var xhr = new XMLHttpRequest();
  293. xhr.open('GET', src, true);
  294. xhr.onreadystatechange = function () {
  295. if (xhr.readyState == 4) {
  296. if (xhr.status < 400 && xhr.responseText) {
  297. code.textContent = xhr.responseText;
  298. Prism.highlightElement(code);
  299. }
  300. else if (xhr.status >= 400) {
  301. code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
  302. }
  303. else {
  304. code.textContent = '✖ Error: File does not exist, is empty or trying to view from localhost';
  305. }
  306. }
  307. };
  308. xhr.send(null);
  309. });
  310. }
  311. var modals = document.querySelectorAll("[data-modal]");
  312. modals.forEach(function (trigger) {
  313. trigger.addEventListener("click", function (event) {
  314. //event.preventDefault();
  315. const modal = document.getElementById(trigger.dataset.modal);
  316. modal.classList.add("phpdocumentor-modal__open");
  317. loadExternalCodeSnippets(trigger.dataset.line)
  318. const exits = modal.querySelectorAll("[data-exit-button]");
  319. exits.forEach(function (exit) {
  320. exit.addEventListener("click", function (event) {
  321. event.preventDefault();
  322. modal.classList.remove("phpdocumentor-modal__open");
  323. });
  324. });
  325. });
  326. });
  327. </script>
  328. </article>
  329. <section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
  330. <section class="phpdocumentor-search-results__dialog">
  331. <header class="phpdocumentor-search-results__header">
  332. <h2 class="phpdocumentor-search-results__title">Search results</h2>
  333. <button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
  334. </header>
  335. <section class="phpdocumentor-search-results__body">
  336. <ul class="phpdocumentor-search-results__entries"></ul>
  337. </section>
  338. </section>
  339. </section>
  340. </div>
  341. </div>
  342. <a href="classes/chillerlan-QRCode-Detector-GridSampler.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
  343. </main>
  344. <script>
  345. cssVars({});
  346. </script>
  347. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
  348. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
  349. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
  350. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
  351. </body>
  352. </html>