我试图在opencv java中实现BackgroundSubtractorMOG2。我从apply方法获得此异常。 代码:
package com.java.opencv;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.video.BackgroundSubtractor;
import org.opencv.video.BackgroundSubtractorMOG2;
import org.opencv.video.Video;
import org.opencv.videoio.VideoCapture;
import com.atul.JavaOpenCV.Imshow;
public class HelloCV extends BackgroundSubtractorMOG2{
protected HelloCV(long addr) {
super(addr);
// TODO Auto-generated constructor stub
}
static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }
public static void main(String[] args){
VideoCapture capture = new VideoCapture(2);
HelloCV helloCV = new HelloCV(0);
Mat camImage = new Mat();
BackgroundSubtractorMOG2 mog2 = Video.createBackgroundSubtractorMOG2(10, 16, true);
if (capture.isOpened()) {
while (true) {
capture.read(camImage);
Mat fgMask=new Mat();
/*Line:30*/ mog2.apply(camImage, fgMask,0.1);
Mat output=new Mat();
camImage.copyTo(output,fgMask);
Imshow im = new Imshow("Title");
im.showImage(output);
// displayImageOnScreen(output);
}
}
}
}
线程中的异常" main" java.lang.Exception:未知异常 org.opencv.video.BackgroundSubtractor.apply_0(Native Method)at org.opencv.video.BackgroundSubtractor.apply(BackgroundSubtractor.java:25) 在com.java.opencv.HelloCV.main(HelloCV.java:30)