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":1185,"date":"2021-06-13T20:17:15","date_gmt":"2021-06-13T11:17:15","guid":{"rendered":"https:\/\/craft-gogo.com\/?p=1185"},"modified":"2022-02-06T22:53:04","modified_gmt":"2022-02-06T13:53:04","slug":"python-opencv-drawtext","status":"publish","type":"post","link":"https:\/\/craft-gogo.com\/python-opencv-drawtext\/","title":{"rendered":"Python + OpenCV\u3092\u4f7f\u3063\u3066\u6587\u5b57\u63cf\u753b"},"content":{"rendered":"\n

\u4eca\u56de\u306fOpenCV\u3092\u4f7f\u3063\u3066\u6587\u5b57\u3092\u63cf\u753b\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

\u6587\u5b57\u306e\u5927\u304d\u3055\u3001\u30d5\u30a9\u30f3\u30c8\u3001\u592a\u3055\u3092\u69d8\u3005\u306b\u5909\u3048\u3066\u8868\u793a\u306e\u9055\u3044\u3092\u898b\u308b\u3053\u3068\u3067\u3001\u753b\u50cf\u51e6\u7406\u306a\u3069\u3067\u6587\u5b57\u63cf\u753b\u3092\u4f7f\u3046\u3068\u304d\u306b\u672c\u8a18\u4e8b\u304c\u5f79\u7acb\u3066\u308c\u3070\u3088\u3044\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n

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

\u307e\u305a\u3001\u6587\u5b57\u63cf\u753b\u306e\u571f\u53f0\u3068\u306a\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4e0b\u8a18\u306b\u793a\u3057\u307e\u3059\u3002\u6587\u5b57\u63cf\u753b\u306b\u306fcv.putText()\u3092\u4f7f\u3044\u307e\u3059\u3002\u3053\u306e\u5f15\u6570\u3092\u5909\u3048\u308b\u3053\u3068\u3067\u3001\u6587\u5b57\u306e\u5927\u304d\u3055\u3001\u30d5\u30a9\u30f3\u30c8\u3001\u8272\u3092\u5909\u3048\u308b\u3053\u3068\u304c\u51fa\u6765\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((240,640,3), np.uint8)\n\n# \u3053\u3053\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u8ffd\u52a0\u3057\u3066\u3001\u6587\u5b57\u3092\u63cf\u753b\u3057\u307e\u3059\nfont = cv.FONT_HERSHEY_SIMPLEX\ncv.putText(img,'CRAFT',(20,150),font,4,(0,255,0),2,cv.LINE_AA)\n\ncv.imshow("Draw Text", 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

\u6587\u5b57\u63cf\u753b\u306e\u65b9\u6cd5<\/h2>\n\n\n\n

\u6587\u5b57\u63cf\u753b\u306fcv.putText()\u3092\u7528\u3044\u308b\u3053\u3068\u3067\u5b9f\u73fe\u51fa\u6765\u307e\u3059\u3002<\/p>\n\n\n\n

cv.putText(img, text, (X0,Y0), fontType, scale, (Blue, Green, Red), thickness, lineType)<\/code><\/pre><\/div>\n\n\n\n
  • img: \u6587\u5b57\u3092\u63cf\u753b\u3059\u308b\u753b\u50cf<\/li>
  • text: \u63cf\u753b\u3059\u308b\u6587\u5b57<\/li>
  • (X0,Y0): \u6587\u5b57\u3092\u63cf\u753b\u3059\u308b\u5ea7\u6a19 (\u6587\u5b57\u306e\u5de6\u4e0b\u304c\u57fa\u6e96\u3068\u306a\u308a\u307e\u3059)<\/li>
  • fontType: \u30d5\u30a9\u30f3\u30c8<\/li>
  • scale: \u6587\u5b57\u306e\u5927\u304d\u3055<\/li>
  • (Blue, Green, Red): \u6587\u5b57\u306e\u8272<\/li>
  • thickness: \u6587\u5b57\u306e\u592a\u3055<\/li>
  • lineType: \u30e9\u30a4\u30f3\u30bf\u30a4\u30d7<\/li><\/ul>\n\n\n\n

    \u6587\u5b57\u306e\u5927\u304d\u3055\u3092\u5909\u3048\u3066\u307f\u308b<\/h4>\n\n\n\n

    \u6587\u5b57\u306e\u5927\u304d\u3055\u30921\uff5e4\u307e\u3067\u5909\u5316\u3055\u305b\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n

    cv.putText(img,'CRAFT',(10,30),font,1,(0,255,0),2,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,80),font,2,(0,255,0),2,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,150),font,3,(0,255,0),2,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,240),font,4,(0,255,0),2,cv.LINE_AA)<\/code><\/pre><\/div>\n\n\n\n

    \u8868\u793a\u306f\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n

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

    \u30d5\u30a9\u30f3\u30c8\u3092\u5909\u3048\u3066\u307f\u308b<\/h4>\n\n\n\n

    OpenCV\u306b\u306f\u30d5\u30a9\u30f3\u30c8\u304c9\u7a2e\u985e\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u5168\u90e8\u8868\u793a\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n

    font1 = cv.FONT_HERSHEY_SIMPLEX\nfont2 = cv.FONT_HERSHEY_PLAIN\nfont3 = cv.FONT_HERSHEY_DUPLEX\nfont4 = cv.FONT_HERSHEY_COMPLEX\nfont5 = cv.FONT_HERSHEY_TRIPLEX\nfont6 = cv.FONT_HERSHEY_COMPLEX_SMALL\nfont7 = cv.FONT_HERSHEY_SCRIPT_SIMPLEX\nfont8 = cv.FONT_HERSHEY_SCRIPT_COMPLEX\nfont9 = cv.FONT_ITALIC\ncv.putText(img,'CRAFT',(10,30),font1,1,(0,255,0),2,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,60),font2,1,(0,255,0),2,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,90),font3,1,(0,255,0),2,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,120),font4,1,(0,255,0),2,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,150),font5,1,(0,255,0),2,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,180),font6,1,(0,255,0),2,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,210),font7,1,(0,255,0),2,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,240),font8,1,(0,255,0),2,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,270),font9,1,(0,255,0),2,cv.LINE_AA)<\/code><\/pre><\/div>\n\n\n\n

    \u8868\u793a\u7d50\u679c\u3067\u3059\u3002<\/p>\n\n\n\n

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

    \u500b\u4eba\u7684\u306b\u306f\u4e0a\u304b\u30895\u756a\u76ee\u306e\u300cFONT_HERSHEY_TRIPLEX\u300d\u304c\u597d\u307f\u3067\u3059\u306d\u3002<\/p>\n\n\n\n

    \u6587\u5b57\u592a\u3055\u3092\u5909\u3048\u3066\u307f\u308b<\/h4>\n\n\n\n

    \u4eca\u5ea6\u306f\u3001\u6587\u5b57\u592a\u3055\u30921\uff5e9\u307e\u3067\u5909\u3048\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n

    font = cv.FONT_HERSHEY_SIMPLEX\ncv.putText(img,'CRAFT',(10,30),font,1,(0,255,0),1,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,60),font,1,(0,255,0),2,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,90),font,1,(0,255,0),3,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,120),font,1,(0,255,0),4,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,150),font,1,(0,255,0),5,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,180),font,1,(0,255,0),6,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,210),font,1,(0,255,0),7,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,240),font,1,(0,255,0),8,cv.LINE_AA)\ncv.putText(img,'CRAFT',(10,270),font,1,(0,255,0),9,cv.LINE_AA)<\/code><\/pre><\/div>\n\n\n\n

    \u8868\u793a\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n\n\n\n

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

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

    OpenCV\u3092\u4f7f\u3063\u3066\u6587\u5b57\u3092\u63cf\u753b\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n

    \u6587\u5b57\u3092\u63cf\u753b\u3059\u308b\u95a2\u6570\u306f\u3001cv.putText()\u3067\u3059\u3002<\/p>\n\n\n\n

    \u4eca\u56de\u3001\u6587\u5b57\u306e\u5927\u304d\u3055\u3001\u30d5\u30a9\u30f3\u30c8\u3001\u592a\u3055\u3092\u5909\u3048\u3001\u8868\u793a\u306e\u9055\u3044\u3092\u78ba\u8a8d\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n

    \u753b\u50cf\u51e6\u7406\u306a\u3069\u3067\u6587\u5b57\u63cf\u753b\u3092\u5b9f\u969b\u306b\u4f7f\u3046\u6642\u306e\u30a4\u30e1\u30fc\u30b8\u304c\u3064\u304b\u3081\u305f\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n\n\n\n

    \u3053\u308c\u304b\u3089\u3082OpenCV\u306e\u4f7f\u3044\u65b9\u3092\u89e3\u8aac\u3057\u3066\u3044\u304f\u4e88\u5b9a\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u4eca\u56de\u306fOpenCV\u3092\u4f7f\u3063\u3066\u6587\u5b57\u3092\u63cf\u753b\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002 \u6587\u5b57\u306e\u5927\u304d\u3055\u3001\u30d5\u30a9\u30f3\u30c8\u3001\u592a\u3055\u3092\u69d8\u3005\u306b\u5909\u3048\u3066\u8868\u793a\u306e\u9055\u3044\u3092\u898b\u308b\u3053\u3068\u3067\u3001\u753b\u50cf\u51e6\u7406\u306a\u3069\u3067\u6587\u5b57\u63cf\u753b\u3092\u4f7f\u3046\u3068\u304d\u306b\u672c\u8a18\u4e8b\u304c\u5f79\u7acb\u3066\u308c\u3070\u3088\u3044\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002 \u6587\u5b57\u63cf\u753b\u306e\u57fa\u672c […]<\/p>\n","protected":false},"author":1,"featured_media":1190,"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\/1185"}],"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=1185"}],"version-history":[{"count":10,"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/posts\/1185\/revisions"}],"predecessor-version":[{"id":1201,"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/posts\/1185\/revisions\/1201"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/media\/1190"}],"wp:attachment":[{"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/media?parent=1185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/categories?post=1185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/craft-gogo.com\/wp-json\/wp\/v2\/tags?post=1185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}