chillerlan-QRCode-Detector-GridSampler.html 23 KB

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