我的问题是opencv 3.4.3 for android中的javacamera2类中的createcamerapreviewsession()方法
我需要正确创建javacamera2的框架。当我的平面的pixelstride等于1时,我遇到了验证Assert的问题。
在“assert(planes[1].getpixelstride()==2)”验证中应用程序失败,因为摩托罗拉g8中的飞机的pixelstride等于1。在摩托罗拉g6没有问题,因为pixelstride在平面[1]中等于2,但在摩托罗拉g8中它失败了
你知道怎么解决这个问题吗?
mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(ImageReader reader) {
Image image = reader.acquireLatestImage();
if (image == null)
return;
// sanity checks - 3 planes
Image.Plane[] planes = image.getPlanes();
assert (planes.length == 3);
//assert (image.getFormat() == mPreviewFormat);
// see also https://developer.android.com/reference/android/graphics/ImageFormat.html#YUV_420_888
// Y plane (0) non-interleaved => stride == 1; U/V plane interleaved => stride == 2
assert (planes[0].getPixelStride() == 1);
assert (planes[1].getPixelStride() == 2);
assert (planes[2].getPixelStride() == 2);
ByteBuffer y_plane = planes[0].getBuffer();
ByteBuffer uv_plane = planes[1].getBuffer();
Mat y_mat = new Mat(h, w, CvType.CV_8UC1, y_plane);
Mat uv_mat = new Mat(h / 2, w / 2, CvType.CV_8UC2, uv_plane);
JavaCamera2Frame tempFrame = new JavaCamera2Frame(y_mat, uv_mat, w, h);
deliverAndDrawFrame(tempFrame);
tempFrame.release();
image.close();
}
}, mBackgroundHandler);
谢谢
暂无答案!
目前还没有任何答案,快来回答吧!