Example usage for org.opencv.android Utils loadResource

List of usage examples for org.opencv.android Utils loadResource

Introduction

In this page you can find the example usage for org.opencv.android Utils loadResource.

Prototype

public static Mat loadResource(Context context, int resourceId, int flags) throws IOException 

Source Link

Usage

From source file:com.projectcs2103t.openglestest.OpenGLES20Activity.java

License:Apache License

private void initNative() {
    String secStore = System.getenv("EXTERNAL_STORAGE");//internal sd
    System.out.println("external storage:" + secStore);
    String modelFile = secStore + "/virtual/model.ply";
    File f = new File(modelFile);
    System.out.println("file existence = " + f.exists());
    System.out.println("file readable = " + f.canRead());

    nl = new NativeLinker();
    nl.loadModel(modelFile);//  w  w w.  j a  v a2 s . c o m
    try {
        Mat patternImg = Utils.loadResource(OpenGLES20Activity.this, R.drawable.pattern1, 1);
        nl.loadPattern(patternImg.getNativeObjAddr());
        patternImg = Utils.loadResource(OpenGLES20Activity.this, R.drawable.pattern2, 1);
        nl.loadPattern(patternImg.getNativeObjAddr());
        patternImg = Utils.loadResource(OpenGLES20Activity.this, R.drawable.pattern3, 1);
        nl.loadPattern(patternImg.getNativeObjAddr());
    } catch (Exception e) {
    }
}

From source file:com.team.formal.eyeshopping.ActivityFindingResults.java

License:Open Source License

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_finding_results);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//  w w  w .j  av  a2s .com
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    gridView = (GridView) findViewById(R.id.list_view);

    try {
        // TODO ?? naverPrImgTarget .. url 
        userSelImg = Utils.loadResource(this, R.drawable.user_image, CvType.CV_8UC4); // return BGR 
        // naverPrImg = Utils.loadResource(this, R.drawable.marmont_bag, CvType.CV_8UC4);
    } catch (IOException e) {
        e.printStackTrace();
    }

    // made by jaeman
    Intent intent = getIntent();
    String url = intent.getStringExtra("url");
    Uri uri = Uri.parse(intent.getStringExtra("uri"));

    //        TextView textView = (TextView) findViewById(R.id.text_view);
    //        String text = "Url : " + url + "\nUri: " + uri.toString();
    //        textView.setText(text);

    Bitmap bitmap = null;
    // get Bitmap image from uri
    try {
        bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {
        callCloudVision(bitmap);
    } catch (IOException e) {
        Log.d(TAG, "Image picking failed because " + e.getMessage());
    }
    // end of jaeman

    TextView t = (TextView) findViewById(R.id.loadingText);
    t.setVisibility(View.VISIBLE);
    GridView g = (GridView) findViewById(R.id.list_view);
    g.setVisibility(View.GONE);
}