openCV2.0 Netbeans 6.8
openCV2.0 Netbeans 6.8
openCV2.0 Netbeans 6.8
Finally click OK
Step 4. Now we'll build a new project in Netbeans to test that we can create/compile & run a simply C/C++ program. fig 2. First create a new folder on your desktop & call it C++_Projects Now in Netbeans File>>New Project>>C/C++>>C/C++Application(fig 2.)
Click Next In the next window do the following(fig 3.) Project Name: Myfirst_project Project Location: use the Browse button to point to the C++_Project folder you created on your desktop earlier, and check that the other settings match (fig 3). fig 3.
Finally click Finish RECAP so far: 1. Installed Cygwin Compiler. 2. Installed Netbeans and configured Cygwin Compiler. 3. Created a folder on the desktop which contains our new C++ project named Myfirst_project
Steps 1. Double click on the main.cpp file under Source Files to load code in the right hand window(Item 1 fig 4.) 2. Click on the blue hammer (Item 2 fig 4.) to build the project. 3. Click on the green button (Item 3 fig 4.) to run the compiled exe. 4. If all goes well you should see RUN SUCCESSFUL (Item 4 fig 4.) WARNING: You should be aware that if you encounter any problems with any of the above steps or you can not build/compile or run your new project, then these issues need to be addressed before trying to install OpenCV, because it's probably not going to work.
By default OpenCV install location is C:\OpenCV2.0 so we are going to assume from here that this is the case. Navigate to the OpenCV directory(fig 6.) fig 6.
The folders we're interested in are the include(Item 1 fig 6.) and the lib(Item 2 fig 6.) include folder contains the header files for OpenCV lib folder contains the dlls/library files The first thing we need to do is open the file cxoperation.hpp this is found in the ...include/opencv folder and change lines 67-68 from this 67 #include <bits/atomicity.h> 68 #if __GNUC__ >= 4 to this 67 #include <bits/atomicity.h> 68 #if __GNUC__ >= 4 || __CYGWIN__ then Save the file.
Its best to use a text editor that can display line numbers to make this easy,VIM etc, you can use Netbeans IDE too of course to do this.
Now in Netbeans IDE, right click Myfirst_project and select Properties(fig 7.) fig 7.
Click on C++ Compiler tab and change the Include Directories path so it points to c:/OpenCV2.0/include/opencv(fig 7.) this is where the header files are, for opencv projects. Next we need to tell Netbeans where to find the library files needed for opencv projects, this is under the Linker tab (fig 8.) the only two library files we need to install at this moment are cv200.dll and highgui200.dll the others dlls can be loaded later and also the Additional Library Directories points to c:/OpenCV2.0/lib
Fig 8.
Click Apply and the OK Buttons That's all the settings done folks!
Plug a web cam into a usb port Copy and Paste the entire code below into the main.cpp file(overwrite any previous code) Build project Blue Hammer Run Green Button If all's well your web cam should light up and a demo window should appear with the output of your web cam(fig 9.) fig 9.
I hope you enjoyed the tutorial... Steve Hodkin And one final bonus, Eclipse user's check out this link for installing Opencv2.0 on Eclipse IDE. http://carrierfrequency.blogspot.com/2010/02/setting-up-opencv-20-in-eclipse-on.html
//============================================================================ // Name : main.cpp // Author : Steve Hodkin // Version : 1.0 // Copyright : Your copyright notice // Description : opencv example in C++, Ansi-style //============================================================================ #include <stdio.h> #include "cv.h" #include "highgui.h" using namespace std; int main(int argc, char* argv[]) { //create and setup a window called "Demo" cvNamedWindow("Demo", CV_WINDOW_AUTOSIZE); //setup camera capture process CvCapture* capture=cvCaptureFromCAM(0); //loop and keep displaying web cam image while( 1 ) { //exit when esc key pressed if (cvWaitKey(100)== 27) break; //get's image IplImage* frame = cvQueryFrame(capture); //display's image in the window cvShowImage("Demo", frame); } //clean up and destroy Demo window cvDestroyWindow("Demo"); return 0; }
Copyright 2010 Steve Hodkin - All Rights Reserved Permission to use, copy, this documentation, without fee or royalty is hereby granted for your personal and non-commercial use only. THIS DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.