GithubHelp home page GithubHelp logo

Comments (9)

mikebuss avatar mikebuss commented on July 26, 2024

Hey @nickw444, thanks for the suggestion. I can definitely add tap-to-focus functionality to MTBBarcodeScanner, but I don't have any plans to expose the capture session or device.

I'm hoping to keep the library as easy to use as possible, which means abstracting some of these details away from the user and exposing easier interfaces. For example with the torch functionality, we almost chose to expose the AVCaptureDeviceInput object, which would make turning on the torch as simple as:

if ([captureDeviceInput.device hasTorch]) {
    if ([captureDeviceInput.device lockForConfiguration:nil] == YES) {
        [captureDeviceInput.device setTorchMode:AVCaptureTorchModeOn];
        [captureDeviceInput.device unlockForConfiguration];
    }
}

But instead we exposed a simpler way, which is now:

self.scanner.torchMode = MTBTorchModeOn;

This takes away some of the functionality (i.e. we can't tell if the device actually has a torch), but for the majority of use-cases that's OK.

If you think adding tap-to-focus would be useful, I can maybe add a tapToFocus boolean to the library to enable this. Were you thinking of implementing this in a way similar to this?:

  • User taps the previewView
  • Based on the tap location, the focusPointOfInterest is set to a window around the touch

Or were there other properties you wanted to change based on user interaction?

Pull requests are also welcome if you'd like to implement this. I should be able to get to it in the next few weeks, but some people have tight deadlines and choose to take a swing themselves!

from mtbbarcodescanner.

nickw444 avatar nickw444 commented on July 26, 2024

Hey @mikebuss that's a fair reason for hiding the internals. Simple is better!

Implementing touch to focus similar to how the torch is implemented is a great way to go about it - no need for the user to rely on their own implementation. I like it!

I can only see a single issue with this - user feedback. It would be nice to show the user where they touched, and, not every app will do this the same - they might want to use different UI Features, or just not show the user at all.

My suggestion is that upon touch handle, a block/callback is triggered, which allows the user to provide their own feedback view drawing code, which will paint the feedback square (or whatever view they wish) over the preview view. (and at the same time MTBBarcodeScanner handles the focusing)

This would allow MTBBarcodeScanner to handle the internals of focusing, whilst still allowing the user to provide their own custom UI.

What are your thoughts on this method?

I'll see if I can find some time to implement this (since it would improve 2 apps using this library), however i'm also pretty tied up at the moment.

from mtbbarcodescanner.

mikebuss avatar mikebuss commented on July 26, 2024

Yes that sounds great.

from mtbbarcodescanner.

jaybowong avatar jaybowong commented on July 26, 2024

Want this feature so much!

from mtbbarcodescanner.

jaybowong avatar jaybowong commented on July 26, 2024

@nickw444 Have you implemented this? How about a PR? I think a lot of people need this feature and it can help a lot.

It's quite often to me that It doesn't focus when scanning a bar code (e.g. a bar code on the back of a book).

from mtbbarcodescanner.

mikebuss avatar mikebuss commented on July 26, 2024

@jaybowong I can take a stab at this over the weekend. I will update this ticket with the results.

from mtbbarcodescanner.

mikebuss avatar mikebuss commented on July 26, 2024

I added an initial implementation for this. When the user taps the screen, MTBBarcodeScanner will now set the focusPointOfInterest to the point the user tapped and call a block named didTapToFocusBlock(), which can be overridden for custom drawing.

The full details can be found here. The README also has documentation on this.

Please feel free to submit a PR with any improvements.

from mtbbarcodescanner.

jaybowong avatar jaybowong commented on July 26, 2024

Thanks @mikebuss 👍
Can't wait to try this!

from mtbbarcodescanner.

nickw444 avatar nickw444 commented on July 26, 2024

Awesome stuff. I'll be sharing a gist as soon as I can which uses this and adds a apple camera like focus square.

from mtbbarcodescanner.

Related Issues (20)

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.