How to get Mat with a drawable input in Android using OpenCV
Asked Answered
Q

1

11

I have some image files in the drawable folder. And now, I want to convert them into opencv Mat object. I've found a function:

Mat img = Highgui.imread(inFile);

which is reading a file path to get the Mat.

However, I can't get path of my images as I can only read them by using their id like R.drawable.img1.

How could I achieve what I want?

Queeniequeenly answered 25/11, 2013 at 3:23 Comment(0)
V
15

This should do

Mat img = Utils.loadResource(context, refrenceimgID, Highgui.CV_LOAD_IMAGE_COLOR);
Imgproc.cvtColor(img, gryimg, Imgproc.COLOR_RGB2BGRA);
Vuong answered 25/11, 2013 at 8:57 Comment(1)
what's gryimg?Sturges

© 2022 - 2024 — McMap. All rights reserved.