{"id":349,"date":"2013-12-05T16:01:59","date_gmt":"2013-12-05T21:01:59","guid":{"rendered":"http:\/\/homepages.uc.edu\/~yaozo\/wordpress\/?p=349"},"modified":"2013-12-05T16:01:59","modified_gmt":"2013-12-05T21:01:59","slug":"installing-opencv-2-3-for-visual-studio-2008","status":"publish","type":"post","link":"https:\/\/zhuoyao.net\/index.php\/2013\/12\/05\/installing-opencv-2-3-for-visual-studio-2008\/","title":{"rendered":"Installing OpenCV 2.3 for Visual Studio 2008"},"content":{"rendered":"<p>Step 1:<\/p>\n<p>Download\u00a0OpenCV-2.3.0-win-superpack.exe\u00a0from\u00a0<a href=\"http:\/\/sourceforge.net\/projects\/opencvlibrary\/files\/opencv-win\/2.3\/\" target=\"_blank\" rel=\"noopener\">http:\/\/sourceforge.net\/projects\/opencvlibrary\/files\/opencv-win\/2.3\/<\/a><\/p>\n<p>Run\u00a0OpenCV-2.3.0-win-superpack.exe and copy the generated folder\u00a0OpenCV2.3 to C drive<\/p>\n<p>Step 2:<\/p>\n<p>Open Microsoft Visual Studio 2008 and click\u00a0<em>Tools-&gt;Options<\/em><\/p>\n<p><img decoding=\"async\" alt=\"alt\" src=\"https:\/\/lh3.googleusercontent.com\/-tSo-rZLn3m8\/ThmK-14ecVI\/AAAAAAAAAF8\/s3sY0gBWNrE\/s400\/1s.png\" \/><\/p>\n<p>Select\u00a0<em>Projects and Solutions<\/em>\u00a0and then\u00a0<em>VC++ Directories<\/em>. Select\u00a0<em>Include files<\/em>\u00a0in Show directories for: drop down menu. Add the following paths.<\/p>\n<p>C:\\OpenCV2.3\\opencv\\include\\opencv<\/p>\n<p>C:\\OpenCV2.3\\build\\include<\/p>\n<p><img decoding=\"async\" alt=\"alt\" src=\"https:\/\/lh3.googleusercontent.com\/-xPJH7BXrlqk\/ThmK-rsnXaI\/AAAAAAAAAF0\/gBvuDhAnpMg\/s400\/2s.png\" \/><\/p>\n<p>Select\u00a0<em>Library files<\/em>\u00a0in Show directories for: drop down menu. Add the following path.<\/p>\n<p>C:\\OpenCV2.3\\build\\x86\\vc9\\lib<\/p>\n<p>Now we have added include and library file paths and this need to be done only for the first time.<\/p>\n<p>Step 3:<\/p>\n<p>Create an new project in Visual Studio 2008<\/p>\n<p>Click\u00a0<em>Project-&gt;Properties<\/em>. Select\u00a0<em>Configuration Properties -&gt; Linker -&gt; Input<\/em>. Make sure you select\u00a0<em>Debug<\/em>\u00a0in &#8216;Configuration:&#8217; drop down menu and then add the following to the\u00a0<em>Additional Dependencies.<\/em><\/p>\n<p>opencv_features2d230d.lib opencv_highgui230d.lib opencv_core230d.lib opencv_imgproc230d.lib opencv_ml230d.lib opencv_objdetect230d.lib opencv_video230d.lib opencv_contrib230d.lib opencv_calib3d230d.lib<\/p>\n<p>Now select\u00a0<em>Release<\/em>\u00a0in &#8216;Configuration:&#8217; drop down menu and\u00a0then add the following to the\u00a0<em>Additional Dependencies \u00a0<\/em>and click OK<\/p>\n<p>opencv_features2d230.lib opencv_highgui230.lib opencv_core230.lib opencv_imgproc230.lib opencv_ml230.lib opencv_objdetect230.lib opencv_video230.lib opencv_contrib230.lib opencv_calib3d230.lib<\/p>\n<p><img decoding=\"async\" alt=\"alt\" src=\"https:\/\/lh5.googleusercontent.com\/-zFbXumw5cFI\/ThmK-2J4bVI\/AAAAAAAAAF4\/Rsm8qv_jkVw\/s400\/3s.png\" \/><\/p>\n<p><img decoding=\"async\" alt=\"alt\" src=\"https:\/\/lh6.googleusercontent.com\/-P0CmDWgSKmU\/ThmMHXLDTbI\/AAAAAAAAAGI\/_EqZEZtotc8\/s400\/6s.png\" \/><\/p>\n<p>Step 4:<\/p>\n<p>Add\u00a0C:\\OpenCV2.3\\build\\x86\\vc9\\bin\u00a0to the environment path as shown in screenshot below. You may need to restart the system after setting this.<\/p>\n<p><img decoding=\"async\" alt=\"alt\" src=\"https:\/\/lh6.googleusercontent.com\/-mAxU7s1LCcY\/TiWrkBfEPkI\/AAAAAAAAAGY\/8ewUA2cmhuI\/s400\/7s.png\" \/><\/p>\n<p>To test whether the OpenCV is working, add a C++ file under Source files as shown in screen shots below.<\/p>\n<p><img decoding=\"async\" alt=\"alt\" src=\"https:\/\/lh6.googleusercontent.com\/-r0FA37Kod-g\/ThmK_GjUmtI\/AAAAAAAAAGE\/xLGP385BvI4\/s800\/4s.png\" \/><\/p>\n<p><img decoding=\"async\" alt=\"alt\" src=\"https:\/\/lh3.googleusercontent.com\/-NV1KcUHF_lw\/ThmK-2UKQgI\/AAAAAAAAAGA\/IOGu1jC-CpY\/s400\/5s.png\" \/><\/p>\n<p>Copy the sample program given below and build it and run. An image will be displayed in a window.<\/p>\n<div>\n<div>\n<div id=\"highlighter_769469\">\n<div>\n<div><code>01.<\/code><code>#include &lt;cv.h&gt;<\/code><\/div>\n<div><code>02.<\/code><\/div>\n<div><code>03.<\/code><code>#include &lt;highgui.h&gt;<\/code><\/div>\n<div><code>04.<\/code><\/div>\n<div><code>05.<\/code><code>using namespace cv;<\/code><\/div>\n<div><code>06.<\/code><\/div>\n<div><code>07.<\/code><code>int main()<\/code><\/div>\n<div><code>08.<\/code><\/div>\n<div><code>09.<\/code><code>{<\/code><\/div>\n<div><code>10.<\/code><\/div>\n<div><code>11.<\/code><code>namedWindow(\"wnd\");<\/code><\/div>\n<div><code>12.<\/code><\/div>\n<div><code>13.<\/code><code>Mat img;<\/code><\/div>\n<div><code>14.<\/code><\/div>\n<div><code>15.<\/code><code>img= imread(\"C:\/\/Users\/\/Public\/\/Pictures\/\/Sample Pictures\/\/Desert.JPG\"); \/\/image path<\/code><\/div>\n<div><code>16.<\/code><\/div>\n<div><code>17.<\/code><code>imshow(\"wnd\",img);<\/code><\/div>\n<div><code>18.<\/code><\/div>\n<div><code>19.<\/code><code>cvWaitKey();<\/code><\/div>\n<div><code>20.<\/code><\/div>\n<div><code>21.<\/code><code>return 0;<\/code><\/div>\n<div><code>22.<\/code><\/div>\n<div><code>23.<\/code><code>}<\/code><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div>Note the double backslash in image path in the program.<\/div>\n<div><\/div>\n<div><\/div>\n<div>\n<hr \/>\n<p>For\u00a0<strong>OpenCV 2.3.1<\/strong>, the only change is in step 3. Add the library files accordingly as shown below.<\/p>\n<p>In debug mode<\/p>\n<p>opencv_features2d231d.lib opencv_highgui231d.lib opencv_core231d.lib opencv_imgproc231d.lib opencv_ml231d.lib opencv_objdetect231d.lib opencv_video231d.lib opencv_contrib231d.lib opencv_calib3d231d.lib<\/p>\n<p>In release mode<\/p>\n<p>opencv_features2d231.lib opencv_highgui231.lib opencv_core231.lib opencv_imgproc231.lib opencv_ml231.lib opencv_objdetect231.lib opencv_video231.lib opencv_contrib231.lib opencv_calib3d231.lib<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Step 1: Download\u00a0OpenCV-2.3.0-win-superpack.exe\u00a0from\u00a0http:\/\/sourceforge.net\/projects\/opencvlibrary\/files\/opencv-win\/2.3\/ Run\u00a0OpenCV-2.3.0-win-superpack.exe and copy the generated folder\u00a0OpenCV2.3 to C drive Step 2: Open Microsoft Visual Studio 2008 and click\u00a0Tools-&gt;Options Select\u00a0Projects and Solutions\u00a0and then\u00a0VC++&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-349","post","type-post","status-publish","format-standard","hentry","category-image-processing"],"_links":{"self":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/comments?post=349"}],"version-history":[{"count":0,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/349\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/media?parent=349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/categories?post=349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/tags?post=349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}