{"id":45828,"date":"2021-12-08T22:21:13","date_gmt":"2021-12-08T13:21:13","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=45828"},"modified":"2021-12-08T22:21:15","modified_gmt":"2021-12-08T13:21:15","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%a3%bc%ec%96%b4%ec%a7%84-%ec%a0%90%ec%97%90-%ec%a0%81%ed%95%a9%ed%95%9c-%ed%83%80%ec%9b%90-%ea%b5%ac","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=45828","title":{"rendered":"[\uc548\ub4dc\ub85c\uc774\ub4dc\ub85c \ubc30\uc6b0\ub294 OpenCV] \uc8fc\uc5b4\uc9c4 \uc810\uc5d0 \uc801\ud569\ud55c \ud0c0\uc6d0 \uad6c\ud558\uae30 (fitEllipse)"},"content":{"rendered":"\n<p>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\">fitEllipse \ud568\uc218<\/h2>\n\n\n\n<p>OpenCV\uc5d0\uc11c\ub294 fitEllipse\ub77c\ub294 \ud568\uc218\ub97c \uc81c\uacf5\ud558\ub294\ub370, \uc774\ub294 <strong>\uc8fc\uc5b4\uc9c4 \uc810\ub4e4\uc744 \uc801\ub2f9\ud788 \uac10\uc2f8\ub294 \ud0c0\uc6d0<\/strong> \uc815\ubcf4\ub97c \uad6c\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Imgproc.fitEllipse(contour)<\/pre>\n\n\n\n<p>contour: \uc724\uacfd\uc120 \uc88c\ud45c<br>\ubc18\ud658\uac12: RotatedRect \ud0c0\uc785\uc758 \ud0c0\uc6d0 \uc815\ubcf4<\/p>\n\n\n\n<p>fitEllipse\uc640 \ud568\uaed8 \uc774\ubbf8\uc9c0 \ub0b4 \ub3c4\ud615\uc744 \ud0c0\uc6d0\uc73c\ub85c \uc801\ub2f9\ud788 \uac10\uc2f8\ub294 \uc608\uc81c\ub97c \uc0b4\ud3b4\ubcf4\uc790.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.charlezz.com\/wordpress\/wp-content\/uploads\/2021\/12\/www.charlezz.com-opencv-fitellipse-screenshot-1638969467832-820x1024.png\" alt=\"\" class=\"wp-image-45829\" width=\"615\" height=\"768\" srcset=\"https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/12\/www.charlezz.com-opencv-fitellipse-screenshot-1638969467832-820x1024.png 820w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/12\/www.charlezz.com-opencv-fitellipse-screenshot-1638969467832-240x300.png 240w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/12\/www.charlezz.com-opencv-fitellipse-screenshot-1638969467832-768x959.png 768w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/12\/www.charlezz.com-opencv-fitellipse-screenshot-1638969467832-1230x1536.png 1230w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/12\/www.charlezz.com-opencv-fitellipse-screenshot-1638969467832-1640x2048.png 1640w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/12\/www.charlezz.com-opencv-fitellipse-screenshot-1638969467832.png 1768w\" sizes=\"(max-width: 615px) 100vw, 615px\" \/><\/figure><\/div>\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()\nImgproc.findContours(\n    binarySrc,\n    contours,\n    hierarchy,\n    Imgproc.<em>RETR_TREE<\/em>,\n    Imgproc.<em>CHAIN_APPROX_SIMPLE\n<\/em>)\nfor (i in 0 <em>until <\/em>contours.size) {\n    \/\/ \ub0b4\ubd80\uc5d0\uc11c \uc0ac\uc6a9\ud558\ub294 fitEllipseNoDirect \ud568\uc218\uc5d0\uc11c \ucd5c\uc18c 5\uac1c \uc774\uc0c1\uc758 \uc815\uc810\uc744 \uc694\uad6c\ud55c\ub2e4.\n    if (contours[i].rows() >= 5){\n        val contour2f = MatOfPoint2f(*contours[i].toArray())\n        \/\/ \ub3c4\ud615\uc744 \uac10\uc2f8\ub294 \ud0c0\uc6d0 \uc815\ubcf4 \uad6c\ud558\uae30\n        val rotatedRect = Imgproc.fitEllipse(contour2f)\n        \/\/ \ud0c0\uc6d0 \uadf8\ub9ac\uae30\n        Imgproc.ellipse(src, rotatedRect, <em>RED<\/em>)\n    }\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Prerequisite : \uc724\uacfd\uc120 \uae38\uc774 \uad6c\ud558\uae30 fitEllipse \ud568\uc218 OpenCV\uc5d0\uc11c\ub294 fitEllipse\ub77c\ub294 \ud568\uc218\ub97c \uc81c\uacf5\ud558\ub294\ub370, \uc774\ub294 \uc8fc\uc5b4\uc9c4 \uc810\ub4e4\uc744 \uc801\ub2f9\ud788 \uac10\uc2f8\ub294 \ud0c0\uc6d0 \uc815\ubcf4\ub97c \uad6c\ud560 \uc218 \uc788\ub2e4. Imgproc.fitEllipse(contour) contour: \uc724\uacfd\uc120 \uc88c\ud45c\ubc18\ud658\uac12: RotatedRect \ud0c0\uc785\uc758 \ud0c0\uc6d0 \uc815\ubcf4 fitEllipse\uc640 \ud568\uaed8 \uc774\ubbf8\uc9c0 \ub0b4 \ub3c4\ud615\uc744 \ud0c0\uc6d0\uc73c\ub85c \uc801\ub2f9\ud788 \uac10\uc2f8\ub294 \uc608\uc81c\ub97c \uc0b4\ud3b4\ubcf4\uc790. \uc608\uc81c\ucf54\ub4dc: val contours = ArrayList&lt;MatOfPoint>() val hierarchy = Mat() Imgproc.findContours( binarySrc, [&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\/45828"}],"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=45828"}],"version-history":[{"count":1,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45828\/revisions"}],"predecessor-version":[{"id":45830,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45828\/revisions\/45830"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=45828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=45828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=45828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}