GithubHelp home page GithubHelp logo

Comments (8)

i1E avatar i1E commented on July 19, 2024

Hi @rachelfong,

with provided QuadViewManager it is not possible to achieve what you want. You can not get the quad size nor the quad position. You should create your own overlay view with the desired behaviour. If you want that scanning is not active outside of the shown scanning window, you should set the same scanning window on the RecognizerView (make sure that it is identical to the scan window that is shown to the user) by using method setScanningRegion.

As an example, you can use BlinkOCRSegmentDemo demo app and see how the scan overlay is defined in that app.

from blinkinput-android.

rachelfong avatar rachelfong commented on July 19, 2024

Hi @i1E ,

Thank you for pointing me to the right direction. I took a quick look at the demo app mentioned and managed to implement the overlay view on top of RecognizerView. The red/green edges which tells the user that it is a successful scan are no longer implemented? Also, can I keep changing the scanning region during runtime to accommodate orientation changes? Would there be any risks in doing so (memory leaks, concurrency/threading issues)?

from blinkinput-android.

i1E avatar i1E commented on July 19, 2024

Hi @rachelfong,

adding your custom overlay over the RecognizerVIew does not prevent you to add QuadView on top of it. You can take a look at the IDScanActivity from BlinkOCRDetectorDemo app and see how built in QuadViewManager is used to display successful detections. You can use OcrResultCharsView or OcrResultDotsView to indicate successfully recognized characters over the camera overlay (there is example for this in mentioned activity).

You can change the scanning region during runtime without worrying about memory leaks or concurrency issues, but if you want to change the scanning region only to accommodate orientation changes, you can achieve this with setScanningRegion method (pass true as the second argument to define that scanning region should be rotated with device).

from blinkinput-android.

rachelfong avatar rachelfong commented on July 19, 2024

Hi @i1E ,

I am unable to get the static QuadView to be displayed on my blurred overlay and have it to be transparent, showing the camera preview. So I opted to follow the CustomSegment way of doing things which is to build segments around a view which is transparent to get the user to position their documents within the frame. However, like I mentioned, one of the losses would be not being able to get the red/green edges. My project does not need the OcrResultsCharsView on top of the RecognizerView so I left that out.

I tried out the setScanningRegion method, but as most smart phones go, the ratio of the view I built for Portrait vastly differs from the Landscape.

This is what I was expecting, blue region is supposed to be blurred, red region supposed to be fully transparent to show the clear camera preview and get the user to position their document within this frame:

expected results

What I got was this upon rotating:

actual results

So I have no choice but to build two different overlays for each orientation to achieve what I needed, overlap them in my activity layout and hide one of them based on current orientation, hence my attempts to change the scanning region repeatedly, but apparent setScanningRegion does not allow repeated initializations.

I will keep trying to achieve it for a few more hours, otherwise, I will have no choice but to give up on Landscape and just force Portrait on the Activity.

Update: Apologies on the many questions on this. Let me rephrase my matter into a summary. Basically what I need is the functionality of the demo app you mentioned in your first answer, but with landscape orientation (without distorting the fully transparent frame, like the QuadViewPreset.DEFAULT_FROM_SCAN_CARD_ACTIVITY on another demo) and red/green edges of the viewfinder supported. Would it be possible?

from blinkinput-android.

DoDoENT avatar DoDoENT commented on July 19, 2024

What you got is actually expected, because scanning region is defined with relative rectangle, so same percentages are used in both portrait and landscape. If you want to have different scanning regions in portrait and landscape then proceed as follows:

  • put your activity in portrait-only mode
  • implement OrientationChangeListener
  • set it to RecognizerView
  • in onOrientationChange callback of OrientationChangeListener for portait orientations call setScanningRegion with portait rectangle, and for landscape orientations call it with landscape rectangle
  • also, use same callback to animate your blurred view from one rectangle into another (note that your view is still in portrait coordinates, as activity is still in portrait)

Note that if you allow sensor orientation changes for your activity in AndroidManifest.xml you cannot have smooth animated transition in UI from portrait rectangle to landscape rectangle (as is demonstrated with builtin QuadViewPreset.DEFAULT_FROM_SCAN_CARD_ACTIVITY) due to activity restarts that happen when activity configuration changes.

However, if you use onConfigurationChange callback to update your views when activity changes configuration from portrait to landscape and vice versa, first make sure that you call changeConfiguraion on RecognizerView and also update its scanning region in same callback.

from blinkinput-android.

rachelfong avatar rachelfong commented on July 19, 2024

Hi @i1E ,

Thanks for the advice. Followed your instructions and it seems to work towards what I needed. Thank you very much for this.

from blinkinput-android.

DoDoENT avatar DoDoENT commented on July 19, 2024

If that has solved your problem, please close this issue.

from blinkinput-android.

rachelfong avatar rachelfong commented on July 19, 2024

Thank you very much. I shall close it now.

from blinkinput-android.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.