{"id":960,"date":"2020-06-05T09:14:49","date_gmt":"2020-06-05T02:14:49","guid":{"rendered":"http:\/\/www.miai.vn\/?p=960"},"modified":"2020-06-05T09:14:49","modified_gmt":"2020-06-05T02:14:49","slug":"thu-lam-phan-mem-quet-van-ban-scanner-app-bang-opencv","status":"publish","type":"post","link":"https:\/\/miai.vn\/?p=960","title":{"rendered":"Th\u1eed l\u00e0m ph\u1ea7n m\u1ec1m qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV"},"content":{"rendered":"\n<p>Xin ch\u00e0o anh em M\u00ec AI, h\u00f4m nay ch\u00fang ta s\u1ebd Th\u1eed gi\u1ea3 l\u1eadp m\u00e1y qu\u00e9t v\u0103n b\u1ea3n\/scanner b\u1eb1ng OpenCV xem nh\u00e9.<\/p>\n\n\n\n<p>Ch\u1eafc h\u1eb3n anh em c\u00f2n nh\u1edb ng\u00e0y tr\u01b0\u1edbc mu\u1ed1n scan c\u00e1c v\u0103n b\u1ea3n th\u00ec ch\u1ec9 c\u00f3 m\u1ed9t c\u00e1ch duy nh\u1ea5t \u0111\u00f3 l\u00e0 s\u1eed d\u1ee5ng nh\u1eefng chi\u1ebfc m\u00e1y scann to b\u1ea3n, n\u1eb7ng tr\u1ecbch nh\u01b0 n\u00e0y: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/4.imimg.com\/data4\/AH\/MJ\/MY-26848583\/scanner-machine-500x500.jpg\" alt=\"scanner m\u00e1y qu\u00e9t\"\/><figcaption>Ngu\u1ed3n: <a href=\"https:\/\/4.imimg.com\/data4\/AH\/MJ\/MY-26848583\/scanner-machine-500x500.jpg\" target=\"_blank\" rel=\"noreferrer noopener\">T\u1ea1i \u0111\u00e2y<\/a><\/figcaption><\/figure>\n\n\n\n<!-- InPost_Ad -->\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>Tuy nhi\u00ean nh\u1eefng n\u0103m g\u1ea7n \u0111\u00e2y th\u00ec anh em \u0111\u00e3 th\u1ea5y r\u1eb1ng nh\u1eefng chi\u1ebfc m\u00e1y qu\u00e9t \u0111\u00e3 d\u1ea7n v\u1eafng b\u00f3ng v\u00e0 h\u1ea7u nh\u01b0 ch\u1ec9 c\u00f2n s\u1eed d\u1ee5ng trong c\u00e1c nghi\u1ec7p v\u1ee5 \u0111\u1eb7c th\u00f9, c\u1ea7n t\u1ed1c \u0111\u1ed9 nhanh v\u00e0 s\u1ed1 l\u01b0\u1ee3ng scan nhi\u1ec1u. \u0110a s\u1ed1 ch\u00fang ta \u0111\u00e3 s\u1eed d\u1ee5ng \u0111i\u1ec7n tho\u1ea1i \u0111\u1ec3 l\u00e0m m\u00e1y scan v\u1edbi v\u00f4 v\u00e0n c\u00e1c \u1ee9ng d\u1ee5ng: Tiny Scan, Scan 2 PDF,&#8230;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/i.ytimg.com\/vi\/KfHa6yTx96s\/maxresdefault.jpg\" alt=\"\"\/><figcaption>Ngu\u1ed3n: <a href=\"https:\/\/i.ytimg.com\/vi\/KfHa6yTx96s\/maxresdefault.jpg\" target=\"_blank\" rel=\"noreferrer noopener\">T\u1ea1i \u0111\u00e2y<\/a><\/figcaption><\/figure>\n\n\n\n<p>V\u1eady \u0111\u00e3 bao gi\u1edd c\u00e1c b\u1ea1n t\u1ef1 h\u1ecfi l\u00e0 c\u00e1ch th\u1ee9c ho\u1ea1t \u0111\u1ed9ng c\u1ee7a c\u00e1c \u1ee9ng d\u1ee5ng scan \u0111\u00f3 l\u00e0 nh\u01b0 n\u00e0o kh\u00f4ng? V\u1eady th\u00ec h\u00f4m nay ch\u00fang ta s\u1ebd c\u00f9ng nhau l\u00e0m th\u1eed nh\u00e9. Let&#8217;s go!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ph\u1ea7n 1 &#8211; Ph\u00e2n t\u00edch b\u00e0i to\u00e1n qu\u00e9t v\u0103n b\u1ea3n<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\">Ph\u00e2n t\u00edch \u0111\u1ec1 b\u00e0i<\/h5>\n\n\n\n<p>B\u00e0i to\u00e1n c\u1ee7a ch\u00fang ta \u0111\u01a1n gi\u1ea3n l\u00e0 ch\u1ee5p \u1ea3nh m\u1ed9t v\u0103n b\u1ea3n n\u1eb1m tr\u00ean b\u1ec1 m\u1eb7t ph\u1eb3ng nh\u01b0 m\u1eb7t b\u00e0n v\u00e0 xu\u1ea5t ra phi\u00ean b\u1ea3n scan c\u1ee7a v\u0103n b\u1ea3n \u0111\u00f3 (nh\u01b0 h\u00ecnh d\u01b0\u1edbi)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/img3.thuthuatphanmem.vn\/uploads\/2019\/08\/12\/microsoft-office-lens_112241858.jpg\" alt=\"\"\/><figcaption>Ngu\u1ed3n: <a href=\"https:\/\/img3.thuthuatphanmem.vn\/uploads\/2019\/08\/12\/microsoft-office-lens_112241858.jpg\">T\u1ea1i \u0111\u00e2y<\/a><\/figcaption><\/figure>\n\n\n\n<!-- InPost_Ad -->\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>\u0110\u1ec3 \u0111\u01a1n gi\u1ea3n ta c\u00f3 th\u1ec3 gi\u1ea3 s\u1eed b\u1ec1 m\u1eb7t s\u1ea1ch, ch\u1ec9 c\u00f3 n\u1ec1n v\u00e0 t\u1edd v\u0103n b\u1ea3n c\u1ea7n scan nh\u00e9. N\u1ebfu b\u1ec1 m\u1eb7t ph\u1ee9c t\u1ea1p th\u00ec s\u1ebd c\u1ea7n nhi\u1ec1u ph\u01b0\u01a1ng ph\u00e1p x\u1eed l\u00fd ph\u1ee9c t\u1ea1p h\u01a1n v\u00e0 th\u1eadm ch\u00ed l\u00e0 Deep Learning. <\/p>\n\n\n\n<p>B\u00e0i n\u00e0y ch\u00fang ta s\u1ebd ch\u1ec9 s\u1eed d\u1ee5ng OpenCV thu\u1ea7n.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Pipeline c\u1ee7a b\u00e0i to\u00e1n<\/h5>\n\n\n\n<p>B\u00e0i n\u00e0y ch\u00fang ta s\u1ebd qua c\u00e1c b\u01b0\u1edbc nh\u01b0 sau:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/github.com\/thangnch\/MiAI_Scanner_App\/blob\/master\/Screen%20Shot%202020-06-05%20at%2015.03.57.png?raw=true\" alt=\"\"\/><\/figure>\n\n\n\n<p>R\u1ed3i, b\u00e2y gi\u1edd ch\u00fang ta s\u1ebd c\u00f9ng nhau \u0111i l\u00e0m t\u1eebng b\u01b0\u1edbc chi ti\u1ebft nh\u00e9!<\/p>\n\n\n\n<p>Link github cho c\u00e1c b\u1ea1n tham kh\u1ea3o nha: <strong><a href=\"https:\/\/github.com\/thangnch\/MiAI_Scanner_App\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/thangnch\/MiAI_Scanner_App<\/a><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ph\u1ea7n 2 &#8211; Tri\u1ec3n khai \u1ee9ng d\u1ee5ng <\/h2>\n\n\n\n<!-- InPost_Ad -->\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>\u1ee8ng d\u1ee5ng n\u00e0y \u0111\u1ec3 tri\u1ec3n khai v\u00e0o th\u1ef1c t\u1ebf th\u00ec c\u1ea7n ph\u1ea3i c\u00f3 app tr\u00ean mobile th\u00ec m\u1edbi ti\u1ec7n cho ng\u01b0\u1eddi s\u1eed d\u1ee5ng. Tuy nhi\u00ean \u1edf \u0111\u00e2y m\u00ecnh ch\u1ec9 demo c\u00e1ch th\u1ee9c tri\u1ec3n khai n\u00ean xin ph\u00e9p \u0111\u01b0\u1ee3c l\u00e0m tr\u00ean python th\u00f4i nh\u00e9. Sau khi \u0111\u00e3 bi\u1ebft c\u00e1ch tri\u1ec3n khai c\u00e1c b\u1ea1n c\u00f3 th\u1ec3 vi\u1ebft tr\u00ean t\u1ea5t c\u1ea3 c\u00e1c n\u1ec1n t\u1ea3ng OS kh\u00e1c nhau v\u00f4 t\u01b0.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">B\u01b0\u1edbc 1. \u0110\u1ecdc \u1ea3nh \u0111\u1ea7u v\u00e0o<\/h5>\n\n\n\n<p>\u0110\u1ec3 \u0111\u01a1n gi\u1ea3n ta s\u1ebd \u0111\u1ecdc \u1ea3nh t\u1eeb m\u1ed9t file c\u00f3 s\u1eb5n thay cho camera c\u1ee7a \u0111i\u1ec7n tho\u1ea1i nh\u00e9. Ph\u1ea7n \u0111\u1ecdc n\u00e0y th\u00ec ho\u00e0n to\u00e0n thu\u1ea7n OpenCV v\u1edbi l\u1ec7nh imread th\u1ea7n th\u00e1nh.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># import c\u00e1c th\u01b0 vi\u1ec7n\nimport cv2\n\n# T\u00ean file \u1ea3nh \u0111\u1ea7u v\u00e0o\ninput_image  = 'mydoc.jpg'\n\n# \u0110\u1ecdc \u1ea3nh\nimage = cv2.imread(input_image)\n\n# Hi\u1ec3n th\u1ecb l\u00ean m\u00e0n h\u00ecnh\ncv2.imshow('Input', image)\ncv2.waitKey()<\/code><\/pre>\n\n\n\n<p>\u0110\u1ec3 tr\u00e1nh l\u1ed7i c\u00e1c b\u1ea1n c\u00f3 th\u1ec3 c\u00e0i \u0111\u1eb7t th\u01b0 vi\u1ec7n b\u1eb1ng l\u1ec7nh:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install opencv-python imutils numpy<\/code><\/pre>\n\n\n\n<p>Okie! N\u1ebfu \u1ea3nh c\u1ee7a b\u1ea1n \u0111\u00e3 hi\u1ec7n l\u00ean m\u00e0n h\u00ecnh l\u00e0 b\u1ea1n \u0111\u00e3 th\u00e0nh c\u00f4ng b\u01b0\u1edbc \u0111\u1ea7u r\u1ed3i.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/github.com\/thangnch\/MiAI_Scanner_App\/blob\/master\/mydoc.jpg?raw=true\" alt=\"scan v\u0103n b\u1ea3n qu\u00e9t\"\/><\/figure>\n\n\n\n<!-- InPost_Ad -->\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<h5 class=\"wp-block-heading\">B\u01b0\u1edbc 2.  L\u00e0m n\u1ed5i b\u1eadt ph\u1ea7n c\u1ea1nh c\u1ee7a v\u0103n b\u1ea3n<\/h5>\n\n\n\n<p>\u0110\u1ec3 ph\u00e1t hi\u1ec7n \u0111\u01b0\u1ee3c c\u1ea1nh v\u0103n b\u1ea3n th\u00ec ta ph\u1ea3i l\u00e0m cho n\u00f3 show h\u00e0ng l\u00ean cho d\u1ec5 ph\u00e1t hi\u1ec7n.<\/p>\n\n\n\n<p>May thay trong OpenCV c\u00f3 s\u1eb5n h\u00e0m Canny t\u00ecm c\u1ea1nh b\u00e1 \u0111\u1ea1o tr\u00ean t\u1eebng h\u1ea1t g\u1ea1o lu\u00f4n. Chi ti\u1ebft h\u00e0m n\u00e0y <strong><a rel=\"noreferrer noopener\" href=\"http:\/\/opencv-python-tutroals.readthedocs.io\/en\/latest\/py_tutorials\/py_imgproc\/py_canny\/py_canny.html\" target=\"_blank\">t\u1ea1i \u0111\u00e2y<\/a><\/strong> nh\u00e9 c\u00e1c b\u1ea1n!<\/p>\n\n\n\n<p>Vi\u1ec7c t\u00ecm c\u1ea1nh kh\u00e1 \u0111\u01a1n gi\u1ea3n nh\u01b0 sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Chuy\u1ec3n \u1ea3nh m\u00e0y th\u00e0nh \u1ea3nh x\u00e1m\ngray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n\n# L\u00e0m m\u1edd \u1ea3nh x\u00e1m \u0111\u1ec3 x\u00f3a noise\nblur = cv2.blur(gray,(3,3))\n\n# T\u00ecm c\u1ea1nh b\u1eb1ng Canny\nedge = cv2.Canny(blur, 50, 300, 3)\n\n# Hi\u1ec3n th\u1ecb l\u00ean m\u00e0n h\u00ecnh cho d\u1ec5 xem\ncv2.imshow(\"gray\", gray)\ncv2.imshow(\"blur\", blur)\ncv2.imshow(\"edge\", edge)\ncv2.waitKey()<\/code><\/pre>\n\n\n\n<p>V\u00e0 k\u1ebft qu\u1ea3 c\u1ee7a b\u01b0\u1edbc n\u00e0y l\u00e0 m\u1ed9t t\u1edd v\u0103n b\u1ea3n v\u1edbi c\u00e1c c\u1ea1nh \u0111\u00e3 show ra kh\u00e1 r\u00f5 r\u00e0ng r\u1ed3i:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/github.com\/thangnch\/MiAI_Scanner_App\/blob\/master\/edge_screenshot_05.06.2020.png?raw=true\" alt=\"qu\u00e9t v\u0103n b\u1ea3n\"\/><\/figure>\n\n\n\n<!-- InPost_Ad -->\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>Ch\u00fang ta sang b\u01b0\u1edbc ti\u1ebfp theo!<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">B\u01b0\u1edbc 3. &#8220;T\u00f3m&#8221; l\u1ea5y c\u00e1c c\u1ea1nh c\u1ee7a v\u0103n b\u1ea3n<\/h5>\n\n\n\n<p>H\u00e0ng \u0111\u00e3 show ra, gi\u1edd ta d\u00f9ng contours finding \u0111\u1ec3 t\u00f3m l\u1ea5y c\u00e1c c\u1ea1nh \u0111\u00f3. Nh\u00ecn qua th\u00ec ta d\u1ef1 ki\u1ebfn s\u1ebd l\u00e0m nh\u01b0 sau:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>T\u00ecm t\u1ea5t c\u1ea3 c\u00e1c contour trong \u1ea3nh ch\u1ee9a c\u1ea1nh<\/li><li>S\u1eafp x\u1ebfp c\u00e1c contour theo di\u1ec7n t\u00edch gi\u1ea3m d\u1ea7n<\/li><li>L\u1ea5y contour to nh\u1ea5t ch\u00ednh l\u00e0 v\u0103n b\u1ea3n c\u1ee7a ch\u00fang ta<\/li><\/ul>\n\n\n\n<p>Ok! Tri\u1ec3n lu\u00f4n!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># T\u00ecm contours\ncnts = cv2.findContours(edge, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)\nimport imutils\ncnts = imutils.grab_contours(cnts)\n\n# S\u1eafp x\u1ebfp theo di\u1ec7n t\u00edch gi\u1ea3m d\u1ea7n\ncnts = sorted(cnts, key=cv2.contourArea, reverse=True)\n\n\n# L\u1ea5y contour \u0111\u1ea7u ti\u00ean - to nh\u1ea5t\ncnts = cnts&#91;:1]\n\n# V\u1ebd contour l\u00ean \u1ea3nh g\u1ed1c cho tr\u1ef1c quan\np = cv2.arcLength(cnts&#91;0], True)\nr = cv2.approxPolyDP(cnts&#91;0], 0.02*p, True)\ncv2.drawContours(image, &#91;r], -1, (0,0,255), 3)\n\n# Show \u1ea3nh\ncv2.imshow(\"Draw\", image)\ncv2.waitKey()\n<\/code><\/pre>\n\n\n\n<p>V\u00e0 \u0111\u00e2y r\u1ed3i, \u0111\u01b0\u1eddng vi\u1ec1n \u0111\u1eb9p \u0111\u1ebd \u0111\u00e3 \u0111\u01b0\u1ee3c show ra:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/github.com\/thangnch\/MiAI_Scanner_App\/blob\/master\/Draw_screenshot_05.06.2020.png?raw=true\" alt=\"scannner app qu\u00e9t v\u0103n b\u1ea3n\"\/><\/figure>\n\n\n\n<!-- InPost_Ad -->\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>Chu\u1ea9n v\u00e3i r\u1ed3i anh em. <\/p>\n\n\n\n<h5 class=\"wp-block-heading\">B\u01b0\u1edbc 4. B\u00e2y gi\u1edd l\u00e0 xoay n\u00f3 th\u1eb3ng th\u1eafn ra th\u00f4i<\/h5>\n\n\n\n<p>Gi\u1edd c\u00f3 khung r\u1ed3i, bi\u1ebft v\u0103n b\u1ea3n \u1edf \u0111\u00e2u r\u1ed3i th\u00ec xoay ph\u00e1t cho n\u00f3 th\u1eb3ng ra n\u00e0o. \u0110o\u1ea1n n\u00e0y ta s\u1ebd t\u00ednh chi\u1ec1u r\u1ed9ng, chi\u1ec1u d\u00e0i bi\u00ean v\u0103n b\u1ea3n:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u0110\u1ea7u ti\u00ean reshape c\u00e1i ROI c\u1ee7a ch\u00fang ta v\u1ec1 (4,2) - 4 t\u1ecda \u0111\u1ed9, m\u1ed7i t\u1ecda \u0111\u1ed9 g\u1ed3m x,y\nr = r.reshape(4,2)\n\n# T\u00ednh to\u00e1n 04 g\u00f3c theo th\u1ee9 t\u1ef1 tr\u00ean tr\u00e1i, tr\u00ean ph\u1ea3i, d\u01b0\u1edbi ph\u1ea3i, d\u01b0\u1edbi tr\u00e1i\nrect = np.zeros((4,2), dtype='float32')\n\n# Ta t\u00ednh t\u1ed5ng c\u00e1c t\u1ecda \u0111\u1ed9 theo c\u1ed9t\n# \u0110i\u1ec3m tr\u00ean tr\u00e1i s\u1ebd c\u00f3 t\u1ed5ng nh\u1ecf nh\u1ea5t\n# \u0110i\u1ec3m d\u01b0\u1edbi ph\u1ea3i s\u1ebd c\u00f3 t\u1ed5ng l\u1edbn nh\u1ea5t\ns = np.sum(r, axis=1)\nrect&#91;0] = r&#91;np.argmin(s)] # Tr\u00ean tr\u00e1i\nrect&#91;2] = r&#91;np.argmax(s)] # D\u01b0\u1edbi ph\u1ea3i\n\n# Ta t\u00ednh s\u1ef1 kh\u00e1c nhau gi\u1eefa c\u00e1c t\u1ecda \u0111\u1ed9 theo c\u1ed9t\n# Tr\u00ean ph\u1ea3i s\u1ebd \u00edt kh\u00e1c bi\u1ec7t nh\u1ea5t\n# d\u01b0\u1edbi tr\u00e1i l\u00e0 kh\u00e1c bi\u1ec7t nh\u1ea5t\ndiff = np.diff(r, axis=1)\nrect&#91;1] = r&#91;np.argmin(diff)]\nrect&#91;3] = r&#91;np.argmax(diff)]\n\n# T\u00ednh to\u00e1n chi\u1ec1u r\u1ed9ng v\u00e0 chi\u1ec1u cao c\u1ee7a v\u0103n b\u1ea3n\n(tl, tr, br, bl) = rect\n\nwidth1 = np.sqrt((tl&#91;0] - tr&#91;0])**2 + (tl&#91;1] - tr&#91;1])**2 )\nwidth2 = np.sqrt((bl&#91;0] - br&#91;0])**2 + (bl&#91;1] - br&#91;1])**2 )\nWidth = max(int(width1), int(width2))\n\nheight1 = np.sqrt((tl&#91;0] - bl&#91;0])**2 + (tl&#91;1] - bl&#91;1])**2 )\nheight2 = np.sqrt((tr&#91;0] - br&#91;0])**2 + (tr&#91;1] - br&#91;1])**2 )\nHeight = max(int(height1), int(height2))<\/code><\/pre>\n\n\n\n<p>Sau \u0111\u00f3 l\u00e0 xoay:<\/p>\n\n\n\n<!-- InPost_Ad -->\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<pre class=\"wp-block-code\"><code># \u0110\u1ea7u ti\u00ean reshape c\u00e1i ROI c\u1ee7a ch\u00fang ta v\u1ec1 (4,2) - 4 t\u1ecda \u0111\u1ed9, m\u1ed7i t\u1ecda \u0111\u1ed9 g\u1ed3m x,y\nr = r.reshape(4,2)\n\n# T\u00ednh to\u00e1n 04 g\u00f3c theo th\u1ee9 t\u1ef1 tr\u00ean tr\u00e1i, tr\u00ean ph\u1ea3i, d\u01b0\u1edbi ph\u1ea3i, d\u01b0\u1edbi tr\u00e1i\nimport numpy as np\nrect = np.zeros((4,2), dtype='float32')\n\n# Ta t\u00ednh t\u1ed5ng c\u00e1c t\u1ecda \u0111\u1ed9 theo c\u1ed9t\n# \u0110i\u1ec3m tr\u00ean tr\u00e1i s\u1ebd c\u00f3 t\u1ed5ng nh\u1ecf nh\u1ea5t\n# \u0110i\u1ec3m d\u01b0\u1edbi ph\u1ea3i s\u1ebd c\u00f3 t\u1ed5ng l\u1edbn nh\u1ea5t\ns = np.sum(r, axis=1)\nrect&#91;0] = r&#91;np.argmin(s)] # Tr\u00ean tr\u00e1i\nrect&#91;2] = r&#91;np.argmax(s)] # D\u01b0\u1edbi ph\u1ea3i\n\n# Ta t\u00ednh s\u1ef1 kh\u00e1c nhau gi\u1eefa c\u00e1c t\u1ecda \u0111\u1ed9 theo c\u1ed9t\n# Tr\u00ean ph\u1ea3i s\u1ebd \u00edt kh\u00e1c bi\u1ec7t nh\u1ea5t\n# d\u01b0\u1edbi tr\u00e1i l\u00e0 kh\u00e1c bi\u1ec7t nh\u1ea5t\ndiff = np.diff(r, axis=1)\nrect&#91;1] = r&#91;np.argmin(diff)]\nrect&#91;3] = r&#91;np.argmax(diff)]\n\n# T\u00ednh to\u00e1n chi\u1ec1u r\u1ed9ng v\u00e0 chi\u1ec1u cao c\u1ee7a v\u0103n b\u1ea3n\n(tl, tr, br, bl) = rect\n\nwidth1 = np.sqrt((tl&#91;0] - tr&#91;0])**2 + (tl&#91;1] - tr&#91;1])**2 )\nwidth2 = np.sqrt((bl&#91;0] - br&#91;0])**2 + (bl&#91;1] - br&#91;1])**2 )\nWidth = max(int(width1), int(width2))\n\nheight1 = np.sqrt((tl&#91;0] - bl&#91;0])**2 + (tl&#91;1] - bl&#91;1])**2 )\nheight2 = np.sqrt((tr&#91;0] - br&#91;0])**2 + (tr&#91;1] - br&#91;1])**2 )\nHeight = max(int(height1), int(height2))\n\n\n# T\u1ecda \u0111\u1ed9 m\u1edbi c\u1ee7a v\u0103n b\u1ea3n\nnew_rect = np.array(&#91;\n    &#91;0,0],\n    &#91;Width-1, 0],\n    &#91;Width-1, Height-1],\n    &#91;0, Height-1]], dtype=\"float32\")\n\n# Tinh to\u00e1n ma tr\u1eadn transform\nM = cv2.getPerspectiveTransform(rect, new_rect)\n\n# Th\u1ef1c hi\u1ec7n xoay v\u00e0 crop\noutput = cv2.warpPerspective(image, M, (Width, Height))\n\n# Show \u1ea3nh\ncv2.imshow(\"Output\",output)\ncv2.waitKey()<\/code><\/pre>\n\n\n\n<p>H\u00e0ng v\u1ec1 h\u00e0ng v\u1ec1 \u0111\u00e2y r\u1ed3i:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/github.com\/thangnch\/MiAI_Scanner_App\/blob\/master\/Output_screenshot_05.06.2020.png?raw=true\" alt=\"qu\u00e9t v\u0103n b\u1ea3n scan document\"\/><\/figure>\n\n\n\n<!-- InPost_Ad -->\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<h5 class=\"wp-block-heading\">B\u01b0\u1edbc 5. Trau chu\u1ed1t k\u1ebft qu\u1ea3 qu\u00e9t v\u0103n b\u1ea3n<\/h5>\n\n\n\n<p>Anh em nh\u00ecn v\u00e0o k\u1ebft qu\u1ea3 tr\u00ean s\u1ebd th\u1ea5y n\u00f3 sao sao \u1ea5y nh\u1ec9:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u0110\u1ea7u ti\u00ean l\u00e0 c\u00f3 c\u00e1i vi\u1ec1n \u0111\u1ecf ng\u1ee9a m\u1eaft v\u00e3i<\/li><li>Th\u1ee9 hai l\u00e0 n\u00f3 c\u00f3 v\u1ebb kh\u00f4ng gi\u1ed1ng \u1ea3nh scan th\u01b0\u1eddng th\u1ea5y.<\/li><\/ul>\n\n\n\n<p>Chu\u1ea9n \u0111\u1edbi, b\u00e2y gi\u1edd ta th\u1ef1c hi\u1ec7n nh\u01b0 sau:\u0110\u1ec3 b\u1ecf vi\u1ec1n \u0111\u1ecf, ta b\u1ecf \u0111i d\u00f2ng &#8220;<em>cv2.drawContours(image, [r], -1, (0,0,255), 3)<\/em>&#8221; t\u1ea1i b\u01b0\u1edbc 3. <\/p>\n\n\n\n<p>\u0110\u1ec3 tr\u00f4ng cho n\u00f3 c\u00f3 v\u1ebb gi\u1ed1ng \u1ea3nh scan th\u00ec \u0111\u01a1n gi\u1ea3n l\u1eafm, ta \u00e1p th\u00eam cho n\u00f3 c\u00e1i threshold n\u1eefa l\u00e0 \u1ed5n<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# Chuy\u1ec3n th\u00e0nh x\u00e1m\ngray = cv2.cvtColor(output, cv2.COLOR_BGR2GRAY)\n\n# \u00c1p threshold\n\n_, output_final = cv2.threshold(gray,200,255,cv2.THRESH_BINARY)\n\n# Show h\u00e0ng\ncv2.imshow(\"Ouput\", output_final)\ncv2.waitKey()<\/code><\/pre>\n\n\n\n<p>R\u1ed3i b\u00e2y gi\u1edd th\u00ec ngon l\u00e0nh c\u00e0nh \u0111\u00e0o nh\u00e9 anh em!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/github.com\/thangnch\/MiAI_Scanner_App\/blob\/master\/Ouput1_screenshot_05.06.2020.png?raw=true\" alt=\"qu\u00e9t v\u0103n b\u1ea3n\"\/><\/figure>\n\n\n\n<p>Ok, nh\u01b0 v\u1eady h\u00f4m nay m\u00ecnh \u0111\u00e3 ch\u1ec9 cho c\u00e1c b\u1ea1n c\u00e1ch l\u00e0m ph\u1ea7n m\u1ec1m qu\u00e9t v\u0103n b\u1ea3n\/scan v\u0103n b\u1ea3n. C\u00e1c b\u1ea1n th\u1ea5y \u0111\u00f3 OpenCV c\u00f3 th\u1ec3 l\u00e0m \u0111\u01b0\u1ee3c kh\u00e1c nhi\u1ec1u th\u1ee9 gi\u00fap \u00edch cho cu\u1ed9c s\u1ed1ng ch\u1ee9 \u0111\u00e2u ph\u1ea3i c\u1ee9 ph\u1ea3i l\u00e0 Deep Learning \u0111\u00e2u.<\/p>\n\n\n\n<p>M\u00ecnh xin d\u1eebng b\u00e0i n\u00e0y t\u1ea1i \u0111\u00e2y v\u00e0 h\u1eb9n g\u1eb7p l\u1ea1i c\u00e1c b\u1ea1n trong c\u00e1c b\u00e0i ti\u1ebfp theo v\u1ec1 OpenCV thu\u1ea7n nh\u00e9!<\/p>\n\n\n\n<!-- InPost_Ad -->\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p><strong><em>H\u00e3y join c\u00f9ng c\u1ed9ng \u0111\u1ed3ng M\u00ec AI nh\u00e9!<\/em><\/strong><\/p>\n\n\n\n<p>Fanpage:&nbsp;<a rel=\"noreferrer noopener\" href=\"http:\/\/facebook.com\/miaiblog\" target=\"_blank\">http:\/\/facebook.com\/miaiblog<\/a><br>Group trao \u0111\u1ed5i, chia s\u1ebb:&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.facebook.com\/groups\/miaigroup\" target=\"_blank\">https:\/\/www.facebook.com\/groups\/miaigroup<\/a><br>Website:&nbsp;<a href=\"https:\/\/miai.vn\/\">https:\/\/miai.vn\/<\/a><br>Youtube:&nbsp;<a rel=\"noreferrer noopener\" href=\"http:\/\/bit.ly\/miaiyoutube\" target=\"_blank\">http:\/\/bit.ly\/miaiyoutube<\/a><\/p>\n\n\n\n<p>C\u1ea3m \u01a1n b\u00e0i tham kh\u1ea3o <a href=\"https:\/\/towardsdatascience.com\/document-scanner-using-computer-vision-opencv-and-python-20b87b1cbb06\">t\u1ea1i \u0111\u00e2y.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Xin ch\u00e0o anh em M\u00ec AI, h\u00f4m nay ch\u00fang ta s\u1ebd Th\u1eed gi\u1ea3 l\u1eadp m\u00e1y qu\u00e9t v\u0103n b\u1ea3n\/scanner b\u1eb1ng OpenCV xem nh\u00e9. Ch\u1eafc h\u1eb3n anh em c\u00f2n nh\u1edb ng\u00e0y tr\u01b0\u1edbc mu\u1ed1n scan c\u00e1c v\u0103n b\u1ea3n th\u00ec ch\u1ec9 c\u00f3 m\u1ed9t c\u00e1ch duy nh\u1ea5t \u0111\u00f3 l\u00e0 s\u1eed d\u1ee5ng nh\u1eefng chi\u1ebfc m\u00e1y scann to b\u1ea3n, n\u1eb7ng tr\u1ecbch nh\u01b0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[292,293,294,295,296,28,32,297,298,299,229],"class_list":["post-960","post","type-post","status-publish","format-standard","hentry","category-computer-vision","tag-canny","tag-contour","tag-deskew","tag-document-scan","tag-grayscale","tag-opencv","tag-python","tag-quet-van-ban","tag-scan-van-ban","tag-scanner-app","tag-threshold"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Th\u1eed l\u00e0m ph\u1ea7n m\u1ec1m qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV - M\u00ec AI<\/title>\n<meta name=\"description\" content=\"Xin ch\u00e0o anh em M\u00ec AI th\u00e2n m\u1ebfn, h\u00f4m nay ch\u00fang ta s\u1ebd c\u00f9ng nhau th\u1eed gi\u1ea3 l\u1eadp m\u00e1y qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV xem nh\u00e9.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/miai.vn\/?p=960\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Th\u1eed l\u00e0m ph\u1ea7n m\u1ec1m qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV - M\u00ec AI\" \/>\n<meta property=\"og:description\" content=\"Xin ch\u00e0o anh em M\u00ec AI th\u00e2n m\u1ebfn, h\u00f4m nay ch\u00fang ta s\u1ebd c\u00f9ng nhau th\u1eed gi\u1ea3 l\u1eadp m\u00e1y qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV xem nh\u00e9.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/miai.vn\/?p=960\" \/>\n<meta property=\"og:site_name\" content=\"M\u00ec AI\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-05T02:14:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/4.imimg.com\/data4\/AH\/MJ\/MY-26848583\/scanner-machine-500x500.jpg\" \/>\n<meta name=\"author\" content=\"Ch\u1ee7 ti\u1ec7m M\u00ec\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ch\u1ee7 ti\u1ec7m M\u00ec\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=960#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=960\"},\"author\":{\"name\":\"Ch\u1ee7 ti\u1ec7m M\u00ec\",\"@id\":\"https:\\\/\\\/miai.vn\\\/#\\\/schema\\\/person\\\/cc8bc24bb90bd3f596add82f3a59948c\"},\"headline\":\"Th\u1eed l\u00e0m ph\u1ea7n m\u1ec1m qu\u00e9t v\u0103n b\u1ea3n\\\/scanner app b\u1eb1ng OpenCV\",\"datePublished\":\"2020-06-05T02:14:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=960\"},\"wordCount\":1317,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=960#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/4.imimg.com\\\/data4\\\/AH\\\/MJ\\\/MY-26848583\\\/scanner-machine-500x500.jpg\",\"keywords\":[\"canny\",\"contour\",\"deskew\",\"document scan\",\"grayscale\",\"opencv\",\"python\",\"qu\u00e9t v\u0103n b\u1ea3n\",\"scan v\u0103n b\u1ea3n\",\"scanner app\",\"threshold\"],\"articleSection\":[\"Computer Vision\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/miai.vn\\\/?p=960#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=960\",\"url\":\"https:\\\/\\\/miai.vn\\\/?p=960\",\"name\":\"Th\u1eed l\u00e0m ph\u1ea7n m\u1ec1m qu\u00e9t v\u0103n b\u1ea3n\\\/scanner app b\u1eb1ng OpenCV - M\u00ec AI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=960#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=960#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/4.imimg.com\\\/data4\\\/AH\\\/MJ\\\/MY-26848583\\\/scanner-machine-500x500.jpg\",\"datePublished\":\"2020-06-05T02:14:49+00:00\",\"description\":\"Xin ch\u00e0o anh em M\u00ec AI th\u00e2n m\u1ebfn, h\u00f4m nay ch\u00fang ta s\u1ebd c\u00f9ng nhau th\u1eed gi\u1ea3 l\u1eadp m\u00e1y qu\u00e9t v\u0103n b\u1ea3n\\\/scanner app b\u1eb1ng OpenCV xem nh\u00e9.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=960#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/miai.vn\\\/?p=960\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=960#primaryimage\",\"url\":\"https:\\\/\\\/4.imimg.com\\\/data4\\\/AH\\\/MJ\\\/MY-26848583\\\/scanner-machine-500x500.jpg\",\"contentUrl\":\"https:\\\/\\\/4.imimg.com\\\/data4\\\/AH\\\/MJ\\\/MY-26848583\\\/scanner-machine-500x500.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=960#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/miai.vn\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Th\u1eed l\u00e0m ph\u1ea7n m\u1ec1m qu\u00e9t v\u0103n b\u1ea3n\\\/scanner app b\u1eb1ng OpenCV\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/miai.vn\\\/#website\",\"url\":\"https:\\\/\\\/miai.vn\\\/\",\"name\":\"M\u00ec AI\",\"description\":\"H\u1ecdc AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n!\",\"publisher\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/miai.vn\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/miai.vn\\\/#organization\",\"name\":\"M\u00ec AI\",\"url\":\"https:\\\/\\\/miai.vn\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/miai.vn\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/miai.vn\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/cropped-Logo_w_slogan.png\",\"contentUrl\":\"https:\\\/\\\/miai.vn\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/cropped-Logo_w_slogan.png\",\"width\":240,\"height\":193,\"caption\":\"M\u00ec AI\"},\"image\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/miai.vn\\\/#\\\/schema\\\/person\\\/cc8bc24bb90bd3f596add82f3a59948c\",\"name\":\"Ch\u1ee7 ti\u1ec7m M\u00ec\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b0b5124b0d2c0a8054d7127d2c236bdc3dc7a50e2d4e8728ab32eee5b122a8d1?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b0b5124b0d2c0a8054d7127d2c236bdc3dc7a50e2d4e8728ab32eee5b122a8d1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b0b5124b0d2c0a8054d7127d2c236bdc3dc7a50e2d4e8728ab32eee5b122a8d1?s=96&d=mm&r=g\",\"caption\":\"Ch\u1ee7 ti\u1ec7m M\u00ec\"},\"sameAs\":[\"https:\\\/\\\/miai.vn\"],\"url\":\"https:\\\/\\\/miai.vn\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Th\u1eed l\u00e0m ph\u1ea7n m\u1ec1m qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV - M\u00ec AI","description":"Xin ch\u00e0o anh em M\u00ec AI th\u00e2n m\u1ebfn, h\u00f4m nay ch\u00fang ta s\u1ebd c\u00f9ng nhau th\u1eed gi\u1ea3 l\u1eadp m\u00e1y qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV xem nh\u00e9.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/miai.vn\/?p=960","og_locale":"en_US","og_type":"article","og_title":"Th\u1eed l\u00e0m ph\u1ea7n m\u1ec1m qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV - M\u00ec AI","og_description":"Xin ch\u00e0o anh em M\u00ec AI th\u00e2n m\u1ebfn, h\u00f4m nay ch\u00fang ta s\u1ebd c\u00f9ng nhau th\u1eed gi\u1ea3 l\u1eadp m\u00e1y qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV xem nh\u00e9.","og_url":"https:\/\/miai.vn\/?p=960","og_site_name":"M\u00ec AI","article_published_time":"2020-06-05T02:14:49+00:00","og_image":[{"url":"https:\/\/4.imimg.com\/data4\/AH\/MJ\/MY-26848583\/scanner-machine-500x500.jpg","type":"","width":"","height":""}],"author":"Ch\u1ee7 ti\u1ec7m M\u00ec","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Ch\u1ee7 ti\u1ec7m M\u00ec","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/miai.vn\/?p=960#article","isPartOf":{"@id":"https:\/\/miai.vn\/?p=960"},"author":{"name":"Ch\u1ee7 ti\u1ec7m M\u00ec","@id":"https:\/\/miai.vn\/#\/schema\/person\/cc8bc24bb90bd3f596add82f3a59948c"},"headline":"Th\u1eed l\u00e0m ph\u1ea7n m\u1ec1m qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV","datePublished":"2020-06-05T02:14:49+00:00","mainEntityOfPage":{"@id":"https:\/\/miai.vn\/?p=960"},"wordCount":1317,"commentCount":2,"publisher":{"@id":"https:\/\/miai.vn\/#organization"},"image":{"@id":"https:\/\/miai.vn\/?p=960#primaryimage"},"thumbnailUrl":"https:\/\/4.imimg.com\/data4\/AH\/MJ\/MY-26848583\/scanner-machine-500x500.jpg","keywords":["canny","contour","deskew","document scan","grayscale","opencv","python","qu\u00e9t v\u0103n b\u1ea3n","scan v\u0103n b\u1ea3n","scanner app","threshold"],"articleSection":["Computer Vision"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/miai.vn\/?p=960#respond"]}]},{"@type":"WebPage","@id":"https:\/\/miai.vn\/?p=960","url":"https:\/\/miai.vn\/?p=960","name":"Th\u1eed l\u00e0m ph\u1ea7n m\u1ec1m qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV - M\u00ec AI","isPartOf":{"@id":"https:\/\/miai.vn\/#website"},"primaryImageOfPage":{"@id":"https:\/\/miai.vn\/?p=960#primaryimage"},"image":{"@id":"https:\/\/miai.vn\/?p=960#primaryimage"},"thumbnailUrl":"https:\/\/4.imimg.com\/data4\/AH\/MJ\/MY-26848583\/scanner-machine-500x500.jpg","datePublished":"2020-06-05T02:14:49+00:00","description":"Xin ch\u00e0o anh em M\u00ec AI th\u00e2n m\u1ebfn, h\u00f4m nay ch\u00fang ta s\u1ebd c\u00f9ng nhau th\u1eed gi\u1ea3 l\u1eadp m\u00e1y qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV xem nh\u00e9.","breadcrumb":{"@id":"https:\/\/miai.vn\/?p=960#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/miai.vn\/?p=960"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/miai.vn\/?p=960#primaryimage","url":"https:\/\/4.imimg.com\/data4\/AH\/MJ\/MY-26848583\/scanner-machine-500x500.jpg","contentUrl":"https:\/\/4.imimg.com\/data4\/AH\/MJ\/MY-26848583\/scanner-machine-500x500.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/miai.vn\/?p=960#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/miai.vn\/"},{"@type":"ListItem","position":2,"name":"Th\u1eed l\u00e0m ph\u1ea7n m\u1ec1m qu\u00e9t v\u0103n b\u1ea3n\/scanner app b\u1eb1ng OpenCV"}]},{"@type":"WebSite","@id":"https:\/\/miai.vn\/#website","url":"https:\/\/miai.vn\/","name":"M\u00ec AI","description":"H\u1ecdc AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n!","publisher":{"@id":"https:\/\/miai.vn\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/miai.vn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/miai.vn\/#organization","name":"M\u00ec AI","url":"https:\/\/miai.vn\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/miai.vn\/#\/schema\/logo\/image\/","url":"https:\/\/miai.vn\/wp-content\/uploads\/2026\/05\/cropped-Logo_w_slogan.png","contentUrl":"https:\/\/miai.vn\/wp-content\/uploads\/2026\/05\/cropped-Logo_w_slogan.png","width":240,"height":193,"caption":"M\u00ec AI"},"image":{"@id":"https:\/\/miai.vn\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/miai.vn\/#\/schema\/person\/cc8bc24bb90bd3f596add82f3a59948c","name":"Ch\u1ee7 ti\u1ec7m M\u00ec","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b0b5124b0d2c0a8054d7127d2c236bdc3dc7a50e2d4e8728ab32eee5b122a8d1?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b0b5124b0d2c0a8054d7127d2c236bdc3dc7a50e2d4e8728ab32eee5b122a8d1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b0b5124b0d2c0a8054d7127d2c236bdc3dc7a50e2d4e8728ab32eee5b122a8d1?s=96&d=mm&r=g","caption":"Ch\u1ee7 ti\u1ec7m M\u00ec"},"sameAs":["https:\/\/miai.vn"],"url":"https:\/\/miai.vn\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/miai.vn\/index.php?rest_route=\/wp\/v2\/posts\/960","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/miai.vn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/miai.vn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/miai.vn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/miai.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=960"}],"version-history":[{"count":0,"href":"https:\/\/miai.vn\/index.php?rest_route=\/wp\/v2\/posts\/960\/revisions"}],"wp:attachment":[{"href":"https:\/\/miai.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/miai.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/miai.vn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}