Introduction to openCV (Java)

1. Today I will show you how using openCv with java

2. OpenCV is a very use full tool for working with images

3. Normally openCV is using with c++. But we can use openCV with java

4. First you have to download and install the openCV

5. You can download it from following link

OpenCV

When you installing the openCV, it will asks folder to extract. Then choose C drive and extract them.

6. Then you have download few jar files. Download them and extract them

7. Go to following link and download them(only the following files)

JavaCV


8. After you extract it you can see "javac-bin" folder and "javacv-cppjars" folder

OK. Now open neatbeans and make new project

9. Now you have add few libraries

10. Right click on libraries and choose "Add Jar/Folder"


11. Now open the javac-bin folde. Select javacpp.jar,javacv.jar jar files and if you using windows choos javacv-windows-x86.jar and javacv-windows-x86_64.jar files.if you usin another operating system please choose jar file by compareing with your operating system.
12. Select them and click open.
13. Same way go to javacv-cppjars folde and choose jar files with your operating system name.

14. Now simply add a button to jframe. Double click on it and got click event of button

15. Type the following codes

IplImage image=cvLoadImage("C:\\Users\\Udayanga\\Desktop\\Internet\\img.png");
        final CanvasFrame canvas= new CanvasFrame("Demo");
        canvas.showImage(image);
        canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);

16. If you see some erro right clic on code area and choose Fix Imports

17. Now run your programm.


By using openCV we can make very interesting applications. Follow is some of them.




2 comments: