Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775

Warning: Cannot modify header information - headers already sent by (output started at /home/cra-log/www/index.php:1) in /home/cra-log/www/site-admin-wp/wp-includes/rest-api/class-wp-rest-server.php on line 1775
{"id":1153,"date":"2021-06-12T15:38:47","date_gmt":"2021-06-12T06:38:47","guid":{"rendered":"https:\/\/craft-gogo.com\/?p=1153"},"modified":"2022-02-06T22:53:04","modified_gmt":"2022-02-06T13:53:04","slug":"python-opencv-draw-figure","status":"publish","type":"post","link":"https:\/\/craft-gogo.com\/python-opencv-draw-figure\/","title":{"rendered":"Python + OpenCV\u3092\u4f7f\u3063\u3066\u56f3\u5f62\u63cf\u753b"},"content":{"rendered":"\n

OpenCV\u3092\u4f7f\u3046\u3068\u753b\u50cf\u3084\u52d5\u753b\u304b\u3089\u7279\u5b9a\u306e\u7269\u4f53\u3092\u691c\u51fa\u3059\u308b\u3053\u3068\u306a\u3069\u304c\u7c21\u5358\u306b\u51fa\u6765\u307e\u3059\u3002\u3053\u3093\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u305f\u3068\u304d\u306b\u3001\u691c\u51fa\u3057\u305f\u7269\u4f53\u3092\u67a0\u3067\u56f2\u3093\u3067\u30de\u30fc\u30af\u3057\u305f\u3044\u3067\u3059\u3088\u306d\u3002<\/p>\n\n\n\n

\u25bc\u3053\u3093\u306a\u3075\u3046\u306b<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

\u4eca\u56de\u306f\u3001OpenCV\u3092\u4f7f\u3063\u3066\u7dda\u3001\u5186\u3001\u6955\u5186\u3001\u77e9\u5f62\u3092\u63cf\u753b\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

\u56f3\u5f62\u63cf\u753b\u306e\u57fa\u672c\u30d7\u30ed\u30b0\u30e9\u30e0<\/h2>\n\n\n\n

\u307e\u305a\u3001\u56f3\u5f62\u3092\u63cf\u753b\u3059\u308b\u306e\u306b\u571f\u53f0\u3068\u306a\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4e0b\u8a18\u306b\u8a18\u3057\u307e\u3057\u305f\u3002cv.line()\u3067\u8d64\u7dda\u3092\u63cf\u3044\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u90e8\u5206\u306b\u56f3\u5f62\u63cf\u753b\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3067\u69d8\u3005\u306a\u56f3\u5f62\u3092\u63cf\u304f\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n\n\n\n

\u6b21\u7ae0\u3067\u306f\u3001\u7dda\u3001\u5186\u3001\u77e9\u5f62\u306e\u63cf\u304d\u65b9\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

import cv2 as cv\nimport numpy as np\n\n# \u9ed2\u3044\u80cc\u666f\u3092\u4f5c\u6210\nimg = np.zeros((480,640,3), np.uint8)\n\n# \u3053\u3053\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u8ffd\u52a0\u3057\u3066\u3001\u8272\u3005\u306a\u56f3\u5f62\u3092\u63cf\u304d\u307e\u3059\ncv.line(img,(0,0),(640,480),(0,0,255),10)\n\ncv.imshow("Drawing Figure", img)\nk = cv.waitKey(0)\n\nif k == ord("q"):\n    cv.destroyAllWindows()<\/code><\/pre><\/div>\n\n\n\n
\"\"<\/figure>\n\n\n\n

\u7dda\u306e\u63cf\u753b\u65b9\u6cd5<\/h2>\n\n\n\n

\u6700\u521d\u306b\u7dda\u306e\u63cf\u753b\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002\u7dda\u3092\u5f15\u304f\u306b\u306fcv.line()\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

cv.line(Img,(X0,Y0),(X1,Y1),(Blue,Green,Red),Thickness)<\/code><\/pre><\/div>\n\n\n\n
  • Img: \u7dda\u3092\u63cf\u304d\u305f\u3044\u753b\u50cf<\/li>
  • (X0,Y0): \u7dda\u306e\u5ea7\u6a19<\/li>
  • (X1,Y1): \u7dda\u306e\u7d42\u70b9\u5ea7\u6a19<\/li>
  • (Blue, Green, Red): \u7dda\u306e\u8272<\/li>
  • Thickness: \u7dda\u306e\u592a\u3055<\/li><\/ul>\n\n\n\n
    \"\"<\/figure>\n\n\n\n

    \u5ea7\u6a19\u306e\u539f\u70b9\u306f\u3001\u753b\u50cf\u306e\u5de6\u4e0a\u3067\u3059\u3002\u6c34\u5e73\u53f3\u65b9\u5411\u304cX\u5ea7\u6a19\u3001\u925b\u76f4\u4e0b\u65b9\u5411\u304cY\u5ea7\u6a19\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n

    \u7dda\u306e\u8272\u3068\u592a\u3055\u3092\u5909\u3048\u3066\u307f\u308b<\/h4>\n\n\n\n
    cv.line(img,(20, 20),(600,400),(255,0,0),1)\ncv.line(img,(20, 40),(600,420),(0,255,0),3)\ncv.line(img,(20, 60),(600,440),(0,0,255),5)<\/code><\/pre><\/div>\n\n\n\n
    \"\"<\/figure>\n\n\n\n

    \u7dda\u30bf\u30a4\u30d7\u3092\u30a2\u30f3\u30c1\u30a8\u30a4\u30ea\u30a2\u30b9\u306b\u3059\u308b\u3068\u7dda\u304c\u6ed1\u3089\u304b\u306b<\/h4>\n\n\n\n

    \u7b2c5\u5f15\u6570\u3067\u7dda\u306e\u30bf\u30a4\u30d7\u3092\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002\u7dda\u306e\u30bf\u30a4\u30d7\u306f\u7701\u7565\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n

    cv.line(img,(20, 20),(600,400),(255,0,0),3, cv.FILLED)\ncv.line(img,(20, 40),(600,420),(255,0,0),3, cv.LINE_4) # 4-connected line\ncv.line(img,(20, 60),(600,440),(255,0,0),3, cv.LINE_8) # 8-connected line (\u30c7\u30d5\u30a9\u30eb\u30c8)\ncv.line(img,(20, 80),(600,460),(255,0,0),3, cv.LINE_AA) # antialiased line<\/code><\/pre><\/div>\n\n\n\n
    \"\"<\/figure>\n\n\n\n

    \u3046\u30fc\u3093\u30fb\u30fb\u30fb\u3002\u79c1\u306b\u306f\u30a2\u30f3\u30c1\u30a8\u30a4\u30ea\u30a2\u30b9\u306e\u7dda\u4ee5\u5916\u3001\u9055\u3044\u304c\u5206\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30a2\u30f3\u30c1\u30a8\u30a4\u30ea\u30a2\u30b9\u306b\u3059\u308b\u304b\u3057\u306a\u3044\u304b\u306e\u9078\u629e\u3067\u826f\u3044\u6c17\u304c\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

    \u5186\u306e\u63cf\u753b\u65b9\u6cd5<\/h2>\n\n\n\n

    \u7d9a\u3044\u3066\u5186\u306e\u63cf\u753b\u65b9\u6cd5\u3067\u3059\u3002\u5186\u3092\u63cf\u304f\u306b\u306fcv.circle()\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

    cv.circle(Img, (X0, Y0), Radius, (Blue, Green, Red), Thickness)<\/code><\/pre><\/div>\n\n\n\n
    • Img: \u5186\u3092\u63cf\u304d\u305f\u3044\u753b\u50cf<\/li>
    • (X0,Y0): \u5186\u306e\u4e2d\u5fc3\u5ea7\u6a19<\/li>
    • Radius: \u5186\u306e\u534a\u5f84<\/li>
    • (Blue, Green, Red): \u5186\u306e\u8272<\/li>
    • Thickness: \u7dda\u306e\u592a\u3055<\/li><\/ul>\n\n\n\n
      \"\"<\/figure>\n\n\n\n

      \u5186\u306e\u5927\u304d\u3055\u3001\u8272\u3092\u5909\u3048\u3066\u307f\u308b<\/h4>\n\n\n\n
      cv.circle(img, (100, 100), 50, (255,0,0), 1)\ncv.circle(img, (150, 150), 80, (0,255,0), 3)\ncv.circle(img, (200, 200), 100, (0,0,255), 5)\ncv.circle(img, (250, 250), 130, (255,0,0), -1)<\/code><\/pre><\/div>\n\n\n\n
      \"\"<\/figure>\n\n\n\n

      \u7dda\u306e\u592a\u3055\u3092-1\u306b\u8a2d\u5b9a\u3059\u308b\u3068\u5186\u304c\u5857\u308a\u3064\u3076\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n

      \u6955\u5186\u306e\u63cf\u753b\u65b9\u6cd5<\/h2>\n\n\n\n

      \u6955\u5186\u306e\u63cf\u753b\u65b9\u6cd5\u306f\u3084\u3084\u3053\u3057\u3044\u3067\u3059\u3002<\/p>\n\n\n\n

      cv.ellipse(Img, (X0,Y0),(Width,Height),Angle,StartAngle,EndAngle,(Blue,Green,Red),Thickness)<\/code><\/pre><\/div>\n\n\n\n
      \"\"<\/figure>\n\n\n\n
      • Img: \u6955\u5186\u3092\u63cf\u304d\u305f\u3044\u753b\u50cf<\/li>
      • (X0,Y0): \u6955\u5186\u306e\u4e2d\u5fc3\u5ea7\u6a19<\/li>
      • (Width, Height): \u6955\u5186\u306e\u5e45\u3001\u9ad8\u3055<\/li>
      • Angle: \u6955\u5186\u3092\u50be\u3051\u308b\u89d2\u5ea6<\/li>
      • StartAngle: \u6955\u5186\u3092\u63cf\u304d\u59cb\u3081\u308b\u89d2\u5ea6<\/li>
      • EndAngle: \u6955\u5186\u3092\u63cf\u304d\u7d42\u308f\u308b\u89d2\u5ea6<\/li>
      • (Blue, Green, Red): \u6955\u5186\u306e\u8272<\/li>
      • Thickness: \u7dda\u306e\u592a\u3055<\/li><\/ul>\n\n\n\n

        \u6955\u5186\u306e\u5927\u304d\u3055\u3001\u8272\u3001\u89d2\u5ea6\u3092\u5909\u3048\u3066\u307f\u308b<\/h4>\n\n\n\n
        cv.ellipse(img, (100,50),(20,50),0,0,360,(255,0,0),1)\ncv.ellipse(img, (150,100),(100,50),0,45,270,(0,255,0),3)\ncv.ellipse(img, (200,150),(100,50),45,0,360,(0,0,255),5)\ncv.ellipse(img, (400,300),(200,50),0,45,180,(255,0,0),-1)<\/code><\/pre><\/div>\n\n\n\n
        \"\"<\/figure>\n\n\n\n

        \u77e9\u5f62\u306e\u63cf\u753b\u65b9\u6cd5<\/h2>\n\n\n\n
        cv.rectangle(img, (X0,Y0), (X1,Y1), (Blue, Green, Red), Thickness)<\/code><\/pre><\/div>\n\n\n\n
        • Img: \u77e9\u5f62\u3092\u63cf\u304d\u305f\u3044\u753b\u50cf<\/li>
        • (X0,Y0): \u77e9\u5f62\u306e\u5ea7\u6a19<\/li>
        • (X1,Y1): (X0,Y0)\u306e\u5bfe\u89d2\u5ea7\u6a19<\/li>
        • (Blue, Green, Red): \u77e9\u5f62\u306e\u8272<\/li>
        • Thickness: \u7dda\u306e\u592a\u3055<\/li><\/ul>\n\n\n\n
          \"\"<\/figure>\n\n\n\n

          \u77e9\u5f62\u306e\u5927\u304d\u3055\u3001\u8272\u3092\u5909\u3048\u3066\u307f\u308b<\/h4>\n\n\n\n
          cv.rectangle(img, (50,50),(150,100), (255,0,0),1)\ncv.rectangle(img, (100,150),(350,250), (0,255,0),3)\ncv.rectangle(img, (150,200),(400,300), (0,0,255),5)\ncv.rectangle(img, (350,350),(600,450), (255,0,0),-1)<\/code><\/pre><\/div>\n\n\n\n
          \"\"<\/figure>\n\n\n\n

          \u307e\u3068\u3081<\/h2>\n\n\n\n

          OpenCV\u3092\u4f7f\u3063\u3066\u7dda\u3001\u5186\u3001\u6955\u5186\u3001\u77e9\u5f62\u3092\u63cf\u753b\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n

          \u56f3\u5f62\u63cf\u753b\u306e\u95a2\u6570\u3092\u307e\u3068\u3081\u308b\u3068<\/p>\n\n\n\n

          • \u7dda\u63cf\u753b: cv.line()<\/li>
          • \u5186\u63cf\u753b: cv.circle()<\/li>
          • \u6955\u5186\u63cf\u753b: cv.ellipse()<\/li>
          • \u77e9\u5f62\u63cf\u753b: cv.rectangle()<\/li><\/ul>\n\n\n\n

            \u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

            OpenCV\u3092\u4f7f\u3046\u3068\u753b\u50cf\u3084\u52d5\u753b\u304b\u3089\u7279\u5b9a\u306e\u7269\u4f53\u3092\u691c\u51fa\u3059\u308b\u3053\u3068\u306a\u3069\u304c\u7c21\u5358\u306b\u51fa\u6765\u307e\u3059\u3002\u3053\u3093\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u305f\u3068\u304d\u306b\u3001\u691c\u51fa\u3057\u305f\u7269\u4f53\u3092\u67a0\u3067\u56f2\u3093\u3067\u30de\u30fc\u30af\u3057\u305f\u3044\u3067\u3059\u3088\u306d\u3002 \u25bc\u3053\u3093\u306a\u3075\u3046\u306b \u4eca\u56de\u306f\u3001OpenCV\u3092\u4f7f\u3063\u3066\u7dda\u3001\u5186\u3001\u6955\u5186\u3001 […]<\/p>\n","protected":false},"author":1,"featured_media":1183,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[6,5],"tags":[],"_links":{"self":[{"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/posts\/1153"}],"collection":[{"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/comments?post=1153"}],"version-history":[{"count":18,"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/posts\/1153\/revisions"}],"predecessor-version":[{"id":1184,"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/posts\/1153\/revisions\/1184"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/media\/1183"}],"wp:attachment":[{"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/media?parent=1153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/categories?post=1153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/tags?post=1153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}