{"id":33,"date":"2012-06-20T03:59:00","date_gmt":"2012-06-19T18:59:00","guid":{"rendered":"http:\/\/cms.inter-arteq.com\/?p=33"},"modified":"2022-03-05T14:39:13","modified_gmt":"2022-03-05T05:39:13","slug":"background_substraction_with_processing_and_opencv","status":"publish","type":"post","link":"http:\/\/cms.inter-arteq.com\/background_substraction_with_processing_and_opencv\/","title":{"rendered":"Processing+OpenCV\u3067\u80cc\u666f\u5dee\u5206"},"content":{"rendered":"\n

\u5f8c\u8f29\u304b\u3089Processing\u3068OpenCV\u3067\u80cc\u666f\u5dee\u5206\u3092\u53d6\u308a\u305f\u3044\u3068\u76f8\u8ac7\u3092\u53d7\u3051\u305f\u305f\u3081\u3001\u305d\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u3064\u304f\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n

\u3053\u306e\u8a18\u4e8b\u3067\u306fProcessing\u3068OpenCV\u3092\u4f7f\u3063\u3066\u80cc\u666f\u5dee\u5206\u3092\u53d6\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n

\u5927\u307e\u304b\u306a\u6d41\u308c<\/h2>\n\n\n\n
  1. \u30ab\u30e1\u30e9\u3067\u4e88\u3081\u80cc\u666f\u753b\u50cf\u3092\u53d6\u5f97\u3059\u308b<\/li>
  2. \u30ab\u30e1\u30e9\u3067\u53d6\u5f97\u3057\u305f\u753b\u50cf\u3092\u53d6\u5f97\u3059\u308b<\/li>
  3. \u80cc\u666f\u753b\u50cf\u3068\u53d6\u5f97\u753b\u50cf\u3092\u30b0\u30ec\u30fc\u30b9\u30b1\u30fc\u30eb\u306b\u5909\u63db\u3059\u308b<\/li>
  4. 2\u679a\u306e\u30b0\u30ec\u30fc\u30b9\u30b1\u30fc\u30eb\u306e\u753b\u50cf\u306e\u5dee\u306e\u7d76\u5bfe\u5024\u3092\u53d6\u5f97\u3059\u308b<\/li>
  5. \u51fa\u6765\u4e0a\u304c\u3063\u305f\u5dee\u5206\u753b\u50cf\u3092\u30d5\u30a3\u30eb\u30bf\u30fc\u3067\u30ce\u30a4\u30ba\u51e6\u7406\u3059\u308b<\/li>
  6. \u3042\u308b\u4e00\u5b9a\u4ee5\u4e0a\u5dee\u304c\u5927\u304d\u3044\u90e8\u5206\u3092255, \u305d\u308c\u4ee5\u5916\u30920\u3068\u3057\u30662\u5024\u5316\u3059\u308b<\/li><\/ol>\n\n\n\n

    \u30b3\u30fc\u30c9<\/h2>\n\n\n\n
    import hypermedia.video.*;\n\nOpenCV opencv; \/\/OpenCV\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3059\u3002\nPImage binImage; \/\/ \u3053\u308c\u304c\u6700\u7d42\u76ee\u6a19(\u5909\u308f\u3063\u305f\u90e8\u5206\u304c\u767d\u3001\u5909\u308f\u3089\u306a\u304b\u3063\u305f\u90e8\u5206\u304c\u9ed2\u306e\u4e8c\u5024\u753b\u50cf)\nboolean bLearnBgImage = true; \/\/ \u80cc\u666f\u753b\u50cf\u3092\u64ae\u308b\u30d5\u30e9\u30b0\n\nvoid setup(){\n  size(640, 480);\n  opencv = new OpenCV(this);\n  opencv.capture(width, height);\n}\n\nvoid draw(){\n  opencv.read(); \/\/ \u30ab\u30e1\u30e9\u304b\u3089\u753b\u50cf\u3092\u53d6\u5f97\n  opencv.flip(OpenCV.FLIP_HORIZONTAL); \/\/ \u93e1\u5199\u3057\u306b\u3059\u308b\n\n  if(bLearnBgImage){ \/\/ \u80cc\u666f\u64ae\u308b\u306a\u3089\n    opencv.remember(OpenCV.SOURCE, OpenCV.FLIP_HORIZONTAL); \/\/ \u30e1\u30e2\u30ea\u30fc\u306b\u753b\u50cf\u3092\u4fdd\u5b58\n    bLearnBgImage = false; \/\/ flag\u3092\u5207\u308b\u3002\n  }\n\n  opencv.absDiff();\/\/ \u80cc\u666f\u753b\u50cf\u3068\u4eca\u306e\u753b\u50cf\u306e\u5dee\u306e\u7d76\u5bfe\u5024\u3092\u3068\u308b\n  opencv.convert(OpenCV.GRAY); \/\/ \u30b0\u30ec\u30a4\u30b9\u30b1\u30fc\u30eb\u306b\u5909\u63db\n  opencv.blur(OpenCV.BLUR, 5); \/\/ \u30ce\u30a4\u30ba\u3092\u6d88\u3059\u305f\u3081\u306b\u307c\u304b\u3059\n  opencv.threshold(30); \/\/ \u30b9\u30ec\u30c3\u30b7\u30e7\u30eb\u30c9\u3092\u6307\u5b9a\n  binImage = opencv.image(); \/\/ \u6700\u7d42\u76ee\u6a19\uff01\uff01\uff01\n\n  image(binImage, 0, 0); \/\/\u8868\u793a\n}\n\nvoid keyPressed(){\n  if(key == ' '){ \/\/ \u30b9\u30da\u30fc\u30b9\u30ad\u30fc\u304c\u62bc\u3055\u308c\u305f\u3089\n    bLearnBgImage = true; \/\/ \u80cc\u666f\u3092\u64ae\u308b\n  }\n}<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"

    \u5f8c\u8f29\u304b\u3089Processing\u3068OpenCV\u3067\u80cc\u666f\u5dee\u5206\u3092\u53d6\u308a\u305f\u3044\u3068\u76f8\u8ac7\u3092\u53d7\u3051\u305f\u305f\u3081\u3001\u305d\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u3064\u304f\u308a\u307e\u3057\u305f\u3002 \u3053\u306e\u8a18\u4e8b\u3067\u306fProcessing\u3068OpenCV\u3092\u4f7f\u3063\u3066\u80cc\u666f\u5dee\u5206\u3092\u53d6\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002 \u5927\u307e\u304b […]<\/p>\n","protected":false},"author":1,"featured_media":37,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10,5],"tags":[3,9],"class_list":["post-33","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-processing","category-program","tag-opencv","tag-processing"],"aioseo_notices":[],"jetpack_featured_media_url":"http:\/\/cms.inter-arteq.com\/wp-content\/uploads\/2022\/02\/thumb_20120620.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/cms.inter-arteq.com\/wp-json\/wp\/v2\/posts\/33"}],"collection":[{"href":"http:\/\/cms.inter-arteq.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/cms.inter-arteq.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/cms.inter-arteq.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/cms.inter-arteq.com\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":5,"href":"http:\/\/cms.inter-arteq.com\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":208386,"href":"http:\/\/cms.inter-arteq.com\/wp-json\/wp\/v2\/posts\/33\/revisions\/208386"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/cms.inter-arteq.com\/wp-json\/wp\/v2\/media\/37"}],"wp:attachment":[{"href":"http:\/\/cms.inter-arteq.com\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/cms.inter-arteq.com\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/cms.inter-arteq.com\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}