{"id":1591,"date":"2013-06-08T21:30:22","date_gmt":"2013-06-08T12:30:22","guid":{"rendered":"http:\/\/mattyan.net\/blog\/?p=1591"},"modified":"2013-06-08T21:30:22","modified_gmt":"2013-06-08T12:30:22","slug":"opencv%e3%81%ae%e3%82%ad%e3%83%a3%e3%83%97%e3%83%81%e3%83%a3%e7%94%bb%e5%83%8f%e3%82%92wxwidgets%e3%81%ae%e3%82%a4%e3%83%a1%e3%83%bc%e3%82%b8%e5%bd%a2%e5%bc%8f%e3%81%ab%e5%a4%89%e6%8f%9b%e3%81%97","status":"publish","type":"post","link":"https:\/\/mattyan.net\/blog\/?p=1591","title":{"rendered":"OpenCV\u306e\u30ad\u30e3\u30d7\u30c1\u30e3\u753b\u50cf\u3092wxWidgets\u306e\u30a4\u30e1\u30fc\u30b8\u5f62\u5f0f\u306b\u5909\u63db\u3057\u3066\u307f\u305f"},"content":{"rendered":"<p>OpenCV\u306eCvCapture\u3067\u53d6\u5f97\u3057\u305fIplImage\u69cb\u9020\u4f53\u306e\u30c7\u30fc\u30bf\u3092wxImage\u306b\u5909\u63db\u3059\u308b\u65b9\u6cd5\u3092\u8abf\u3079\u305f\u3051\u3069\u3042\u3093\u307e\u308a\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f\u304b\u3089\u4f5c\u3063\u3066\u307f\u305f\u3002<br \/>\n<!--more--><br \/>\n<a href=\"http:\/\/mattyan.net\/blog\/wp-content\/uploads\/2013\/06\/capture.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mattyan.net\/blog\/wp-content\/uploads\/2013\/06\/capture.png\" alt=\"capture\" width=\"300\" height=\"200\"\/><\/a><br \/>\n\u3068\u308a\u3042\u3048\u305a\u5b9f\u884c\u7d50\u679c\u3002\u30a6\u30a4\u30f3\u30c9\u30a6\u30bf\u30a4\u30c8\u30eb\u306b\u3064\u3044\u3066\u306f\u6c17\u306b\u3057\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002<br \/>\n[cpp]<br \/>\n\/**<br \/>\n * OpenCV\u753b\u50cf\u304b\u3089wxImage\u5f62\u5f0f\u306b\u5909\u63db<br \/>\n * @param[in] base \u5143\u753b\u50cf<br \/>\n * @return \u5909\u63db\u5f8c\u306ewxImage<br \/>\n *\/<br \/>\nwxImage *CvWxImageConvert(IplImage *base){<br \/>\n\twxImage *img = new wxImage();<br \/>\n\timg-&gt;Create(base-&gt;width, base-&gt;height);<br \/>\n\tunsigned char *pixels = img-&gt;GetData();<br \/>\n\t\/\/\u30b3\u30d4\u30fc<br \/>\n\tfor(int x = 0; x &lt; base-&gt;width; x++){<br \/>\n\t\tfor(int y = 0; y &lt; base-&gt;height; y++){<br \/>\n\t\t\tint index = x * 3 + base-&gt;width * y * 3;<br \/>\n\t\t\tpixels[index + 0] = base-&gt;imageData[index + 2];<br \/>\n\t\t\tpixels[index + 1] = base-&gt;imageData[index + 1];<br \/>\n\t\t\tpixels[index + 2] = base-&gt;imageData[index + 0];<br \/>\n\t\t}<br \/>\n\t}<br \/>\n\treturn img;<br \/>\n}<br \/>\n[\/cpp]<br \/>\n\u5909\u63db\u30b3\u30fc\u30c9\u3002OpenCV\u3068wxWidgets\u3067RGB\u306e\u9806\u756a\u304c\u9055\u3046\u306e\u304b\u3001\u305d\u306e\u307e\u307e\u30b3\u30d4\u30fc\u3059\u308b\u3068\u8272\u304c\u304a\u304b\u3057\u304f\u306a\u308b\u306e\u3067RGB\u3092\u53cd\u8ee2\u3057\u3066\u30b3\u30d4\u30fc\u3002<br \/>\n\u3053\u308c\u3092<br \/>\n[cpp]<br \/>\n\tIplImage *frame = cvQueryFrame(camera);<br \/>\n\twxImage *image = CvWxImageConvert(frame);<br \/>\n\tthis-&gt;capture-&gt;SetBitmap(wxBitmap(*image));<br \/>\n\tdelete image;<br \/>\n[\/cpp]<br \/>\n\u3068\u3057\u3066\u3042\u3052\u308b\u3068\u3001\u5b9f\u884c\u4f8b\u306e\u3088\u3046\u306b\u753b\u9762\u306ewxStaticBitmap\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306b\u63cf\u5199\u3055\u308c\u308b\u3002<br \/>\n\u305f\u3060\u3001\u3053\u308c\u66f8\u3044\u3066\u304b\u3089\u6c17\u3065\u3044\u305f\u3051\u3069\u3001\u753b\u9762\u304c\u3059\u3063\u3054\u3044\u3061\u3089\u3064\u304f\u306e\u3067\u4f55\u3068\u304b\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3068\u601d\u3046\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenCV\u306eCvCapture\u3067\u53d6\u5f97\u3057\u305fIplImage\u69cb\u9020\u4f53\u306e\u30c7\u30fc\u30bf\u3092wxImage\u306b\u5909\u63db\u3059\u308b\u65b9\u6cd5\u3092\u8abf\u3079\u305f\u3051\u3069\u3042\u3093\u307e\u308a\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f\u304b\u3089\u4f5c\u3063\u3066\u307f\u305f\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,1],"tags":[],"class_list":["post-1591","post","type-post","status-publish","format-standard","hentry","category-3","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1591","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1591"}],"version-history":[{"count":0,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1591\/revisions"}],"wp:attachment":[{"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}