{"id":391,"date":"2021-08-28T12:55:24","date_gmt":"2021-08-28T03:55:24","guid":{"rendered":"https:\/\/rfsec.ddns.net\/db\/?p=391"},"modified":"2021-08-29T09:02:43","modified_gmt":"2021-08-29T00:02:43","slug":"m-jpeg-streamer%e3%81%a8opencvcv2%e3%81%a7%e3%82%bf%e3%82%a4%e3%83%a0%e3%83%a9%e3%83%97%e3%82%b9%e5%8b%95%e7%94%bb%e3%82%92%e4%bd%9c%e6%88%90","status":"publish","type":"post","link":"https:\/\/rfsec.ddns.net\/db\/?p=391","title":{"rendered":"M-JPEG streamer\u3068OpenCV(CV2)\u3067\u30bf\u30a4\u30e0\u30e9\u30d7\u30b9\u52d5\u753b\u3092\u4f5c\u6210"},"content":{"rendered":"\n<p><strong>10\u79d2\u9593\u9694\u3067\u753b\u50cf\u3092400\u679a jpg\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u4fdd\u5b58<\/strong><\/p>\n\n\n\n<p>\u4e8b\u524d\u306bM-JPEG streamer\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3001\u30a2\u30c9\u30ec\u30b9xxx.xxx.xxx.xxx:8080\u3067\u7a3c\u50cd\u3057\u3066\u3044\u308b\u74b0\u5883\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u540d T0000.jpg\u304b\u3089T0399.jpg\u3068\u3057\u3066\u753b\u50cf\u3092\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\" data-line=\"xxx.xxx.xxx.xxx:8080\"><code>import time\nimport cv2\n\n# VideoCapture \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3057\u307e\u3059\nURL = &quot;http:\/\/xxx.xxx.xxx.xxx:8080\/?action=stream&quot;\ncapture = cv2.VideoCapture(URL)\nfor n in range(400):\n    ret, frame = capture.read()\n    name = &quot;T&quot; + &#39;{:04d}&#39;.format(n)+&quot;.jpg&quot;\n    print(name)\n    cv2.imwrite(name, frame)\n    time.sleep(10)\n\nprint(&quot;Done!&quot;)<\/code><\/pre><\/div>\n\n\n\n<p> <strong>jpg\u30d5\u30a1\u30a4\u30eb\u304b\u3089mp4\u52d5\u753b\u3092\u751f\u6210<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import glob\nimport cv2\n\nimg_array = []\nfor filename in sorted(glob.glob(&quot;*.jpg&quot;)):\n    print(filename)\n    img = cv2.imread(filename)\n    height, width, layers = img.shape\n    size = (width, height)\n    img_array.append(img)\n\nname = &#39;project.mp4&#39;\nout = cv2.VideoWriter(name, cv2.VideoWriter_fourcc(*&#39;mp4v&#39;), 5.0, size)\n\nfor i in range(len(img_array)):\n    out.write(img_array[i])\nout.release()<\/code><\/pre><\/div>\n\n\n\n<p> \u751f\u6210\u3057\u305fmp4\u52d5\u753b\u306e\u7de8\u96c6\uff08\u4e0d\u8981\u90e8\u5206\u306e\u524a\u9664\u3001\u56de\u8ee2\u3001\u518d\u751f\u901f\u5ea6\u306e\u8abf\u6574\u306a\u3069\uff09\u306b\u306f\u3001Windows10\u6a19\u6e96\u306e\u30bd\u30d5\u30c8\u300c\u30d5\u30a9\u30c8\u300d\u304c\u4fbf\u5229\u3002<\/p>\n\n\n\n<p><strong>\u4f5c\u4f8b<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"bibo2\" width=\"625\" height=\"352\" src=\"https:\/\/www.youtube.com\/embed\/l_yhZC0YN6o?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>10\u79d2\u9593\u9694\u3067\u753b\u50cf\u3092400\u679a jpg\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u4fdd\u5b58 \u4e8b\u524d\u306bM-JPEG streamer\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3001\u30a2\u30c9\u30ec\u30b9xxx.xxx.xxx.xxx:8080\u3067\u7a3c\u50cd\u3057\u3066\u3044\u308b\u74b0\u5883\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u540d T0000.jpg\u304b\u3089T03 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2,6],"tags":[],"class_list":["post-391","post","type-post","status-publish","format-standard","hentry","category-camera","category-make"],"featured_image_src":null,"author_info":{"display_name":"mars","author_link":"https:\/\/rfsec.ddns.net\/db\/?author=1"},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rfsec.ddns.net\/db\/index.php?rest_route=\/wp\/v2\/posts\/391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rfsec.ddns.net\/db\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rfsec.ddns.net\/db\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rfsec.ddns.net\/db\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rfsec.ddns.net\/db\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=391"}],"version-history":[{"count":3,"href":"https:\/\/rfsec.ddns.net\/db\/index.php?rest_route=\/wp\/v2\/posts\/391\/revisions"}],"predecessor-version":[{"id":412,"href":"https:\/\/rfsec.ddns.net\/db\/index.php?rest_route=\/wp\/v2\/posts\/391\/revisions\/412"}],"wp:attachment":[{"href":"https:\/\/rfsec.ddns.net\/db\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rfsec.ddns.net\/db\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rfsec.ddns.net\/db\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}