Tuesday, November 19, 2013

JavaCV Tutorial 2 -Video Processing




 In this tutorial I've explained some basic video processing operations such as getting the input from a Video file or a webcam, process those frame and apply some image trans formation operations.
In the function "cvCreateFileCapture("");" , the default location is the project directory from where it loads the Video file, you can also include the path of the video file inside quotes just like in the last tutorial I've explained.
In the function "cvCreateCameraCapture();", 'CV_CAP_ANY ' argument detects the default webcam connected to PC and gets the input from that. But if you are having multiple webcams then you can include arguments like :
Arguments                          Numerical Value
CV_CAP_ANY                          0
CV_CAP_MIL                           100
CV_CAP_VFW                         200
CV_CAP_V4L                           200
CV_CAP_V4L2                         200
CV_CAP_FIREWIRE               300
CV_CAP_IEEE1394                  300
CV_CAP_DC1394                     300
CV_CAP_CMU1394                 300

In " if(c==27) " statement you can compare the value with any other key pressed and break the loop, visit the link below to know the ascii values of different keys :
" http://www.lucidtechnologies.info/ascii.htm "

Source Code: " https://drive.google.com/file/d/0Bxr1St4kFOnQT3ZhbFlTS2V1UFE/edit?usp=sharing "


14 comments:

  1. I am facing a problem while loading a video file .There is an error

    A fatal error has been detected by the Java Runtime Environment:

    # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000066de2030, pid=180, tid=7980

    I am using opencv 2.4.5 .Camera capturing is working fine but i can't load a video

    ReplyDelete
    Replies
    1. Its not the problem with JavaCv, but its the core java which is throwing this kind of an exception. This might be due to the fact that the video might not accessible by the program, try running eclipse using admin rights or change the access rights of that video file which you are trying to load.

      Delete
    2. Thank You for answering .It worked with eclipse .But I am doing swings project on netbeans .Its almost done and want to add the video processing feature in my project.Is there any way that I can continue on netbeans

      Delete
    3. Nevermind I will use vlcj for loading video .Thanks for your help

      Delete
    4. OK :) .. All the best with your project... If possible do post a youtube video on tat ... :)

      Delete
  2. Hello once again.I am facing a problem .According to opencv 2.4.5 documentation there is a photo package in it ,but I can't find one .
    Link
    http://docs.opencv.org/java/2.4.5/
    I am trying to use fastNlMeansDenoising method in my program ,but netbeans says it can't find the symbol.All other packages are there but package Photo is not there .Do I have to use any other package for fastNlMeansDenoising?

    ReplyDelete
  3. Recently I haven't tried coding in Opnecv(JavaCV), but have you imported " org.opencv.photo.Photo" or " org.opencv.photo.Photo.* " into ur project. .... ? Try to import it if u haven't . : )

    ReplyDelete
  4. I tried but netbeans says there is no package as org.opencv.photo.Photo.

    ReplyDelete
  5. i cannot use cvCreateFileCapture("kjewr.mp4"); function. Like this there are many other functions i cannot use..why is that,can you help me... i have opencv-2.4.10 installed and javacv installed according to this link ( https://github.com/bytedeco/javacv ) ..is it the problem with importing or version conflicting...
    also can you please tell me how did you import all the libraries before the start of the code .. please help me...i cannot go ahead because of this

    ReplyDelete
  6. i want to extract all frame from video file using opencv or javacv
    please can you explain to me or ex sourcode program java. thanks

    ReplyDelete
  7. Hello your work is vital to a project I am doing so please help me to get pass an Eclipse-bug/error: Tried to import ALL the latest update libraries for the the Eclipse IDE; but I still get: Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_highgui in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
    at com.googlecode.javacpp.Loader.load(Loader.java:586)
    at com.googlecode.javacpp.Loader.load(Loader.java:540)
    at com.googlecode.javacv.cpp.opencv_highgui.(opencv_highgui.java:79)
    at JVCV4.main(JVCV4.java:24)
    Caused by: java.lang.UnsatisfiedLinkError: C:\Users\Ejer\AppData\Local\Temp\javacpp3220830472281\jniopencv_highgui.dll: Can't find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:700)
    ... 4 more

    ReplyDelete
  8. cvCreateFileCapture("FileName") is not able read file even though the file is present in the directory. Can you help me.

    ReplyDelete
  9. hello sir i am using netbeans
    i am getting this errors for the program videoprocessing

    Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1865)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1119)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
    at com.googlecode.javacpp.Loader.load(Loader.java:489)
    at com.googlecode.javacpp.Loader.load(Loader.java:431)
    at com.googlecode.javacv.cpp.opencv_core.(opencv_core.java:127)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:344)
    at com.googlecode.javacpp.Loader.load(Loader.java:453)
    at com.googlecode.javacv.cpp.opencv_imgproc.(opencv_imgproc.java:96)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:344)
    at com.googlecode.javacpp.Loader.load(Loader.java:453)
    at com.googlecode.javacv.cpp.opencv_highgui.(opencv_highgui.java:91)
    at javaapplication22.javacv.main(javacv.java:46)
    Caused by: java.lang.UnsatisfiedLinkError: no opencv_core231 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1865)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1119)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
    at com.googlecode.javacpp.Loader.load(Loader.java:481)
    ... 11 more
    Java Result: 1
    BUILD SUCCESSFUL (total time: 1 second)


    thanks

    ReplyDelete
  10. Hello

    Can you update your video ?

    Thanks

    ReplyDelete