Android SLIC超像素

时间:2018-09-12 23:12:42

标签: android opencv opencv-contrib

我是新的android开发人员。我正在寻找在Android Studio上使用超像素SLIC算法。但是在测试我的代码后,我得到了这个错误:

java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.ximgproc.Ximgproc.createSuperpixelSLIC_0(long, int, int, float) (tried Java_org_opencv_ximgproc_Ximgproc_createSuperpixelSLIC_10 and Java_org_opencv_ximgproc_Ximgproc_createSuperpixelSLIC_10__JIIF)

这是我的代码,有人可以帮助我,我的应用程序中需要SLIC超像素,但我不知道如何解决此错误吗?!!

public class MainActivity extends AppCompatActivity {

private static final String TAG = "3:qinQctivity";
Button button;
ImageView imageView;

Mat newImage;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    button = findViewById(R.id.button);
    imageView = findViewById(R.id.image);


    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            if (!OpenCVLoader.initDebug()) {
                OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_4_0, getApplicationContext(), baseLoaderCallback);
            } else {
                baseLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);

            }
        }
    });

}

BaseLoaderCallback baseLoaderCallback = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {
        super.onManagerConnected(status);
        if (status == LoaderCallbackInterface.SUCCESS) {
            try {
                newImage = new Mat();

                newImage = Utils.loadResource(getApplicationContext(), R.drawable.retinalimage, CvType.CV_32FC3);

                SuperpixelSLIC x= Ximgproc.createSuperpixelSLIC(newImage, Ximgproc.SLIC,50,(float)0.001);



            } catch(IOException e){
                e.printStackTrace();
            }
        }

    }


} ;

void showImage (Mat y){
    Bitmap bm = Bitmap.createBitmap(y.width(), y.height(), Bitmap.Config.ARGB_8888);
    Utils.matToBitmap(y, bm);
    imageView.setImageBitmap(bm);
}

0 个答案:

没有答案