Closed kprathap23 closed 5 years ago
taking a look at this now. Would add this functionality to the next update.
I just added setCustomDetector(Detector<Barcode> customDetector)
to help achieve this.
Here is an example of how you can achieve this:
public class CustomBarCodeDetector extends Detector<Barcode> {
public SparseArray<Barcode> detect(Frame frame) {
// do something with frame
return null;
}
public boolean isOperational() {
return super.isOperational();
}
}
see this on for further clarification on how you can use this.
don't forget to call barcodeCapture.refresh()
after calling setCustomDetector()
@kprathap23 available in the latest release.
Pls share how did you customized the detector like the way u did :)
// init Barcode Detector BarcodeDetector mBarcodeDetector = new BarcodeDetector.Builder(getContext()).build(); CustomBarcodeDetector mCustomBarcodeDetector = new CustomBarcodeDetector(mBarcodeDetector);
// init BarcodeCapture
mBarcodeCapture = (BarcodeCapture) getChildFragmentManager().findFragmentById(R.id.barcode);
mBarcodeCapture.setRetrieval(this);
mBarcodeCapture.setBarcodeFormat(Barcode.CODE_128)
.shouldAutoFocus(true)
.setCameraFacing(CameraSource.CAMERA_FACING_BACK)
.setShowDrawRect(false)
.setSupportMultipleScan(false)
.setTouchAsCallback(false)
.setShowFlash(false)
.setShouldShowText(false);
mBarcodeCapture.setCustomDetector(mCustomBarcodeDetector);
mBarcodeCapture.refresh(true);
E/OpenCameraSource: Exception thrown from receiver. java.lang.IllegalStateException: Detector processor must first be set with setProcessor in order to receive detection results. at com.google.android.gms.vision.Detector.receiveFrame(Unknown Source) at com.google.android.gms.samples.vision.barcodereader.ui.camera.CameraSource$FrameProcessingRunnable.run(CameraSource.java:1222) at java.lang.Thread.run(Thread.java:818)
Hi @jpabanil, do you achieve the success result now? Hi @KingsMentor, I try what you suggest at that link. However, i can't find the setCustomDetector method (using gradle dependency). Would you mind to provide more details in the readme section and the params (preferably in Kotlin version though)? Thanks.