Use Netbeans to work with OpenCV on Ubuntu

Step1:  In Netbeans, create a new C/C++ project.

I chose C/C++ application here.

Step2:Edit project properties.

Right click on the project, select properties. Here edit values in two sections.
1.C++ compiler:in the Include directories, add “/usr/local/include/opencv2” (include opencv2 if you want to code both c++ & c programs. if you want to make only c progs, include /usr/local/include/opencv)2.Linker : Add the path added above, “/usr/local/include/opencv2″(or /usr/local/include/opencv as instructed above) in the Runtime Search Directories field.In the Libraries field, click on ..,the select Add PkgCofig Library.In the list that shows up, select opencv. It will automatically add the line `pkg-config –libs opencv` as shown.

Step3: Test

In the application ,there will be a main.cpp under source file. Add this code to test if your configuration is working

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <cv.h>
 #include <highgui.h>
int main ( int argc, char **argv )
 {
 cvNamedWindow( "My Window", 1 );
 IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
 CvFont font;
 double hScale = 1.0;
 double vScale = 1.0;
 int lineWidth = 1;
 cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,
 hScale, vScale, 0, lineWidth );
 cvPutText( img, "Hello World!, I can now code openCV ", cvPoint( 0, 200 ), &font,
 cvScalar( 255, 255, 0 ) );
 cvPutText( img, "in a kickass IDE ", cvPoint( 150, 300 ), &font,
 cvScalar( 255, 255, 0 ) );
 cvShowImage( "My Window", img );
 cvWaitKey();
 return 0;
 }


https://thefreecoder.wordpress.com/2012/09/10/use-netbeans-to-work-with-opencv-on-ubuntuand-linux-mint-and-other-distros-too/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s