I've got a simple setup:
preview = new Preview.Builder().build();
preview.setSurfaceProvider(mPreviewView.createSurfaceProvider());
imageAnalysis = new ImageAnalysis.Builder().setTargetResolution(new Size(mPreviewView.getWidth(),mPreviewView.getHeight())).build();
imageAnalysis.setAnalyzer(executor, new PaperImageAnalyser());
ImageAnalyzer:
@SuppressLint("UnsafeExperimentalUsageError")
@Override
public void analyze(@NonNull ImageProxy imageProxy) {
Image mediaImage = imageProxy.getImage();
if (mediaImage != null) {
InputImage image = InputImage.fromMediaImage(mediaImage, imageProxy.getImageInfo().getRotationDegrees());
Log.e("madieaimage",mediaImage.getHeight() + " and with" + mediaImage.getWidth()); //480 and with640
Log.e("inputimage", image.getHeight() + " and width" + image.getWidth()); //480 and width640
Log.e("imageproxy", image.getHeight() + " and width" + image.getWidth()); //480 and width640
Log.e("cameraimp previewview ", CameraImp.mPreviewView.getBitmap().getHeight() + " and widht" + CameraImp.mPreviewView.getBitmap().getWidth()); //2145 and widht1080
image = InputImage.fromBitmap(CameraImp.mPreviewView.getBitmap(),0); //analyzes much better cause resolution is set but its not good practise right?
}
//analyze with image...
}
The issue is that the resolution of the Image I receive from the analyze method is much smaller than the previewview resoltion (widht/height), so that causes that images are not really good recongnized.
If I use the bitmap of the previewview I get the entire pic of the screen basically which works better for the analyzation, but thats bad practice I assume?
So my question is: Is it possible to set the resolution of the ImageAnalyzer (eg setTargetResolution) I tried above?
Or what would the best way be to deal with such an issue?