yeahdongcn / rsbarcodes_swift Goto Github PK
View Code? Open in Web Editor NEW1D and 2D barcodes reader and generators for iOS 8 with delightful controls. Now Swift.
License: MIT License
1D and 2D barcodes reader and generators for iOS 8 with delightful controls. Now Swift.
License: MIT License
Can you add Release notes for new releases?
It appears that setting
self.window?.backgroundColor = UIColor.greenColor()
in didFinishLaunchingWithOptions conflicts with the RSCodeReaderViewController camera view. The camera view doesn't use the camera; rather, it is simply a UIViewController with the same background color as declared above
I successfully reproduced this bug on a dummy project, and it does demonstrate this behavior for regular UIImagePickerController
Any ideas/ suggestions?
QR Images returned by generateBarcode are low res.
Hi,
I've created a view controller that is working in general.
The problem however is that if I start the app in portrait mode everything is working.
If I turn the app to landscape, all UI elements are changing but the camera is still showing the portrait view.
Does anyone know this problem?
Thanks
David
I can't seem to figure out why the barcodes are only scanned when it's in the top half of the camera feed. This is true in portrait and landscape orientation. Is this expected behavior?
The scanner view (actually the AVCaptureVideoPreviewLayer) does not handle rotation properly.
I could make it better by adding this in RSCodeReaderViewController.swift - however the orientation is still wrong when the initial device orientation is not portrait (such as with an iPad).
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
let previousTransform = layer!.affineTransform()
let rotation = coordinator.targetTransform()
let newTransform = CGAffineTransformConcat(previousTransform, CGAffineTransformInvert(rotation))
layer!.setAffineTransform(newTransform)
layer!.frame.origin = CGPointZero
}
P.S: Thanks for this great library!
We are supposed to use AVCaptureDeviceDiscoverySession.
not sure how I should change this.
Hi
Installed using Cocoapods, went through the reader process and when I get to the point where I need to choose a subclass for ScanViewController, RSCodeReaderViewController isn't there.
However, if I hard code RSCodeReaderViewController as a subclass, and cmd+click on RSCodeReaderViewController in the file, I successfully get directed to its implementation.
Nonetheless the ScanViewController file throws multiple errors, the first one indicating "Use of undeclared type 'RSCodeReaderViewController'".
Any ideas?
the QRCode appears very small...
let image: UIImage? = gen.generateCode(contents, machineReadableCodeObjectType: AVMetadataObjectTypeQRCode)
if let image = image {
self.barcodeView.image = RSAbstractCodeGenerator.resizeImage(image, scale: 1.0)
}
Need to add Swift 3 support to library.
We're getting some crashes in our live app.
RSCodeGenerator.swift line 210
static RSAbstractCodeGenerator.resizeImage(UIImage, scale : CGFloat) -> UIImageCrashed: com.apple.main-thread
EXC_BREAKPOINT 0x00000001010f1d14
public class func resizeImage(source:UIImage, scale:CGFloat) -> UIImage {
let width = source.size.width * scale
let height = source.size.height * scale
UIGraphicsBeginImageContext(CGSizeMake(width, height))
let context = UIGraphicsGetCurrentContext()
CGContextSetInterpolationQuality(context, CGInterpolationQuality.None)
source.drawInRect(CGRectMake(0, 0, width, height))
let target = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return target
}
Is there a way I can switch the default camera to the front one?
Fails Build due to Beta 5 changes to swift.
The specialized classes are all declared internal, so they can't be used outside the RSBarcodes_Swift
module.
class RSEAN8Generator: RSEANGenerator {
...
}
class RSEAN13Generator: RSEANGenerator {
...
}
class RSISBN13Generator: RSEAN13Generator {
...
}
class RSISSN13Generator: RSEAN13Generator {
...
}
2014-11-29 02:48:10.998 *[1259:60b] Unknown class _TtC10RSBarcodes26RSCodeReaderViewController in Interface Builder file.
I notice that certain layers were not resizing on rotation. Here is a proposed fix in RSCodeReaderViewController.swift
override public func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
if videoPreviewLayer != nil {
videoPreviewLayer!.frame = CGRectMake(0, 0, size.width, size.height)
focusMarkLayer!.frame = CGRectMake(0, 0, size.width, size.height)
cornersLayer!.frame = CGRectMake(0, 0, size.width, size.height)
}
}
I am not certain this is the best way, please advise.
I would like to use Swift-2.0 branch but it seems the 2.0 podspec is the same as master so these is no way to use the 2.0 code via cocopods. Is this correct or am I missing something?
I'd like to do something like:
pod 'RSBarcodes_Swift', :git => 'https://github.com/yeahdongcn/RSBarcodes_Swift.git', :branch => 'Swift-2.0'```
[Update] Seems as though entering the above actually did work for my Swift 2.0 project. Not quite sure why it didn't use the latest tag from master.
You are now using onApplicationDidChangeStatusBarOrientation to handle orientation changes.
This works fine when the device is initially in portrait but not if it is for example an iPad starting the app in landscape.
Using viewDidLayoutSubviews instead with the exact same code works fine:
override func viewDidLayoutSubviews() {
if videoPreviewLayer != nil
&& videoPreviewLayer!.connection.supportsVideoOrientation {
videoPreviewLayer!.connection.videoOrientation = RSCodeReaderViewController.InterfaceOrientationToVideoOrientation(UIApplication.sharedApplication().statusBarOrientation)
}
}
Please add PDF417 support for your component.
Thanks
I created a container view that was placed in the main view. Main view does not use RSCodeReaderViewController, but the view inside container view does. When I get to run the app, it displays the preview layer and I can alternate stroke colors, self.focusMarkLayer.strokeColor = UIColor.redColor().CGColor. However, when I point to the barcode, nothing gets displayed. What am I doing wrong?
Is there any plans to update this for swift 2.0.
Should be a matter of converting and a bit of clean up. I'm not familiar enough with this library and swift to help myself otherwise I would.
It would be nice to be able to chose the color for the RSCornersLayer.
I managed to allow this with these changes - there might be a better way :-)
In class RSCodeReaderViewController I added:
var cornerLayerColor = UIColor.greenColor()
override func viewWillLayoutSubviews() {
cornersLayer.strokeColor = cornerLayerColor.CGColor
}
and in my custom subclass of RSCodeReaderViewController:
override func viewWillLayoutSubviews() {
self.cornerLayerColor = UIColor(red: 255.0/255.0, green: 44.0/255.0, blue: 85.0/255.0, alpha: 1.0)
super.viewWillLayoutSubviews()
}
The correct Barcode is 070177137069 but using RSBarcode it shows 0070177137069.
I have set up a ViewController as described, it worked a few times and I was able to scan codes, however now it just shows a black screen. I've given it access to my camera so I am not sure how to fix this issue. Any ideas?
I want to create a array of barcode scanned. But how i rescan a new barcode without reload viewcontroler.
Plz help me and sorry for my bad English
If so, know that this breaks Cocoapods pointing to the branch. Perhaps a more elegant solution exists?
我发现self.barcodesHandler = {barcodes in } 会执行N次,扫的码有多长就执行多少次,每次barcodes除了坐标不一样,条码的值都一样。
我想当扫码成功后,立即返回一个结果,也就是上述代码只执行一次最好,求指点该如何弄?
Not sure if I'm using the correct xcode terms but here it goes..
Instead of initlizing the barcode scanner to take up the whole view controller, I want it to only display the preview window in a smaller UIView that is inside of the viewcontroller.. I haven't been able to figure out if this is possible with your existing code or not.
I would like to create an application which receives various types of bar codes. How can I detect the type of code you are reading?
Thanks for the help
I'm seeing a EXC_BAD_ACCESS in Crashlytics in RSCornersLayer.swift
. Unfortunately, Crashlytics is reporting this on line 0, which isn't all that helpful. Here's what it says:
RSBarcodes_Swift
RSCornersLayer.swift line 0
function signature specialization <Arg[0] = Owned To Guaranteed, Arg[1] = Owned To Guaranteed> of RSBarcodes_Swift.RSCornersLayer.drawInContext (RSBarcodes_Swift.RSCornersLayer)(ObjectiveC.CGContext!) -> ()
RSBarcodes_Swift
RSCornersLayer.swift line 0
@objc RSBarcodes_Swift.RSCornersLayer.drawInContext (RSBarcodes_Swift.RSCornersLayer)(ObjectiveC.CGContext!) -> ()
Did I do something wrong, or is there an issue here in RSBarcodes?
Hi. It seems that neither Cocoapods nor Carthage are working right now. Are you planing to include this?
I'm getting a build error with the swift2 branch when installing using carthage:
.../RSBarcodes_Swift/Source/RSCodeGenerator.swift:159:76: error: value of optional type 'CIImage?' not unwrapped; did you mean to use '!' or '?'?
.../RSBarcodes_Swift/Source/RSCodeGenerator.swift:159:53: error: value of optional type 'CIImage?' not unwrapped; did you mean to use '!' or '?'?
There is a couple of compiling issues since the beta 6 update.
need to import RSBarcodes_Swift
manually in the ViewController file after creating the file using wizard.
Besides the sample controller file uses import RSBarcodes
which should also be updated.
As seen below, there are a few more errors as well when trying to build this new branch.
Have been using RSBarcodes for some time now, but somewhere between the latest IOS updates (9+), it began not working.
I now receive:
Error Domain=AVFoundationErrorDomain Code=-11814 "Cannot Read" UserInfo={NSLocalizedDescription=Cannot Record, NSLocalizedRecoverySuggestion=Try recording again.}
This occurs within "viewDidLoad()" in RSCodeReaderViewController on
"input = try AVCaptureDeviceInput(device: self.device)"
Any ideas?
Thanks, Ryan
The following block in RSCode39Generator.swift checks the contents against the .uppercaseString:
override public func isValid(contents: String) -> Bool {
let length = contents.length()
if length > 0 && contents == contents.uppercaseString {
for character in contents.characters {
let location = CODE39_ALPHABET_STRING.location(String(character))
if location == NSNotFound {
return false
}
}
return true
}
return false
}
Other libraries (like zxing
and barcodelib
) will simply uppercase the contents and check to make sure afterwards.
Should we do this within RSBarcodes as well?
Re: 37f3de0
I saw your recent commit for "crazy mode," but was wondering if you could explain what this mode does? I looked around to see if I could find a mention here of Klenov Dmitry to see if there was already a discussion about it, but did not see any.
I am building an app that utilizes QR code scanning. What I am trying to do in my ScanViewController
is to scan a QR code, validate what was scanned, and then segue with the scanned data. Currently, when a QR code is detected, my UI freezes, and shortly after I get an error and memory dump:
'NSInternalInconsistencyException', reason: 'Only run on the main thread!'.
Maybe, this isn't the right place to validate the QR code or isn't the right place to segue, but if not, I'm wondering where the validation and segue should take place. My only other requirement is that the validation only occurs when a QR code is detected, which I believe to happen when captureOutput() is called in RSCodeReaderViewController.
class ScanViewController: RSCodeReaderViewController{
// Class Variables
var finalObject: IBuiltCode?
let ObjectHelper = ObjectBuilder() // Service to validate and build valid scanned objects
override func viewDidLoad() {
super.viewDidLoad()
self.focusMarkLayer.strokeColor = UIColor.redColor().CGColor
self.cornersLayer.strokeColor = UIColor.yellowColor().CGColor
self.tapHandler = { point in
println(point)
}
self.barcodesHandler = { barcodes in
for barcode in barcodes {
println("Barcode found: type=" + barcode.type + " value=" + barcode.stringValue)
// returns nil if invalid (can provide validateAndBuild func code if necessary)
var builtObject = self.ObjectHelper.validateAndBuild(barcode,
scannedData: barcode.stringValue)
if builtObject != nil{
println("Good object.")
self.performQR()
}
}
}
}
func performQR(){
performSegueWithIdentifier("toQR", sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "toQR"){
let QRVC: QRViewController = segue.destinationViewController as! QRViewController
QRVC.receivedObject = finalObject as? QRObject
}
}
}
On most occasions after scanning a barcode, the green detection line remains on the view permanently.
The title of your project mentions "delightful controls," yet they apparently are nowhere to be found and undocumented. Are there any controls for a RSCodeReaderViewController, and if so how do they work?
Thank you!
The isValid function is not accessible because the class cannot be initialised.
Is there any reason why the init method is not public?
Thanks
Chetan
want a new function, browse and select image from local, and scan it
希望增加一个读取本地图片并识别的功能
I created a view controller in storyboard and set it's subclass to an RSCodeReaderViewController type class, but when the app runs this view controller seems to come up blank.
When I create a view controller programmatically and present it as a modal, it works fine.
It seems after iOS 10.0.1 update, I'm getting a crash on ViewDidLoad
Here is my code:
https://github.com/Treverr/inSparkle/blob/master/inSparkle/QRCodeScanner.swift
It just jumps right to crashing with very little to no information
libsystem_kernel.dylib`__abort_with_payload:
0x1877c4d6c <+0>: movz x16, #0x209
0x1877c4d70 <+4>: svc #0x80
-> 0x1877c4d74 <+8>: b.lo 0x1877c4d8c ; <+32>
0x1877c4d78 <+12>: stp x29, x30, [sp, #-16]!
0x1877c4d7c <+16>: mov x29, sp
0x1877c4d80 <+20>: bl 0x1877a97b4 ; cerror_nocancel
0x1877c4d84 <+24>: mov sp, x29
0x1877c4d88 <+28>: ldp x29, x30, [sp], #16
0x1877c4d8c <+32>: ret
Any ideas?
I hope only the comments are wrong!
public enum InputCorrectionLevel: String {
case Medium = "M" // 7%
case Low = "L" // 15% default
case Quarter = "Q" // 25%
case High = "H" // 30%
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.