convert byte array to mat in java

asked 2013-10-11 07:02:16 -0500

Melvin gravatar image

updated 2013-10-11 14:29:55 -0500

public void onPictureTaken(byte[] data, Camera camera) {

    // The camera preview was automatically stopped. Start it again.
    byte buf[] = new byte[100];

  Mat m = new Mat(1, 100, CvType.CV_8UC1);
m.put(0, 0, buf);
//  MatOfRect faceDetections = new MatOfRect();
//  fd.NATIVE_DETECTOR.detectMultiScale(m, faceDetections);

Error: Cannot invoke detectMultiScale(Mat, MatofRect) on primitive type int

The image data will be passed into this method so I can convert it to Mat so i can use the detect multi scale to detect faces on the image. But I do not know how to convert it. Any idea or suggestions is greatly appreciated. Thank you.

edit retag flag offensive close merge delete


Are you trying to use detectMultiScale on an empty Mat? If not, please add the rest of your code.

Moster gravatar imageMoster ( 2013-10-11 15:30:56 -0500 )edit