{"id":45824,"date":"2021-12-08T21:49:54","date_gmt":"2021-12-08T12:49:54","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=45824"},"modified":"2021-12-08T21:49:56","modified_gmt":"2021-12-08T12:49:56","slug":"%ec%95%88%eb%93%9c%eb%a1%9c%ec%9d%b4%eb%93%9c%eb%a1%9c-%eb%b0%b0%ec%9a%b0%eb%8a%94-opencv-%ec%9c%a4%ea%b3%bd%ec%84%a0%ec%9d%84-%ea%b7%bc%ec%82%ac%ed%99%94%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=45824","title":{"rendered":"[\uc548\ub4dc\ub85c\uc774\ub4dc\ub85c \ubc30\uc6b0\ub294 OpenCV] \uc724\uacfd\uc120\uc744 \uadfc\uc0ac\ud654\ud558\uae30"},"content":{"rendered":"\n<p><meta charset=\"utf-8\">Prerequisite : <a href=\"https:\/\/www.charlezz.com\/?p=45795\">\uc724\uacfd\uc120 \uae38\uc774 \uad6c\ud558\uae30<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\uc724\uacfd\uc120 \uadfc\uc0ac\ud654<\/h2>\n\n\n\n<p>\uc724\uacfd\uc120 \uadfc\uc0ac\ud654\ub780 \uac80\ucd9c\ud55c \uc724\uacfd\uc120 \uc815\ubcf4\ub97c \ubd84\uc11d\ud558\uc5ec \uc815\uc810(vertex) \uc218\uac00 \uc801\uc740 \uc724\uacfd\uc120 \ub610\ub294 \ub2e4\uac01\ud615\uc73c\ub85c \ud45c\ud604\ud560 \uc218 \uc788\uac8c \ub9cc\ub4dc\ub294 \ubc29\ubc95\uc744 \uc758\ubbf8 \ud55c\ub2e4. \uc774\ub54c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm\">Douglas-Peucker \uc54c\uace0\ub9ac\uc998<\/a>\uc744 \uc0ac\uc6a9\ud55c\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.charlezz.com\/wordpress\/wp-content\/uploads\/2021\/12\/www.charlezz.com-opencv-440px-douglas-peucker-animated.gif\" alt=\"\" class=\"wp-image-45825\" width=\"660\" height=\"210\"\/><figcaption>Douglas-Peucker \uc54c\uace0\ub9ac\uc998\uc73c\ub85c \uadfc\uc0ac\ud654 \ud558\ub294 \uacfc\uc815\uc744 \ubcf4\uc5ec\uc8fc\ub294 \uc601\uc0c1<\/figcaption><\/figure><\/div>\n\n\n\n<p>OpenCV\uc5d0\uc11c \uc724\uacfd\uc120 \uadfc\uc0ac\ud654\ub97c \uc704\ud574 approxPolyDP\ub77c\ub294 \ud568\uc218\ub97c \uc81c\uacf5\ud558\uace0 \uc788\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">approxPolyDP(curve, approxCurve, epsilon, closed)<\/pre>\n\n\n\n<p>curve: \uc785\ub825\ud560 \uace1\uc120 \uc88c\ud45c(\uc724\uacfd\uc120 \uc88c\ud45c) <br>approxCurve: \ud568\uc218 \ud638\ucd9c \ud6c4 \ucc38\uc870 \uac00\ub2a5\ud55c \uadfc\uc0ac\ud654 \ub41c \uace1\uc120 \uc88c\ud45c<br>epsilon: \uadfc\uc0ac\ud654 \uc815\ubc00\ub3c4 \uc870\uc808. \uc785\ub825 \uace1\uc120\uacfc \uadfc\uc0ac\ud654 \uace1\uc120 \uac04\uc758 \ucd5c\ub300 \uac70\ub9ac.<br>\uc608) arcLenth(curve) *0.02<br>closed: \ud3d0\uace1\uc120 \uc5ec\ubd80. true\uba74 \ud3d0\uace1\uc120<\/p>\n\n\n\n<p>epsilon\uac12\uc744 \uc870\uc808\ud558\uc5ec \uadfc\uc0ac\ud654 \ub41c \uace1\uc120\uc744 \uc5bb\ub294 \uc608\uc81c\ub97c \uc0b4\ud3b4\ubcf4\uc790.<\/p>\n\n\n\n<figure class=\"wp-block-video aligncenter\"><video controls src=\"https:\/\/www.charlezz.com\/wordpress\/wp-content\/uploads\/2021\/12\/www.charlezz.com-opencv-screencapture-1638967532126.mp4\"><\/video><\/figure>\n\n\n\n<p>\uc608\uc81c\ucf54\ub4dc:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">val contours = ArrayList&lt;MatOfPoint>()\nval hierarchy = Mat()\n\/\/\uc724\uacfd\uc120 \ucc3e\uae30\nImgproc.findContours(binarySrc, contours, hierarchy, Imgproc.<em>RETR_TREE<\/em>, Imgproc.<em>CHAIN_APPROX_SIMPLE<\/em>)\nfor(contour in contours){\n    \/\/ \uc724\uacfd\uc120 \uc815\ubcf4\ub97c MatOfPoint2f\ud0c0\uc785\uc73c\ub85c \ubcc0\ud658\n    val contour2f = MatOfPoint2f(*contour.toArray())\n    \/\/ approxPolyDP \ud638\ucd9c\ud6c4 \ucc38\uc870\ud560 \uadfc\uc0ac\ud654 \ub41c \uc724\uacfd\uc120 \uc815\ubcf4\n    val approxCurve = MatOfPoint2f()\n    \/\/ \uc724\uacfd\uc120 \uadfc\uc0ac\ud654 \uc815\ubcf4 \uc5bb\uae30\n    Imgproc.approxPolyDP(\n        contour2f, \n        approxCurve, \n        Imgproc.arcLength(contour2f, true)*(0.005*value1),\n        true\n    )\n    val points = approxCurve.toList()\n    \/\/ \uadfc\uc0ac\ud654 \ub41c \uc724\uacfd\uc120 \uc815\uc810\ub4e4\uc744 line \ud568\uc218\ub97c \ud1b5\ud574 \uc774\uc5b4 \uadf8\ub9ac\uae30\n    for(i in points.<em>indices<\/em>){\n        Imgproc.line(src, points[i], points[(i+1)%points.size], <em>RED<\/em>, 2)\n    }\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Prerequisite : \uc724\uacfd\uc120 \uae38\uc774 \uad6c\ud558\uae30 \uc724\uacfd\uc120 \uadfc\uc0ac\ud654 \uc724\uacfd\uc120 \uadfc\uc0ac\ud654\ub780 \uac80\ucd9c\ud55c \uc724\uacfd\uc120 \uc815\ubcf4\ub97c \ubd84\uc11d\ud558\uc5ec \uc815\uc810(vertex) \uc218\uac00 \uc801\uc740 \uc724\uacfd\uc120 \ub610\ub294 \ub2e4\uac01\ud615\uc73c\ub85c \ud45c\ud604\ud560 \uc218 \uc788\uac8c \ub9cc\ub4dc\ub294 \ubc29\ubc95\uc744 \uc758\ubbf8 \ud55c\ub2e4. \uc774\ub54c Douglas-Peucker \uc54c\uace0\ub9ac\uc998\uc744 \uc0ac\uc6a9\ud55c\ub2e4. OpenCV\uc5d0\uc11c \uc724\uacfd\uc120 \uadfc\uc0ac\ud654\ub97c \uc704\ud574 approxPolyDP\ub77c\ub294 \ud568\uc218\ub97c \uc81c\uacf5\ud558\uace0 \uc788\ub2e4. approxPolyDP(curve, approxCurve, epsilon, closed) curve: \uc785\ub825\ud560 \uace1\uc120 \uc88c\ud45c(\uc724\uacfd\uc120 \uc88c\ud45c) approxCurve: \ud568\uc218 \ud638\ucd9c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[27],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45824"}],"collection":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=45824"}],"version-history":[{"count":1,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45824\/revisions"}],"predecessor-version":[{"id":45827,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45824\/revisions\/45827"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=45824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=45824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=45824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}