小编典典
在我看来,为什么为opencv所谓的自动生成的Java包装器缺少此功能是一个谜。我首先用VideoCapture(String
filename)构造函数创建了一个新的VideoCapture类,并调用了私有本机方法。这导致不满意的链接错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.highgui.VideoCapture.n_VideoCapture(Ljava/lang/String;)J
at org.opencv.highgui.VideoCapture.n_VideoCapture(Native Method)
at org.opencv.highgui.VideoCapture.(VideoCapture.java:90)
at Tester.main(Tester.java:30)
这表明缺少相应的JNIEXPORT。幸运的是,这可以解决。
令人惊讶的是,所需的c构造函数已在 opencv-2.4.6 / modules / highgui / include / opencv2 /
highgui / highgui.cpp中定义
CV_WRAP VideoCapture(const string& filename);
我们在 opencv-2.4.6 / modules / java / generator / src / java / highgui +
VideoCapture.java中 的VideoCapture类中添加我们很久的构造函数 :
//
// C++: VideoCapture::VideoCapture(const string& filename)