Rohan Yadav
Rohan Yadav

Reputation: 11

affdex frame.getOriginalBitmapFrame() returns null when analyzing camera feed

So I am writing some facial landmarking code with the affdex sdk, and I am trying to pass the frame I recieved from the image listener to get certain pixels from its bitmap, and I am getting back null when I try to get this bitmap. Any help to figure out why this is the case would really help! Additionally, I am using the CameraDetector.

@Override
public void onImageResults(List<Face> faces, Frame frame, float v) {
    if (faces == null|| frame == null)
        return; //frame was not processed

    if (faces.size() == 0)
        overlayView.adjustFaces(null, null);
    //final Bitmap b = Bitmap.createBitmap(cameraView.getMeasuredWidth(), cameraView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);

    overlayView.adjustFaces(faces, frame);

    final Bitmap frameF = frame.getOriginalBitmapFrame();
    final List<Face> facesF = faces;

    extractorThread.addToRunnableQueue(new Runnable() {
        @Override
        public void run() {
            float data = regionVal(facesF, frameF);
            System.out.println(data);
            extractorThread.updateBuffer(data);
            extractorThread.computeHR();
        }
    });
}

The frameF bitmap I get is always null, and I dont know why

Upvotes: 1

Views: 70

Answers (1)

Andy Dennie
Andy Dennie

Reputation: 6052

getOriginalBitmapFrame() only returns a Bitmap if the Frame is a BitmapFrame. If the Frame is a ByteArrayFrame, it returns null.

CameraDetector works with ByteArrayFrames, since the camera's onPreviewFrame callback provides a byte array. So, you can get the image data via getByteArray().

Upvotes: 1

Related Questions