我有这个代码打开默认相机
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(camera, CAMERA_REQUEST);
这是为了拍摄照片
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap bitmap = (Bitmap) Objects.requireNonNull(data.getExtras()).get("data");
ByteArrayOutputStream stream=new ByteArrayOutputStream();
assert bitmap != null;
bitmap.compress(Bitmap.CompressFormat.PNG,100,stream);
byte[] imageBytes=stream.toByteArray();
sendReceive.write(String.valueOf(imageBytes.length).getBytes());
int subArraySize=400;
for(int i=0;i<imageBytes.length;i+=subArraySize){
byte[] tempArray;
tempArray= Arrays.copyOfRange(imageBytes,i,Math.min(imageBytes.length,i+subArraySize));
sendReceive.write(tempArray);
}
}
我有一个问题,我如何捕捉相机预览帧?