Mat (int, int, int, byte[]) is undefinded

asked 2018-03-20 13:09:04 -0600

Marko5280 gravatar image

My camera outputs data in the form byte[] and I can get to a black and white image. But, I need to convert to Mat color. My attempt gets me the error message above. Is there a different method? Working code.

byte[] Still;
Insten.grabFrame(Still);
YUYVImage BlackWhiteImage;
BlackWhiteImage = new YUYVImage(Still, WIDTH, HEIGHT);

Code I need to work.

byte[] Still;
Insten.grabFrame(Still);
if(Still.length == HEIGHT * WIDTH * 3)
    {    Mat cvyuv = new Mat(HEIGHT, WIDTH, CvType.CV_8UC1, Still);
         Mat cvbgr = new Mat();
        Imgproc.cvtColor(cvyuv, cvbgr, Imgproc.COLOR_YUV2BGR);
   }
edit retag flag offensive close merge delete

Comments

yes, that constructor does not exist (for reasons unknown). you can still use cvyuv.put(0,0,Still) later.

and you cannot retrieve the color information from a b/w image, so the cvtColor currently does not make any sense.

see documentation here

it seems, that your YUVYImage has color information, but that might be in seperate image planes, consecutive, not interleaved. (so you'd have to get 3 seperate Y,U,V Mat's (like: with System.arraycopy and some offset) from your byte[] and later merge() those to a yuv image, then you can convert that to bgr.

berak gravatar imageberak ( 2018-03-21 03:15:18 -0600 )edit