ZBar之ZBarReaderViewController

简介:

//
//  ViewController.m
//  ZBarReaderViewController
//
//  Created by City--Online on 15/6/9.
//  Copyright (c) 2015年 CYW. All rights reserved.
//

#import "ViewController.h"
#import "ZBarSDK.h"

@interface ViewController ()<ZBarReaderDelegate>
@property(nonatomic,strong) UIImageView *imgView;
@property(nonatomic,strong) UILabel *label;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];
    [btn setTitle:@"扫你" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    btn.frame=CGRectMake(10, 100, 60, 40);
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
    _imgView=[[UIImageView alloc]initWithFrame:CGRectMake(100, 200, 200, 200)];
    [self.view addSubview:_imgView];
    
    _label=[[UILabel alloc]initWithFrame:CGRectMake(10, 150, 300, 40)];
    [_label setTextColor:[UIColor redColor]];
    [self.view addSubview:_label];
}
-(void)btnClick:(id)sender
{
    ZBarReaderViewController *reader=[[ZBarReaderViewController alloc]init];
    reader.readerDelegate=self;
    ZBarImageScanner *scanner=reader.scanner;
    [scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0];
    reader.showsZBarControls=YES;
    reader.showsHelpOnFail=NO;
//    reader.showsCameraControls=YES;
    [self presentViewController:reader animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    id<NSFastEnumeration> results = [info objectForKey:ZBarReaderControllerResults];
    ZBarSymbol * symbol;
    for(symbol in results)
        break;
    
    _imgView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    
    [picker dismissViewControllerAnimated:YES completion:nil];
    
    _label.text = symbol.data;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end



相关文章
|
机器学习/深度学习 安全
A Lightweight and Accurate Recognition Framework for Signs of X-ray Weld Images
在质量检测行业中,x射线图像是保证设备安全的常用手段。x射线焊缝图像标识识别在制造业数字化溯源系统中起着至关重要的作用。焊缝图像中物体的尺度差异较大,难以实现理想的识别。
151 0
|
边缘计算 并行计算 算法
Opencv+ZBar识别条形码、二维码
Opencv+ZBar识别条形码、二维码
790 0
Opencv+ZBar识别条形码、二维码
|
开发工具 计算机视觉
配置zbar识别二维码(转载)
原文地址:http://blog.csdn.net/dcrmg/article/details/52108258  二维码解码器Zbar+VS2012开发环境配置 Zbar条码解码器是一个开源的二维码(包括条形码)解码器,可以识别来至于视频流,图像文件、手持扫码器和视频设备(如摄像头)等二维码识别,支持EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, QR Code(二维码)等常用编码方式的条形码/二维码。
2538 0
|
传感器 机器人
robot_pose_ekf运行报错问题解决
robot_pose_ekf运行报错问题解决
robot_pose_ekf运行报错问题解决
|
编解码
Google Earth Engine(GEE)——大尺度范围的GIMMS NDVI From AVHRR Sensors (3rd Generation)如何下载?
Google Earth Engine(GEE)——大尺度范围的GIMMS NDVI From AVHRR Sensors (3rd Generation)如何下载?
358 0
Google Earth Engine(GEE)——大尺度范围的GIMMS NDVI From AVHRR Sensors (3rd Generation)如何下载?
|
编解码
Google Earth Engine(GEE)——影像导出到assets中出现问题
Google Earth Engine(GEE)——影像导出到assets中出现问题
688 0
Google Earth Engine(GEE)——影像导出到assets中出现问题
ZBAR库
ZBAR库
231 0
zbar库中的zbar_scan_y函数
zbar库中的zbar_scan_y函数
221 0
zbar中的zbar_scan_image 函数
zbar中的zbar_scan_image 函数
384 0