- Install Microsoft Visual C++ Microsoft Visual C++ 2010 Redistributable Package (x86) or Microsoft Visual C++ 2010 Redistributable Package (x64) (If your system is 64 bit)
- Download opencv 2.4.0 OpenCV windows SuperPack version 2.4.0
- Note- Opencv 2.4.1 does not work with this. It gives a linking error.
- Extract opencv to C:
- Set up environment variables
- 64-bit version of the JDK: C:\opencv\build\common\tbb\intel64\vc10\;C:\opencv\build\x64\vc10\bin\;
- 32-bit version of the JDK: C:\opencv\build\common\tbb\ia32\vc10\;C:\opencv\build\x86\vc10\bin\; ”.
- Download and extract javacv Link. This contains 8 jar files
- When creating projects add those jar files to the libraries folder
- In netbeans right click Libraries and select ”add JAR/folder” and select above jar files.
- In eclipse right click the project folder and select properties. Select “java build path” and select the Libraries tab and add the required jar files.
- Check the following code. This captures an image from the web cam.
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
public class CaptureImage {
private static void captureFrame() {
// 0-default camera, 1 - next...so on
final OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0);
try {
grabber.start();
IplImage img = grabber.grab();
if (img != null) {
cvSaveImage("capture.jpg", img);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
captureFrame();
}
}
- You can find the captured picture on the project folder. To change the camera change the number that is passed to the OpenCVFrameGrabber constructor.
Sutra Directory
when i try this code after doing this steps,i have error that i cant resolve it .please help me
ReplyDeleteC:\Users\MaJeSTiC\AppData\Local\Temp\javacpp867018211705\jniopencv_core.dll: Can't find dependent libraries
I got the same error when I used opencv 2.4.1 (as stated in step 2)
ReplyDeleteBut when I used 2.4.0 there was no error. Also check whether the step 4 is done correctly.
when i try this code after doing this steps, I used 2.4.0 ,i have error that i cant resolve it .please help me
ReplyDeleteC:\Users\MaJeSTiC\AppData\Local\Temp\javacpp867018211705\jniopencv_core.dll: Can't find dependent libraries
Please help me quickly
@nuwan
ReplyDeleteI got the same error with 2.4.1.
But was able to successfully run openCV using the above steps.
Did you correctly set up environment variables ??
I've followed all the instructions you gave. But the error is-
ReplyDelete"java.lang.UnsatisfiedLinkError: jniopencv_core.dll: Can't find dependent libraries" can you please help me in this? It was kind of urgent.
Thank you.
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Jaimin\AppData\Local\Temp\javacpp824382310842\jniopencv_core.dll: Can't find dependent libraries
ReplyDeleteDid you correctly set up environment variables ??
DeleteI am having same Error even after setting up environment variables perfectly. OpenCV is working perfectly but not JCV, nither using 2.4.8 nor 2.4.0
ReplyDeleteMay be a problem with the version of OpenCV. When I used 2.4.1 there was some error.
DeleteI was seen error "could not find the main class?"
ReplyDeleteplz reply me...what i do?
may be something wrong with the code.
DeleteI did not get such an error