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?

1 Answer 1

15

This should do

Mat img = Utils.loadResource(context, refrenceimgID, Highgui.CV_LOAD_IMAGE_COLOR);
Imgproc.cvtColor(img, gryimg, Imgproc.COLOR_RGB2BGRA);
Sign up to request clarification or add additional context in comments.

1 Comment

what's gryimg?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.