Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set Set Rectangular overlay on Camera Preview #30

Closed
kprathap23 opened this issue Nov 10, 2017 · 6 comments
Closed

How to set Set Rectangular overlay on Camera Preview #30

kprathap23 opened this issue Nov 10, 2017 · 6 comments

Comments

@kprathap23
Copy link

kprathap23 commented Nov 10, 2017

32494173-a12cae9a-c3e6-11e7-9668-66e2977dae3f

@KingsMentor
Copy link
Owner

taking a look at this now. Would add this functionality to the next update.

@KingsMentor
Copy link
Owner

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()

@KingsMentor
Copy link
Owner

@kprathap23 available in the latest release.

@jpabanil
Copy link

jpabanil commented Dec 1, 2017

Pls share how did you customized the detector like the way u did :)

@jpabanil
Copy link

jpabanil commented Dec 4, 2017

Still getting this error

CODE

// 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);

ERROR

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)

@eternalBlast
Copy link

eternalBlast commented Aug 23, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants