Barcode Generation from within iOS App - ios

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 ]

Related

add stamp annotation using PSPDFKit iOS objective-c

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.

GPUImage failed to init ACVFile with data:(null)

First of all, I must say that GPUImage is an excellent framework. However, when loading an ACV file that I export from Photoshop CS6, it gives me an error saying that: failed to init ACVFile with data:(null). The thing is though, that the same code works for some other ACV files, and the file definitely has data, 64 bites of it in fact.
Here is how I am trying to load it:
GPUImageToneCurveFilter *stillImageFilter2 = [[GPUImageToneCurveFilter alloc] initWithACV:#"test"];
UIImage *quickFilteredImage = [stillImageFilter2 imageByFilteringImage:baseImage];
photoImage.image = quickFilteredImage;
If I change test to another ACV file, it works perfectly. Not sure what is wrong.
Thanks
MehtaiPhoneApps
just add the extension of tone curve file test.acv and you are good to go
=> updated code
GPUImageToneCurveFilter *stillImageFilter2 = [[GPUImageToneCurveFilter alloc] initWithACV:#"test.acv"];
UIImage *quickFilteredImage = [stillImageFilter2 imageByFilteringImage:baseImage];
photoImage.image = quickFilteredImage;

adding GPUImage framework to IOS project

The hours are turning into days trying to add the GPUImage framework into an IOS project. Now I've got it working I'm trying the sample filtering live video code from Sunset Lake Software page. The app fails to build with the following red error: ' Use of undeclared 'thresholdfFilter'
GPUImageVideoCamera *videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
GPUImageFilter *customFilter = [[GPUImageFilter alloc] initWithFragmentShaderFromFile:#"CustomShader"];
GPUImageView *filteredVideoView = [[GPUImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 768, 1024)];
// problem here
[videoCamera addTarget:thresholdFilter];
[customFilter addTarget:filteredVideoView];
[videoCamera startCameraCapture];
Using Xcode 6.0.1 and testing app on iPad2 with IOS 8.0.2 - If required, I can post screen shots of how I emdedded the framework.
First, the code written in my initial blog post announcing the framework should not be copied to use with the modern version of the framework. That initial post was written over two years ago, and does not reflect the current state of the API. In fact, I've just deleted all of that code from the original post and directed folks to the instructions on the GitHub page which are kept up to date. Thanks for the reminder.
Second, the problem you're describing above is that you're attempting to use a variable called thresholdFilter without ever defining such a variable. That's not a problem with the framework, the compiler has no idea what you're referring to.
Third, the above code won't work for another reason: you're not holding on to your camera instance. You're defining it locally, instead of assigning it to an instance variable of your encapsulating class. This will lead to ARC deallocating that camera as soon as your above setup method is complete, leading to a black screen or to a crash. You need to create an instance variable or property and assign your camera to that, so that a strong reference is made to it.

iOS Barcode Efficient Scanner

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

OpenCV and iPhone

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).

Resources