Thursday, 1 January 2015

Some users do not know how to setup OpenCV in Eclipse (A pre requisite to Object tracking OpenCV tutorial I published earlier) , so I decided to make a small tutorial.

STEPS

1.Create a Java Project from "New"

2. Right click on the project and select "Properties"


3.Navigate to "Java Build path" section, and select the "Libraries" tab.

4. Click "Add External Jar"
5. Navigate to "Your OpenCV directory\build\java" and select "opencv-249.jar"

6. Not done yet, You have to set path to native library.
7. Expand the opencv-249.jar as shown and select "Native library location". Click Edit button.

8. Point to  "Your OpenCV directory\build\java\x86" for 32Bit Processor OR "Your OpenCV directory\build\java\x64" for 64Bit Processor



Native libary must be set, else it will generate an "UnsatisfiedLinkException" .


 

9. "System.loadLibrary(Core.NATIVE_LIBRARY_NAME);"  must be used for every OpenCV java program written. To make Eclipse load OpenCV libraries.


Done !

5 comments:

  1. Hello,
    I have a problem to read file video at :

    VideoCapture camera = new VideoCapture("D:\\Videos\\ball.avi");

    How am i going to fix it?

    ReplyDelete
    Replies
    1. This can be due to various problems.
      1. The input video file ball.avi is not present at D:\\Videos\\ . Your path or drive might be different
      2. Your computer does not have decoders. Try using ffdshow codecs
      3. OpenCV's native Library path must be set as in steps 7&8

      Delete
    2. i am also facing the same issue.

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Thank you very much...
    Your Explanation helped me to run a ready code which i was trying to run from last week.
    thanks a lot for such a wonderful explanation.

    ReplyDelete