{"id":83,"date":"2010-09-05T20:45:35","date_gmt":"2010-09-05T12:45:35","guid":{"rendered":"http:\/\/www.magicandlove.com\/blog\/?p=83"},"modified":"2010-09-05T20:45:35","modified_gmt":"2010-09-05T12:45:35","slug":"opencv-c-usage","status":"publish","type":"post","link":"http:\/\/www.magicandlove.com\/blog\/2010\/09\/05\/opencv-c-usage\/","title":{"rendered":"OpenCV C++ usage"},"content":{"rendered":"<p>I start using the C++ interface for OpenCV, instead of the old highgui C functions. Here is an example to do real time video capture from the default webcam.<\/p>\n<pre>#include \"stdafx.h\"\r\n#include \"cv.h\"\r\n#include \"highgui.h\"\r\n\r\nusing namespace cv;\r\n\r\nint main(int, char**)\r\n{\r\n\tVideoCapture cap(0);\r\n\tcap.set(CV_CAP_PROP_FRAME_WIDTH, 640);\r\n\tcap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);\r\n\tif (!cap.isOpened())\r\n\t\treturn -1;\r\n\r\n\tnamedWindow(\"camera\",CV_WINDOW_AUTOSIZE);\r\n\twhile (true)\r\n\t{\r\n\t\tMat frame;\r\n\t\tcap &gt;&gt; frame;\r\n\t\timshow(\"camera\", frame);\r\n\t\tif (waitKey(10) &gt;= 0)\r\n\t\t\tbreak;\r\n\t}\r\n\treturn 0;\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I start using the C++ interface for OpenCV, instead of the old highgui C functions. Here is an example to do real time video capture from the default webcam. #include &#8220;stdafx.h&#8221; #include &#8220;cv.h&#8221; #include &#8220;highgui.h&#8221; using namespace cv; int main(int, char**) { VideoCapture cap(0); cap.set(CV_CAP_PROP_FRAME_WIDTH, 640); cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480); if (!cap.isOpened()) return -1; namedWindow(&#8220;camera&#8221;,CV_WINDOW_AUTOSIZE); while (true) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[14,3],"class_list":["post-83","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-c","tag-opencv"],"_links":{"self":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/comments?post=83"}],"version-history":[{"count":1,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/83\/revisions"}],"predecessor-version":[{"id":84,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/83\/revisions\/84"}],"wp:attachment":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/media?parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/categories?post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/tags?post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}