{"id":1024,"date":"2017-07-12T22:07:34","date_gmt":"2017-07-12T14:07:34","guid":{"rendered":"http:\/\/www.luwl.net\/?p=1024"},"modified":"2017-07-12T22:18:59","modified_gmt":"2017-07-12T14:18:59","slug":"opencv%e7%9a%84%e5%ad%a6%e4%b9%a0","status":"publish","type":"post","link":"http:\/\/www.luwl.net\/?p=1024","title":{"rendered":"OpenCV\u7684\u5b66\u4e60"},"content":{"rendered":"<p>1\u3001opencv\u7248\u672c\u9009\u62e91.0\u3002\u7f16\u8bd1\u73af\u5883\u4e3avc6.0\u7eff\u8272\u7248\u3002<br \/>\n2\u3001\u4e0b\u8f7d<a class=\"replace_word\" title=\"OpenCV\u77e5\u8bc6\u5e93\" href=\"http:\/\/lib.csdn.net\/base\/opencv\" target=\"_blank\" rel=\"noopener\">OpenCV<\/a>\u5b89\u88c5\u7a0b\u5e8f\uff081.0\u7248\u672c\uff09\u3002\u5047\u5982\u8981\u5c06<a class=\"replace_word\" title=\"OpenCV\u77e5\u8bc6\u5e93\" href=\"http:\/\/lib.csdn.net\/base\/opencv\" target=\"_blank\" rel=\"noopener\">opencv<\/a>\u5b89\u88c5\u5230C:\\Program Files\\OpenCV\u3002\u5728\u5b89\u88c5\u65f6\u9009\u62e9&#8221;\u5c06?? \\OpenCV\\bin\u52a0\u5165\u7cfb\u7edf\u53d8\u91cf&#8221;\u3002\u6216\u5b89\u88c5\u5b8c\u6210\u540e\u624b\u52a8\u6dfb\u52a0\u73af\u5883\u53d8\u91cf\u201c<strong>C:\\Program Files\\OpenCV\\bin<\/strong>\u201d\u3002\u5b89\u88c5\u5b8c\u6210\u540e\u91cd\u542f\u624d\u80fd\u4f7f\u5f97\u73af\u5883\u53d8\u91cf\u751f\u6548\u3002<br \/>\n3\u3001VC6.0\u914d\u7f6e<\/p>\n<div id=\"article_content\" class=\"article_content tracking-ad\" data-mod=\"popu_307\" data-dsm=\"post\">\n<p>\u542f\u52a8VC++6.0\uff0c\u83dc\u5355Tools-&gt;Options-&gt;Directories\uff1a\u5148\u8bbe\u7f6elib\u8def\u5f84\uff0c\u9009\u62e9<strong>Library files<\/strong>\uff0c\u5728\u4e0b\u65b9\u586b\u5165\u8def\u5f84\uff1a<strong>????????? C:\\Program Files\\OpenCV\\lib<\/strong><\/p>\n<p>\u7136\u540e\u9009\u62e9<strong>include files<\/strong>\uff0c\u5728\u4e0b\u65b9\u586b\u5165\u8def\u5f84\uff1a<\/p>\n<p>C:\\Program Files\\OpenCV\\cxcore\\include<br \/>\nC:\\Program Files\\OpenCV\\cv\\include<br \/>\nC:\\Program Files\\OpenCV\\cvaux\\include<br \/>\nC:\\Program Files\\OpenCV\\ml\\include<br \/>\nC:\\Program Files\\OpenCV\\otherlibs\\highgui<br \/>\nC:\\Program Files\\OpenCV\\otherlibs\\cvcam\\include<\/p>\n<p>4.\u6bcf\u521b\u5efa\u4e00\u4e2a\u5c06\u8981\u4f7f\u7528OpenCV\u7684VC Project\uff0c\u90fd\u9700\u8981\u7ed9\u5b83\u6307\u5b9a\u9700\u8981\u7684lib\u3002\u83dc\u5355\uff1aProject-&gt;Settings\uff0c\u7136\u540e\u5c06Setting for\u9009\u4e3aAll Configurations\uff0c\u7136\u540e\u9009\u62e9\u53f3\u8fb9\u7684link\u6807\u7b7e\uff0c\u5728Object\/library modules\u9644\u52a0\u4e0a\uff1a<\/p>\n<p><strong>cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib<\/strong><\/p>\n<p>\u5982\u679c\u4e0d\u9700\u8981\u8fd9\u4e48\u591alib\uff0c\u4f60\u53ef\u4ee5\u53ea\u6dfb\u52a0\u4f60\u9700\u8981\u7684lib\u3002<\/p>\n<\/div>\n<div class=\"bdsharebuttonbox tracking-ad bdshare-button-style0-16\" data-mod=\"popu_172\" data-bd-bind=\"1499867226285\"><\/div>\n<div id=\"digg\">?5.\u4f8b\u5b50<\/div>\n<div>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\/\/ PictureSelectToSave.cpp : Defines the entry point for the console application.\r\n\/\/\r\n\r\n\/\/#include &quot;stdafx.h&quot;\r\n\/\/#include &lt;iostream.h&gt;\r\n#include &lt;cv.h&gt;\r\n#include &lt;highgui.h&gt;\r\n#include &lt;math.h&gt;\r\n#include &lt;stdio.h&gt;\r\n#include &lt;cxcore.h&gt;\r\n\r\nIplImage* img=0;\r\nCvRect selection;\r\nCvPoint origin;\r\nint select_object = 0;\r\nint track_object = 0;\r\n\r\n\/\/\/\/\/\/\u9f20\u6807\u4e8b\u4ef6\u51fd\u6570\r\nvoid on_mouse( int event, int x, int y, int flags, void* param )\r\n{\r\nif( !img )\r\nreturn;\r\nif( img-&gt;origin )\r\ny = img-&gt;height - y;\r\nif( select_object )\r\n{\r\nselection.x = MIN(x,origin.x);\r\nselection.y = MIN(y,origin.y);\r\n\r\n\r\nselection.width = selection.x + CV_IABS(x - origin.x);\r\nselection.height = selection.y + CV_IABS(y - origin.y);\r\n\r\nselection.x = MAX( selection.x, 0 );\r\nselection.y = MAX( selection.y, 0 );\r\nselection.width = MIN( selection.width, img-&gt;width );\r\nselection.height = MIN( selection.height, img-&gt;height );\r\nselection.width -= selection.x;\r\nselection.height -= selection.y;\r\n}\r\nswitch( event )\r\n{\r\ncase CV_EVENT_LBUTTONDOWN:\r\norigin = cvPoint(x,y);\r\nselection = cvRect(x,y,0,0);\r\nselect_object = 1;\r\nbreak;\r\ncase CV_EVENT_LBUTTONUP:\r\nselect_object = 0;\r\nif( selection.width &gt; 0 &amp;&amp; selection.height &gt; 0 )\r\ntrack_object = -1;\r\nbreak;\r\n}\r\nif( track_object &lt;0 )\r\n{\r\nCvPoint point1 = { selection.x,selection.y};\r\nCvPoint point2 = { selection.x+selection.width+1, selection.y+selection.height+1 };\r\n\/\/\/\/\/\/\u753b\u9762\u4e0a\u753b\u6846\u5e76\u663e\u793a\r\nif(selection.width&gt;0 &amp;&amp; selection.height&gt;0)\r\ncvRectangle(img,point1,point2,CV_RGB(0,255,0),1,8,0);\r\ncvShowImage( &quot;PictureShow&quot;, img);\r\n\/\/\/\/\/\u83b7\u5f97\u6846\u4e2d\u56fe\u7247\u533a\u57df\r\n\r\n\/\/\/\u65b9\u6cd5\u4e00\uff1a\u53ef\u83b7\u5f97\u4e0e\u539f\u56fe\u50cf\u5927\u5c0f\u4e00\u6837\u7684\u56fe\u7247\/\/\/\r\n\/*\r\nIplImage* img2 = cvCreateImage(cvGetSize(img), 8, 1 );\r\ncvSet(img2,CV_RGB(0,0,0),NULL);\/\/\u80cc\u666f\u8bbe\u4e3a\u767d\u8272\r\ncvRectangle(img2,point1,point2, CV_RGB(255,255,255),-1,8,0);\/\/\u6846\u533a\u57df\u8bbe\u4e3a\u9ed1\u8272\r\ncvAnd(img,img2,img2);\/\/\u903b\u8f91\u4e0e\u8fd0\u7b97\r\ncvShowImage(&quot;output&quot;, img2);\r\ncvSaveImage(&quot;.\\\\output\\\\SelectedAera.jpg&quot;,img2);\r\n*\/\r\n\r\n\/\/\/\u65b9\u6cd5\u4e8c\uff1a\u4ec5\u4ec5\u5c06\u83b7\u53d6\u56fe\u7247\u4fdd\u5b58\u4e3a\u5b9e\u9645\u533a\u57df\u7684\u5927\u5c0f\/\/\/\r\nIplImage* img2 = cvCreateImage(cvSize(selection.width+1,selection.height+1), 8,1 );\r\nCvRect rect = cvRect(selection.x, selection.y, selection.width+1,selection.height+1);\r\ncvSetImageROI(img, rect);\r\ncvCopy(img,img2);\/\/\u590d\u5236\u5bf9\u8c61\u533a\u57df\r\ncvShowImage(&quot;output&quot;, img2);\r\ncvResetImageROI(img);\r\ncvSaveImage(&quot;.\\\\a2.bmp&quot;,img2);\r\n\r\n}\r\n}\r\n\r\nint main()\r\n{\r\nimg=cvLoadImage(&quot;C:\\\\a1.bmp&quot;,0 );\r\n\/\/cvCanny(img,img, 120, 120, 3);\r\ncvNamedWindow( &quot;PictureShow&quot;, CV_WINDOW_AUTOSIZE );\r\ncvNamedWindow( &quot;output&quot;,1 );\r\n\/\/\/\/\/\/\u9f20\u6807\u4e8b\u4ef6\u56de\u8c03\u51fd\u6570\r\ncvSetMouseCallback( &quot;PictureShow&quot;,on_mouse,0);\r\ncvShowImage( &quot;PictureShow&quot;, img);\r\ncvWaitKey(0);\r\n\r\ncvDestroyWindow( &quot;PictureShow&quot; );\/\/\u9500\u6bc1\u7a97\u53e3\r\ncvDestroyWindow( &quot;output&quot; );\r\ncvReleaseImage( &amp;img ); \/\/\u91ca\u653e\u56fe\u50cf\r\n\/\/ cvReleaseImage( &amp;img2 );\r\nreturn 0;\r\n}\r\n\r\n<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001opencv\u7248\u672c\u9009\u62e91.0\u3002\u7f16\u8bd1\u73af\u5883\u4e3avc6.0\u7eff\u8272\u7248\u3002 2\u3001\u4e0b\u8f7dOpenC &hellip; <a href=\"http:\/\/www.luwl.net\/?p=1024\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1024","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/posts\/1024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.luwl.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1024"}],"version-history":[{"count":4,"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/posts\/1024\/revisions"}],"predecessor-version":[{"id":1028,"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/posts\/1024\/revisions\/1028"}],"wp:attachment":[{"href":"http:\/\/www.luwl.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.luwl.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1024"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.luwl.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}