{"id":9128,"date":"2016-11-26T08:06:56","date_gmt":"2016-11-26T13:06:56","guid":{"rendered":"httpss:\/\/www.powenko.com\/wordpress\/?p=9128"},"modified":"2016-11-26T08:06:56","modified_gmt":"2016-11-26T13:06:56","slug":"09-%e9%8c%84%e5%bd%b1","status":"publish","type":"post","link":"https:\/\/www.powenko.com\/wordpress\/?p=9128","title":{"rendered":"09 \u9304\u5f71"},"content":{"rendered":"<p><a href=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2016\/11\/Screen-Shot-2016-11-26-at-9.05.46-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9129\" src=\"httpss:\/\/www.powenko.com\/wordpress\/wp-content\/uploads\/2016\/11\/Screen-Shot-2016-11-26-at-9.05.46-PM.png\" alt=\"screen-shot-2016-11-26-at-9-05-46-pm\" width=\"117\" height=\"107\" \/><\/a><\/p>\n<p><code><\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n#include &lt;cstdio&gt;\r\n#include &lt;opencv2\/opencv.hpp&gt;\r\nusing namespace cv;\r\nint main(){\r\n    VideoCapture capture(0);\r\n    if(!capture.isOpened()){\r\n        return -1;\r\n    }\r\n    \/*\r\n    int fps = 15;\r\n    \/\/capSize = (1028,720) # this is the size of my source video\r\n    fourcc = cv2.cv.CV_FOURCC('m', 'p', '4', 'v');\r\n    \/\/self.vout = cv2.VideoWriter();\r\n    success = self.vout.open('\/Users\/powenko\/Desktop\/output.mov',fourcc,fps,capSize,True)\r\n    \r\n    *\/\r\n    Size videoSize = Size((int)capture.get(CV_CAP_PROP_FRAME_WIDTH),(int)capture.get(CV_CAP_PROP_FRAME_HEIGHT));\r\n    VideoWriter writer;\r\n  \/\/  writer.open(&quot;\/Users\/powenko\/Desktop\/VideoTest.avi&quot;, CV_FOURCC('m', 'p', '4', 'v'), 15, videoSize);\u3000\/\/\u5176\u4ed6\u7cfb\u7d71\u4e0a\u4f7f\u7528\r\n    writer.open(&quot;\/Users\/powenko\/Desktop\/VideoTest.mov&quot;, CV_FOURCC('m', 'p', '4', 'v'), 15, videoSize);   \/\/ MAC \u53ef\u4ee5\u4f7f\u7528\r\n  \r\n    \r\n    \/*\r\n     CV_FOURCC('P', 'I', 'M', '1') = MPEG-1 codec\r\n     CV_FOURCC('M', 'J', 'P', 'G') = motion-jpeg codec\r\n     CV_FOURCC('M', 'P', '4', '2') = MPEG-4.2 codec\r\n     CV_FOURCC('D', 'I', 'V', '3') = MPEG-4.3 codec\r\n     CV_FOURCC('D', 'I', 'V', 'X') = MPEG-4 codec\r\n     CV_FOURCC('U', '2', '6', '3') = H263 codec\r\n     CV_FOURCC('I', '2', '6', '3') = H263I codec\r\n     CV_FOURCC('F', 'L', 'V', '1') = FLV1 codec\r\n     *\/\r\n    namedWindow(&quot;show image&quot;,0);\r\n    \r\n    \r\n    while(true){\r\n        Mat frame;\r\n        capture &gt;&gt; frame;\r\n        if(!frame.empty()){\r\n            writer.write(frame);\r\n            \r\n            \/\/capture &gt;&gt; frame;\r\n            \/\/writer &lt;&lt; frame;\r\n            \r\n            \r\n            \r\n            imshow(&quot;show image&quot;, frame);\r\n            if(waitKey(33) == 27){\r\n                break;\r\n            }\r\n        }\r\n    }\r\n    return 0;\r\n}\r\n<\/pre>\n<p><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;cstdio&gt; #include &lt;opencv2\/opencv.hpp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9129,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[247],"tags":[],"class_list":["post-9128","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ch01---ios--opencv"],"_links":{"self":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/9128"}],"collection":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9128"}],"version-history":[{"count":1,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/9128\/revisions"}],"predecessor-version":[{"id":9130,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/9128\/revisions\/9130"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/media\/9129"}],"wp:attachment":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}