这是一款Android应用,可将RGB图像转换为灰度并在屏幕上显示。根据{{1}},我从
获得了logcat
unsatisfiedLinkError
有什么问题?
Mat ImageMat = new Mat (image.getHeight(), image.getWidth(), CvType.CV_8U, new Scalar(4));
答案 0 :(得分:0)
onCreate是放置opencv代码的错误位置,因为它依赖于本机的c ++代码。
首先你需要加载opencv,所以:
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
if (status == LoaderCallbackInterface.SUCCESS ) {
// now we can call opencv code !
} else {
super.onManagerConnected(status);
}
}
};
@Override
public void onResume() {;
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_5,this, mLoaderCallback);
// you may be tempted, to do something here, but it's *async*, and may take some time,
// so any opencv call here will lead to unresolved native errors.
}
@Override
public void onCameraViewStarted(int width, int height) {
// probably the best place for your opencv code
}