I am working on an iOS application and I am interested to embed some already developed and tested barcode scanner into it. I tried zxing but this never extract the numbers out of it. My goal is to scan this image and get 24 characters out of it.
If there is not a already developed thing, I would like to build one myself. How should I start in order to create it from scratch for 1D barcodes initially?
Using zxing I am using this piece of code now.
- (IBAction)scanPressed:(id)sender {
ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:YES];
zxing::oned::Code128Reader *code128Reader = new zxing::oned::Code128Reader();
MultiFormatOneDReader *mfReader = [[MultiFormatOneDReader alloc] initWithReader:code128Reader];
NSSet *readers = [[NSSet alloc ] initWithObjects:mfReader,nil];
[mfReader release];
widController.readers = readers;
[readers release];
NSBundle *mainBundle = [NSBundle mainBundle];
widController.soundToPlay =
[NSURL fileURLWithPath:[mainBundle pathForResource:#"beep-beep" ofType:#"aiff"] isDirectory:NO];
[self presentModalViewController:widController animated:YES];
[widController release];
}
I tried ZXing SDK first but it didn't work. I then tried ZBar SDK which worked just amazingly great.
If in future someone would need the same thing I am going to post the link which helped me make it work.
http://zbar.sourceforge.net/iphone/sdkdoc/tutorial.html
If this is a "Code 128" barcode, pay attention of the variant of the code.
For example if using zxing you successfully scanned the code but the decoded values do not match the numbers under the barcode, that's probably because zxing decoded the barcode bytes successfully but didn't render the result using the expected alphabet.
Code 128 exists in three variants:
Code 128 A which uses the alphabet "!#$%&'()*+.-/0123456789:;<=>?# ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
Code 128 A which uses the wider alphabet "!#$%&'()*+.-/0123456789:;<=>?# ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`` abcdefghijklmnopqrstuvwxyz{|}~
Code 128 C which encodes numbers 0-9
Maybe zxing returns the 128-A or 128-B interpretation of the barcode and not the 128-C variant? In such cases it would mean that the scanning works correctly but you may force the barcode format so it can interpret it right.
Maybe I'm wrong about this the zxing code bases for iphone only allows for QR codes.
From the website site http://code.google.com/p/zxing/
There are also additional modules which are contributed and/or
intermittently maintained:
zxing.appspot.com: The source behind our web-based barcode generator
csharp: Partial C# port
cpp: Partial C++ port
**iphone: iPhone client + port to Objective C / C++ (QR code only)**
jruby: Ruby wrapper
actionscript: partial port to Actionscript
Related
I am using PSPDFKit framework, and I am unable to add stamp annotation, using this I have implemented following:
[pdfController.annotationStateManager toggleState:PSPDFAnnotationStringStamp];
NSMutableArray<PSPDFStampAnnotation *> *defaultStamps = [NSMutableArray array];
for (NSString *stampSubject in #[#"Great!", #"Stamp", #"Like"]) {
PSPDFStampAnnotation *stamp = [[PSPDFStampAnnotation alloc] initWithSubject:stampSubject];
stamp.boundingBox = CGRectMake(0.f, 0.f, 200.f, 70.f);
[defaultStamps addObject:stamp];
}
PSPDFStampAnnotation *imageStamp = [[PSPDFStampAnnotation alloc] init];
imageStamp.image = [UIImage imageNamed:#"abc.jpg"];
imageStamp.boundingBox = CGRectMake(0.f, 0.f, imageStamp.image.size.width/4.f, imageStamp.image.size.height/4.f);
[defaultStamps addObject:imageStamp];
[PSPDFStampViewController setDefaultStampAnnotations:defaultStamps];
but I have no output.
Peter here, Founder and CEO of PSPDFKit, the PDF SDK for iOS, Android, Web, macOS and (soon) Windows. The best way to reach our support is reaching out directly to our support page. Support is part of your license subscription.
You're setting default stamps for the PSPDFStampViewController. Can you post a screenshot how things look? You're changing the default here (APPROVED, REJECTED and so on and replacing this with your own images, which is valid and works.)
Note that you only need to call this once and it needs to be called before you switch/toggle the stamp mode, so your current code will not work.
Please also make sure you use the latest version so we can rule out any old bugs or incompatibilities. As of writing this, it's Xcode 8.3 and PSPDFKit 6.6 (click for release blog post).
Stamps only show up if you have the annotation component licensed - if you ping us on support my team can check what components you have to make sure that's not the problem here.
If you're just trying to programmatically add annotations via our framework, check out this guide article instead.
I used AVFoundation framework delegate methods to read QR Code.It is reading almost all QR codes & giving resulted data for them. But when I try with some QR code(eg. below QR image) , it is predicting that it is QR code but does not give any data for it.
Your sample is triggering an internal (C++) exception.. it seems to be getting caught around [AVAssetCache setMaxSize:] which suggests either the data in this particular sample is corrupt, or it's just to large for AVFoundation to handle.
As it's an internal exception it is (mostly) failing silently. The exception occurs when you try to extract the stringValue from your AVMetadataMachineReadableCodeObject.
So if you test for the existence of your AVMetadataMachineReadableCodeObject, you will get YES, whereas if you test for stringValue you will get NO.
AVMetadataMachineReadableCodeObject *readableObject =
(AVMetadataMachineReadableCodeObject *)[self.previewLayer
transformedMetadataObjectForMetadataObject:metadataObject];
BOOL foundObject = readableObject != nil;
//returns YES
BOOL foundString = readableObject.stringValue != nil;
//returns NO + triggers internal exception
It's probably best to test for the string, rather than the object, and ignore any result that returns NO.
update
In your comment you ask about native framework solution that will read this barcode. AVFoundation is the native framework for barcode reading, so if it fails on your sample, you will have to look for third-party solutions.
zxing offers an iOS port but it looks to be old and unsupported.
zbarSDK used to be a good solution but also seems to be unsupported past ios4. As AVFoundation now has built-in barcode reading, this is unsurprising.
This solution by Accusoft does read the sample but is proprietary and really pricey.
I do wonder about the content of you sample though - it looks either corrupt or some kind of exotic encoding...
Is it possible to create a single QR code that contains the url, vcard and geo location all in one?
QR Codes can contain anything you want, they are just data.
There are no norms for the data inside QR Codes, but there are good practice such as MeCARD, Wireless network, Geolocation. It's hard to predict whether the phone/OS/QR Code reader
will read it correctly or not.
Here is a great list maintained by ZXing: https://code.google.com/p/zxing/wiki/BarcodeContents.
Anyway, the best is to create a QR Code with a web link, and do your thing in a web page or with a file to download. You can create editable web links for QR Code at http://www.unitag.fr, they are called QR Code Live.
There are lots of QR code generators.
Here is one:
http://www.qrstuff.com/
Click on "text" and you can put in all kinds of stuff - up to 1000 characters.
Here is the first line of the Gettysburg Address:
One QR code generator is also at zxing QR code generator. I used it and generated a QR code and scanned that code with QR code reader app on my Windows 8 phone. Works great. Many thanks to those guys at zxing. Moreover, you can generate QR code in any app (Windows Phone/Android/iPhone/WinForms/Windows 8 desktop app) using the libraries for respective platform.
An example in .NET 4.0 follows. This code doesn't use any obsolete classes/methods.
string contact = File.ReadAllText(#"C:\Users\****\Documents\****.vcf");
BarcodeWriter bcWriter = new BarcodeWriter();
ZXing.Rendering.BitmapRenderer renderer = new ZXing.Rendering.BitmapRenderer();
bcWriter.Renderer = renderer;
bcWriter.Format = BarcodeFormat.QR_CODE;
Bitmap bm = bcWriter.Write(contact);
pictureBoxQrCode.Image = bm;
bm.Save(#"C:\Users\****\Documents\****.png");
I want to take a numerical string and generate a simple barcode that can be read by any scanner.
I can already use the camera and read a barcode but now I would like to generate a barcode.
Does anyone know of an sdk that will allow me to do this, resources or code snipets?
Thank you
The only free library to do this is Cocoa-Touch-Barcodes, which is a fork of cocoabarcodes. If you are considering commercial libraries, there is one called iPhone Barcode Generator.
update Check this objective-c port of ZXing: https://github.com/TheLevelUp/ZXingObjC
Include : #import "NKDBarcodeFramework.h" in your Header File and put these lines below in your init function.
barcode = [NKDExtendedCode39Barcode alloc];
barcode = [barcode initWithContent:#"1234567890123" printsCaption:0];
[barcode calculateWidth];
NSLog(#"%#",[barcode description]);
theImage = [UIImage imageFromBarcode:barcode];
subview = [[UIImageView alloc]initWithFrame:TTScreenBounds()];
[subview setImage:theImage];
[self addSubview:subview];
self.frame = self.bounds;
have fun :-)
There are so many barcode types
One D
Two D
Three D
Each barcode type has so many subtypes and each has its own purpose.
I explain how to generate one of the One D barcode type code 39
here i explain how to generate that barcode using Custom font
Steps:
1)Download the custom font from here
2)Attach the file FRE3OF9X.ttf from the downloaded zip
3)add the key Fonts provided by application in info.plist and in item 0 give FRE3OF9X.ttf as value
4)Try the below code snippet
UIFont *fntCode39=[UIFont fontWithName:#"Free3of9Extended" size:30.0];
UILabel *lblBarCodeTest=[[UILabel alloc]initWithFrame:CGRectMake(0,100,768,30)];
[lblBarCodeTest setBackgroundColor:[UIColor lightGrayColor]];
[lblBarCodeTest setTextAlignment:NSTextAlignmentCenter];
[lblBarCodeTest setFont:fntCode39];
[lblBarCodeTest setText:#"*BarCode3Of9_AKA_Code39-ItsA1DBarcode*"];
[self.view addSubview:lblBarCodeTest];
Result:
You can use CoreImage to generate Barcode images. CoreImage contains 4 filters to generate different barcodes: CICode128BarcodeGenerator, CIQRCodeGenerator, CIPDF417BarcodeGenerator, CIAztecCodeGenerator.
I've created a simple class for generating Code 39 Barcode, only one .h and one .m needed to add to your project, and with one line of code it generates the UIImage with code 39 encoded data for you, like this:
UIImage *code39Image = [Code39 code39ImageFromString:#"HELLO CODE39" Width:barcode_width Height:barcode_height];
Here's the link to the project on github:
[https://github.com/bclin087/Simple-Code39-generator-for-iOS.git ]
I am writing an application to create a movie file from a bunch of images on an iPhone. I am using OpenCv. I downloaded OpenCv static libraries for ARM(iPhone's native instruction architecture) and the libraries were generated just fine. There were no problems linking to them libraries.
As a first step, I was trying to create a .avi file using one image, to see if it works. But cvCreateVideoWriter always returns me a NULL value. I did some searching and I believe its due to the codec not being present. I am trying this on the iPhone simulator. This is what i do:
- (void)viewDidLoad {
[super viewDidLoad];
UIImage *anImage = [UIImage imageNamed:#"1.jpg"];
IplImage *img_color = [self CreateIplImageFromUIImage:anImage];
//The image gets created just fine
CvVideoWriter *writer =
cvCreateVideoWriter("out.avi",CV_FOURCC('P','I','M','1'),
25,cvSize(320,480),1);
//writer is always null
int result = cvWriteFrame(writer, img_color);
NSLog(#"\n%d",result);
//hence this is also 0 all the time
cvReleaseVideoWriter(&writer);
}
I am not sure about the second parameter. What sort of codec or what exactly does it do...
I am a n00B at this. Any suggestions?
On *nix flavors, OpenCV uses ffmpeg under the covers to encode video files, so you need to make sure your static libraries are built with ffmpeg support. The second parameter, CV_FOURCC('P','I','M','1'), is the FOURCC code describing the video format/codec you are requesting, in this case the MPEG1 codec. Check out fourcc.org for a complete listing (not all of which work in ffmpeg).