{"id":5418,"date":"2021-04-24T15:39:50","date_gmt":"2021-04-24T06:39:50","guid":{"rendered":"https:\/\/kats-eye.net\/info\/?p=5418"},"modified":"2021-06-10T20:52:31","modified_gmt":"2021-06-10T11:52:31","slug":"opencv_hough","status":"publish","type":"post","link":"https:\/\/kats-eye.net\/info\/2021\/04\/24\/opencv_hough\/","title":{"rendered":"\u30e9\u30ba\u30d1\u30a4\uff14 \u3067OpenCV\u306e\u30cf\u30d5\uff08HougH\uff09\u5909\u63db\u3092\u4f7f\u3063\u3066\u3001\u79d2\u91dd\u3092\u8aad\u3080"},"content":{"rendered":"\n<h2>\u6982\u8981<\/h2>\n\n\n\n<p>\u3000\u5148\u56de\u3001\u30e9\u30ba\u30d1\u30a4\uff14\u306b pypylon \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001Basler\u793e\u30ab\u30e1\u30e9\u3092\u4f7f\u3048\u308b\u69d8\u306b\u3057\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306f\u8fd1\u6240\u306e\u96fb\u6c17\u5c4b\u3055\u3093\u3067\u6bd4\u8f03\u7684\u30ea\u30fc\u30ba\u30ca\u30d6\u30eb\u306b\u8cfc\u5165\u3067\u304d\u308bweb\u30ab\u30e1\u30e9\u3092\u4f7f\u3063\u3066\u307f\u307e\u3059\u3002<br>\u3000\u307e\u305f\u3001OpenCV\u306e\u30cf\u30d5\uff08Hough\uff09\u5909\u63db\u3068\u3044\u3046\u51e6\u7406\u3092\u4f7f\u3063\u3066\u3001\u6c34\u5e73\u65b9\u5411\u306e\u30b9\u30de\u30db\u6642\u8a08\u306e\u4f4d\u7f6e\u30fb\u50be\u304d\u3092\u691c\u51fa\u3057\u3001\u79d2\u91dd\u3092\u8aad\u307f\u53d6\u308b\u691c\u8a0e\u3092\u3057\u307e\u3057\u305f\u3002\u5965\u884c\u65b9\u5411\u79fb\u52d5\u306f\u4eca\u56de\u672a\u691c\u8a0e\u3067\u3059\u3002<\/p>\n\n\n\n<!-- START MoshimoAffiliateEasyLink -->\n<script type=\"text\/javascript\">\n(function(b,c,f,g,a,d,e){b.MoshimoAffiliateObject=a;\nb[a]=b[a]||function(){arguments.currentScript=c.currentScript\n||c.scripts[c.scripts.length-2];(b[a].q=b[a].q||[]).push(arguments)};\nc.getElementById(a)||(d=c.createElement(f),d.src=g,\nd.id=a,e=c.getElementsByTagName(\"body\")[0],e.appendChild(d))})\n(window,document,\"script\",\"\/\/dn.msmstatic.com\/site\/cardlink\/bundle.js?20210203\",\"msmaflink\");\nmsmaflink({\"n\":\"LABISTS Raspberry Pi 4 4B-32GB\uff08\u6280\u9069\u30de\u30fc\u30af\u5165\uff09MicroSDHC\u30ab\u30fc\u30c932G\\\/NOOBS\u30b7\u30b9\u30c6\u30e0\u30d7\u30ea\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\\\/\u30ab\u30fc\u30c9\u30ea\u30fc\u30c0 \\\/5.1V\\\/3A Type-C \u30b9\u30a4\u30c3\u30c1\u4ed8\u96fb\u6e90\\\/MicroHDMI-to-HDMI\u30b1\u30fc\u30d6\u30eb\u30e9\u30a4\u30f3\\\/\u4e09\u3064\u30d2\u30fc\u30c8\u30b7\u30f3\u30af\\\/\u7c21\u5358\u306b\u53d6\u308a\u4ed8\u3051\u30b1\u30fc\u30b9\\\/\u65e5\u672c\u8a9e\u53d6\u6271\u8aac\u660e\u66f8\\\/\uff12\uff14\u30f6\u6708\u4fdd\u8a3c\",\"b\":\"LABISTS\",\"t\":\"Ras-4B-4GB-JP\",\"d\":\"https:\\\/\\\/m.media-amazon.com\",\"c_p\":\"\\\/images\\\/I\",\"p\":[\"\\\/51yb9HfX7xL._SL500_.jpg\",\"\\\/51fce-L9HHL._SL500_.jpg\",\"\\\/51XQT5IIfaL._SL500_.jpg\",\"\\\/5138BQYoRqL._SL500_.jpg\",\"\\\/51SPaXAArwL._SL500_.jpg\",\"\\\/41tl9GHJSdL._SL500_.jpg\",\"\\\/5124+v+JwvL._SL500_.jpg\",\"\\\/411GNQKg9LL._SL500_.jpg\",\"\\\/51ar4osZpgL._SL500_.jpg\"],\"u\":{\"u\":\"https:\\\/\\\/www.amazon.co.jp\\\/dp\\\/B084WT4G3P\",\"t\":\"amazon\",\"r_v\":\"\"},\"v\":\"2.1\",\"b_l\":[{\"id\":1,\"u_tx\":\"Amazon\u3067\u898b\u308b\",\"u_bc\":\"#f79256\",\"u_url\":\"https:\\\/\\\/www.amazon.co.jp\\\/dp\\\/B084WT4G3P\",\"a_id\":1848374,\"p_id\":170,\"pl_id\":27060,\"pc_id\":185,\"s_n\":\"amazon\",\"u_so\":1}],\"eid\":\"fKWSf\",\"s\":\"s\"});\n<\/script>\n<div id=\"msmaflink-fKWSf\">\u30ea\u30f3\u30af<\/div>\n<!-- MoshimoAffiliateEasyLink END -->\n\n\n\n<h2>\u7d50\u679c<\/h2>\n\n\n\n<p>\u3000\u6b21\u52d5\u753b\u306e\u901a\u308a \u5de6\u4e0a\u306b\u79d2\u91dd\u8aad\u53d6\u7d50\u679c\u3092\u6c34\u8272\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002\u9014\u4e2d\u3067\u6642\u8a08\u3092\u6c34\u5e73\u79fb\u52d5\u3057\u307e\u3059\u304c\u3001\u4f4d\u7f6e\u30fb\u50be\u304d\u3092\u88dc\u6b63\u3057\u7d50\u679c\u8868\u793a\u3057\u307e\u3059\u3002\u7d30\u304f\u306f\u3044\u308d\u3044\u308d\u8ab2\u984c\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u52d5\u3044\u3066\u304f\u308c\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-video aligncenter\"><video controls src=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2021\/04\/watch_detector.mp4\"><\/video><figcaption>\u3010 \u30b9\u30de\u30db\u30b9\u30c8\u30c3\u30d7\u30a6\u30a9\u30c3\u30c1\u306e\u79d2\u91dd\u3092\u8aad\u3080 \u3011<\/figcaption><\/figure>\n\n\n\n<!-- START MoshimoAffiliateEasyLink --><script type=\"text\/javascript\">(function(b,c,f,g,a,d,e){b.MoshimoAffiliateObject=a;b[a]=b[a]||function(){arguments.currentScript=c.currentScript||c.scripts[c.scripts.length-2];(b[a].q=b[a].q||[]).push(arguments)};c.getElementById(a)||(d=c.createElement(f),d.src=g,d.id=a,e=c.getElementsByTagName(\"body\")[0],e.appendChild(d))})(window,document,\"script\",\"\/\/dn.msmstatic.com\/site\/cardlink\/bundle.js?20210203\",\"msmaflink\");msmaflink({\"n\":\"\u30ed\u30b8\u30af\u30fc\u30eb \u30a6\u30a7\u30d6\u30ab\u30e1\u30e9 C920n \u30d6\u30e9\u30c3\u30af \u30d5\u30ebHD 1080P \u30a6\u30a7\u30d6\u30ab\u30e0 \u30b9\u30c8\u30ea\u30fc\u30df\u30f3\u30b0 \u81ea\u52d5\u30d5\u30a9\u30fc\u30ab\u30b9 \u30b9\u30c6\u30ec\u30aa\u30de\u30a4\u30af \u56fd\u5185\u6b63\u898f\u54c1 2\u5e74\u9593\u30e1\u30fc\u30ab\u30fc\u4fdd\u8a3c \u30d6\u30e9\u30c3\u30af\",\"b\":\"Logicool(\u30ed\u30b8\u30af\u30fc\u30eb)\",\"t\":\"960-001261\",\"d\":\"https:\\\/\\\/m.media-amazon.com\",\"c_p\":\"\\\/images\\\/I\",\"p\":[\"\\\/41BprZjZbQL._SL500_.jpg\",\"\\\/41cwunXEPbL._SL500_.jpg\",\"\\\/41ryXZBta3L._SL500_.jpg\",\"\\\/41fkxKPtW1L._SL500_.jpg\",\"\\\/41IpXzF0nDL._SL500_.jpg\",\"\\\/51BSaVSIA-L._SL500_.jpg\",\"\\\/41cjvQN4OkL._SL500_.jpg\",\"\\\/41EQBtTghhL._SL500_.jpg\",\"\\\/41QntRco+UL._SL500_.jpg\"],\"u\":{\"u\":\"https:\\\/\\\/www.amazon.co.jp\\\/dp\\\/B07QQR6G5N\",\"t\":\"amazon\",\"r_v\":\"\"},\"v\":\"2.1\",\"b_l\":[{\"id\":1,\"u_tx\":\"Amazon\u3067\u898b\u308b\",\"u_bc\":\"#f79256\",\"u_url\":\"https:\\\/\\\/www.amazon.co.jp\\\/dp\\\/B07QQR6G5N\",\"a_id\":1848374,\"p_id\":170,\"pl_id\":27060,\"pc_id\":185,\"s_n\":\"amazon\",\"u_so\":1},{\"id\":2,\"u_tx\":\"\u697d\u5929\u5e02\u5834\u3067\u898b\u308b\",\"u_bc\":\"#f76956\",\"u_url\":\"https:\\\/\\\/search.rakuten.co.jp\\\/search\\\/mall\\\/%E3%83%AD%E3%82%B8%E3%82%AF%E3%83%BC%E3%83%AB%20%E3%82%A6%E3%82%A7%E3%83%96%E3%82%AB%E3%83%A1%E3%83%A9%20C920n%20%E3%83%96%E3%83%A9%E3%83%83%E3%82%AF%20%E3%83%95%E3%83%ABHD%201080P%20%E3%82%A6%E3%82%A7%E3%83%96%E3%82%AB%E3%83%A0%20%E3%82%B9%E3%83%88%E3%83%AA%E3%83%BC%E3%83%9F%E3%83%B3%E3%82%B0%20%E8%87%AA%E5%8B%95%E3%83%95%E3%82%A9%E3%83%BC%E3%82%AB%E3%82%B9%20%E3%82%B9%E3%83%86%E3%83%AC%E3%82%AA%E3%83%9E%E3%82%A4%E3%82%AF%20%E5%9B%BD%E5%86%85%E6%AD%A3%E8%A6%8F%E5%93%81%202%E5%B9%B4%E9%96%93%E3%83%A1%E3%83%BC%E3%82%AB%E3%83%BC%E4%BF%9D%E8%A8%BC%20%E3%83%96%E3%83%A9%E3%83%83%E3%82%AF\\\/\",\"a_id\":1848376,\"p_id\":54,\"pl_id\":27059,\"pc_id\":54,\"s_n\":\"rakuten\",\"u_so\":2},{\"id\":3,\"u_tx\":\"Yahoo!\u30b7\u30e7\u30c3\u30d4\u30f3\u30b0\u3067\u898b\u308b\",\"u_bc\":\"#66a7ff\",\"u_url\":\"https:\\\/\\\/shopping.yahoo.co.jp\\\/search?first=1\\u0026p=%E3%83%AD%E3%82%B8%E3%82%AF%E3%83%BC%E3%83%AB%20%E3%82%A6%E3%82%A7%E3%83%96%E3%82%AB%E3%83%A1%E3%83%A9%20C920n%20%E3%83%96%E3%83%A9%E3%83%83%E3%82%AF%20%E3%83%95%E3%83%ABHD%201080P%20%E3%82%A6%E3%82%A7%E3%83%96%E3%82%AB%E3%83%A0%20%E3%82%B9%E3%83%88%E3%83%AA%E3%83%BC%E3%83%9F%E3%83%B3%E3%82%B0%20%E8%87%AA%E5%8B%95%E3%83%95%E3%82%A9%E3%83%BC%E3%82%AB%E3%82%B9%20%E3%82%B9%E3%83%86%E3%83%AC%E3%82%AA%E3%83%9E%E3%82%A4%E3%82%AF%20%E5%9B%BD%E5%86%85%E6%AD%A3%E8%A6%8F%E5%93%81%202%E5%B9%B4%E9%96%93%E3%83%A1%E3%83%BC%E3%82%AB%E3%83%BC%E4%BF%9D%E8%A8%BC%20%E3%83%96%E3%83%A9%E3%83%83%E3%82%AF\",\"a_id\":1848375,\"p_id\":1225,\"pl_id\":27061,\"pc_id\":1925,\"s_n\":\"yahoo\",\"u_so\":3}],\"eid\":\"iyP1f\",\"s\":\"s\"});<\/script><div id=\"msmaflink-iyP1f\">\u30ea\u30f3\u30af<\/div><!-- MoshimoAffiliateEasyLink END -->\n\n\n\n<h2>\u51e6\u7406\u30d5\u30ed\u30fc<\/h2>\n\n\n\n<p>\u3000\u51e6\u7406\u30d5\u30ed\u30fc\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<br>\u3000\u2460\u3000\u30cf\u30d5\u5909\u63db\uff08\u5186\uff09\u3067\u6642\u8a08\u90e8\u3068\u4e2d\u5fc3\u5ea7\u6a19\u3092\u691c\u51fa\uff08\u9ec4\u7dd1\u8272\uff09<br>\u3000\u2461\u3000\u30cf\u30d5\u5909\u63db\uff08\u76f4\u7dda\uff09\u3067\u79d2\u91dd\uff08\u30d4\u30f3\u30af\uff09\u691c\u51fa<br>\u3000\u3000\u3000\u691c\u51fa\u76f4\u7dda\u3067\u5186\u4e2d\u5fc3\u306b\u6700\u3082\u8fd1\u3044\u3082\u306e\u3092\u79d2\u91dd\u3068\u5224\u5b9a<br>\u3000\u2462\u3000\u79d2\u91dd\u306e\u59cb\u70b9\u3092\u5186\u4e2d\u5fc3\u306b\u8fd1\u3044\u5074\u3068\u3057\u3066\u50be\u304d\u8a08\u7b97<br>\u3000\u2463\u3000\u30cf\u30d5\u5909\u63db\uff08\u76f4\u7dda\uff09\u3067\u30b9\u30de\u30db\u4e0a\u7aef\uff08\u6c34\u8272\uff09\u691c\u51fa<br>\u3000\u3000\u3000\u5186\u4e2d\u5fc3\u304b\u3089\u306e\u8ddd\u96e2\u3068\u50be\u304d\uff08\uff11\uff10\u5ea6\u4ee5\u5185\uff09\u3067\u5224\u5b9a<br>\u3000\u2464\u3000\u79d2\u91dd\u50be\u304d\u3068\u30b9\u30de\u30db\u50be\u304d\u304b\u3089\u3001\u7d4c\u904e\u6642\u9593\uff08\u79d2\uff09\u8a08\u7b97<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" width=\"642\" height=\"558\" src=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2021\/04\/screen_main.png\" alt=\"\" class=\"wp-image-5426\" srcset=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2021\/04\/screen_main.png 642w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2021\/04\/screen_main-300x261.png 300w\" sizes=\"(max-width: 642px) 100vw, 642px\" \/><figcaption>\u3000\u3000<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u3000OpenCV\u306e\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306f\u3001\u30cf\u30d5\u5909\u63db\uff08\u76f4\u7dda\uff09\u524d\u306bCanny\u6cd5\u3067\u30a8\u30c3\u30b8\u691c\u51fa\u3057\u3066\u3044\u308b\u306e\u3067\u540c\u3058\u69d8\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u53c2\u8003\u307e\u3067\u306b\u51e6\u7406\u7d50\u679c\u306f\u6b21\u306e\u69d8\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" width=\"642\" height=\"558\" src=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2021\/04\/screen_canny.png\" alt=\"\" class=\"wp-image-5427\" srcset=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2021\/04\/screen_canny.png 642w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2021\/04\/screen_canny-300x261.png 300w\" sizes=\"(max-width: 642px) 100vw, 642px\" \/><figcaption>\u3000\u3000<\/figcaption><\/figure><\/div>\n\n\n\n<h2>\u30d7\u30ed\u30b0\u30e9\u30e0<\/h2>\n\n\n\n<p>\u3000\u4eca\u56de\u306e\u30c6\u30b9\u30c8\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-file=\"008_Hough_Circles_Lines.py\" data-lang=\"Python\"><code>import cv2\nimport math\nimport numpy as np\nimport time\n\n\nx3 = 0              # \u79d2\u91dd\u4e2d\u5fc3\u5ea7\u6a19\u521d\u671f\u5316\uff08\uff58\uff09\ny3 = 0              # \u79d2\u91dd\u4e2d\u5fc3\u5ea7\u6a19\u521d\u671f\u5316\uff08\uff59\uff09\nsec_trs=0           # \u7d4c\u904e\u6642\u9593\nang_pin=0           # \u79d2\u91dd\u89d2\u5ea6\nang_hsi=0           # \u88dc\u6b63\u89d2\u5ea6\npic_cnt=0           # \u753b\u50cf\u4fdd\u5b58\u679a\u6570\n\ncapture = cv2.VideoCapture(0)\nif capture.isOpened() is False:\n  raise IOError\n\n# \u30eb\u30fc\u30d7\u51e6\u7406\nwhile(True):\n  try:\n    ret, frame = capture.read()\n    if ret is False:\n      raise IOError\n\n    img_gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)       # \u30b0\u30ec\u30a4\u5909\u63db\n    edges = cv2.Canny(img_gray,10,220,apertureSize=3)       # \u30a8\u30c3\u30b8\u691c\u51fa\n\n    # \u30cf\u30d5\u5909\u63db\u3067\u6642\u8a08\u90e8\u5186\u691c\u51fa \uff08\u534a\u5f84\u7b49\u6761\u4ef6\u8a2d\u5b9a\u306b\u3088\u308a\u3001\u6642\u8a08\u90e8\u306e\u307f\u691c\u51fa\u3059\u308b\u69d8\u306b\u3057\u3066\u3044\u308b\uff09\n    circles=cv2.HoughCircles(img_gray,cv2.HOUGH_GRADIENT,1,30,param1=70,param2=30,minRadius=80,maxRadius=110)\n    cnt_cntr=0\n    if circles is not None:\n      for cx,cy,r in circles.squeeze(axis=0).astype(int):\n        cv2.circle(frame,(cx,cy),r,(0,255,0),2)\n        cv2.circle(frame,(cx,cy),1,(0,0,255),3)\n        x3_tmp = cx\n        y3_tmp = cy\n        cnt_cntr = cnt_cntr + 1\n\n    if cnt_cntr==1:\n      x3 = x3_tmp\n      y3 = y3_tmp\n\n    if x3 &gt; 0 and y3 &gt; 0 :\n      # \u30cf\u30d5\u5909\u63db\u3067\u76f4\u7dda\u62bd\u51fa   \n      lines = cv2.HoughLinesP(edges, rho=1, theta=np.pi\/180, threshold=90,minLineLength=20,maxLineGap=5)\n      ang_hsi =0\n      \n      if lines is not None:  \n        for line in lines:\n          x1 , y1 , x2 , y2 = line[0]                       # \u691c\u51fa\u76f4\u7dda\u59cb\u70b9\u30fb\u7d42\u70b9\u5ea7\u6a19\u53d6\u5f97\n\n          # \u5186\u4e2d\u5fc3\u3068\u691c\u51fa\u3057\u305f\u76f4\u7dda\u306e\u8ddd\u96e2\u8a08\u7b97\n          u = np.array([ x2-x1 , y2-y1 ])\n          v = np.array([ x3-x1 , y3-y1 ])\n          D_CTR = math.floor(abs(np.cross(u,v) \/ np.linalg.norm(u))) \n          \n          D_P1 = math.sqrt((x1-x3)**2+(y1-y3)**2)           # \u5186\u4e2d\u5fc3\u3068\u76f4\u7dda\u59cb\u70b9\u306e\u8ddd\u96e2\u8a08\u7b97\n          D_P2 = math.sqrt((x2-x3)**2+(y2-y3)**2)           # \u5186\u4e2d\u5fc3\u3068\u76f4\u7dda\u7d42\u70b9\u306e\u8ddd\u96e2\u8a08\u7b97\n\n          # \u8ddd\u96e2\u304c\u77ed\u3044\u70b9\u3092\u59cb\u70b9\u3068\u3057\u3066\u89d2\u5ea6\u8a08\u7b97(\u30e9\u30b8\u30a2\u30f3)\n          if D_P1 &gt; D_P2 and D_CTR &lt; 10:\n            rslt_rad = math.atan2( y1-y2 , x1-x2 )\n          else :\n            rslt_rad = math.atan2( y2-y1 , x2-x1 ) \n            \n          rslt_ang = math.degrees(rslt_rad)                 # \u30e9\u30b8\u30a2\u30f3\u304b\u3089\u89d2\u5ea6\u5909\u63db\n\n          # \uff10\u79d2=\uff10\u5ea6\u3068\u3057\u3066\u3001\u89d2\u5ea6\u5909\u63db\n          if rslt_ang &gt; -90 :\n            rslt_ang_360 = rslt_ang + 90\n          else :\n            rslt_ang_360 = rslt_ang + 450\n\n          dsp_ang = str(math.floor(rslt_ang_360))\n  \n          if D_CTR &lt; 10:\n            # \u5186\u4e2d\u5fc3\u304b\u3089\u306e\u8ddd\u96e2\u304c\uff11\uff10\u4ee5\u4e0b \u2192 \u79d2\u91dd\u3068\u5224\u5b9a\n            cv2.putText(frame,dsp_ang,(x2,y2),cv2.FONT_HERSHEY_PLAIN,2,(255,0,255),1,cv2.LINE_AA)\n            cv2.line(frame,(x1,y1),(x2,y2),(255,0,255),3)   # \u79d2\u91dd\u63cf\u753b\uff08\u30d4\u30f3\u30af\uff09\n            ang_pin = rslt_ang_360\n      \n          else:\n            # \u79d2\u91dd\u4ee5\u5916\u306b\u691c\u51fa\u3057\u305f\u76f4\u7dda\n            if rslt_ang &lt; 15 and rslt_ang &gt; -15 and D_CTR &gt; 150 and D_CTR &lt; 220 and y1 &lt; y3 and y2 &lt; y3 :\n              # \u30b9\u30af\u30ea\u30fc\u30f3\u4e0a\u5074\u306e\u6c34\u5e73\u65b9\u5411\u76f4\u7dda\uff08\u50be\u304d\uff11\uff10\u5ea6\u4ee5\u5185 + \u4ed6\u6761\u4ef6\uff09\n              cv2.putText(frame,str(math.floor(rslt_ang))+&quot;,D&quot; + str(D_CTR),(x1,y1+30),cv2.FONT_HERSHEY_PLAIN,1,(255,125,0),1,cv2.LINE_AA)\n              cv2.line(frame,(x1,y1),(x2,y2),(255,255,0),3) # \u30b9\u30af\u30ea\u30fc\u30f3\u4e0a\u5074\u6c34\u5e73\u65b9\u5411\u76f4\u7dda\uff08\u6c34\u8272\uff09\n              ang_hsi = rslt_ang                            # \u88dc\u6b63\u89d2\u5ea6\u8a18\u61b6\n              \n            else:\n              # \u305d\u306e\u4ed6\u306e\u691c\u51fa\u3057\u305f\u76f4\u7dda\n              #cv2.putText(frame,str(math.floor(rslt_ang))+&quot;,D&quot; + str(D_CTR),(x1,y1-10),cv2.FONT_HERSHEY_PLAIN,1,(0,0,255),1,cv2.LINE_AA)\n              cv2.line(frame,(x1,y1),(x2,y2),(0,0,255),2)   # \u8d64\u8272\u76f4\u7dda\n           \n        \n  except KeyboardInterrupt:\n    cv2.putText(frame,&quot;Error&quot;,(25,25),cv2.FONT_HERSHEY_PLAIN,2,(0,0,255),1,cv2.LINE_AA)\n\n  # \u89d2\u5ea6\u304b\u3089\u79d2\u306b\u5909\u63db\uff08\u79d2\u91dd\u50be\u304d\u3068\u88dc\u6b63\u89d2\u5ea6\u8003\u616e\uff09\n  sec_trs = math.floor( 60 * (ang_pin - ang_hsi) \/ 360 )\n  if sec_trs&lt;=0:\n    sec_trs = 60+sec_trs\n  if sec_trs&gt;=60:\n    sec_trs = sec_trs-60  \n\n  # \u7d4c\u904e\u6642\u9593\u30fb\u6642\u8a08\u90e8\u4e2d\u5fc3\u5ea7\u6a19\u7b49\u3001\u8868\u793a\u8ffd\u52a0\n  cv2.putText(frame,&quot;TIME : &quot;+str(sec_trs)+&quot;sec&quot;,(15,45),cv2.FONT_HERSHEY_PLAIN,3,(255,255,0),1,cv2.LINE_AA)\n  cv2.putText(frame,&quot;( Center Of Circle : &quot;+str(x3)+&quot; , &quot;+str(y3) + &quot; )&quot;,(350,25),cv2.FONT_HERSHEY_PLAIN,1,(0,255,255),1,cv2.LINE_AA)\n\n  edges_rgb=cv2.cvtColor(edges,cv2.COLOR_GRAY2RGB)        # \u753b\u50cf\u5408\u6210\u7528\u306b\u5909\u63db\n  cv2.putText(edges_rgb,&quot;Canny Edge Detection&quot;,(15,45),cv2.FONT_HERSHEY_PLAIN,3,(0,0,255),1,cv2.LINE_AA)\n\n  img_mrg=cv2.hconcat([edges_rgb,frame])                  # \u753b\u50cf\u5408\u6210\n  cv2.imshow( &#39;img_mrg&#39; , img_mrg )\n\n  cv2.imshow(&#39;frame&#39;,frame)\n  #cv2.imshow(&#39;edges&#39;,edges_rgb)\n\n  time.sleep(0.09)\n\n  # ESC\u3067\u51e6\u7406\u4e2d\u65ad\n  k = cv2.waitKey(1)\n  if k==27:\n    break\n\ncapture.release()\ncv2.destroyAllWindows()<\/code><\/pre><\/div>\n\n\n\n<h2>\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u3000\u7167\u660e\u30fb\u80cc\u666f\u8272\u30fb\u79fb\u52d5\u7bc4\u56f2\u7b49\u3092\u3042\u308b\u7a0b\u5ea6\u9650\u5b9a\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u6642\u8a08\u79fb\u52d5\u306b\u8ffd\u5f93\u3057\u3066\u3001\u79d2\u91dd\u3092\u89e3\u6790\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3057\u305f\u3002\u305f\u3060\u3001\u9023\u7d9a\u3057\u3066\u52d5\u304b\u3059\u3068\u3001\u8aa4\u8a8d\u8b58\u7b49\u3082\u3042\u308b\u306e\u3067\u4eca\u5f8c\u306e\u8ab2\u984c\u3068\u3057\u3066\u8a8d\u8b58\u3057\u3066\u304a\u304d\u307e\u3059\u3002<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 \u3000\u5148\u56de\u3001\u30e9\u30ba\u30d1\u30a4\uff14\u306b pypylon \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001Basler\u793e\u30ab\u30e1\u30e9\u3092\u4f7f\u3048\u308b\u69d8\u306b\u3057\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306f\u8fd1\u6240\u306e\u96fb\u6c17\u5c4b\u3055\u3093\u3067\u6bd4\u8f03\u7684\u30ea\u30fc\u30ba\u30ca\u30d6\u30eb\u306b\u8cfc\u5165\u3067\u304d\u308bweb\u30ab\u30e1\u30e9\u3092\u4f7f\u3063\u3066\u307f\u307e\u3059\u3002\u3000\u307e\u305f\u3001OpenCV\u306e\u30cf\u30d5\uff08Ho &hellip; <a href=\"https:\/\/kats-eye.net\/info\/2021\/04\/24\/opencv_hough\/\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u30e9\u30ba\u30d1\u30a4\uff14 \u3067OpenCV\u306e\u30cf\u30d5\uff08HougH\uff09\u5909\u63db\u3092\u4f7f\u3063\u3066\u3001\u79d2\u91dd\u3092\u8aad\u3080<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":5423,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[110],"tags":[159,119,116,111],"_links":{"self":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts\/5418"}],"collection":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/comments?post=5418"}],"version-history":[{"count":19,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts\/5418\/revisions"}],"predecessor-version":[{"id":5990,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts\/5418\/revisions\/5990"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/media\/5423"}],"wp:attachment":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/media?parent=5418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/categories?post=5418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/tags?post=5418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}