Comments (9)
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.
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.
Yes that sounds great.
from mtbbarcodescanner.
Want this feature so much!
from mtbbarcodescanner.
@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.
@jaybowong I can take a stab at this over the weekend. I will update this ticket with the results.
from mtbbarcodescanner.
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.
Thanks @mikebuss
Can't wait to try this!
from mtbbarcodescanner.
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)
- Only works with iOS10+ after recent changes HOT 2
- Impossible to read CODABAR barcode HOT 1
- Disable rotation HOT 1
- Initial camera setting HOT 1
- Warnings HOT 4
- Call stopScanning crash in viewDidDisappear HOT 4
- Flutter + Xcode 8.0: 3 errors, 9 warnings HOT 1
- Catalyst Support? HOT 4
- Maximum of read multiple codes HOT 3
- Problem configurating scanner with QR and Barcode HOT 5
- output becomes Garbled text HOT 8
- Crash NSInvalidArgumentException *** -[AVCaptureMetadataOutput setMetadataObjectTypes:] Unsupported type found - use -availableMetadataObjectTypes HOT 3
- when barcode data increased it is difficult to read Code.. HOT 1
- UIView preview has issues during orientation changes HOT 6
- Define Barcodetype in Swift HOT 3
- Camera Unfreeze method not working on. HOT 3
- Unrecognized Barcode Style HOT 1
- Camera unfreeze is corrupting flash HOT 3
- Getting the bytes raw HOT 1
- It's crashing on iPad and iPhone after you try to scan QR code. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mtbbarcodescanner.