{"id":1153,"date":"2012-09-28T20:32:09","date_gmt":"2012-09-28T11:32:09","guid":{"rendered":"http:\/\/daily.belltail.jp\/?p=1153"},"modified":"2012-09-28T20:33:16","modified_gmt":"2012-09-28T11:33:16","slug":"line-segment-detector%e7%b7%9a%e5%88%86%e6%a4%9c%e5%87%ba%e5%99%a8%e3%81%a7%e9%81%8a%e3%82%93%e3%81%a7%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/daily.belltail.jp\/?p=1153","title":{"rendered":"Line Segment Detector\u7dda\u5206\u691c\u51fa\u5668\u3067\u79cb\u3092\u304a\u3044\u3057\u304f\u3044\u305f\u3060\u304f"},"content":{"rendered":"<p>\u590f\u306e\u6691\u3055\u3082\u3060\u3044\u3076\u3084\u308f\u3089\u304e\uff0c\u304a\u3055\u304b\u306a\u304c\u7f8e\u5473\u3057\u3044\u5b63\u7bc0\u306b\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u306d\uff0e<\/p>\n<p>\u753b\u50cf\u304b\u3089\u306e\u7dda\u5206\u691c\u51fa\u3068\u3044\u3048\u3070Hough\u5909\u63db\u3084RANSAC\u306a\u3069\u304c\u3042\u308a\uff0c\u305d\u3093\u306a\u624b\u6cd5\u306e\u3072\u3068\u3064\u3067\u3042\u308bLSD;Line Segment Detector\u3092\u4f7f\u3063\u3066\u307f\u305f\uff0e<br \/>\n\u539f\u8457\u306f2010\u5e74\u306eIEEE\u8ad6\u6587\u8a8c\u3067\u767a\u8868\u3055\u308c\u305f\u3088\u3046\u3067\u3059\u306d\uff0e\u4eca\u3067\u3082\u3053\u308c\u7cfb\u306e\u5206\u91ce\u304c\u30a2\u30c4\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u898b\u3066\u3044\u3066\u697d\u3057\u3044\u3067\u3059\uff57<\/p>\n<p>\u3055\u3066\uff0c\u3068\u3053\u308d\u3067\u4eca\u65e5\u306e\u8a18\u4e8b\u306f\uff0c<br \/>\n[http:\/\/blog.livedoor.jp\/juggleryou\/archives\/5234344.html:title=JugglerYou\u65e5\u8a18 :: LineSegmentDetector\u3092\u4f7f\u3063\u3066\u307f\u305f]<br \/>\n\u3055\u3093\u306e\u8a18\u4e8b\u306e\u4e38\u30d1\u30af\u30ea\u306b\u8fd1\u3044\uff0e<br \/>\njuggler_you\u3055\u3093\u306f\u30ea\u30a2\u30eb\u77e5\u308a\u5408\u3044\u3060\u3063\u305f\u308a\u3057\u307e\u3059\uff0e\uff54\uff48\uff58\uff01<\/p>\n<p>[:contents]<\/p>\n<p><!--more--><\/p>\n<p>*\u6982\u8981<\/p>\n<p>[http:\/\/www.ipol.im\/pub\/art\/2012\/gjmr-lsd\/]<\/p>\n<p>\u30db\u30f3\u30c8\u306f\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u305f\u304b\u3063\u305f\u3093\u3067\u3059\u304c\u6c17\u529b\u304c\u306a\u304b\u3063\u305f\u3057\u8aac\u660e\u30da\u30fc\u30b8\u3092\u8aad\u3081\u3070\u82f1\u8a9e\u3060\u3051\u3069\u3051\u3063\u3053\u3046\u308f\u304b\u308a\u3084\u3059\u3044\u306e\u3067\uff0c\u8a73\u7d30\u3092\u77e5\u308a\u305f\u3044\u65b9\u306f\u305d\u3061\u3089\u3067\uff0e<\/p>\n<p>\u30b5\u30d6\u30d4\u30af\u30bb\u30eb\u7cbe\u5ea6\u306a\u3053\u3068\uff0c\u30d1\u30e9\u30e1\u30fc\u30bf\u8abf\u6574\u304c\u3042\u307e\u308a\u5fc5\u8981\u306a\u3044\u3053\u3068\uff0cHough\u5909\u63db\u3088\u308arobust\u306a\u3053\u3068\u3068\u304b\u304c\u7d50\u69cb\u30a2\u30d4\u30fc\u30eb\u30dd\u30a4\u30f3\u30c8\u306e\u3088\u3046\u3067\u3059\uff0e<\/p>\n<p>*\u304a\u3055\u304b\u306a\u3055\u3093\u6d41\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/p>\n<p>[http:\/\/www.ipol.im\/pub\/art\/2012\/gjmr-lsd\/]\u304b\u3089\u30bd\u30fc\u30b9\u3092\u843d\u3068\u3057\u3066\u304d\u3066\uff0c\u305d\u306e\u3046\u3061lsd.c\u3068lsd.h\u3060\u3051\u304c\u5fc5\u8981\u3067\u3059\uff0e<\/p>\n<p>**\u30bd\u30fc\u30b9<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;iostream&gt;\r\n#include &lt;opencv2\/opencv.hpp&gt;\r\n#include &quot;lsd.h&quot;\r\n\r\ncv::Mat img;\r\nint n_lines;\r\ndouble* lines;\u3000\r\n\r\nvoid change_th_lsd(int nfa, void* dummy)\r\n{\r\n    cv::Mat result = img.clone();\r\n    for(int i = 0; i &lt; n_lines; i++)\r\n    {\r\n        const double *line = &amp;lines&#x5B;i * 7];\r\n        if(nfa &lt; line&#x5B;6])\r\n        {\r\n            const cv::Point p1(line&#x5B;0], line&#x5B;1]);\r\n            const cv::Point p2(line&#x5B;2], line&#x5B;3]);\r\n            cv::line(result, p1, p2, cv::Scalar(0, 0, 255));\r\n        }\r\n    }\r\n    cv::imshow(&quot;result_image&quot;, result);\r\n}\r\n\r\nint main(int argc, char *argv&#x5B;])\r\n{\r\n    \/\/\u753b\u50cf\u3092\u30b0\u30ec\u30fc\u30b9\u30b1\u30fc\u30eb\u3068\u3057\u3066\u8aad\u307f\u8fbc\u307f\r\n    img = cv::imread(argv&#x5B;1], 0);\r\n\r\n    \/\/LSD\u7528\u753b\u50cf\u306b\u5909\u63db\uff1e\uff1c\r\n    double *dat = new double&#x5B;img.rows * img.cols];\r\n    for(int y = 0; y &lt; img.rows; y++)\r\n        for(int x = 0; x &lt; img.cols; x++)\r\n            dat&#x5B;y * img.cols + x] = img.at&lt;unsigned char&gt;(y, x);\r\n\r\n    \/\/LSD\u51e6\u7406\r\n    lines = lsd(&amp;n_lines, dat, img.cols, img.rows);\r\n\r\n    \/\/\u3057\u304d\u3044\u5024\u306e\u6700\u5927\u5024\u3068\u6700\u5c0f\u5024\u3092\u3082\u3063\u3066\u304f\u308b\r\n    int max_NFA = 0;\r\n    for(int i = 0; i &lt; n_lines; i++)\r\n        max_NFA = std::max(max_NFA, static_cast&lt;int&gt;(lines&#x5B;i * 7 + 6]));\r\n\r\n    \/\/\u7d50\u679c\u63cf\u753b\u7528\u753b\u50cf\r\n    cv::cvtColor(img, img, CV_GRAY2RGB);\r\n\r\n    \/\/\u7d50\u679c\u8868\u793a\u7528\u30a6\u30a3\u30f3\u30c9\u30a6\r\n    cv::namedWindow(&quot;result_image&quot;);\r\n    cv::createTrackbar(&quot;NFA&quot;, &quot;result_image&quot;, NULL, max_NFA, change_th_lsd);\r\n    cv::setTrackbarPos(&quot;NFA&quot;, &quot;result_image&quot;, max_NFA);\r\n\r\n    \/\/\u7d50\u679c\u8868\u793a\r\n    cv::imshow(&quot;result_image&quot;, img);\r\n    cv::waitKey(0);\r\n}\r\n<\/pre>\n<p>**\u30b3\u30fc\u30c9\u89e3\u8aac<br \/>\n\u3042\u307e\u308a\u5fc5\u8981\u306a\u3044\u3068\u306f\u601d\u3044\u307e\u3059\u304c\u2026\uff0e<\/p>\n<p>-LSD\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u5185\u90e8\u51e6\u7406\u306e\u305f\u3081\u306b\u753b\u50cf\u3092double\u914d\u5217\u306b\u5909\u63db\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059<br \/>\n&#8211;cv::Mat\u3067\u306f\u3069\u3046\u3057\u3066\u3082\u4e2d\u306e\u30c7\u30fc\u30bf\u3092\u76f4\u306b\u305d\u306e\u307e\u307e\u6d41\u7528\u3067\u304d\u306a\u3044\u3088\u3046\u3067\u3059\u2026<br \/>\n-\u753b\u9762\u306b\u51fa\u3059\u3068\u304d\u30c8\u30e9\u30c3\u30af\u30d0\u30fc\u3067\u691c\u51fa\u7d50\u679c\u30b9\u30b3\u30a2\u3067\u3057\u304d\u3044\u5024\u8abf\u6574\u3057\u305f\u3044\u306e\u3067\uff0c\u30b9\u30b3\u30a2\u306e\u6700\u5927\u5024\u3092\u3068\u3063\u3066\u304d\u3066\u30c8\u30e9\u30c3\u30af\u30d0\u30fc\u306e\u6700\u5927\u5024\u3068\u3057\u307e\u3059<br \/>\n-OpenCV\u306ehighgui\u307e\u308f\u308a\u306b\u3064\u3044\u3066\u306f\u4ed6\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044<\/p>\n<p>**\u5b9f\u884c\u65b9\u6cd5<\/p>\n<p>Linux\u306e\u5834\u5408\u306e\u30b3\u30f3\u30d1\u30a4\u30eb\u3068\u5b9f\u884c\u306f<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n% g++ prog.cpp lsd.c -lopencv_core -lopencv_highgui -O3\r\n% .\/a.out hoge.jpg\r\n<\/pre>\n<p>*\u5b9f\u884c\u4f8b<\/p>\n<p>\u5b9f\u884c\u4f8b\u306f\u3053\u3093\u306a\u304b\u3093\u3058\uff0e\u3057\u304d\u3044\u5024\u3092\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306b\u5909\u3048\u306a\u304c\u3089\u7d50\u679c\u3092\u898b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff0e<\/p>\n<p><a href=\"http:\/\/daily.belltail.jp\/wp-content\/uploads\/2012\/09\/20120928_scr1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1157\" title=\"20120928_scr1\" src=\"http:\/\/daily.belltail.jp\/wp-content\/uploads\/2012\/09\/20120928_scr1.png\" alt=\"\" width=\"802\" height=\"536\" srcset=\"https:\/\/daily.belltail.jp\/wp-content\/uploads\/2012\/09\/20120928_scr1.png 802w, https:\/\/daily.belltail.jp\/wp-content\/uploads\/2012\/09\/20120928_scr1-300x200.png 300w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/daily.belltail.jp\/wp-content\/uploads\/2012\/09\/20120928_scr2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1157\" title=\"20120928_scr2\" src=\"http:\/\/daily.belltail.jp\/wp-content\/uploads\/2012\/09\/20120928_scr2.png\" alt=\"\" width=\"802\" height=\"536\" \/><\/a><\/p>\n<p>\u3051\u3063\u3053\u3046\u7dba\u9e97\u306b\u3068\u308c\u3066\u3066\uff0c\u3044\u308d\u3093\u306a\u753b\u50cf\u3092\u3044\u308c\u306a\u304c\u3089\u3084\u308b\u3068\u306a\u304b\u306a\u304b\u697d\u3057\u3044\u3067\u3059\uff0e<\/p>\n<p>\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u3057\u3066\u306e\u5b9f\u88c5\u306f\u306a\u304b\u306a\u304b\u6b8b\u5ff5\u306a\u304b\u3093\u3058\u3060\u3051\u3069\u307e\u3041OpenCV\u4f7f\u3063\u3066\u305f\u3089\u9a5a\u304f\u307b\u3069\u3067\u3082\u306a\u3044\u304b\u3068\uff08\u3053\u3089<\/p>\n<p>\u4ee5\u4e0a\uff0c\u4eca\u6708\u306e\u30bf\u30a4\u30c8\u30eb\u8a50\u6b3a\u3067\u3057\u305f\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u590f\u306e\u6691\u3055\u3082\u3060\u3044\u3076\u3084\u308f\u3089\u304e\uff0c\u304a\u3055\u304b\u306a\u304c\u7f8e\u5473\u3057\u3044\u5b63\u7bc0\u306b\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u306d\uff0e \u753b\u50cf\u304b\u3089\u306e\u7dda\u5206\u691c\u51fa\u3068\u3044\u3048\u3070Hough\u5909\u63db\u3084RANSAC\u306a\u3069\u304c\u3042\u308a\uff0c\u305d\u3093\u306a\u624b\u6cd5\u306e\u3072\u3068\u3064\u3067\u3042\u308bLSD;Line Segment Detector\u3092\u4f7f\u3063\u3066\u307f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[26,32],"class_list":["post-1153","post","type-post","status-publish","format-standard","hentry","category-1","tag-cvprml","tag-32"],"_links":{"self":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/posts\/1153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1153"}],"version-history":[{"count":0,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/posts\/1153\/revisions"}],"wp:attachment":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}