Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Added preview callback #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Sumsar
Copy link

@Sumsar Sumsar commented Mar 22, 2017

Callback to get preview byte data

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@Sumsar
Copy link
Author

Sumsar commented Mar 22, 2017

I signed it!

@xCatG xCatG mentioned this pull request Mar 22, 2017
}

mCallbackImageDataReader = ImageReader.newInstance(width, height,
ImageFormat.NV21, /* maxImages */ 1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I don't think NV21 is supported in Camera2. It should be YUV_420_888 in Camera2 case. It cashed on my N5X with Caused by: java.lang.IllegalArgumentException: NV21 format is not supported

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackyhieu1211
Copy link

Camera1 on device HTC Butterfly 4.3 API 18 not call
mCamera.setPreviewCallback(new Camera.PreviewCallback() {
@OverRide
public void onPreviewFrame(byte[] data, Camera camera) {
Timber.e("onPreviewFrame");
final Camera.Parameters parameters = camera.getParameters();
final int width = parameters.getPreviewSize().width;
final int height = parameters.getPreviewSize().height;
mCallback.onPreviewFrame(data, parameters.getPreviewFormat(), width, height);
}
});

@jackyhieu1211
Copy link

I fix it

@OverRide
public void onSurfaceChanged() {
if (mCamera != null) {
setUpPreview();
adjustCameraParameters();
mCamera.setPreviewCallback(Camera1.this);
}
}

}
return data;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some image formats have multiple planes, including YUV420_888 (the default for Camera2). All planes need to be included in the output byte array.

@hardysim
Copy link

Any progress on this? I'm trying to get ML Kit to work but the example code uses Camera 1 API and lags terribly and this here seems like the perfect match but is not yet included 😭.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants