mgcrea / vision-camera-barcode-scanner

High performance barcode scanner for React Native using VisionCamera
MIT License
84 stars 10 forks source link

Android build fails on 0.6.x #10

Closed prabucki closed 10 months ago

prabucki commented 10 months ago

Hi - first of all, thank you for picking up code scanning through vision camera after rodgomesc.

I'm afraid the changes made starting from v0.6.0 are causing error when building on Android. Here is the output when building the example app from the repo:

error: cannot find symbol inputImage.setCropRegion(regionOfInterestRect); ^ symbol: method setCropRegion(Rect) location: variable inputImage of type InputImage Note: /vision-camera-barcode-scanner-master/example/node_modules/@mgcrea/vision-camera-code-scanner/android/src/main/java/com/visioncameracodescanner/CodeScannerProcessorPlugin.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error

From what I gathered, InputImage does not have a method setCropRegion: https://developers.google.com/android/reference/com/google/mlkit/vision/common/InputImage

Removing the following lines:

if (regionOfInterestList != null) {
  Rect regionOfInterestRect = new Rect(
    regionOfInterestList.get(0).intValue(),
    regionOfInterestList.get(1).intValue(),
    regionOfInterestList.get(0).intValue() +
    regionOfInterestList.get(2).intValue(),
    regionOfInterestList.get(1).intValue() +
    regionOfInterestList.get(3).intValue()
  );
  inputImage.setCropRegion(regionOfInterestRect);
}

from /android/src/main/java/com/visioncameracodescanner/CodeScannerProcessorPlugin.java solves the issue, but I'm not sure how to properly implement the region of interest feature then (personally not an issue for me, but thought I'll mention).

mgcrea commented 10 months ago

Not sure how I missed the build failing, just released a new version (https://github.com/mgcrea/vision-camera-barcode-scanner/releases/tag/0.6.3) without the problematic line and will look to implement the regionOfInterest properly in a future release (unfortunately it's not trivial on android!). Thanks for the quick feedback!