Delete ZBar
@@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module external.linked.project.id="android" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
|
||||||
<component name="FacetManager">
|
|
||||||
<facet type="java-gradle" name="Java-Gradle">
|
|
||||||
<configuration>
|
|
||||||
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/../build" />
|
|
||||||
<option name="BUILDABLE" value="false" />
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
|
||||||
<component name="FacetManager">
|
|
||||||
<facet type="android-gradle" name="Android-Gradle">
|
|
||||||
<configuration>
|
|
||||||
<option name="GRADLE_PROJECT_PATH" value=":app" />
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
<facet type="android" name="Android">
|
|
||||||
<configuration>
|
|
||||||
<option name="SELECTED_BUILD_VARIANT" value="autobonusDebug" />
|
|
||||||
<option name="ASSEMBLE_TASK_NAME" value="assembleAutobonusDebug" />
|
|
||||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileAutobonusDebugSources" />
|
|
||||||
<afterSyncTasks>
|
|
||||||
<task>generateAutobonusDebugSources</task>
|
|
||||||
</afterSyncTasks>
|
|
||||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
|
||||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
|
||||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
|
||||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/src/autobonus/res" />
|
|
||||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
|
||||||
<output url="file://$MODULE_DIR$/../../build/app/intermediates/classes/autobonus/debug" />
|
|
||||||
<output-test url="file://$MODULE_DIR$/../../build/app/intermediates/classes/test/autobonus/debug" />
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonusDebug/res" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonusDebug/resources" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonusDebug/assets" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonusDebug/aidl" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonusDebug/java" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonusDebug/rs" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonusDebug/shaders" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonusDebug/res" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonusDebug/resources" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonusDebug/assets" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonusDebug/aidl" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonusDebug/java" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonusDebug/rs" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonusDebug/shaders" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonus/res" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonus/resources" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonus/assets" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonus/aidl" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonus/java" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonus/rs" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/autobonus/shaders" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonus/res" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonus/resources" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonus/assets" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonus/aidl" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonus/java" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonus/rs" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testAutobonus/shaders" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAutobonus/res" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAutobonus/resources" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAutobonus/assets" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAutobonus/aidl" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAutobonus/java" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAutobonus/rs" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAutobonus/shaders" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
|
||||||
</content>
|
|
||||||
<content url="file://$MODULE_DIR$/../../build/app">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/source/r/autobonus/debug" isTestSource="false" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/source/aidl/autobonus/debug" isTestSource="false" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/source/buildConfig/autobonus/debug" isTestSource="false" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/source/rs/autobonus/debug" isTestSource="false" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/source/apt/autobonus/debug" isTestSource="false" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/res/rs/autobonus/debug" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/res/resValues/autobonus/debug" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/source/r/androidTest/autobonus/debug" isTestSource="true" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/source/aidl/androidTest/autobonus/debug" isTestSource="true" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/source/buildConfig/androidTest/autobonus/debug" isTestSource="true" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/source/rs/androidTest/autobonus/debug" isTestSource="true" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/source/apt/androidTest/autobonus/debug" isTestSource="true" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/res/rs/androidTest/autobonus/debug" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../build/app/generated/res/resValues/androidTest/autobonus/debug" type="java-test-resource" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/assets" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/blame" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/builds" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/classes" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/flutter" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/incremental" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/incremental-classes" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/incremental-runtime-classes" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/incremental-safeguard" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/incremental-verifier" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/instant-run-resources" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/instant-run-support" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/jniLibs" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/manifests" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/pre-dexed" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/reload-dex" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/res" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/restart-dex" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/rs" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/shaders" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/split-apk" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/symbols" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/intermediates/transforms" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/outputs" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/reports" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../build/app/tmp" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
<orderEntry type="library" exported="" name="zbar" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="okio-1.13.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="zxing-1.9.8" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="core-3.3.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="support-core-ui-25.4.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="okhttp-3.8.1" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="flutter" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="support-v4-25.4.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="support-media-compat-25.4.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="flutter-x86" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="imagepicker-1.5.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="core-1.9.8" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="recyclerview-v7-25.4.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="support-annotations-25.4.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="appcompat-v7-25.4.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="support-vector-drawable-25.4.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="support-compat-25.4.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="support-core-utils-25.4.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="support-fragment-25.4.0" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="animated-vector-drawable-25.4.0" level="project" />
|
|
||||||
<orderEntry type="module" module-name="path_provider" exported="" />
|
|
||||||
<orderEntry type="module" module-name="sqflite" exported="" />
|
|
||||||
<orderEntry type="module" module-name="image_picker" exported="" />
|
|
||||||
<orderEntry type="library" exported="" name="glide-3.7.0" level="project" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
|
Before Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 19 KiB |
BIN
ios/Runner.xcodeproj/project.xcworkspace/xcuserdata/kifio.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
@@ -1,45 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2010-2011 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
@class ZBarReaderView;
|
|
||||||
|
|
||||||
// hack around missing simulator support for AVCapture interfaces
|
|
||||||
|
|
||||||
@interface ZBarCameraSimulator
|
|
||||||
: NSObject
|
|
||||||
< UINavigationControllerDelegate,
|
|
||||||
UIImagePickerControllerDelegate,
|
|
||||||
UIPopoverControllerDelegate >
|
|
||||||
{
|
|
||||||
UIViewController *viewController;
|
|
||||||
ZBarReaderView *readerView;
|
|
||||||
UIImagePickerController *picker;
|
|
||||||
UIPopoverController *pickerPopover;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) initWithViewController: (UIViewController*) viewController;
|
|
||||||
- (void) takePicture;
|
|
||||||
|
|
||||||
@property (nonatomic, assign) ZBarReaderView *readerView;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <CoreGraphics/CoreGraphics.h>
|
|
||||||
#import "ZBarImageScanner.h"
|
|
||||||
|
|
||||||
@class AVCaptureVideoDataOutput, AVCaptureOutput;
|
|
||||||
@class ZBarCaptureReader, ZBarCVImage;
|
|
||||||
|
|
||||||
@protocol ZBarCaptureDelegate <NSObject>
|
|
||||||
|
|
||||||
// called when a new barcode is detected. the image refers to the
|
|
||||||
// video buffer and must not be retained for long
|
|
||||||
- (void) captureReader: (ZBarCaptureReader*) captureReader
|
|
||||||
didReadNewSymbolsFromImage: (ZBarImage*) image;
|
|
||||||
|
|
||||||
@optional
|
|
||||||
// called when a potential/uncertain barcode is detected. will also
|
|
||||||
// be called *after* captureReader:didReadNewSymbolsFromImage:
|
|
||||||
// when good barcodes are detected
|
|
||||||
- (void) captureReader: (ZBarCaptureReader*) captureReader
|
|
||||||
didTrackSymbols: (ZBarSymbolSet*) symbols;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface ZBarCaptureReader
|
|
||||||
: NSObject
|
|
||||||
{
|
|
||||||
#if !TARGET_IPHONE_SIMULATOR
|
|
||||||
AVCaptureVideoDataOutput *captureOutput;
|
|
||||||
id<ZBarCaptureDelegate> captureDelegate;
|
|
||||||
ZBarImageScanner *scanner;
|
|
||||||
CGRect scanCrop;
|
|
||||||
CGSize size;
|
|
||||||
CGFloat framesPerSecond;
|
|
||||||
BOOL enableCache;
|
|
||||||
|
|
||||||
dispatch_queue_t queue;
|
|
||||||
ZBarImage *image;
|
|
||||||
ZBarCVImage *result;
|
|
||||||
volatile uint32_t state;
|
|
||||||
int framecnt;
|
|
||||||
unsigned width, height;
|
|
||||||
uint64_t t_frame, t_fps, t_scan;
|
|
||||||
CGFloat dt_frame;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// supply a pre-configured image scanner
|
|
||||||
- (id) initWithImageScanner: (ZBarImageScanner*) imageScanner;
|
|
||||||
|
|
||||||
// this must be called before the session is started
|
|
||||||
- (void) willStartRunning;
|
|
||||||
|
|
||||||
// this must be called *before* the session is stopped
|
|
||||||
- (void) willStopRunning;
|
|
||||||
|
|
||||||
// clear the internal result cache
|
|
||||||
- (void) flushCache;
|
|
||||||
|
|
||||||
// capture the next frame after processing. the captured image will
|
|
||||||
// follow the same delegate path as an image with decoded symbols.
|
|
||||||
- (void) captureFrame;
|
|
||||||
|
|
||||||
// the capture output. add this to an instance of AVCaptureSession
|
|
||||||
@property (nonatomic, readonly) AVCaptureOutput *captureOutput;
|
|
||||||
|
|
||||||
// delegate is notified of decode results and symbol tracking.
|
|
||||||
@property (nonatomic, assign) id<ZBarCaptureDelegate> captureDelegate;
|
|
||||||
|
|
||||||
// access to image scanner for configuration.
|
|
||||||
@property (nonatomic, readonly) ZBarImageScanner *scanner;
|
|
||||||
|
|
||||||
// region of image to scan in normalized coordinates.
|
|
||||||
// NB horizontal crop currently ignored...
|
|
||||||
@property (nonatomic, assign) CGRect scanCrop;
|
|
||||||
|
|
||||||
// size of video frames.
|
|
||||||
@property (nonatomic, readonly) CGSize size;
|
|
||||||
|
|
||||||
// (quickly) gate the reader function without interrupting the video
|
|
||||||
// stream. also flushes the cache when enabled. defaults to *NO*
|
|
||||||
@property (nonatomic) BOOL enableReader;
|
|
||||||
|
|
||||||
// current frame rate (for debug/optimization).
|
|
||||||
// only valid when running
|
|
||||||
@property (nonatomic, readonly) CGFloat framesPerSecond;
|
|
||||||
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
@class ZBarHelpController;
|
|
||||||
|
|
||||||
@protocol ZBarHelpDelegate
|
|
||||||
@optional
|
|
||||||
|
|
||||||
- (void) helpControllerDidFinish: (ZBarHelpController*) help;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
// failure dialog w/a few useful tips
|
|
||||||
|
|
||||||
@interface ZBarHelpController : UIViewController
|
|
||||||
< UIWebViewDelegate,
|
|
||||||
UIAlertViewDelegate >
|
|
||||||
{
|
|
||||||
NSString *reason;
|
|
||||||
id delegate;
|
|
||||||
UIWebView *webView;
|
|
||||||
UIToolbar *toolbar;
|
|
||||||
UIBarButtonItem *doneBtn, *backBtn, *space;
|
|
||||||
NSURL *linkURL;
|
|
||||||
NSUInteger orientations;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (nonatomic, assign) id<ZBarHelpDelegate> delegate;
|
|
||||||
|
|
||||||
// designated initializer
|
|
||||||
- (id) initWithReason: (NSString*) reason;
|
|
||||||
|
|
||||||
- (BOOL) isInterfaceOrientationSupported: (UIInterfaceOrientation) orientation;
|
|
||||||
- (void) setInterfaceOrientation: (UIInterfaceOrientation) orientation
|
|
||||||
supported: (BOOL) supported;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "zbar.h"
|
|
||||||
#import "ZBarSymbol.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
using namespace zbar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Obj-C wrapper for ZBar image
|
|
||||||
|
|
||||||
@interface ZBarImage : NSObject
|
|
||||||
{
|
|
||||||
zbar_image_t *zimg;
|
|
||||||
double t_convert;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (nonatomic) unsigned long format;
|
|
||||||
@property (nonatomic) unsigned sequence;
|
|
||||||
@property (nonatomic) CGSize size;
|
|
||||||
@property (nonatomic) CGRect crop;
|
|
||||||
@property (readonly, nonatomic) const void *data;
|
|
||||||
@property (readonly, nonatomic) unsigned long dataLength;
|
|
||||||
@property (copy, nonatomic) ZBarSymbolSet *symbols;
|
|
||||||
@property (readonly, nonatomic) zbar_image_t *zbarImage;
|
|
||||||
@property (readonly, nonatomic) UIImage *UIImage;
|
|
||||||
|
|
||||||
- (id) initWithImage: (zbar_image_t*) image;
|
|
||||||
- (id) initWithCGImage: (CGImageRef) image;
|
|
||||||
- (id) initWithCGImage: (CGImageRef) image
|
|
||||||
size: (CGSize) size;
|
|
||||||
- (id) initWithCGImage: (CGImageRef) image
|
|
||||||
crop: (CGRect) crop
|
|
||||||
size: (CGSize) size;
|
|
||||||
|
|
||||||
- (void) setData: (const void*) data
|
|
||||||
withLength: (unsigned long) length;
|
|
||||||
- (UIImage*) UIImageWithOrientation: (UIImageOrientation) imageOrientation;
|
|
||||||
- (void) cleanup;
|
|
||||||
|
|
||||||
+ (unsigned long) fourcc: (NSString*) format;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
- convertToFormat: (unsigned long) format;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import "zbar.h"
|
|
||||||
#import "ZBarImage.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
using namespace zbar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Obj-C wrapper for ZBar image scanner
|
|
||||||
|
|
||||||
@interface ZBarImageScanner : NSObject
|
|
||||||
{
|
|
||||||
zbar_image_scanner_t *scanner;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
@property (readonly, nonatomic) ZBarSymbolSet *results;
|
|
||||||
|
|
||||||
// decoder configuration
|
|
||||||
- (void) parseConfig: (NSString*) configStr;
|
|
||||||
- (void) setSymbology: (zbar_symbol_type_t) symbology
|
|
||||||
config: (zbar_config_t) config
|
|
||||||
to: (int) value;
|
|
||||||
|
|
||||||
// image scanning interface
|
|
||||||
- (NSInteger) scanImage: (ZBarImage*) image;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "ZBarImageScanner.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
using namespace zbar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
// default interface provided by UIImagePickerController - user manually
|
|
||||||
// captures an image by pressing a button
|
|
||||||
ZBarReaderControllerCameraModeDefault = 0,
|
|
||||||
|
|
||||||
// automatically scan by taking screenshots with UIGetScreenImage().
|
|
||||||
// resolution is limited by the screen, so this is inappropriate for
|
|
||||||
// longer codes
|
|
||||||
ZBarReaderControllerCameraModeSampling,
|
|
||||||
|
|
||||||
// automatically scan by rapidly taking pictures with takePicture.
|
|
||||||
// tradeoff resolution with frame rate by adjusting the crop, and size
|
|
||||||
// properties of the reader along with the density configs of the image
|
|
||||||
// scanner
|
|
||||||
ZBarReaderControllerCameraModeSequence,
|
|
||||||
|
|
||||||
} ZBarReaderControllerCameraMode;
|
|
||||||
|
|
||||||
|
|
||||||
@class ZBarReaderController, ZBarHelpController;
|
|
||||||
|
|
||||||
@protocol ZBarReaderDelegate <UIImagePickerControllerDelegate>
|
|
||||||
@optional
|
|
||||||
|
|
||||||
// called when no barcode is found in an image selected by the user.
|
|
||||||
// if retry is NO, the delegate *must* dismiss the controller
|
|
||||||
- (void) readerControllerDidFailToRead: (ZBarReaderController*) reader
|
|
||||||
withRetry: (BOOL) retry;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
@interface ZBarReaderController
|
|
||||||
: UIImagePickerController
|
|
||||||
< UINavigationControllerDelegate,
|
|
||||||
UIImagePickerControllerDelegate >
|
|
||||||
{
|
|
||||||
ZBarImageScanner *scanner;
|
|
||||||
ZBarHelpController *help;
|
|
||||||
UIView *overlay, *boxView;
|
|
||||||
CALayer *boxLayer;
|
|
||||||
|
|
||||||
UIToolbar *toolbar;
|
|
||||||
UIBarButtonItem *cancelBtn, *scanBtn, *space[3];
|
|
||||||
UIButton *infoBtn;
|
|
||||||
|
|
||||||
id <ZBarReaderDelegate> readerDelegate;
|
|
||||||
BOOL showsZBarControls, showsHelpOnFail, takesPicture, enableCache;
|
|
||||||
ZBarReaderControllerCameraMode cameraMode;
|
|
||||||
CGRect scanCrop;
|
|
||||||
NSInteger maxScanDimension;
|
|
||||||
|
|
||||||
BOOL hasOverlay, sampling;
|
|
||||||
uint64_t t_frame;
|
|
||||||
double dt_frame;
|
|
||||||
|
|
||||||
ZBarSymbol *symbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
// access to configure image scanner
|
|
||||||
@property (readonly, nonatomic) ZBarImageScanner *scanner;
|
|
||||||
|
|
||||||
// barcode result recipient (NB don't use delegate)
|
|
||||||
@property (nonatomic, assign) id <ZBarReaderDelegate> readerDelegate;
|
|
||||||
|
|
||||||
// whether to use alternate control set
|
|
||||||
@property (nonatomic) BOOL showsZBarControls;
|
|
||||||
|
|
||||||
// whether to display helpful information when decoding fails
|
|
||||||
@property (nonatomic) BOOL showsHelpOnFail;
|
|
||||||
|
|
||||||
// how to use the camera (when sourceType == Camera)
|
|
||||||
@property (nonatomic) ZBarReaderControllerCameraMode cameraMode;
|
|
||||||
|
|
||||||
// whether to outline symbols with the green tracking box.
|
|
||||||
@property (nonatomic) BOOL tracksSymbols;
|
|
||||||
|
|
||||||
// whether to automatically take a full picture when a barcode is detected
|
|
||||||
// (when cameraMode == Sampling)
|
|
||||||
@property (nonatomic) BOOL takesPicture;
|
|
||||||
|
|
||||||
// whether to use the "cache" for realtime modes (default YES). this can be
|
|
||||||
// used to safely disable the inter-frame consistency and duplicate checks,
|
|
||||||
// speeding up recognition, iff:
|
|
||||||
// 1. the controller is dismissed when a barcode is read and
|
|
||||||
// 2. unreliable symbologies are disabled (all EAN/UPC variants and I2/5)
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
|
|
||||||
// crop images for scanning. the original image will be cropped to this
|
|
||||||
// rectangle before scanning. the rectangle is normalized to the image size
|
|
||||||
// and aspect ratio; useful values will place the rectangle between 0 and 1
|
|
||||||
// on each axis, where the x-axis corresponds to the image major axis.
|
|
||||||
// defaults to the full image (0, 0, 1, 1).
|
|
||||||
@property (nonatomic) CGRect scanCrop;
|
|
||||||
|
|
||||||
// scale image to scan. after cropping, the image will be scaled if
|
|
||||||
// necessary, such that neither of its dimensions exceed this value.
|
|
||||||
// defaults to 640.
|
|
||||||
@property (nonatomic) NSInteger maxScanDimension;
|
|
||||||
|
|
||||||
// display the built-in help browser. for use with custom overlays if
|
|
||||||
// you don't also want to create your own help view. only send this
|
|
||||||
// message when the reader is displayed. the argument will be passed
|
|
||||||
// to the onZBarHelp() javascript function.
|
|
||||||
- (void) showHelpWithReason: (NSString*) reason;
|
|
||||||
|
|
||||||
// direct scanner interface - scan UIImage and return something enumerable
|
|
||||||
- (id <NSFastEnumeration>) scanImage: (CGImageRef) image;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
extern NSString* const ZBarReaderControllerResults;
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "ZBarImageScanner.h"
|
|
||||||
|
|
||||||
@class AVCaptureSession, AVCaptureDevice;
|
|
||||||
@class CALayer;
|
|
||||||
@class ZBarImageScanner, ZBarCaptureReader, ZBarReaderView;
|
|
||||||
|
|
||||||
// delegate is notified of decode results.
|
|
||||||
|
|
||||||
@protocol ZBarReaderViewDelegate < NSObject >
|
|
||||||
|
|
||||||
- (void) readerView: (ZBarReaderView*) readerView
|
|
||||||
didReadSymbols: (ZBarSymbolSet*) symbols
|
|
||||||
fromImage: (UIImage*) image;
|
|
||||||
|
|
||||||
@optional
|
|
||||||
- (void) readerViewDidStart: (ZBarReaderView*) readerView;
|
|
||||||
- (void) readerView: (ZBarReaderView*) readerView
|
|
||||||
didStopWithError: (NSError*) error;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
// read barcodes from the displayed video preview. the view maintains
|
|
||||||
// a complete video capture session feeding a ZBarCaptureReader and
|
|
||||||
// presents the associated preview with symbol tracking annotations.
|
|
||||||
|
|
||||||
@interface ZBarReaderView
|
|
||||||
: UIView
|
|
||||||
{
|
|
||||||
id<ZBarReaderViewDelegate> readerDelegate;
|
|
||||||
ZBarCaptureReader *captureReader;
|
|
||||||
CGRect scanCrop, effectiveCrop;
|
|
||||||
CGAffineTransform previewTransform;
|
|
||||||
CGFloat zoom, zoom0, maxZoom;
|
|
||||||
UIColor *trackingColor;
|
|
||||||
BOOL tracksSymbols, showsFPS;
|
|
||||||
NSInteger torchMode;
|
|
||||||
UIInterfaceOrientation interfaceOrientation;
|
|
||||||
NSTimeInterval animationDuration;
|
|
||||||
|
|
||||||
CALayer *preview, *overlay, *tracking, *cropLayer;
|
|
||||||
UIView *fpsView;
|
|
||||||
UILabel *fpsLabel;
|
|
||||||
UIPinchGestureRecognizer *pinch;
|
|
||||||
CGFloat imageScale;
|
|
||||||
CGSize imageSize;
|
|
||||||
BOOL started, running, locked;
|
|
||||||
}
|
|
||||||
|
|
||||||
// supply a pre-configured image scanner.
|
|
||||||
- (id) initWithImageScanner: (ZBarImageScanner*) imageScanner;
|
|
||||||
|
|
||||||
// start the video stream and barcode reader.
|
|
||||||
- (void) start;
|
|
||||||
|
|
||||||
// stop the video stream and barcode reader.
|
|
||||||
- (void) stop;
|
|
||||||
|
|
||||||
// clear the internal result cache
|
|
||||||
- (void) flushCache;
|
|
||||||
|
|
||||||
// compensate for device/camera/interface orientation
|
|
||||||
- (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) orient
|
|
||||||
duration: (NSTimeInterval) duration;
|
|
||||||
|
|
||||||
// delegate is notified of decode results.
|
|
||||||
@property (nonatomic, assign) id<ZBarReaderViewDelegate> readerDelegate;
|
|
||||||
|
|
||||||
// access to image scanner for configuration.
|
|
||||||
@property (nonatomic, readonly) ZBarImageScanner *scanner;
|
|
||||||
|
|
||||||
// whether to display the tracking annotation for uncertain barcodes
|
|
||||||
// (default YES).
|
|
||||||
@property (nonatomic) BOOL tracksSymbols;
|
|
||||||
|
|
||||||
// color of the tracking box (default green)
|
|
||||||
@property (nonatomic, retain) UIColor *trackingColor;
|
|
||||||
|
|
||||||
// enable pinch gesture recognition for zooming the preview/decode
|
|
||||||
// (default YES).
|
|
||||||
@property (nonatomic) BOOL allowsPinchZoom;
|
|
||||||
|
|
||||||
// torch mode to set automatically (default Auto).
|
|
||||||
@property (nonatomic) NSInteger torchMode;
|
|
||||||
|
|
||||||
// whether to display the frame rate for debug/configuration
|
|
||||||
// (default NO).
|
|
||||||
@property (nonatomic) BOOL showsFPS;
|
|
||||||
|
|
||||||
// zoom scale factor applied to video preview *and* scanCrop.
|
|
||||||
// also updated by pinch-zoom gesture. clipped to range [1,maxZoom],
|
|
||||||
// defaults to 1.25
|
|
||||||
@property (nonatomic) CGFloat zoom;
|
|
||||||
- (void) setZoom: (CGFloat) zoom
|
|
||||||
animated: (BOOL) animated;
|
|
||||||
|
|
||||||
// maximum settable zoom factor.
|
|
||||||
@property (nonatomic) CGFloat maxZoom;
|
|
||||||
|
|
||||||
// the region of the image that will be scanned. normalized coordinates.
|
|
||||||
@property (nonatomic) CGRect scanCrop;
|
|
||||||
|
|
||||||
// additional transform applied to video preview.
|
|
||||||
// (NB *not* applied to scan crop)
|
|
||||||
@property (nonatomic) CGAffineTransform previewTransform;
|
|
||||||
|
|
||||||
// specify an alternate capture device.
|
|
||||||
@property (nonatomic, retain) AVCaptureDevice *device;
|
|
||||||
|
|
||||||
// direct access to the capture session. warranty void if opened...
|
|
||||||
@property (nonatomic, readonly) AVCaptureSession *session;
|
|
||||||
@property (nonatomic, readonly) ZBarCaptureReader *captureReader;
|
|
||||||
|
|
||||||
// this flag still works, but its use is deprecated
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "ZBarReaderController.h"
|
|
||||||
|
|
||||||
// orientation set support
|
|
||||||
#define ZBarOrientationMask(orient) (1 << orient)
|
|
||||||
#define ZBarOrientationMaskAll \
|
|
||||||
(ZBarOrientationMask(UIInterfaceOrientationPortrait) | \
|
|
||||||
ZBarOrientationMask(UIInterfaceOrientationPortraitUpsideDown) | \
|
|
||||||
ZBarOrientationMask(UIInterfaceOrientationLandscapeLeft) | \
|
|
||||||
ZBarOrientationMask(UIInterfaceOrientationLandscapeRight))
|
|
||||||
|
|
||||||
@class ZBarReaderView, ZBarCameraSimulator;
|
|
||||||
|
|
||||||
// drop in video scanning replacement for ZBarReaderController.
|
|
||||||
// this is a thin controller around a ZBarReaderView that adds the UI
|
|
||||||
// controls and select functionality offered by ZBarReaderController.
|
|
||||||
// Automatically falls back to a ZBarReaderController if video APIs
|
|
||||||
// are unavailable (eg for OS < 4.0)
|
|
||||||
|
|
||||||
@interface ZBarReaderViewController
|
|
||||||
: UIViewController
|
|
||||||
{
|
|
||||||
ZBarImageScanner *scanner;
|
|
||||||
id <ZBarReaderDelegate> readerDelegate;
|
|
||||||
ZBarReaderView *readerView;
|
|
||||||
UIView *cameraOverlayView;
|
|
||||||
CGAffineTransform cameraViewTransform;
|
|
||||||
CGRect scanCrop;
|
|
||||||
NSUInteger supportedOrientationsMask;
|
|
||||||
UIImagePickerControllerCameraDevice cameraDevice;
|
|
||||||
UIImagePickerControllerCameraFlashMode cameraFlashMode;
|
|
||||||
UIImagePickerControllerQualityType videoQuality;
|
|
||||||
BOOL showsZBarControls, tracksSymbols, enableCache;
|
|
||||||
|
|
||||||
ZBarHelpController *helpController;
|
|
||||||
UIView *controls, *shutter;
|
|
||||||
BOOL didHideStatusBar, rotating;
|
|
||||||
ZBarCameraSimulator *cameraSim;
|
|
||||||
}
|
|
||||||
|
|
||||||
// access to configure image scanner
|
|
||||||
@property (nonatomic, readonly) ZBarImageScanner *scanner;
|
|
||||||
|
|
||||||
// barcode result recipient
|
|
||||||
@property (nonatomic, assign) id <ZBarReaderDelegate> readerDelegate;
|
|
||||||
|
|
||||||
// whether to use alternate control set
|
|
||||||
@property (nonatomic) BOOL showsZBarControls;
|
|
||||||
|
|
||||||
// whether to show the green tracking box. note that, even when
|
|
||||||
// enabled, the box will only be visible when scanning EAN and I2/5.
|
|
||||||
@property (nonatomic) BOOL tracksSymbols;
|
|
||||||
|
|
||||||
// interface orientation support. bit-mask of accepted orientations.
|
|
||||||
// see eg ZBarOrientationMask() and ZBarOrientationMaskAll
|
|
||||||
@property (nonatomic) NSUInteger supportedOrientationsMask;
|
|
||||||
|
|
||||||
// crop images for scanning. the image will be cropped to this
|
|
||||||
// rectangle before scanning. the rectangle is normalized to the
|
|
||||||
// image size and aspect ratio; useful values will place the rectangle
|
|
||||||
// between 0 and 1 on each axis, where the x-axis corresponds to the
|
|
||||||
// image major axis. defaults to the full image (0, 0, 1, 1).
|
|
||||||
@property (nonatomic) CGRect scanCrop;
|
|
||||||
|
|
||||||
// provide a custom overlay. note that this can be used with
|
|
||||||
// showsZBarControls enabled (but not if you want backward compatibility)
|
|
||||||
@property (nonatomic, retain) UIView *cameraOverlayView;
|
|
||||||
|
|
||||||
// transform applied to the preview image.
|
|
||||||
@property (nonatomic) CGAffineTransform cameraViewTransform;
|
|
||||||
|
|
||||||
// display the built-in help browser. the argument will be passed to
|
|
||||||
// the onZBarHelp() javascript function.
|
|
||||||
- (void) showHelpWithReason: (NSString*) reason;
|
|
||||||
|
|
||||||
// capture the next frame and send it over the usual delegate path.
|
|
||||||
- (void) takePicture;
|
|
||||||
|
|
||||||
// these attempt to emulate UIImagePickerController
|
|
||||||
+ (BOOL) isCameraDeviceAvailable: (UIImagePickerControllerCameraDevice) cameraDevice;
|
|
||||||
+ (BOOL) isFlashAvailableForCameraDevice: (UIImagePickerControllerCameraDevice) cameraDevice;
|
|
||||||
+ (NSArray*) availableCaptureModesForCameraDevice: (UIImagePickerControllerCameraDevice) cameraDevice;
|
|
||||||
@property(nonatomic) UIImagePickerControllerCameraDevice cameraDevice;
|
|
||||||
@property(nonatomic) UIImagePickerControllerCameraFlashMode cameraFlashMode;
|
|
||||||
@property(nonatomic) UIImagePickerControllerCameraCaptureMode cameraCaptureMode;
|
|
||||||
@property(nonatomic) UIImagePickerControllerQualityType videoQuality;
|
|
||||||
|
|
||||||
// direct access to the ZBarReaderView
|
|
||||||
@property (nonatomic, readonly) ZBarReaderView *readerView;
|
|
||||||
|
|
||||||
// this flag still works, but its use is deprecated
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
|
|
||||||
// these are present only for backward compatibility.
|
|
||||||
// they will error if inappropriate/unsupported values are set
|
|
||||||
@property (nonatomic) UIImagePickerControllerSourceType sourceType; // Camera
|
|
||||||
@property (nonatomic) BOOL allowsEditing; // NO
|
|
||||||
@property (nonatomic) BOOL allowsImageEditing; // NO
|
|
||||||
@property (nonatomic) BOOL showsCameraControls; // NO
|
|
||||||
@property (nonatomic) BOOL showsHelpOnFail; // ignored
|
|
||||||
@property (nonatomic) ZBarReaderControllerCameraMode cameraMode; // Sampling
|
|
||||||
@property (nonatomic) BOOL takesPicture; // NO
|
|
||||||
@property (nonatomic) NSInteger maxScanDimension; // ignored
|
|
||||||
|
|
||||||
+ (BOOL) isSourceTypeAvailable: (UIImagePickerControllerSourceType) sourceType;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
/*------------------------------------------------------------------------
|
|
||||||
* Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* This file is part of the ZBar Bar Code Reader.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser Public License
|
|
||||||
* along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* http://sourceforge.net/projects/zbar
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#import "zbar.h"
|
|
||||||
|
|
||||||
#import "ZBarSymbol.h"
|
|
||||||
#import "ZBarImage.h"
|
|
||||||
#import "ZBarImageScanner.h"
|
|
||||||
#import "ZBarReaderView.h"
|
|
||||||
#import "ZBarReaderViewController.h"
|
|
||||||
#import "ZBarReaderController.h"
|
|
||||||
#import "ZBarCaptureReader.h"
|
|
||||||
#import "ZBarHelpController.h"
|
|
||||||
#import "ZBarCameraSimulator.h"
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2010-2011 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
@class ZBarReaderView;
|
|
||||||
|
|
||||||
// hack around missing simulator support for AVCapture interfaces
|
|
||||||
|
|
||||||
@interface ZBarCameraSimulator
|
|
||||||
: NSObject
|
|
||||||
< UINavigationControllerDelegate,
|
|
||||||
UIImagePickerControllerDelegate,
|
|
||||||
UIPopoverControllerDelegate >
|
|
||||||
{
|
|
||||||
UIViewController *viewController;
|
|
||||||
ZBarReaderView *readerView;
|
|
||||||
UIImagePickerController *picker;
|
|
||||||
UIPopoverController *pickerPopover;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) initWithViewController: (UIViewController*) viewController;
|
|
||||||
- (void) takePicture;
|
|
||||||
|
|
||||||
@property (nonatomic, assign) ZBarReaderView *readerView;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <CoreGraphics/CoreGraphics.h>
|
|
||||||
#import "ZBarImageScanner.h"
|
|
||||||
|
|
||||||
@class AVCaptureVideoDataOutput, AVCaptureOutput;
|
|
||||||
@class ZBarCaptureReader, ZBarCVImage;
|
|
||||||
|
|
||||||
@protocol ZBarCaptureDelegate <NSObject>
|
|
||||||
|
|
||||||
// called when a new barcode is detected. the image refers to the
|
|
||||||
// video buffer and must not be retained for long
|
|
||||||
- (void) captureReader: (ZBarCaptureReader*) captureReader
|
|
||||||
didReadNewSymbolsFromImage: (ZBarImage*) image;
|
|
||||||
|
|
||||||
@optional
|
|
||||||
// called when a potential/uncertain barcode is detected. will also
|
|
||||||
// be called *after* captureReader:didReadNewSymbolsFromImage:
|
|
||||||
// when good barcodes are detected
|
|
||||||
- (void) captureReader: (ZBarCaptureReader*) captureReader
|
|
||||||
didTrackSymbols: (ZBarSymbolSet*) symbols;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface ZBarCaptureReader
|
|
||||||
: NSObject
|
|
||||||
{
|
|
||||||
#if !TARGET_IPHONE_SIMULATOR
|
|
||||||
AVCaptureVideoDataOutput *captureOutput;
|
|
||||||
id<ZBarCaptureDelegate> captureDelegate;
|
|
||||||
ZBarImageScanner *scanner;
|
|
||||||
CGRect scanCrop;
|
|
||||||
CGSize size;
|
|
||||||
CGFloat framesPerSecond;
|
|
||||||
BOOL enableCache;
|
|
||||||
|
|
||||||
dispatch_queue_t queue;
|
|
||||||
ZBarImage *image;
|
|
||||||
ZBarCVImage *result;
|
|
||||||
volatile uint32_t state;
|
|
||||||
int framecnt;
|
|
||||||
unsigned width, height;
|
|
||||||
uint64_t t_frame, t_fps, t_scan;
|
|
||||||
CGFloat dt_frame;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// supply a pre-configured image scanner
|
|
||||||
- (id) initWithImageScanner: (ZBarImageScanner*) imageScanner;
|
|
||||||
|
|
||||||
// this must be called before the session is started
|
|
||||||
- (void) willStartRunning;
|
|
||||||
|
|
||||||
// this must be called *before* the session is stopped
|
|
||||||
- (void) willStopRunning;
|
|
||||||
|
|
||||||
// clear the internal result cache
|
|
||||||
- (void) flushCache;
|
|
||||||
|
|
||||||
// capture the next frame after processing. the captured image will
|
|
||||||
// follow the same delegate path as an image with decoded symbols.
|
|
||||||
- (void) captureFrame;
|
|
||||||
|
|
||||||
// the capture output. add this to an instance of AVCaptureSession
|
|
||||||
@property (nonatomic, readonly) AVCaptureOutput *captureOutput;
|
|
||||||
|
|
||||||
// delegate is notified of decode results and symbol tracking.
|
|
||||||
@property (nonatomic, assign) id<ZBarCaptureDelegate> captureDelegate;
|
|
||||||
|
|
||||||
// access to image scanner for configuration.
|
|
||||||
@property (nonatomic, readonly) ZBarImageScanner *scanner;
|
|
||||||
|
|
||||||
// region of image to scan in normalized coordinates.
|
|
||||||
// NB horizontal crop currently ignored...
|
|
||||||
@property (nonatomic, assign) CGRect scanCrop;
|
|
||||||
|
|
||||||
// size of video frames.
|
|
||||||
@property (nonatomic, readonly) CGSize size;
|
|
||||||
|
|
||||||
// (quickly) gate the reader function without interrupting the video
|
|
||||||
// stream. also flushes the cache when enabled. defaults to *NO*
|
|
||||||
@property (nonatomic) BOOL enableReader;
|
|
||||||
|
|
||||||
// current frame rate (for debug/optimization).
|
|
||||||
// only valid when running
|
|
||||||
@property (nonatomic, readonly) CGFloat framesPerSecond;
|
|
||||||
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
@class ZBarHelpController;
|
|
||||||
|
|
||||||
@protocol ZBarHelpDelegate
|
|
||||||
@optional
|
|
||||||
|
|
||||||
- (void) helpControllerDidFinish: (ZBarHelpController*) help;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
// failure dialog w/a few useful tips
|
|
||||||
|
|
||||||
@interface ZBarHelpController : UIViewController
|
|
||||||
< UIWebViewDelegate,
|
|
||||||
UIAlertViewDelegate >
|
|
||||||
{
|
|
||||||
NSString *reason;
|
|
||||||
id delegate;
|
|
||||||
UIWebView *webView;
|
|
||||||
UIToolbar *toolbar;
|
|
||||||
UIBarButtonItem *doneBtn, *backBtn, *space;
|
|
||||||
NSURL *linkURL;
|
|
||||||
NSUInteger orientations;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (nonatomic, assign) id<ZBarHelpDelegate> delegate;
|
|
||||||
|
|
||||||
// designated initializer
|
|
||||||
- (id) initWithReason: (NSString*) reason;
|
|
||||||
|
|
||||||
- (BOOL) isInterfaceOrientationSupported: (UIInterfaceOrientation) orientation;
|
|
||||||
- (void) setInterfaceOrientation: (UIInterfaceOrientation) orientation
|
|
||||||
supported: (BOOL) supported;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "zbar.h"
|
|
||||||
#import "ZBarSymbol.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
using namespace zbar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Obj-C wrapper for ZBar image
|
|
||||||
|
|
||||||
@interface ZBarImage : NSObject
|
|
||||||
{
|
|
||||||
zbar_image_t *zimg;
|
|
||||||
double t_convert;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (nonatomic) unsigned long format;
|
|
||||||
@property (nonatomic) unsigned sequence;
|
|
||||||
@property (nonatomic) CGSize size;
|
|
||||||
@property (nonatomic) CGRect crop;
|
|
||||||
@property (readonly, nonatomic) const void *data;
|
|
||||||
@property (readonly, nonatomic) unsigned long dataLength;
|
|
||||||
@property (copy, nonatomic) ZBarSymbolSet *symbols;
|
|
||||||
@property (readonly, nonatomic) zbar_image_t *zbarImage;
|
|
||||||
@property (readonly, nonatomic) UIImage *UIImage;
|
|
||||||
|
|
||||||
- (id) initWithImage: (zbar_image_t*) image;
|
|
||||||
- (id) initWithCGImage: (CGImageRef) image;
|
|
||||||
- (id) initWithCGImage: (CGImageRef) image
|
|
||||||
size: (CGSize) size;
|
|
||||||
- (id) initWithCGImage: (CGImageRef) image
|
|
||||||
crop: (CGRect) crop
|
|
||||||
size: (CGSize) size;
|
|
||||||
|
|
||||||
- (void) setData: (const void*) data
|
|
||||||
withLength: (unsigned long) length;
|
|
||||||
- (UIImage*) UIImageWithOrientation: (UIImageOrientation) imageOrientation;
|
|
||||||
- (void) cleanup;
|
|
||||||
|
|
||||||
+ (unsigned long) fourcc: (NSString*) format;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
- convertToFormat: (unsigned long) format;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import "zbar.h"
|
|
||||||
#import "ZBarImage.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
using namespace zbar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Obj-C wrapper for ZBar image scanner
|
|
||||||
|
|
||||||
@interface ZBarImageScanner : NSObject
|
|
||||||
{
|
|
||||||
zbar_image_scanner_t *scanner;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
@property (readonly, nonatomic) ZBarSymbolSet *results;
|
|
||||||
|
|
||||||
// decoder configuration
|
|
||||||
- (void) parseConfig: (NSString*) configStr;
|
|
||||||
- (void) setSymbology: (zbar_symbol_type_t) symbology
|
|
||||||
config: (zbar_config_t) config
|
|
||||||
to: (int) value;
|
|
||||||
|
|
||||||
// image scanning interface
|
|
||||||
- (NSInteger) scanImage: (ZBarImage*) image;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "ZBarImageScanner.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
using namespace zbar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
// default interface provided by UIImagePickerController - user manually
|
|
||||||
// captures an image by pressing a button
|
|
||||||
ZBarReaderControllerCameraModeDefault = 0,
|
|
||||||
|
|
||||||
// automatically scan by taking screenshots with UIGetScreenImage().
|
|
||||||
// resolution is limited by the screen, so this is inappropriate for
|
|
||||||
// longer codes
|
|
||||||
ZBarReaderControllerCameraModeSampling,
|
|
||||||
|
|
||||||
// automatically scan by rapidly taking pictures with takePicture.
|
|
||||||
// tradeoff resolution with frame rate by adjusting the crop, and size
|
|
||||||
// properties of the reader along with the density configs of the image
|
|
||||||
// scanner
|
|
||||||
ZBarReaderControllerCameraModeSequence,
|
|
||||||
|
|
||||||
} ZBarReaderControllerCameraMode;
|
|
||||||
|
|
||||||
|
|
||||||
@class ZBarReaderController, ZBarHelpController;
|
|
||||||
|
|
||||||
@protocol ZBarReaderDelegate <UIImagePickerControllerDelegate>
|
|
||||||
@optional
|
|
||||||
|
|
||||||
// called when no barcode is found in an image selected by the user.
|
|
||||||
// if retry is NO, the delegate *must* dismiss the controller
|
|
||||||
- (void) readerControllerDidFailToRead: (ZBarReaderController*) reader
|
|
||||||
withRetry: (BOOL) retry;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
@interface ZBarReaderController
|
|
||||||
: UIImagePickerController
|
|
||||||
< UINavigationControllerDelegate,
|
|
||||||
UIImagePickerControllerDelegate >
|
|
||||||
{
|
|
||||||
ZBarImageScanner *scanner;
|
|
||||||
ZBarHelpController *help;
|
|
||||||
UIView *overlay, *boxView;
|
|
||||||
CALayer *boxLayer;
|
|
||||||
|
|
||||||
UIToolbar *toolbar;
|
|
||||||
UIBarButtonItem *cancelBtn, *scanBtn, *space[3];
|
|
||||||
UIButton *infoBtn;
|
|
||||||
|
|
||||||
id <ZBarReaderDelegate> readerDelegate;
|
|
||||||
BOOL showsZBarControls, showsHelpOnFail, takesPicture, enableCache;
|
|
||||||
ZBarReaderControllerCameraMode cameraMode;
|
|
||||||
CGRect scanCrop;
|
|
||||||
NSInteger maxScanDimension;
|
|
||||||
|
|
||||||
BOOL hasOverlay, sampling;
|
|
||||||
uint64_t t_frame;
|
|
||||||
double dt_frame;
|
|
||||||
|
|
||||||
ZBarSymbol *symbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
// access to configure image scanner
|
|
||||||
@property (readonly, nonatomic) ZBarImageScanner *scanner;
|
|
||||||
|
|
||||||
// barcode result recipient (NB don't use delegate)
|
|
||||||
@property (nonatomic, assign) id <ZBarReaderDelegate> readerDelegate;
|
|
||||||
|
|
||||||
// whether to use alternate control set
|
|
||||||
@property (nonatomic) BOOL showsZBarControls;
|
|
||||||
|
|
||||||
// whether to display helpful information when decoding fails
|
|
||||||
@property (nonatomic) BOOL showsHelpOnFail;
|
|
||||||
|
|
||||||
// how to use the camera (when sourceType == Camera)
|
|
||||||
@property (nonatomic) ZBarReaderControllerCameraMode cameraMode;
|
|
||||||
|
|
||||||
// whether to outline symbols with the green tracking box.
|
|
||||||
@property (nonatomic) BOOL tracksSymbols;
|
|
||||||
|
|
||||||
// whether to automatically take a full picture when a barcode is detected
|
|
||||||
// (when cameraMode == Sampling)
|
|
||||||
@property (nonatomic) BOOL takesPicture;
|
|
||||||
|
|
||||||
// whether to use the "cache" for realtime modes (default YES). this can be
|
|
||||||
// used to safely disable the inter-frame consistency and duplicate checks,
|
|
||||||
// speeding up recognition, iff:
|
|
||||||
// 1. the controller is dismissed when a barcode is read and
|
|
||||||
// 2. unreliable symbologies are disabled (all EAN/UPC variants and I2/5)
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
|
|
||||||
// crop images for scanning. the original image will be cropped to this
|
|
||||||
// rectangle before scanning. the rectangle is normalized to the image size
|
|
||||||
// and aspect ratio; useful values will place the rectangle between 0 and 1
|
|
||||||
// on each axis, where the x-axis corresponds to the image major axis.
|
|
||||||
// defaults to the full image (0, 0, 1, 1).
|
|
||||||
@property (nonatomic) CGRect scanCrop;
|
|
||||||
|
|
||||||
// scale image to scan. after cropping, the image will be scaled if
|
|
||||||
// necessary, such that neither of its dimensions exceed this value.
|
|
||||||
// defaults to 640.
|
|
||||||
@property (nonatomic) NSInteger maxScanDimension;
|
|
||||||
|
|
||||||
// display the built-in help browser. for use with custom overlays if
|
|
||||||
// you don't also want to create your own help view. only send this
|
|
||||||
// message when the reader is displayed. the argument will be passed
|
|
||||||
// to the onZBarHelp() javascript function.
|
|
||||||
- (void) showHelpWithReason: (NSString*) reason;
|
|
||||||
|
|
||||||
// direct scanner interface - scan UIImage and return something enumerable
|
|
||||||
- (id <NSFastEnumeration>) scanImage: (CGImageRef) image;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
extern NSString* const ZBarReaderControllerResults;
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "ZBarImageScanner.h"
|
|
||||||
|
|
||||||
@class AVCaptureSession, AVCaptureDevice;
|
|
||||||
@class CALayer;
|
|
||||||
@class ZBarImageScanner, ZBarCaptureReader, ZBarReaderView;
|
|
||||||
|
|
||||||
// delegate is notified of decode results.
|
|
||||||
|
|
||||||
@protocol ZBarReaderViewDelegate < NSObject >
|
|
||||||
|
|
||||||
- (void) readerView: (ZBarReaderView*) readerView
|
|
||||||
didReadSymbols: (ZBarSymbolSet*) symbols
|
|
||||||
fromImage: (UIImage*) image;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
// read barcodes from the displayed video preview. the view maintains
|
|
||||||
// a complete video capture session feeding a ZBarCaptureReader and
|
|
||||||
// presents the associated preview with symbol tracking annotations.
|
|
||||||
|
|
||||||
@interface ZBarReaderView
|
|
||||||
: UIView
|
|
||||||
{
|
|
||||||
id<ZBarReaderViewDelegate> readerDelegate;
|
|
||||||
ZBarCaptureReader *captureReader;
|
|
||||||
CGRect scanCrop, effectiveCrop;
|
|
||||||
CGAffineTransform previewTransform;
|
|
||||||
CGFloat zoom, zoom0, maxZoom;
|
|
||||||
UIColor *trackingColor;
|
|
||||||
BOOL tracksSymbols, showsFPS;
|
|
||||||
NSInteger torchMode;
|
|
||||||
UIInterfaceOrientation interfaceOrientation;
|
|
||||||
NSTimeInterval animationDuration;
|
|
||||||
|
|
||||||
CALayer *preview, *overlay, *tracking, *cropLayer;
|
|
||||||
UIView *fpsView;
|
|
||||||
UILabel *fpsLabel;
|
|
||||||
UIPinchGestureRecognizer *pinch;
|
|
||||||
CGFloat imageScale;
|
|
||||||
CGSize imageSize;
|
|
||||||
BOOL started, running;
|
|
||||||
}
|
|
||||||
|
|
||||||
// supply a pre-configured image scanner.
|
|
||||||
- (id) initWithImageScanner: (ZBarImageScanner*) imageScanner;
|
|
||||||
|
|
||||||
// start the video stream and barcode reader.
|
|
||||||
- (void) start;
|
|
||||||
|
|
||||||
// stop the video stream and barcode reader.
|
|
||||||
- (void) stop;
|
|
||||||
|
|
||||||
// clear the internal result cache
|
|
||||||
- (void) flushCache;
|
|
||||||
|
|
||||||
// compensate for device/camera/interface orientation
|
|
||||||
- (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) orient
|
|
||||||
duration: (NSTimeInterval) duration;
|
|
||||||
|
|
||||||
// delegate is notified of decode results.
|
|
||||||
@property (nonatomic, assign) id<ZBarReaderViewDelegate> readerDelegate;
|
|
||||||
|
|
||||||
// access to image scanner for configuration.
|
|
||||||
@property (nonatomic, readonly) ZBarImageScanner *scanner;
|
|
||||||
|
|
||||||
// whether to display the tracking annotation for uncertain barcodes
|
|
||||||
// (default YES).
|
|
||||||
@property (nonatomic) BOOL tracksSymbols;
|
|
||||||
|
|
||||||
// color of the tracking box (default green)
|
|
||||||
@property (nonatomic, retain) UIColor *trackingColor;
|
|
||||||
|
|
||||||
// enable pinch gesture recognition for zooming the preview/decode
|
|
||||||
// (default YES).
|
|
||||||
@property (nonatomic) BOOL allowsPinchZoom;
|
|
||||||
|
|
||||||
// torch mode to set automatically (default Auto).
|
|
||||||
@property (nonatomic) NSInteger torchMode;
|
|
||||||
|
|
||||||
// whether to display the frame rate for debug/configuration
|
|
||||||
// (default NO).
|
|
||||||
@property (nonatomic) BOOL showsFPS;
|
|
||||||
|
|
||||||
// zoom scale factor applied to video preview *and* scanCrop.
|
|
||||||
// also updated by pinch-zoom gesture. clipped to range [1,maxZoom],
|
|
||||||
// defaults to 1.25
|
|
||||||
@property (nonatomic) CGFloat zoom;
|
|
||||||
- (void) setZoom: (CGFloat) zoom
|
|
||||||
animated: (BOOL) animated;
|
|
||||||
|
|
||||||
// maximum settable zoom factor.
|
|
||||||
@property (nonatomic) CGFloat maxZoom;
|
|
||||||
|
|
||||||
// the region of the image that will be scanned. normalized coordinates.
|
|
||||||
@property (nonatomic) CGRect scanCrop;
|
|
||||||
|
|
||||||
// additional transform applied to video preview.
|
|
||||||
// (NB *not* applied to scan crop)
|
|
||||||
@property (nonatomic) CGAffineTransform previewTransform;
|
|
||||||
|
|
||||||
// specify an alternate capture device.
|
|
||||||
@property (nonatomic, retain) AVCaptureDevice *device;
|
|
||||||
|
|
||||||
// direct access to the capture session. warranty void if opened...
|
|
||||||
@property (nonatomic, readonly) AVCaptureSession *session;
|
|
||||||
@property (nonatomic, readonly) ZBarCaptureReader *captureReader;
|
|
||||||
|
|
||||||
// this flag still works, but its use is deprecated
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "ZBarReaderController.h"
|
|
||||||
|
|
||||||
// orientation set support
|
|
||||||
#define ZBarOrientationMask(orient) (1 << orient)
|
|
||||||
#define ZBarOrientationMaskAll \
|
|
||||||
(ZBarOrientationMask(UIInterfaceOrientationPortrait) | \
|
|
||||||
ZBarOrientationMask(UIInterfaceOrientationPortraitUpsideDown) | \
|
|
||||||
ZBarOrientationMask(UIInterfaceOrientationLandscapeLeft) | \
|
|
||||||
ZBarOrientationMask(UIInterfaceOrientationLandscapeRight))
|
|
||||||
|
|
||||||
@class ZBarReaderView, ZBarCameraSimulator;
|
|
||||||
|
|
||||||
// drop in video scanning replacement for ZBarReaderController.
|
|
||||||
// this is a thin controller around a ZBarReaderView that adds the UI
|
|
||||||
// controls and select functionality offered by ZBarReaderController.
|
|
||||||
// Automatically falls back to a ZBarReaderController if video APIs
|
|
||||||
// are unavailable (eg for OS < 4.0)
|
|
||||||
|
|
||||||
@interface ZBarReaderViewController
|
|
||||||
: UIViewController
|
|
||||||
{
|
|
||||||
ZBarImageScanner *scanner;
|
|
||||||
id <ZBarReaderDelegate> readerDelegate;
|
|
||||||
ZBarReaderView *readerView;
|
|
||||||
UIView *cameraOverlayView;
|
|
||||||
CGAffineTransform cameraViewTransform;
|
|
||||||
CGRect scanCrop;
|
|
||||||
NSUInteger supportedOrientationsMask;
|
|
||||||
UIImagePickerControllerCameraDevice cameraDevice;
|
|
||||||
UIImagePickerControllerCameraFlashMode cameraFlashMode;
|
|
||||||
UIImagePickerControllerQualityType videoQuality;
|
|
||||||
BOOL showsZBarControls, tracksSymbols, enableCache;
|
|
||||||
|
|
||||||
ZBarHelpController *helpController;
|
|
||||||
UIView *controls;
|
|
||||||
BOOL didHideStatusBar, rotating;
|
|
||||||
ZBarCameraSimulator *cameraSim;
|
|
||||||
}
|
|
||||||
|
|
||||||
// access to configure image scanner
|
|
||||||
@property (nonatomic, readonly) ZBarImageScanner *scanner;
|
|
||||||
|
|
||||||
// barcode result recipient
|
|
||||||
@property (nonatomic, assign) id <ZBarReaderDelegate> readerDelegate;
|
|
||||||
|
|
||||||
// whether to use alternate control set
|
|
||||||
@property (nonatomic) BOOL showsZBarControls;
|
|
||||||
|
|
||||||
// whether to show the green tracking box. note that, even when
|
|
||||||
// enabled, the box will only be visible when scanning EAN and I2/5.
|
|
||||||
@property (nonatomic) BOOL tracksSymbols;
|
|
||||||
|
|
||||||
// interface orientation support. bit-mask of accepted orientations.
|
|
||||||
// see eg ZBarOrientationMask() and ZBarOrientationMaskAll
|
|
||||||
@property (nonatomic) NSUInteger supportedOrientationsMask;
|
|
||||||
|
|
||||||
// crop images for scanning. the image will be cropped to this
|
|
||||||
// rectangle before scanning. the rectangle is normalized to the
|
|
||||||
// image size and aspect ratio; useful values will place the rectangle
|
|
||||||
// between 0 and 1 on each axis, where the x-axis corresponds to the
|
|
||||||
// image major axis. defaults to the full image (0, 0, 1, 1).
|
|
||||||
@property (nonatomic) CGRect scanCrop;
|
|
||||||
|
|
||||||
// provide a custom overlay. note that this can be used with
|
|
||||||
// showsZBarControls enabled (but not if you want backward compatibility)
|
|
||||||
@property (nonatomic, retain) UIView *cameraOverlayView;
|
|
||||||
|
|
||||||
// transform applied to the preview image.
|
|
||||||
@property (nonatomic) CGAffineTransform cameraViewTransform;
|
|
||||||
|
|
||||||
// display the built-in help browser. the argument will be passed to
|
|
||||||
// the onZBarHelp() javascript function.
|
|
||||||
- (void) showHelpWithReason: (NSString*) reason;
|
|
||||||
|
|
||||||
// capture the next frame and send it over the usual delegate path.
|
|
||||||
- (void) takePicture;
|
|
||||||
|
|
||||||
// these attempt to emulate UIImagePickerController
|
|
||||||
+ (BOOL) isCameraDeviceAvailable: (UIImagePickerControllerCameraDevice) cameraDevice;
|
|
||||||
+ (BOOL) isFlashAvailableForCameraDevice: (UIImagePickerControllerCameraDevice) cameraDevice;
|
|
||||||
+ (NSArray*) availableCaptureModesForCameraDevice: (UIImagePickerControllerCameraDevice) cameraDevice;
|
|
||||||
@property(nonatomic) UIImagePickerControllerCameraDevice cameraDevice;
|
|
||||||
@property(nonatomic) UIImagePickerControllerCameraFlashMode cameraFlashMode;
|
|
||||||
@property(nonatomic) UIImagePickerControllerCameraCaptureMode cameraCaptureMode;
|
|
||||||
@property(nonatomic) UIImagePickerControllerQualityType videoQuality;
|
|
||||||
|
|
||||||
// direct access to the ZBarReaderView
|
|
||||||
@property (nonatomic, readonly) ZBarReaderView *readerView;
|
|
||||||
|
|
||||||
// this flag still works, but its use is deprecated
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
|
|
||||||
// these are present only for backward compatibility.
|
|
||||||
// they will error if inappropriate/unsupported values are set
|
|
||||||
@property (nonatomic) UIImagePickerControllerSourceType sourceType; // Camera
|
|
||||||
@property (nonatomic) BOOL allowsEditing; // NO
|
|
||||||
@property (nonatomic) BOOL allowsImageEditing; // NO
|
|
||||||
@property (nonatomic) BOOL showsCameraControls; // NO
|
|
||||||
@property (nonatomic) BOOL showsHelpOnFail; // ignored
|
|
||||||
@property (nonatomic) ZBarReaderControllerCameraMode cameraMode; // Sampling
|
|
||||||
@property (nonatomic) BOOL takesPicture; // NO
|
|
||||||
@property (nonatomic) NSInteger maxScanDimension; // ignored
|
|
||||||
|
|
||||||
+ (BOOL) isSourceTypeAvailable: (UIImagePickerControllerSourceType) sourceType;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
/*------------------------------------------------------------------------
|
|
||||||
* Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* This file is part of the ZBar Bar Code Reader.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser Public License
|
|
||||||
* along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* http://sourceforge.net/projects/zbar
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#import "zbar.h"
|
|
||||||
|
|
||||||
#import "ZBarSymbol.h"
|
|
||||||
#import "ZBarImage.h"
|
|
||||||
#import "ZBarImageScanner.h"
|
|
||||||
#import "ZBarReaderView.h"
|
|
||||||
#import "ZBarReaderViewController.h"
|
|
||||||
#import "ZBarReaderController.h"
|
|
||||||
#import "ZBarCaptureReader.h"
|
|
||||||
#import "ZBarHelpController.h"
|
|
||||||
#import "ZBarCameraSimulator.h"
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import <CoreGraphics/CoreGraphics.h>
|
|
||||||
#import "zbar.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
using namespace zbar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Obj-C wrapper for ZBar result types
|
|
||||||
|
|
||||||
@interface ZBarSymbolSet
|
|
||||||
: NSObject <NSFastEnumeration>
|
|
||||||
{
|
|
||||||
const zbar_symbol_set_t *set;
|
|
||||||
BOOL filterSymbols;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (readonly, nonatomic) int count;
|
|
||||||
@property (readonly, nonatomic) const zbar_symbol_set_t *zbarSymbolSet;
|
|
||||||
@property (nonatomic) BOOL filterSymbols;
|
|
||||||
|
|
||||||
- (id) initWithSymbolSet: (const zbar_symbol_set_t*) set;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
@interface ZBarSymbol : NSObject
|
|
||||||
{
|
|
||||||
const zbar_symbol_t *symbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (readonly, nonatomic) zbar_symbol_type_t type;
|
|
||||||
@property (readonly, nonatomic) NSString *typeName;
|
|
||||||
@property (readonly, nonatomic) NSUInteger configMask;
|
|
||||||
@property (readonly, nonatomic) NSUInteger modifierMask;
|
|
||||||
@property (readonly, nonatomic) NSString *data;
|
|
||||||
@property (readonly, nonatomic) int quality;
|
|
||||||
@property (readonly, nonatomic) int count;
|
|
||||||
@property (readonly, nonatomic) zbar_orientation_t orientation;
|
|
||||||
@property (readonly, nonatomic) ZBarSymbolSet *components;
|
|
||||||
@property (readonly, nonatomic) const zbar_symbol_t *zbarSymbol;
|
|
||||||
@property (readonly, nonatomic) CGRect bounds;
|
|
||||||
|
|
||||||
- (id) initWithSymbol: (const zbar_symbol_t*) symbol;
|
|
||||||
|
|
||||||
+ (NSString*) nameForType: (zbar_symbol_type_t) type;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_DECODER_H_
|
|
||||||
#define _ZBAR_DECODER_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Decoder C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Decoder.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// low-level bar width stream decoder interface.
|
|
||||||
/// identifies symbols and extracts encoded data
|
|
||||||
|
|
||||||
class Decoder {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Decoder result handler.
|
|
||||||
/// applications should subtype this and pass an instance to
|
|
||||||
/// set_handler() to implement result processing
|
|
||||||
class Handler {
|
|
||||||
public:
|
|
||||||
virtual ~Handler() { }
|
|
||||||
|
|
||||||
/// invoked by the Decoder as decode results become available.
|
|
||||||
virtual void decode_callback(Decoder &decoder) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Decoder ()
|
|
||||||
: _handler(NULL)
|
|
||||||
{
|
|
||||||
_decoder = zbar_decoder_create();
|
|
||||||
}
|
|
||||||
|
|
||||||
~Decoder ()
|
|
||||||
{
|
|
||||||
zbar_decoder_destroy(_decoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// clear all decoder state.
|
|
||||||
/// see zbar_decoder_reset()
|
|
||||||
void reset ()
|
|
||||||
{
|
|
||||||
zbar_decoder_reset(_decoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// mark start of a new scan pass.
|
|
||||||
/// see zbar_decoder_new_scan()
|
|
||||||
void new_scan ()
|
|
||||||
{
|
|
||||||
zbar_decoder_new_scan(_decoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next bar/space width from input stream.
|
|
||||||
/// see zbar_decode_width()
|
|
||||||
zbar_symbol_type_t decode_width (unsigned width)
|
|
||||||
{
|
|
||||||
return(zbar_decode_width(_decoder, width));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next bar/space width from input stream.
|
|
||||||
/// see zbar_decode_width()
|
|
||||||
Decoder& operator<< (unsigned width)
|
|
||||||
{
|
|
||||||
zbar_decode_width(_decoder, width);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve color of @em next element passed to Decoder.
|
|
||||||
/// see zbar_decoder_get_color()
|
|
||||||
zbar_color_t get_color () const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_color(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decoded symbol type.
|
|
||||||
/// see zbar_decoder_get_type()
|
|
||||||
zbar_symbol_type_t get_type () const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_type(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve string name of last decoded symbol type.
|
|
||||||
/// see zbar_get_symbol_name()
|
|
||||||
const char *get_symbol_name () const
|
|
||||||
{
|
|
||||||
return(zbar_get_symbol_name(zbar_decoder_get_type(_decoder)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve string name for last decode addon.
|
|
||||||
/// see zbar_get_addon_name()
|
|
||||||
/// @deprecated in 0.11
|
|
||||||
const char *get_addon_name () const
|
|
||||||
{
|
|
||||||
return(zbar_get_addon_name(zbar_decoder_get_type(_decoder)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decoded data in ASCII format as a char array.
|
|
||||||
/// see zbar_decoder_get_data()
|
|
||||||
const char *get_data_chars() const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_data(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decoded data as a std::string.
|
|
||||||
/// see zbar_decoder_get_data()
|
|
||||||
const std::string get_data_string() const
|
|
||||||
{
|
|
||||||
return(std::string(zbar_decoder_get_data(_decoder),
|
|
||||||
zbar_decoder_get_data_length(_decoder)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decoded data as a std::string.
|
|
||||||
/// see zbar_decoder_get_data()
|
|
||||||
const std::string get_data() const
|
|
||||||
{
|
|
||||||
return(get_data_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve length of decoded binary data.
|
|
||||||
/// see zbar_decoder_get_data_length()
|
|
||||||
int get_data_length() const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_data_length(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decode direction.
|
|
||||||
/// see zbar_decoder_get_direction()
|
|
||||||
/// @since 0.11
|
|
||||||
int get_direction() const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_direction(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// setup callback to handle result data.
|
|
||||||
void set_handler (Handler &handler)
|
|
||||||
{
|
|
||||||
_handler = &handler;
|
|
||||||
zbar_decoder_set_handler(_decoder, _cb);
|
|
||||||
zbar_decoder_set_userdata(_decoder, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config for indicated symbology (0 for all) to specified value.
|
|
||||||
/// @see zbar_decoder_set_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (zbar_symbol_type_t symbology,
|
|
||||||
zbar_config_t config,
|
|
||||||
int value)
|
|
||||||
{
|
|
||||||
return(zbar_decoder_set_config(_decoder, symbology, config, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config parsed from configuration string.
|
|
||||||
/// @see zbar_decoder_parse_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (std::string cfgstr)
|
|
||||||
{
|
|
||||||
return(zbar_decoder_parse_config(_decoder, cfgstr.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class Scanner;
|
|
||||||
zbar_decoder_t *_decoder;
|
|
||||||
Handler *_handler;
|
|
||||||
|
|
||||||
static void _cb (zbar_decoder_t *cdcode)
|
|
||||||
{
|
|
||||||
Decoder *dcode = (Decoder*)zbar_decoder_get_userdata(cdcode);
|
|
||||||
if(dcode && dcode->_handler)
|
|
||||||
dcode->_handler->decode_callback(*dcode);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_EXCEPTION_H_
|
|
||||||
#define _ZBAR_EXCEPTION_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// C++ Exception definitions
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Exception.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <exception>
|
|
||||||
#include <new>
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// base class for exceptions defined by this API.
|
|
||||||
class Exception : public std::exception {
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
Exception (const void *obj = NULL)
|
|
||||||
: std::exception(),
|
|
||||||
_obj(obj)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
~Exception () throw() { }
|
|
||||||
|
|
||||||
/// retrieve error message
|
|
||||||
virtual const char* what () const throw()
|
|
||||||
{
|
|
||||||
if(!_obj)
|
|
||||||
return("zbar library unspecified generic error");
|
|
||||||
return(_zbar_error_string(_obj, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const void *_obj;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// internal library error.
|
|
||||||
class InternalError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
InternalError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// unsupported request.
|
|
||||||
class UnsupportedError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
UnsupportedError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// invalid request.
|
|
||||||
class InvalidError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
InvalidError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// failed system call.
|
|
||||||
class SystemError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
SystemError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// locking error.
|
|
||||||
class LockingError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
LockingError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// all resources busy.
|
|
||||||
class BusyError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
BusyError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// X11 display error.
|
|
||||||
class XDisplayError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
XDisplayError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// X11 protocol error.
|
|
||||||
class XProtoError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
XProtoError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// output window is closed.
|
|
||||||
class ClosedError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
ClosedError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// image format error
|
|
||||||
class FormatError : public Exception {
|
|
||||||
// FIXME needs c equivalent
|
|
||||||
|
|
||||||
virtual const char* what () const throw()
|
|
||||||
{
|
|
||||||
// FIXME what format?
|
|
||||||
return("unsupported format");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @internal
|
|
||||||
|
|
||||||
/// extract error information and create exception.
|
|
||||||
static inline std::exception throw_exception (const void *obj)
|
|
||||||
{
|
|
||||||
switch(_zbar_get_error_code(obj)) {
|
|
||||||
case ZBAR_ERR_NOMEM:
|
|
||||||
throw std::bad_alloc();
|
|
||||||
case ZBAR_ERR_INTERNAL:
|
|
||||||
throw InternalError(obj);
|
|
||||||
case ZBAR_ERR_UNSUPPORTED:
|
|
||||||
throw UnsupportedError(obj);
|
|
||||||
case ZBAR_ERR_INVALID:
|
|
||||||
throw InvalidError(obj);
|
|
||||||
case ZBAR_ERR_SYSTEM:
|
|
||||||
throw SystemError(obj);
|
|
||||||
case ZBAR_ERR_LOCKING:
|
|
||||||
throw LockingError(obj);
|
|
||||||
case ZBAR_ERR_BUSY:
|
|
||||||
throw BusyError(obj);
|
|
||||||
case ZBAR_ERR_XDISPLAY:
|
|
||||||
throw XDisplayError(obj);
|
|
||||||
case ZBAR_ERR_XPROTO:
|
|
||||||
throw XProtoError(obj);
|
|
||||||
case ZBAR_ERR_CLOSED:
|
|
||||||
throw ClosedError(obj);
|
|
||||||
default:
|
|
||||||
throw Exception(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,321 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_IMAGE_H_
|
|
||||||
#define _ZBAR_IMAGE_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Image C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Image.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <iterator>
|
|
||||||
#include "Symbol.h"
|
|
||||||
#include "Exception.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
class Video;
|
|
||||||
|
|
||||||
/// stores image data samples along with associated format and size
|
|
||||||
/// metadata
|
|
||||||
|
|
||||||
class Image {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// general Image result handler.
|
|
||||||
/// applications should subtype this and pass an instance to
|
|
||||||
/// eg. ImageScanner::set_handler() to implement result processing
|
|
||||||
class Handler {
|
|
||||||
public:
|
|
||||||
virtual ~Handler() { }
|
|
||||||
|
|
||||||
/// invoked by library when Image should be processed
|
|
||||||
virtual void image_callback(Image &image) = 0;
|
|
||||||
|
|
||||||
/// cast this handler to the C handler
|
|
||||||
operator zbar_image_data_handler_t* () const
|
|
||||||
{
|
|
||||||
return(_cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void _cb (zbar_image_t *zimg,
|
|
||||||
const void *userdata)
|
|
||||||
{
|
|
||||||
if(userdata) {
|
|
||||||
Image *image = (Image*)zbar_image_get_userdata(zimg);
|
|
||||||
if(image)
|
|
||||||
((Handler*)userdata)->image_callback(*image);
|
|
||||||
else {
|
|
||||||
Image tmp(zimg, 1);
|
|
||||||
((Handler*)userdata)->image_callback(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SymbolIterator : public zbar::SymbolIterator {
|
|
||||||
public:
|
|
||||||
/// default constructor.
|
|
||||||
SymbolIterator ()
|
|
||||||
: zbar::SymbolIterator()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
SymbolIterator (const SymbolSet &syms)
|
|
||||||
: zbar::SymbolIterator(syms)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
SymbolIterator (const SymbolIterator& iter)
|
|
||||||
: zbar::SymbolIterator(iter)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
/// create a new Image with the specified parameters
|
|
||||||
Image (unsigned width = 0,
|
|
||||||
unsigned height = 0,
|
|
||||||
const std::string& format = "",
|
|
||||||
const void *data = NULL,
|
|
||||||
unsigned long length = 0)
|
|
||||||
: _img(zbar_image_create())
|
|
||||||
{
|
|
||||||
zbar_image_set_userdata(_img, this);
|
|
||||||
if(width && height)
|
|
||||||
set_size(width, height);
|
|
||||||
if(format.length())
|
|
||||||
set_format(format);
|
|
||||||
if(data && length)
|
|
||||||
set_data(data, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Image ()
|
|
||||||
{
|
|
||||||
set_data(NULL, 0);
|
|
||||||
zbar_image_set_userdata(_img, NULL);
|
|
||||||
zbar_image_ref(_img, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C image object
|
|
||||||
operator const zbar_image_t* () const
|
|
||||||
{
|
|
||||||
return(_img);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C image object
|
|
||||||
operator zbar_image_t* ()
|
|
||||||
{
|
|
||||||
return(_img);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the image format.
|
|
||||||
/// see zbar_image_get_format()
|
|
||||||
unsigned long get_format () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_format(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// specify the fourcc image format code for image sample data.
|
|
||||||
/// see zbar_image_set_format()
|
|
||||||
void set_format (unsigned long format)
|
|
||||||
{
|
|
||||||
zbar_image_set_format(_img, format);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// specify the fourcc image format code for image sample data.
|
|
||||||
/// see zbar_image_set_format()
|
|
||||||
void set_format (const std::string& format)
|
|
||||||
{
|
|
||||||
unsigned long fourcc = zbar_fourcc_parse(format.c_str());
|
|
||||||
zbar_image_set_format(_img, fourcc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve a "sequence" (page/frame) number associated with this
|
|
||||||
/// image.
|
|
||||||
/// see zbar_image_get_sequence()
|
|
||||||
/// @since 0.6
|
|
||||||
unsigned get_sequence () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_sequence(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// associate a "sequence" (page/frame) number with this image.
|
|
||||||
/// see zbar_image_set_sequence()
|
|
||||||
/// @since 0.6
|
|
||||||
void set_sequence (unsigned sequence_num)
|
|
||||||
{
|
|
||||||
zbar_image_set_sequence(_img, sequence_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the width of the image.
|
|
||||||
/// see zbar_image_get_width()
|
|
||||||
unsigned get_width () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_width(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the height of the image.
|
|
||||||
/// see zbar_image_get_height()
|
|
||||||
unsigned get_height () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_height(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve both dimensions of the image.
|
|
||||||
/// see zbar_image_get_size()
|
|
||||||
/// @since 0.11
|
|
||||||
void get_size (unsigned &width,
|
|
||||||
unsigned &height) const
|
|
||||||
{
|
|
||||||
zbar_image_get_size(_img, &width, &height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// specify the pixel size of the image.
|
|
||||||
/// see zbar_image_set_size()
|
|
||||||
void set_size (unsigned width,
|
|
||||||
unsigned height)
|
|
||||||
{
|
|
||||||
zbar_image_set_size(_img, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the scan crop rectangle.
|
|
||||||
/// see zbar_image_get_crop()
|
|
||||||
void get_crop (unsigned &x,
|
|
||||||
unsigned &y,
|
|
||||||
unsigned &width,
|
|
||||||
unsigned &height) const
|
|
||||||
{
|
|
||||||
zbar_image_get_crop(_img, &x, &y, &width, &height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set the scan crop rectangle.
|
|
||||||
/// see zbar_image_set_crop()
|
|
||||||
void set_crop (unsigned x,
|
|
||||||
unsigned y,
|
|
||||||
unsigned width,
|
|
||||||
unsigned height)
|
|
||||||
{
|
|
||||||
zbar_image_set_crop(_img, x, y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return the image sample data.
|
|
||||||
/// see zbar_image_get_data()
|
|
||||||
const void *get_data () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_data(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return the size of the image sample data.
|
|
||||||
/// see zbar_image_get_data_length()
|
|
||||||
/// @since 0.6
|
|
||||||
unsigned long get_data_length () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_data_length(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// specify image sample data.
|
|
||||||
/// see zbar_image_set_data()
|
|
||||||
void set_data (const void *data,
|
|
||||||
unsigned long length)
|
|
||||||
{
|
|
||||||
zbar_image_set_data(_img, data, length, _cleanup);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// image format conversion.
|
|
||||||
/// see zbar_image_convert()
|
|
||||||
Image convert (unsigned long format) const
|
|
||||||
{
|
|
||||||
zbar_image_t *img = zbar_image_convert(_img, format);
|
|
||||||
if(img)
|
|
||||||
return(Image(img));
|
|
||||||
throw FormatError();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// image format conversion with crop/pad.
|
|
||||||
/// see zbar_image_convert_resize()
|
|
||||||
/// @since 0.4
|
|
||||||
Image convert (unsigned long format,
|
|
||||||
unsigned width,
|
|
||||||
unsigned height) const
|
|
||||||
{
|
|
||||||
zbar_image_t *img =
|
|
||||||
zbar_image_convert_resize(_img, format, width, height);
|
|
||||||
if(img)
|
|
||||||
return(Image(img));
|
|
||||||
throw FormatError();
|
|
||||||
}
|
|
||||||
|
|
||||||
const SymbolSet get_symbols () const {
|
|
||||||
return(SymbolSet(zbar_image_get_symbols(_img)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_symbols (const SymbolSet &syms) {
|
|
||||||
zbar_image_set_symbols(_img, syms);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// create a new SymbolIterator over decoded results.
|
|
||||||
SymbolIterator symbol_begin () const {
|
|
||||||
return(SymbolIterator(get_symbols()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return a SymbolIterator suitable for ending iteration.
|
|
||||||
SymbolIterator symbol_end () const {
|
|
||||||
return(SymbolIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
friend class Video;
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
/// @internal
|
|
||||||
/// create a new Image from a zbar_image_t C object
|
|
||||||
Image (zbar_image_t *src,
|
|
||||||
int refs = 0)
|
|
||||||
: _img(src)
|
|
||||||
{
|
|
||||||
if(refs)
|
|
||||||
zbar_image_ref(_img, refs);
|
|
||||||
zbar_image_set_userdata(_img, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// default data cleanup (noop)
|
|
||||||
/// @internal
|
|
||||||
static void _cleanup (zbar_image_t *img)
|
|
||||||
{
|
|
||||||
// by default nothing is cleaned
|
|
||||||
assert(img);
|
|
||||||
assert(zbar_image_get_userdata(img));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_image_t *_img;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_IMAGE_SCANNER_H_
|
|
||||||
#define _ZBAR_IMAGE_SCANNER_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Image Scanner C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/ImageScanner.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Image.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// mid-level image scanner interface.
|
|
||||||
/// reads barcodes from a 2-D Image
|
|
||||||
|
|
||||||
class ImageScanner {
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
ImageScanner (zbar_image_scanner_t *scanner = NULL)
|
|
||||||
{
|
|
||||||
if(scanner)
|
|
||||||
_scanner = scanner;
|
|
||||||
else
|
|
||||||
_scanner = zbar_image_scanner_create();
|
|
||||||
}
|
|
||||||
|
|
||||||
~ImageScanner ()
|
|
||||||
{
|
|
||||||
zbar_image_scanner_destroy(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C image_scanner object
|
|
||||||
operator zbar_image_scanner_t* () const
|
|
||||||
{
|
|
||||||
return(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// setup result handler callback.
|
|
||||||
void set_handler (Image::Handler &handler)
|
|
||||||
{
|
|
||||||
zbar_image_scanner_set_data_handler(_scanner, handler, &handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config for indicated symbology (0 for all) to specified value.
|
|
||||||
/// @see zbar_image_scanner_set_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (zbar_symbol_type_t symbology,
|
|
||||||
zbar_config_t config,
|
|
||||||
int value)
|
|
||||||
{
|
|
||||||
return(zbar_image_scanner_set_config(_scanner, symbology,
|
|
||||||
config, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config parsed from configuration string.
|
|
||||||
/// @see zbar_image_scanner_parse_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (std::string cfgstr)
|
|
||||||
{
|
|
||||||
return(zbar_image_scanner_parse_config(_scanner, cfgstr.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// enable or disable the inter-image result cache.
|
|
||||||
/// see zbar_image_scanner_enable_cache()
|
|
||||||
void enable_cache (bool enable = true)
|
|
||||||
{
|
|
||||||
zbar_image_scanner_enable_cache(_scanner, enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// remove previous results from scanner and image.
|
|
||||||
/// @see zbar_image_scanner_recycle_image()
|
|
||||||
/// @since 0.10
|
|
||||||
void recycle_image (Image &image)
|
|
||||||
{
|
|
||||||
zbar_image_scanner_recycle_image(_scanner, image);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve decode results for last scanned image.
|
|
||||||
/// @see zbar_image_scanner_get_results()
|
|
||||||
/// @since 0.10
|
|
||||||
const SymbolSet get_results () const {
|
|
||||||
return(SymbolSet(zbar_image_scanner_get_results(_scanner)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// scan for symbols in provided image.
|
|
||||||
/// see zbar_scan_image()
|
|
||||||
int scan (Image& image)
|
|
||||||
{
|
|
||||||
return(zbar_scan_image(_scanner, image));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// scan for symbols in provided image.
|
|
||||||
/// see zbar_scan_image()
|
|
||||||
ImageScanner& operator<< (Image& image)
|
|
||||||
{
|
|
||||||
scan(image);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_image_scanner_t *_scanner;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,223 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_PROCESSOR_H_
|
|
||||||
#define _ZBAR_PROCESSOR_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Processor C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Processor.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Exception.h"
|
|
||||||
#include "Image.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// high-level self-contained image processor.
|
|
||||||
/// processes video and images for barcodes, optionally displaying
|
|
||||||
/// images to a library owned output window
|
|
||||||
|
|
||||||
class Processor {
|
|
||||||
public:
|
|
||||||
/// value to pass for no timeout.
|
|
||||||
static const int FOREVER = -1;
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Processor (bool threaded = true,
|
|
||||||
const char *video_device = "",
|
|
||||||
bool enable_display = true)
|
|
||||||
{
|
|
||||||
_processor = zbar_processor_create(threaded);
|
|
||||||
if(!_processor)
|
|
||||||
throw std::bad_alloc();
|
|
||||||
init(video_device, enable_display);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Processor ()
|
|
||||||
{
|
|
||||||
zbar_processor_destroy(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C processor object.
|
|
||||||
operator zbar_processor_t* ()
|
|
||||||
{
|
|
||||||
return(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// opens a video input device and/or prepares to display output.
|
|
||||||
/// see zbar_processor_init()
|
|
||||||
void init (const char *video_device = "",
|
|
||||||
bool enable_display = true)
|
|
||||||
{
|
|
||||||
if(zbar_processor_init(_processor, video_device, enable_display))
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// setup result handler callback.
|
|
||||||
/// see zbar_processor_set_data_handler()
|
|
||||||
void set_handler (Image::Handler& handler)
|
|
||||||
{
|
|
||||||
zbar_processor_set_data_handler(_processor, handler, &handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config for indicated symbology (0 for all) to specified value.
|
|
||||||
/// @see zbar_processor_set_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (zbar_symbol_type_t symbology,
|
|
||||||
zbar_config_t config,
|
|
||||||
int value)
|
|
||||||
{
|
|
||||||
return(zbar_processor_set_config(_processor, symbology,
|
|
||||||
config, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config parsed from configuration string.
|
|
||||||
/// @see zbar_processor_parse_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (std::string cfgstr)
|
|
||||||
{
|
|
||||||
return(zbar_processor_parse_config(_processor, cfgstr.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the current state of the ouput window.
|
|
||||||
/// see zbar_processor_is_visible()
|
|
||||||
bool is_visible ()
|
|
||||||
{
|
|
||||||
int rc = zbar_processor_is_visible(_processor);
|
|
||||||
if(rc < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
return(rc != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// show or hide the display window owned by the library.
|
|
||||||
/// see zbar_processor_set_visible()
|
|
||||||
void set_visible (bool visible = true)
|
|
||||||
{
|
|
||||||
if(zbar_processor_set_visible(_processor, visible) < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// control the processor in free running video mode.
|
|
||||||
/// see zbar_processor_set_active()
|
|
||||||
void set_active (bool active = true)
|
|
||||||
{
|
|
||||||
if(zbar_processor_set_active(_processor, active) < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve decode results for last scanned image.
|
|
||||||
/// @see zbar_processor_get_results()
|
|
||||||
/// @since 0.10
|
|
||||||
const SymbolSet get_results () const {
|
|
||||||
return(SymbolSet(zbar_processor_get_results(_processor)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// wait for input to the display window from the user.
|
|
||||||
/// see zbar_processor_user_wait()
|
|
||||||
int user_wait (int timeout = FOREVER)
|
|
||||||
{
|
|
||||||
int rc = zbar_processor_user_wait(_processor, timeout);
|
|
||||||
if(rc < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
return(rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process from the video stream until a result is available.
|
|
||||||
/// see zbar_process_one()
|
|
||||||
void process_one (int timeout = FOREVER)
|
|
||||||
{
|
|
||||||
if(zbar_process_one(_processor, timeout) < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process the provided image for barcodes.
|
|
||||||
/// see zbar_process_image()
|
|
||||||
void process_image (Image& image)
|
|
||||||
{
|
|
||||||
if(zbar_process_image(_processor, image) < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process the provided image for barcodes.
|
|
||||||
/// see zbar_process_image()
|
|
||||||
Processor& operator<< (Image& image)
|
|
||||||
{
|
|
||||||
process_image(image);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// force specific input and output formats for debug/testing.
|
|
||||||
/// see zbar_processor_force_format()
|
|
||||||
void force_format (unsigned long input_format,
|
|
||||||
unsigned long output_format)
|
|
||||||
{
|
|
||||||
if(zbar_processor_force_format(_processor, input_format,
|
|
||||||
output_format))
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// force specific input and output formats for debug/testing.
|
|
||||||
/// see zbar_processor_force_format()
|
|
||||||
void force_format (std::string& input_format,
|
|
||||||
std::string& output_format)
|
|
||||||
{
|
|
||||||
unsigned long ifourcc = zbar_fourcc_parse(input_format.c_str());
|
|
||||||
unsigned long ofourcc = zbar_fourcc_parse(output_format.c_str());
|
|
||||||
if(zbar_processor_force_format(_processor, ifourcc, ofourcc))
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred size for the video image from the device.
|
|
||||||
/// see zbar_processor_request_size()
|
|
||||||
/// @since 0.6
|
|
||||||
void request_size (int width, int height)
|
|
||||||
{
|
|
||||||
zbar_processor_request_size(_processor, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred driver interface version for debug/testing.
|
|
||||||
/// see zbar_processor_request_interface()
|
|
||||||
/// @since 0.6
|
|
||||||
void request_interface (int version)
|
|
||||||
{
|
|
||||||
zbar_processor_request_interface(_processor, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred I/O mode for debug/testing.
|
|
||||||
/// see zbar_processor_request_iomode()
|
|
||||||
/// @since 0.7
|
|
||||||
void request_iomode (int iomode)
|
|
||||||
{
|
|
||||||
if(zbar_processor_request_iomode(_processor, iomode))
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_processor_t *_processor;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_SCANNER_H_
|
|
||||||
#define _ZBAR_SCANNER_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Scanner C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Scanner.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// low-level linear intensity sample stream scanner interface.
|
|
||||||
/// identifies "bar" edges and measures width between them.
|
|
||||||
/// optionally passes to bar width Decoder
|
|
||||||
|
|
||||||
class Scanner {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
/// @param decoder reference to a Decoder instance which will
|
|
||||||
/// be passed scan results automatically
|
|
||||||
Scanner (Decoder& decoder)
|
|
||||||
{
|
|
||||||
_scanner = zbar_scanner_create(decoder._decoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
/// @param decoder pointer to a Decoder instance which will
|
|
||||||
/// be passed scan results automatically
|
|
||||||
Scanner (Decoder* decoder = NULL)
|
|
||||||
{
|
|
||||||
zbar_decoder_t *zdcode = NULL;
|
|
||||||
if(decoder)
|
|
||||||
zdcode = decoder->_decoder;
|
|
||||||
_scanner = zbar_scanner_create(zdcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Scanner ()
|
|
||||||
{
|
|
||||||
zbar_scanner_destroy(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// clear all scanner state.
|
|
||||||
/// see zbar_scanner_reset()
|
|
||||||
void reset ()
|
|
||||||
{
|
|
||||||
zbar_scanner_reset(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// mark start of a new scan pass.
|
|
||||||
/// see zbar_scanner_new_scan()
|
|
||||||
zbar_symbol_type_t new_scan ()
|
|
||||||
{
|
|
||||||
_type = zbar_scanner_new_scan(_scanner);
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// flush scanner pipeline.
|
|
||||||
/// see zbar_scanner_flush()
|
|
||||||
zbar_symbol_type_t flush ()
|
|
||||||
{
|
|
||||||
_type = zbar_scanner_flush(_scanner);
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next sample intensity value.
|
|
||||||
/// see zbar_scan_y()
|
|
||||||
zbar_symbol_type_t scan_y (int y)
|
|
||||||
{
|
|
||||||
_type = zbar_scan_y(_scanner, y);
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next sample intensity value.
|
|
||||||
/// see zbar_scan_y()
|
|
||||||
Scanner& operator<< (int y)
|
|
||||||
{
|
|
||||||
_type = zbar_scan_y(_scanner, y);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next sample from RGB (or BGR) triple.
|
|
||||||
/// see zbar_scan_rgb24()
|
|
||||||
zbar_symbol_type_t scan_rgb24 (unsigned char *rgb)
|
|
||||||
{
|
|
||||||
_type = zbar_scan_rgb24(_scanner, rgb);
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next sample from RGB (or BGR) triple.
|
|
||||||
/// see zbar_scan_rgb24()
|
|
||||||
Scanner& operator<< (unsigned char *rgb)
|
|
||||||
{
|
|
||||||
_type = zbar_scan_rgb24(_scanner, rgb);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last scanned width.
|
|
||||||
/// see zbar_scanner_get_width()
|
|
||||||
unsigned get_width () const
|
|
||||||
{
|
|
||||||
return(zbar_scanner_get_width(_scanner));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last scanned color.
|
|
||||||
/// see zbar_scanner_get_color()
|
|
||||||
zbar_color_t get_color () const
|
|
||||||
{
|
|
||||||
return(zbar_scanner_get_color(_scanner));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last scan result.
|
|
||||||
zbar_symbol_type_t get_type () const
|
|
||||||
{
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C scanner
|
|
||||||
operator zbar_scanner_t* () const
|
|
||||||
{
|
|
||||||
return(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve C scanner
|
|
||||||
const zbar_scanner_t *get_c_scanner () const
|
|
||||||
{
|
|
||||||
return(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_scanner_t *_scanner;
|
|
||||||
zbar_symbol_type_t _type;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,528 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_SYMBOL_H_
|
|
||||||
#define _ZBAR_SYMBOL_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Symbol C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Symbol.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
|
||||||
#include <ostream>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
class SymbolIterator;
|
|
||||||
|
|
||||||
/// container for decoded result symbols associated with an image
|
|
||||||
/// or a composite symbol.
|
|
||||||
|
|
||||||
class SymbolSet {
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
SymbolSet (const zbar_symbol_set_t *syms = NULL)
|
|
||||||
: _syms(syms)
|
|
||||||
{
|
|
||||||
ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
SymbolSet (const SymbolSet& syms)
|
|
||||||
: _syms(syms._syms)
|
|
||||||
{
|
|
||||||
ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// destructor.
|
|
||||||
~SymbolSet ()
|
|
||||||
{
|
|
||||||
ref(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
SymbolSet& operator= (const SymbolSet& syms)
|
|
||||||
{
|
|
||||||
syms.ref();
|
|
||||||
ref(-1);
|
|
||||||
_syms = syms._syms;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// truth testing.
|
|
||||||
bool operator! () const
|
|
||||||
{
|
|
||||||
return(!_syms || !get_size());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// manipulate reference count.
|
|
||||||
void ref (int delta = 1) const
|
|
||||||
{
|
|
||||||
if(_syms)
|
|
||||||
zbar_symbol_set_ref((zbar_symbol_set_t*)_syms, delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C symbol set.
|
|
||||||
operator const zbar_symbol_set_t* () const
|
|
||||||
{
|
|
||||||
return(_syms);
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_size () const
|
|
||||||
{
|
|
||||||
return((_syms) ? zbar_symbol_set_get_size(_syms) : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// create a new SymbolIterator over decoded results.
|
|
||||||
SymbolIterator symbol_begin() const;
|
|
||||||
|
|
||||||
/// return a SymbolIterator suitable for ending iteration.
|
|
||||||
const SymbolIterator symbol_end() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const zbar_symbol_set_t *_syms;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// decoded barcode symbol result object. stores type, data, and
|
|
||||||
/// image location of decoded symbol
|
|
||||||
|
|
||||||
class Symbol {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// image pixel location (x, y) coordinate tuple.
|
|
||||||
class Point {
|
|
||||||
public:
|
|
||||||
int x; ///< x-coordinate.
|
|
||||||
int y; ///< y-coordinate.
|
|
||||||
|
|
||||||
Point () { }
|
|
||||||
|
|
||||||
Point(int x, int y)
|
|
||||||
: x(x), y(y)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
Point (const Point& pt)
|
|
||||||
: x(pt.x),
|
|
||||||
y(pt.y)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
Point& operator= (const Point& pt)
|
|
||||||
{
|
|
||||||
x = pt.x;
|
|
||||||
y = pt.y;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// iteration over Point objects in a symbol location polygon.
|
|
||||||
class PointIterator
|
|
||||||
: public std::iterator<std::input_iterator_tag, Point> {
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
PointIterator (const Symbol *sym = NULL,
|
|
||||||
int index = 0)
|
|
||||||
: _sym(sym),
|
|
||||||
_index(index)
|
|
||||||
{
|
|
||||||
sym->ref(1);
|
|
||||||
if(!sym ||
|
|
||||||
(unsigned)_index >= zbar_symbol_get_loc_size(*_sym))
|
|
||||||
_index = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
PointIterator (const PointIterator& iter)
|
|
||||||
: _sym(iter._sym),
|
|
||||||
_index(iter._index)
|
|
||||||
{
|
|
||||||
_sym->ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// destructor.
|
|
||||||
~PointIterator ()
|
|
||||||
{
|
|
||||||
_sym->ref(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
PointIterator& operator= (const PointIterator& iter)
|
|
||||||
{
|
|
||||||
iter._sym->ref();
|
|
||||||
_sym->ref(-1);
|
|
||||||
_sym = iter._sym;
|
|
||||||
_index = iter._index;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// truth testing.
|
|
||||||
bool operator! () const
|
|
||||||
{
|
|
||||||
return(!_sym || _index < 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// advance iterator to next Point.
|
|
||||||
PointIterator& operator++ ()
|
|
||||||
{
|
|
||||||
unsigned int i = ++_index;
|
|
||||||
if(i >= zbar_symbol_get_loc_size(*_sym))
|
|
||||||
_index = -1;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve currently referenced Point.
|
|
||||||
const Point operator* () const
|
|
||||||
{
|
|
||||||
assert(!!*this);
|
|
||||||
if(!*this)
|
|
||||||
return(Point());
|
|
||||||
return(Point(zbar_symbol_get_loc_x(*_sym, _index),
|
|
||||||
zbar_symbol_get_loc_y(*_sym, _index)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two iterators refer to the same Point in the same
|
|
||||||
/// Symbol.
|
|
||||||
bool operator== (const PointIterator& iter) const
|
|
||||||
{
|
|
||||||
return(_index == iter._index &&
|
|
||||||
((_index < 0) || _sym == iter._sym));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two iterators refer to the same Point in the same
|
|
||||||
/// Symbol.
|
|
||||||
bool operator!= (const PointIterator& iter) const
|
|
||||||
{
|
|
||||||
return(!(*this == iter));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const Symbol *_sym;
|
|
||||||
int _index;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Symbol (const zbar_symbol_t *sym = NULL)
|
|
||||||
: _xmlbuf(NULL),
|
|
||||||
_xmllen(0)
|
|
||||||
{
|
|
||||||
init(sym);
|
|
||||||
ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
Symbol (const Symbol& sym)
|
|
||||||
: _sym(sym._sym),
|
|
||||||
_type(sym._type),
|
|
||||||
_data(sym._data),
|
|
||||||
_xmlbuf(NULL),
|
|
||||||
_xmllen(0)
|
|
||||||
{
|
|
||||||
ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// destructor.
|
|
||||||
~Symbol () {
|
|
||||||
if(_xmlbuf)
|
|
||||||
free(_xmlbuf);
|
|
||||||
ref(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
Symbol& operator= (const Symbol& sym)
|
|
||||||
{
|
|
||||||
sym.ref(1);
|
|
||||||
ref(-1);
|
|
||||||
_sym = sym._sym;
|
|
||||||
_type = sym._type;
|
|
||||||
_data = sym._data;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Symbol& operator= (const zbar_symbol_t *sym)
|
|
||||||
{
|
|
||||||
if(sym)
|
|
||||||
zbar_symbol_ref(sym, 1);
|
|
||||||
ref(-1);
|
|
||||||
init(sym);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// truth testing.
|
|
||||||
bool operator! () const
|
|
||||||
{
|
|
||||||
return(!_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ref (int delta = 1) const
|
|
||||||
{
|
|
||||||
if(_sym)
|
|
||||||
zbar_symbol_ref((zbar_symbol_t*)_sym, delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C symbol.
|
|
||||||
operator const zbar_symbol_t* () const
|
|
||||||
{
|
|
||||||
return(_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two Symbol objects refer to the same C symbol.
|
|
||||||
bool operator== (const Symbol& sym) const
|
|
||||||
{
|
|
||||||
return(_sym == sym._sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two Symbol objects refer to the same C symbol.
|
|
||||||
bool operator!= (const Symbol& sym) const
|
|
||||||
{
|
|
||||||
return(!(*this == sym));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve type of decoded symbol.
|
|
||||||
zbar_symbol_type_t get_type () const
|
|
||||||
{
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the string name of the symbol type.
|
|
||||||
const std::string get_type_name () const
|
|
||||||
{
|
|
||||||
return(zbar_get_symbol_name(_type));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the string name for any addon.
|
|
||||||
/// @deprecated in 0.11
|
|
||||||
const std::string get_addon_name () const
|
|
||||||
{
|
|
||||||
return(zbar_get_addon_name(_type));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve data decoded from symbol.
|
|
||||||
const std::string get_data () const
|
|
||||||
{
|
|
||||||
return(_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve length of binary data
|
|
||||||
unsigned get_data_length () const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_data_length(_sym) : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve inter-frame coherency count.
|
|
||||||
/// see zbar_symbol_get_count()
|
|
||||||
/// @since 1.5
|
|
||||||
int get_count () const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_count(_sym) : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SymbolSet get_components () const
|
|
||||||
{
|
|
||||||
return(SymbolSet((_sym) ? zbar_symbol_get_components(_sym) : NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// create a new PointIterator at the start of the location
|
|
||||||
/// polygon.
|
|
||||||
PointIterator point_begin() const
|
|
||||||
{
|
|
||||||
return(PointIterator(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return a PointIterator suitable for ending iteration.
|
|
||||||
const PointIterator point_end() const
|
|
||||||
{
|
|
||||||
return(PointIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_get_loc_size().
|
|
||||||
int get_location_size () const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_loc_size(_sym) : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_get_loc_x().
|
|
||||||
int get_location_x (unsigned index) const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_loc_x(_sym, index) : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_get_loc_y().
|
|
||||||
int get_location_y (unsigned index) const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_loc_y(_sym, index) : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_get_orientation().
|
|
||||||
/// @since 0.11
|
|
||||||
int get_orientation () const
|
|
||||||
{
|
|
||||||
return(zbar_symbol_get_orientation(_sym));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_xml().
|
|
||||||
const std::string xml () const
|
|
||||||
{
|
|
||||||
if(!_sym)
|
|
||||||
return("");
|
|
||||||
return(zbar_symbol_xml(_sym, (char**)&_xmlbuf, (unsigned*)&_xmllen));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/// (re)initialize Symbol from C symbol object.
|
|
||||||
void init (const zbar_symbol_t *sym = NULL)
|
|
||||||
{
|
|
||||||
_sym = sym;
|
|
||||||
if(sym) {
|
|
||||||
_type = zbar_symbol_get_type(sym);
|
|
||||||
_data = std::string(zbar_symbol_get_data(sym),
|
|
||||||
zbar_symbol_get_data_length(sym));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_type = ZBAR_NONE;
|
|
||||||
_data = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const zbar_symbol_t *_sym;
|
|
||||||
zbar_symbol_type_t _type;
|
|
||||||
std::string _data;
|
|
||||||
char *_xmlbuf;
|
|
||||||
unsigned _xmllen;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// iteration over Symbol result objects in a scanned Image or SymbolSet.
|
|
||||||
class SymbolIterator
|
|
||||||
: public std::iterator<std::input_iterator_tag, Symbol> {
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// default constructor.
|
|
||||||
SymbolIterator ()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
SymbolIterator (const SymbolSet &syms)
|
|
||||||
: _syms(syms)
|
|
||||||
{
|
|
||||||
const zbar_symbol_set_t *zsyms = _syms;
|
|
||||||
if(zsyms)
|
|
||||||
_sym = zbar_symbol_set_first_symbol(zsyms);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
SymbolIterator (const SymbolIterator& iter)
|
|
||||||
: _syms(iter._syms)
|
|
||||||
{
|
|
||||||
const zbar_symbol_set_t *zsyms = _syms;
|
|
||||||
if(zsyms)
|
|
||||||
_sym = zbar_symbol_set_first_symbol(zsyms);
|
|
||||||
}
|
|
||||||
|
|
||||||
~SymbolIterator ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
SymbolIterator& operator= (const SymbolIterator& iter)
|
|
||||||
{
|
|
||||||
_syms = iter._syms;
|
|
||||||
_sym = iter._sym;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator! () const
|
|
||||||
{
|
|
||||||
return(!_syms || !_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// advance iterator to next Symbol.
|
|
||||||
SymbolIterator& operator++ ()
|
|
||||||
{
|
|
||||||
if(!!_sym)
|
|
||||||
_sym = zbar_symbol_next(_sym);
|
|
||||||
else if(!!_syms)
|
|
||||||
_sym = zbar_symbol_set_first_symbol(_syms);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve currently referenced Symbol.
|
|
||||||
const Symbol operator* () const
|
|
||||||
{
|
|
||||||
return(_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// access currently referenced Symbol.
|
|
||||||
const Symbol* operator-> () const
|
|
||||||
{
|
|
||||||
return(&_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two iterators refer to the same Symbol
|
|
||||||
bool operator== (const SymbolIterator& iter) const
|
|
||||||
{
|
|
||||||
// it is enough to test the symbols, as they belong
|
|
||||||
// to only one set (also simplifies invalid case)
|
|
||||||
return(_sym == iter._sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two iterators refer to the same Symbol
|
|
||||||
bool operator!= (const SymbolIterator& iter) const
|
|
||||||
{
|
|
||||||
return(!(*this == iter));
|
|
||||||
}
|
|
||||||
|
|
||||||
const SymbolIterator end () const {
|
|
||||||
return(SymbolIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
SymbolSet _syms;
|
|
||||||
Symbol _sym;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline SymbolIterator SymbolSet::symbol_begin () const {
|
|
||||||
return(SymbolIterator(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const SymbolIterator SymbolSet::symbol_end () const {
|
|
||||||
return(SymbolIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @relates Symbol
|
|
||||||
/// stream the string representation of a Symbol.
|
|
||||||
static inline std::ostream& operator<< (std::ostream& out,
|
|
||||||
const Symbol& sym)
|
|
||||||
{
|
|
||||||
out << sym.get_type_name() << ":" << sym.get_data();
|
|
||||||
return(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_VIDEO_H_
|
|
||||||
#define _ZBAR_VIDEO_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Video Input C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Video.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Image.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// mid-level video source abstraction.
|
|
||||||
/// captures images from a video device
|
|
||||||
|
|
||||||
class Video {
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
Video (zbar_video_t *video = NULL)
|
|
||||||
{
|
|
||||||
if(video)
|
|
||||||
_video = video;
|
|
||||||
else
|
|
||||||
_video = zbar_video_create();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Video (std::string& device)
|
|
||||||
{
|
|
||||||
_video = zbar_video_create();
|
|
||||||
open(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Video ()
|
|
||||||
{
|
|
||||||
zbar_video_destroy(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C video object.
|
|
||||||
operator zbar_video_t* () const
|
|
||||||
{
|
|
||||||
return(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// open and probe a video device.
|
|
||||||
void open (std::string& device)
|
|
||||||
{
|
|
||||||
if(zbar_video_open(_video, device.c_str()))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// close video device if open.
|
|
||||||
void close ()
|
|
||||||
{
|
|
||||||
if(zbar_video_open(_video, NULL))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// initialize video using a specific format for debug.
|
|
||||||
/// see zbar_video_init()
|
|
||||||
void init (unsigned long fourcc)
|
|
||||||
{
|
|
||||||
if(zbar_video_init(_video, fourcc))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// initialize video using a specific format for debug.
|
|
||||||
/// see zbar_video_init()
|
|
||||||
void init (std::string& format)
|
|
||||||
{
|
|
||||||
unsigned int fourcc = zbar_fourcc_parse(format.c_str());
|
|
||||||
if(zbar_video_init(_video, fourcc))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve file descriptor associated with open *nix video device.
|
|
||||||
/// see zbar_video_get_fd()
|
|
||||||
int get_fd ()
|
|
||||||
{
|
|
||||||
return(zbar_video_get_fd(_video));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve current output image width.
|
|
||||||
/// see zbar_video_get_width()
|
|
||||||
int get_width ()
|
|
||||||
{
|
|
||||||
return(zbar_video_get_width(_video));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve current output image height.
|
|
||||||
/// see zbar_video_get_height()
|
|
||||||
int get_height ()
|
|
||||||
{
|
|
||||||
return(zbar_video_get_height(_video));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// start/stop video capture.
|
|
||||||
/// see zbar_video_enable()
|
|
||||||
void enable (bool enable = true)
|
|
||||||
{
|
|
||||||
if(zbar_video_enable(_video, enable))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve next captured image.
|
|
||||||
/// see zbar_video_next_image()
|
|
||||||
Image next_image ()
|
|
||||||
{
|
|
||||||
zbar_image_t *img = zbar_video_next_image(_video);
|
|
||||||
if(!img)
|
|
||||||
throw_exception(_video);
|
|
||||||
return(Image(img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred size for the video image from the device.
|
|
||||||
/// see zbar_video_request_size()
|
|
||||||
/// @since 0.6
|
|
||||||
void request_size (int width, int height)
|
|
||||||
{
|
|
||||||
zbar_video_request_size(_video, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred driver interface version for debug/testing.
|
|
||||||
/// see zbar_video_request_interface()
|
|
||||||
/// @since 0.6
|
|
||||||
void request_interface (int version)
|
|
||||||
{
|
|
||||||
zbar_video_request_interface(_video, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred I/O mode for debug/testing.
|
|
||||||
/// see zbar_video_request_iomode()
|
|
||||||
/// @since 0.7
|
|
||||||
void request_iomode (int iomode)
|
|
||||||
{
|
|
||||||
if(zbar_video_request_iomode(_video, iomode))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_video_t *_video;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_WINDOW_H_
|
|
||||||
#define _ZBAR_WINDOW_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Output Window C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Window.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Image.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// mid-level output window abstraction.
|
|
||||||
/// displays images to user-specified platform specific output window
|
|
||||||
|
|
||||||
class Window {
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
Window (zbar_window_t *window = NULL)
|
|
||||||
{
|
|
||||||
if(window)
|
|
||||||
_window = window;
|
|
||||||
else
|
|
||||||
_window = zbar_window_create();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Window (void *x11_display_w32_hwnd,
|
|
||||||
unsigned long x11_drawable)
|
|
||||||
{
|
|
||||||
_window = zbar_window_create();
|
|
||||||
attach(x11_display_w32_hwnd, x11_drawable);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Window ()
|
|
||||||
{
|
|
||||||
zbar_window_destroy(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C window object.
|
|
||||||
operator zbar_window_t* () const
|
|
||||||
{
|
|
||||||
return(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// associate reader with an existing platform window.
|
|
||||||
/// see zbar_window_attach()
|
|
||||||
void attach (void *x11_display_w32_hwnd,
|
|
||||||
unsigned long x11_drawable = 0)
|
|
||||||
{
|
|
||||||
if(zbar_window_attach(_window,
|
|
||||||
x11_display_w32_hwnd, x11_drawable) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// control content level of the reader overlay.
|
|
||||||
/// see zbar_window_set_overlay()
|
|
||||||
void set_overlay (int level)
|
|
||||||
{
|
|
||||||
zbar_window_set_overlay(_window, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve current content level of reader overlay.
|
|
||||||
/// see zbar_window_get_overlay()
|
|
||||||
|
|
||||||
/// draw a new image into the output window.
|
|
||||||
/// see zbar_window_draw()
|
|
||||||
void draw (Image& image)
|
|
||||||
{
|
|
||||||
if(zbar_window_draw(_window, image) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// clear the image from the output window.
|
|
||||||
/// see zbar_window_draw()
|
|
||||||
void clear ()
|
|
||||||
{
|
|
||||||
if(zbar_window_draw(_window, NULL) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// redraw the last image.
|
|
||||||
/// zbar_window_redraw()
|
|
||||||
void redraw ()
|
|
||||||
{
|
|
||||||
if(zbar_window_redraw(_window) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// resize the image window.
|
|
||||||
/// zbar_window_resize()
|
|
||||||
void resize (unsigned width, unsigned height)
|
|
||||||
{
|
|
||||||
if(zbar_window_resize(_window, width, height) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_window_t *_window;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// select a compatible format between video input and output window.
|
|
||||||
/// see zbar_negotiate_format()
|
|
||||||
static inline void negotiate_format (Video& video, Window& window)
|
|
||||||
{
|
|
||||||
if(zbar_negotiate_format(video, window) < 0)
|
|
||||||
throw_exception(video);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import <CoreGraphics/CoreGraphics.h>
|
|
||||||
#import "zbar.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
using namespace zbar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Obj-C wrapper for ZBar result types
|
|
||||||
|
|
||||||
@interface ZBarSymbolSet
|
|
||||||
: NSObject <NSFastEnumeration>
|
|
||||||
{
|
|
||||||
const zbar_symbol_set_t *set;
|
|
||||||
BOOL filterSymbols;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (readonly, nonatomic) int count;
|
|
||||||
@property (readonly, nonatomic) const zbar_symbol_set_t *zbarSymbolSet;
|
|
||||||
@property (nonatomic) BOOL filterSymbols;
|
|
||||||
|
|
||||||
- (id) initWithSymbolSet: (const zbar_symbol_set_t*) set;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
@interface ZBarSymbol : NSObject
|
|
||||||
{
|
|
||||||
const zbar_symbol_t *symbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (readonly, nonatomic) zbar_symbol_type_t type;
|
|
||||||
@property (readonly, nonatomic) NSString *typeName;
|
|
||||||
@property (readonly, nonatomic) NSUInteger configMask;
|
|
||||||
@property (readonly, nonatomic) NSUInteger modifierMask;
|
|
||||||
@property (readonly, nonatomic) NSString *data;
|
|
||||||
@property (readonly, nonatomic) int quality;
|
|
||||||
@property (readonly, nonatomic) int count;
|
|
||||||
@property (readonly, nonatomic) zbar_orientation_t orientation;
|
|
||||||
@property (readonly, nonatomic) ZBarSymbolSet *components;
|
|
||||||
@property (readonly, nonatomic) const zbar_symbol_t *zbarSymbol;
|
|
||||||
@property (readonly, nonatomic) CGRect bounds;
|
|
||||||
|
|
||||||
- (id) initWithSymbol: (const zbar_symbol_t*) symbol;
|
|
||||||
|
|
||||||
+ (NSString*) nameForType: (zbar_symbol_type_t) type;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_DECODER_H_
|
|
||||||
#define _ZBAR_DECODER_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Decoder C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Decoder.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// low-level bar width stream decoder interface.
|
|
||||||
/// identifies symbols and extracts encoded data
|
|
||||||
|
|
||||||
class Decoder {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Decoder result handler.
|
|
||||||
/// applications should subtype this and pass an instance to
|
|
||||||
/// set_handler() to implement result processing
|
|
||||||
class Handler {
|
|
||||||
public:
|
|
||||||
virtual ~Handler() { }
|
|
||||||
|
|
||||||
/// invoked by the Decoder as decode results become available.
|
|
||||||
virtual void decode_callback(Decoder &decoder) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Decoder ()
|
|
||||||
: _handler(NULL)
|
|
||||||
{
|
|
||||||
_decoder = zbar_decoder_create();
|
|
||||||
}
|
|
||||||
|
|
||||||
~Decoder ()
|
|
||||||
{
|
|
||||||
zbar_decoder_destroy(_decoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// clear all decoder state.
|
|
||||||
/// see zbar_decoder_reset()
|
|
||||||
void reset ()
|
|
||||||
{
|
|
||||||
zbar_decoder_reset(_decoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// mark start of a new scan pass.
|
|
||||||
/// see zbar_decoder_new_scan()
|
|
||||||
void new_scan ()
|
|
||||||
{
|
|
||||||
zbar_decoder_new_scan(_decoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next bar/space width from input stream.
|
|
||||||
/// see zbar_decode_width()
|
|
||||||
zbar_symbol_type_t decode_width (unsigned width)
|
|
||||||
{
|
|
||||||
return(zbar_decode_width(_decoder, width));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next bar/space width from input stream.
|
|
||||||
/// see zbar_decode_width()
|
|
||||||
Decoder& operator<< (unsigned width)
|
|
||||||
{
|
|
||||||
zbar_decode_width(_decoder, width);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve color of @em next element passed to Decoder.
|
|
||||||
/// see zbar_decoder_get_color()
|
|
||||||
zbar_color_t get_color () const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_color(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decoded symbol type.
|
|
||||||
/// see zbar_decoder_get_type()
|
|
||||||
zbar_symbol_type_t get_type () const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_type(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve string name of last decoded symbol type.
|
|
||||||
/// see zbar_get_symbol_name()
|
|
||||||
const char *get_symbol_name () const
|
|
||||||
{
|
|
||||||
return(zbar_get_symbol_name(zbar_decoder_get_type(_decoder)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve string name for last decode addon.
|
|
||||||
/// see zbar_get_addon_name()
|
|
||||||
/// @deprecated in 0.11
|
|
||||||
const char *get_addon_name () const
|
|
||||||
{
|
|
||||||
return(zbar_get_addon_name(zbar_decoder_get_type(_decoder)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decoded data in ASCII format as a char array.
|
|
||||||
/// see zbar_decoder_get_data()
|
|
||||||
const char *get_data_chars() const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_data(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decoded data as a std::string.
|
|
||||||
/// see zbar_decoder_get_data()
|
|
||||||
const std::string get_data_string() const
|
|
||||||
{
|
|
||||||
return(std::string(zbar_decoder_get_data(_decoder),
|
|
||||||
zbar_decoder_get_data_length(_decoder)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decoded data as a std::string.
|
|
||||||
/// see zbar_decoder_get_data()
|
|
||||||
const std::string get_data() const
|
|
||||||
{
|
|
||||||
return(get_data_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve length of decoded binary data.
|
|
||||||
/// see zbar_decoder_get_data_length()
|
|
||||||
int get_data_length() const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_data_length(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decode direction.
|
|
||||||
/// see zbar_decoder_get_direction()
|
|
||||||
/// @since 0.11
|
|
||||||
int get_direction() const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_direction(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// setup callback to handle result data.
|
|
||||||
void set_handler (Handler &handler)
|
|
||||||
{
|
|
||||||
_handler = &handler;
|
|
||||||
zbar_decoder_set_handler(_decoder, _cb);
|
|
||||||
zbar_decoder_set_userdata(_decoder, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config for indicated symbology (0 for all) to specified value.
|
|
||||||
/// @see zbar_decoder_set_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (zbar_symbol_type_t symbology,
|
|
||||||
zbar_config_t config,
|
|
||||||
int value)
|
|
||||||
{
|
|
||||||
return(zbar_decoder_set_config(_decoder, symbology, config, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config parsed from configuration string.
|
|
||||||
/// @see zbar_decoder_parse_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (std::string cfgstr)
|
|
||||||
{
|
|
||||||
return(zbar_decoder_parse_config(_decoder, cfgstr.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class Scanner;
|
|
||||||
zbar_decoder_t *_decoder;
|
|
||||||
Handler *_handler;
|
|
||||||
|
|
||||||
static void _cb (zbar_decoder_t *cdcode)
|
|
||||||
{
|
|
||||||
Decoder *dcode = (Decoder*)zbar_decoder_get_userdata(cdcode);
|
|
||||||
if(dcode && dcode->_handler)
|
|
||||||
dcode->_handler->decode_callback(*dcode);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_EXCEPTION_H_
|
|
||||||
#define _ZBAR_EXCEPTION_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// C++ Exception definitions
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Exception.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <exception>
|
|
||||||
#include <new>
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// base class for exceptions defined by this API.
|
|
||||||
class Exception : public std::exception {
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
Exception (const void *obj = NULL)
|
|
||||||
: std::exception(),
|
|
||||||
_obj(obj)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
~Exception () throw() { }
|
|
||||||
|
|
||||||
/// retrieve error message
|
|
||||||
virtual const char* what () const throw()
|
|
||||||
{
|
|
||||||
if(!_obj)
|
|
||||||
return("zbar library unspecified generic error");
|
|
||||||
return(_zbar_error_string(_obj, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const void *_obj;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// internal library error.
|
|
||||||
class InternalError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
InternalError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// unsupported request.
|
|
||||||
class UnsupportedError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
UnsupportedError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// invalid request.
|
|
||||||
class InvalidError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
InvalidError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// failed system call.
|
|
||||||
class SystemError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
SystemError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// locking error.
|
|
||||||
class LockingError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
LockingError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// all resources busy.
|
|
||||||
class BusyError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
BusyError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// X11 display error.
|
|
||||||
class XDisplayError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
XDisplayError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// X11 protocol error.
|
|
||||||
class XProtoError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
XProtoError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// output window is closed.
|
|
||||||
class ClosedError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
ClosedError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// image format error
|
|
||||||
class FormatError : public Exception {
|
|
||||||
// FIXME needs c equivalent
|
|
||||||
|
|
||||||
virtual const char* what () const throw()
|
|
||||||
{
|
|
||||||
// FIXME what format?
|
|
||||||
return("unsupported format");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @internal
|
|
||||||
|
|
||||||
/// extract error information and create exception.
|
|
||||||
static inline std::exception throw_exception (const void *obj)
|
|
||||||
{
|
|
||||||
switch(_zbar_get_error_code(obj)) {
|
|
||||||
case ZBAR_ERR_NOMEM:
|
|
||||||
throw std::bad_alloc();
|
|
||||||
case ZBAR_ERR_INTERNAL:
|
|
||||||
throw InternalError(obj);
|
|
||||||
case ZBAR_ERR_UNSUPPORTED:
|
|
||||||
throw UnsupportedError(obj);
|
|
||||||
case ZBAR_ERR_INVALID:
|
|
||||||
throw InvalidError(obj);
|
|
||||||
case ZBAR_ERR_SYSTEM:
|
|
||||||
throw SystemError(obj);
|
|
||||||
case ZBAR_ERR_LOCKING:
|
|
||||||
throw LockingError(obj);
|
|
||||||
case ZBAR_ERR_BUSY:
|
|
||||||
throw BusyError(obj);
|
|
||||||
case ZBAR_ERR_XDISPLAY:
|
|
||||||
throw XDisplayError(obj);
|
|
||||||
case ZBAR_ERR_XPROTO:
|
|
||||||
throw XProtoError(obj);
|
|
||||||
case ZBAR_ERR_CLOSED:
|
|
||||||
throw ClosedError(obj);
|
|
||||||
default:
|
|
||||||
throw Exception(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,329 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_IMAGE_H_
|
|
||||||
#define _ZBAR_IMAGE_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Image C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Image.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <iterator>
|
|
||||||
#include "Symbol.h"
|
|
||||||
#include "Exception.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
class Video;
|
|
||||||
|
|
||||||
/// stores image data samples along with associated format and size
|
|
||||||
/// metadata
|
|
||||||
|
|
||||||
class Image {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// general Image result handler.
|
|
||||||
/// applications should subtype this and pass an instance to
|
|
||||||
/// eg. ImageScanner::set_handler() to implement result processing
|
|
||||||
class Handler {
|
|
||||||
public:
|
|
||||||
virtual ~Handler() { }
|
|
||||||
|
|
||||||
/// invoked by library when Image should be processed
|
|
||||||
virtual void image_callback(Image &image) = 0;
|
|
||||||
|
|
||||||
/// cast this handler to the C handler
|
|
||||||
operator zbar_image_data_handler_t* () const
|
|
||||||
{
|
|
||||||
return(_cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void _cb (zbar_image_t *zimg,
|
|
||||||
const void *userdata)
|
|
||||||
{
|
|
||||||
if(userdata) {
|
|
||||||
Image *image = (Image*)zbar_image_get_userdata(zimg);
|
|
||||||
if(image)
|
|
||||||
((Handler*)userdata)->image_callback(*image);
|
|
||||||
else {
|
|
||||||
Image tmp(zimg, 1);
|
|
||||||
((Handler*)userdata)->image_callback(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SymbolIterator : public zbar::SymbolIterator {
|
|
||||||
public:
|
|
||||||
/// default constructor.
|
|
||||||
SymbolIterator ()
|
|
||||||
: zbar::SymbolIterator()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
SymbolIterator (const SymbolSet &syms)
|
|
||||||
: zbar::SymbolIterator(syms)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
SymbolIterator (const SymbolIterator& iter)
|
|
||||||
: zbar::SymbolIterator(iter)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
/// create a new Image with the specified parameters
|
|
||||||
Image (unsigned width = 0,
|
|
||||||
unsigned height = 0,
|
|
||||||
const std::string& format = "",
|
|
||||||
const void *data = NULL,
|
|
||||||
unsigned long length = 0)
|
|
||||||
: _img(zbar_image_create())
|
|
||||||
{
|
|
||||||
zbar_image_set_userdata(_img, this);
|
|
||||||
if(width && height)
|
|
||||||
set_size(width, height);
|
|
||||||
if(format.length())
|
|
||||||
set_format(format);
|
|
||||||
if(data && length)
|
|
||||||
set_data(data, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Image ()
|
|
||||||
{
|
|
||||||
if(zbar_image_get_userdata(_img) == this)
|
|
||||||
zbar_image_set_userdata(_img, NULL);
|
|
||||||
zbar_image_ref(_img, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C image object
|
|
||||||
operator const zbar_image_t* () const
|
|
||||||
{
|
|
||||||
return(_img);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C image object
|
|
||||||
operator zbar_image_t* ()
|
|
||||||
{
|
|
||||||
return(_img);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the image format.
|
|
||||||
/// see zbar_image_get_format()
|
|
||||||
unsigned long get_format () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_format(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// specify the fourcc image format code for image sample data.
|
|
||||||
/// see zbar_image_set_format()
|
|
||||||
void set_format (unsigned long format)
|
|
||||||
{
|
|
||||||
zbar_image_set_format(_img, format);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// specify the fourcc image format code for image sample data.
|
|
||||||
/// see zbar_image_set_format()
|
|
||||||
void set_format (const std::string& format)
|
|
||||||
{
|
|
||||||
unsigned long fourcc = zbar_fourcc_parse(format.c_str());
|
|
||||||
zbar_image_set_format(_img, fourcc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve a "sequence" (page/frame) number associated with this
|
|
||||||
/// image.
|
|
||||||
/// see zbar_image_get_sequence()
|
|
||||||
/// @since 0.6
|
|
||||||
unsigned get_sequence () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_sequence(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// associate a "sequence" (page/frame) number with this image.
|
|
||||||
/// see zbar_image_set_sequence()
|
|
||||||
/// @since 0.6
|
|
||||||
void set_sequence (unsigned sequence_num)
|
|
||||||
{
|
|
||||||
zbar_image_set_sequence(_img, sequence_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the width of the image.
|
|
||||||
/// see zbar_image_get_width()
|
|
||||||
unsigned get_width () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_width(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the height of the image.
|
|
||||||
/// see zbar_image_get_height()
|
|
||||||
unsigned get_height () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_height(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve both dimensions of the image.
|
|
||||||
/// see zbar_image_get_size()
|
|
||||||
/// @since 0.11
|
|
||||||
void get_size (unsigned &width,
|
|
||||||
unsigned &height) const
|
|
||||||
{
|
|
||||||
zbar_image_get_size(_img, &width, &height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// specify the pixel size of the image.
|
|
||||||
/// see zbar_image_set_size()
|
|
||||||
void set_size (unsigned width,
|
|
||||||
unsigned height)
|
|
||||||
{
|
|
||||||
zbar_image_set_size(_img, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the scan crop rectangle.
|
|
||||||
/// see zbar_image_get_crop()
|
|
||||||
void get_crop (unsigned &x,
|
|
||||||
unsigned &y,
|
|
||||||
unsigned &width,
|
|
||||||
unsigned &height) const
|
|
||||||
{
|
|
||||||
zbar_image_get_crop(_img, &x, &y, &width, &height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set the scan crop rectangle.
|
|
||||||
/// see zbar_image_set_crop()
|
|
||||||
void set_crop (unsigned x,
|
|
||||||
unsigned y,
|
|
||||||
unsigned width,
|
|
||||||
unsigned height)
|
|
||||||
{
|
|
||||||
zbar_image_set_crop(_img, x, y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return the image sample data.
|
|
||||||
/// see zbar_image_get_data()
|
|
||||||
const void *get_data () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_data(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return the size of the image sample data.
|
|
||||||
/// see zbar_image_get_data_length()
|
|
||||||
/// @since 0.6
|
|
||||||
unsigned long get_data_length () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_data_length(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// specify image sample data.
|
|
||||||
/// see zbar_image_set_data()
|
|
||||||
void set_data (const void *data,
|
|
||||||
unsigned long length)
|
|
||||||
{
|
|
||||||
zbar_image_set_data(_img, data, length, _cleanup);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// image format conversion.
|
|
||||||
/// see zbar_image_convert()
|
|
||||||
Image convert (unsigned long format) const
|
|
||||||
{
|
|
||||||
zbar_image_t *img = zbar_image_convert(_img, format);
|
|
||||||
if(img)
|
|
||||||
return(Image(img));
|
|
||||||
throw FormatError();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// image format conversion.
|
|
||||||
/// see zbar_image_convert()
|
|
||||||
/// @since 0.11
|
|
||||||
Image convert (std::string format) const
|
|
||||||
{
|
|
||||||
unsigned long fourcc = zbar_fourcc_parse(format.c_str());
|
|
||||||
return(convert(fourcc));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// image format conversion with crop/pad.
|
|
||||||
/// see zbar_image_convert_resize()
|
|
||||||
/// @since 0.4
|
|
||||||
Image convert (unsigned long format,
|
|
||||||
unsigned width,
|
|
||||||
unsigned height) const
|
|
||||||
{
|
|
||||||
zbar_image_t *img =
|
|
||||||
zbar_image_convert_resize(_img, format, width, height);
|
|
||||||
if(img)
|
|
||||||
return(Image(img));
|
|
||||||
throw FormatError();
|
|
||||||
}
|
|
||||||
|
|
||||||
const SymbolSet get_symbols () const {
|
|
||||||
return(SymbolSet(zbar_image_get_symbols(_img)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_symbols (const SymbolSet &syms) {
|
|
||||||
zbar_image_set_symbols(_img, syms);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// create a new SymbolIterator over decoded results.
|
|
||||||
SymbolIterator symbol_begin () const {
|
|
||||||
return(SymbolIterator(get_symbols()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return a SymbolIterator suitable for ending iteration.
|
|
||||||
SymbolIterator symbol_end () const {
|
|
||||||
return(SymbolIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
friend class Video;
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
/// @internal
|
|
||||||
/// create a new Image from a zbar_image_t C object
|
|
||||||
Image (zbar_image_t *src,
|
|
||||||
int refs = 0)
|
|
||||||
: _img(src)
|
|
||||||
{
|
|
||||||
if(refs)
|
|
||||||
zbar_image_ref(_img, refs);
|
|
||||||
zbar_image_set_userdata(_img, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// default data cleanup (noop)
|
|
||||||
/// @internal
|
|
||||||
static void _cleanup (zbar_image_t *img)
|
|
||||||
{
|
|
||||||
// by default nothing is cleaned
|
|
||||||
assert(img);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_image_t *_img;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_IMAGE_SCANNER_H_
|
|
||||||
#define _ZBAR_IMAGE_SCANNER_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Image Scanner C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/ImageScanner.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Image.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// mid-level image scanner interface.
|
|
||||||
/// reads barcodes from a 2-D Image
|
|
||||||
|
|
||||||
class ImageScanner {
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
ImageScanner (zbar_image_scanner_t *scanner = NULL)
|
|
||||||
{
|
|
||||||
if(scanner)
|
|
||||||
_scanner = scanner;
|
|
||||||
else
|
|
||||||
_scanner = zbar_image_scanner_create();
|
|
||||||
}
|
|
||||||
|
|
||||||
~ImageScanner ()
|
|
||||||
{
|
|
||||||
zbar_image_scanner_destroy(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C image_scanner object
|
|
||||||
operator zbar_image_scanner_t* () const
|
|
||||||
{
|
|
||||||
return(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// setup result handler callback.
|
|
||||||
void set_handler (Image::Handler &handler)
|
|
||||||
{
|
|
||||||
zbar_image_scanner_set_data_handler(_scanner, handler, &handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config for indicated symbology (0 for all) to specified value.
|
|
||||||
/// @see zbar_image_scanner_set_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (zbar_symbol_type_t symbology,
|
|
||||||
zbar_config_t config,
|
|
||||||
int value)
|
|
||||||
{
|
|
||||||
return(zbar_image_scanner_set_config(_scanner, symbology,
|
|
||||||
config, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config parsed from configuration string.
|
|
||||||
/// @see zbar_image_scanner_parse_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (std::string cfgstr)
|
|
||||||
{
|
|
||||||
return(zbar_image_scanner_parse_config(_scanner, cfgstr.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// enable or disable the inter-image result cache.
|
|
||||||
/// see zbar_image_scanner_enable_cache()
|
|
||||||
void enable_cache (bool enable = true)
|
|
||||||
{
|
|
||||||
zbar_image_scanner_enable_cache(_scanner, enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// remove previous results from scanner and image.
|
|
||||||
/// @see zbar_image_scanner_recycle_image()
|
|
||||||
/// @since 0.10
|
|
||||||
void recycle_image (Image &image)
|
|
||||||
{
|
|
||||||
zbar_image_scanner_recycle_image(_scanner, image);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve decode results for last scanned image.
|
|
||||||
/// @see zbar_image_scanner_get_results()
|
|
||||||
/// @since 0.10
|
|
||||||
const SymbolSet get_results () const {
|
|
||||||
return(SymbolSet(zbar_image_scanner_get_results(_scanner)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// scan for symbols in provided image.
|
|
||||||
/// see zbar_scan_image()
|
|
||||||
int scan (Image& image)
|
|
||||||
{
|
|
||||||
return(zbar_scan_image(_scanner, image));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// scan for symbols in provided image.
|
|
||||||
/// see zbar_scan_image()
|
|
||||||
ImageScanner& operator<< (Image& image)
|
|
||||||
{
|
|
||||||
scan(image);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_image_scanner_t *_scanner;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,223 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_PROCESSOR_H_
|
|
||||||
#define _ZBAR_PROCESSOR_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Processor C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Processor.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Exception.h"
|
|
||||||
#include "Image.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// high-level self-contained image processor.
|
|
||||||
/// processes video and images for barcodes, optionally displaying
|
|
||||||
/// images to a library owned output window
|
|
||||||
|
|
||||||
class Processor {
|
|
||||||
public:
|
|
||||||
/// value to pass for no timeout.
|
|
||||||
static const int FOREVER = -1;
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Processor (bool threaded = true,
|
|
||||||
const char *video_device = "",
|
|
||||||
bool enable_display = true)
|
|
||||||
{
|
|
||||||
_processor = zbar_processor_create(threaded);
|
|
||||||
if(!_processor)
|
|
||||||
throw std::bad_alloc();
|
|
||||||
init(video_device, enable_display);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Processor ()
|
|
||||||
{
|
|
||||||
zbar_processor_destroy(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C processor object.
|
|
||||||
operator zbar_processor_t* ()
|
|
||||||
{
|
|
||||||
return(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// opens a video input device and/or prepares to display output.
|
|
||||||
/// see zbar_processor_init()
|
|
||||||
void init (const char *video_device = "",
|
|
||||||
bool enable_display = true)
|
|
||||||
{
|
|
||||||
if(zbar_processor_init(_processor, video_device, enable_display))
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// setup result handler callback.
|
|
||||||
/// see zbar_processor_set_data_handler()
|
|
||||||
void set_handler (Image::Handler& handler)
|
|
||||||
{
|
|
||||||
zbar_processor_set_data_handler(_processor, handler, &handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config for indicated symbology (0 for all) to specified value.
|
|
||||||
/// @see zbar_processor_set_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (zbar_symbol_type_t symbology,
|
|
||||||
zbar_config_t config,
|
|
||||||
int value)
|
|
||||||
{
|
|
||||||
return(zbar_processor_set_config(_processor, symbology,
|
|
||||||
config, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config parsed from configuration string.
|
|
||||||
/// @see zbar_processor_parse_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (std::string cfgstr)
|
|
||||||
{
|
|
||||||
return(zbar_processor_parse_config(_processor, cfgstr.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the current state of the ouput window.
|
|
||||||
/// see zbar_processor_is_visible()
|
|
||||||
bool is_visible ()
|
|
||||||
{
|
|
||||||
int rc = zbar_processor_is_visible(_processor);
|
|
||||||
if(rc < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
return(rc != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// show or hide the display window owned by the library.
|
|
||||||
/// see zbar_processor_set_visible()
|
|
||||||
void set_visible (bool visible = true)
|
|
||||||
{
|
|
||||||
if(zbar_processor_set_visible(_processor, visible) < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// control the processor in free running video mode.
|
|
||||||
/// see zbar_processor_set_active()
|
|
||||||
void set_active (bool active = true)
|
|
||||||
{
|
|
||||||
if(zbar_processor_set_active(_processor, active) < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve decode results for last scanned image.
|
|
||||||
/// @see zbar_processor_get_results()
|
|
||||||
/// @since 0.10
|
|
||||||
const SymbolSet get_results () const {
|
|
||||||
return(SymbolSet(zbar_processor_get_results(_processor)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// wait for input to the display window from the user.
|
|
||||||
/// see zbar_processor_user_wait()
|
|
||||||
int user_wait (int timeout = FOREVER)
|
|
||||||
{
|
|
||||||
int rc = zbar_processor_user_wait(_processor, timeout);
|
|
||||||
if(rc < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
return(rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process from the video stream until a result is available.
|
|
||||||
/// see zbar_process_one()
|
|
||||||
void process_one (int timeout = FOREVER)
|
|
||||||
{
|
|
||||||
if(zbar_process_one(_processor, timeout) < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process the provided image for barcodes.
|
|
||||||
/// see zbar_process_image()
|
|
||||||
void process_image (Image& image)
|
|
||||||
{
|
|
||||||
if(zbar_process_image(_processor, image) < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process the provided image for barcodes.
|
|
||||||
/// see zbar_process_image()
|
|
||||||
Processor& operator<< (Image& image)
|
|
||||||
{
|
|
||||||
process_image(image);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// force specific input and output formats for debug/testing.
|
|
||||||
/// see zbar_processor_force_format()
|
|
||||||
void force_format (unsigned long input_format,
|
|
||||||
unsigned long output_format)
|
|
||||||
{
|
|
||||||
if(zbar_processor_force_format(_processor, input_format,
|
|
||||||
output_format))
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// force specific input and output formats for debug/testing.
|
|
||||||
/// see zbar_processor_force_format()
|
|
||||||
void force_format (std::string& input_format,
|
|
||||||
std::string& output_format)
|
|
||||||
{
|
|
||||||
unsigned long ifourcc = zbar_fourcc_parse(input_format.c_str());
|
|
||||||
unsigned long ofourcc = zbar_fourcc_parse(output_format.c_str());
|
|
||||||
if(zbar_processor_force_format(_processor, ifourcc, ofourcc))
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred size for the video image from the device.
|
|
||||||
/// see zbar_processor_request_size()
|
|
||||||
/// @since 0.6
|
|
||||||
void request_size (int width, int height)
|
|
||||||
{
|
|
||||||
zbar_processor_request_size(_processor, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred driver interface version for debug/testing.
|
|
||||||
/// see zbar_processor_request_interface()
|
|
||||||
/// @since 0.6
|
|
||||||
void request_interface (int version)
|
|
||||||
{
|
|
||||||
zbar_processor_request_interface(_processor, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred I/O mode for debug/testing.
|
|
||||||
/// see zbar_processor_request_iomode()
|
|
||||||
/// @since 0.7
|
|
||||||
void request_iomode (int iomode)
|
|
||||||
{
|
|
||||||
if(zbar_processor_request_iomode(_processor, iomode))
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_processor_t *_processor;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_SCANNER_H_
|
|
||||||
#define _ZBAR_SCANNER_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Scanner C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Scanner.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// low-level linear intensity sample stream scanner interface.
|
|
||||||
/// identifies "bar" edges and measures width between them.
|
|
||||||
/// optionally passes to bar width Decoder
|
|
||||||
|
|
||||||
class Scanner {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
/// @param decoder reference to a Decoder instance which will
|
|
||||||
/// be passed scan results automatically
|
|
||||||
Scanner (Decoder& decoder)
|
|
||||||
{
|
|
||||||
_scanner = zbar_scanner_create(decoder._decoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
/// @param decoder pointer to a Decoder instance which will
|
|
||||||
/// be passed scan results automatically
|
|
||||||
Scanner (Decoder* decoder = NULL)
|
|
||||||
{
|
|
||||||
zbar_decoder_t *zdcode = NULL;
|
|
||||||
if(decoder)
|
|
||||||
zdcode = decoder->_decoder;
|
|
||||||
_scanner = zbar_scanner_create(zdcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Scanner ()
|
|
||||||
{
|
|
||||||
zbar_scanner_destroy(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// clear all scanner state.
|
|
||||||
/// see zbar_scanner_reset()
|
|
||||||
void reset ()
|
|
||||||
{
|
|
||||||
zbar_scanner_reset(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// mark start of a new scan pass.
|
|
||||||
/// see zbar_scanner_new_scan()
|
|
||||||
zbar_symbol_type_t new_scan ()
|
|
||||||
{
|
|
||||||
_type = zbar_scanner_new_scan(_scanner);
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// flush scanner pipeline.
|
|
||||||
/// see zbar_scanner_flush()
|
|
||||||
zbar_symbol_type_t flush ()
|
|
||||||
{
|
|
||||||
_type = zbar_scanner_flush(_scanner);
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next sample intensity value.
|
|
||||||
/// see zbar_scan_y()
|
|
||||||
zbar_symbol_type_t scan_y (int y)
|
|
||||||
{
|
|
||||||
_type = zbar_scan_y(_scanner, y);
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next sample intensity value.
|
|
||||||
/// see zbar_scan_y()
|
|
||||||
Scanner& operator<< (int y)
|
|
||||||
{
|
|
||||||
_type = zbar_scan_y(_scanner, y);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next sample from RGB (or BGR) triple.
|
|
||||||
/// see zbar_scan_rgb24()
|
|
||||||
zbar_symbol_type_t scan_rgb24 (unsigned char *rgb)
|
|
||||||
{
|
|
||||||
_type = zbar_scan_rgb24(_scanner, rgb);
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next sample from RGB (or BGR) triple.
|
|
||||||
/// see zbar_scan_rgb24()
|
|
||||||
Scanner& operator<< (unsigned char *rgb)
|
|
||||||
{
|
|
||||||
_type = zbar_scan_rgb24(_scanner, rgb);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last scanned width.
|
|
||||||
/// see zbar_scanner_get_width()
|
|
||||||
unsigned get_width () const
|
|
||||||
{
|
|
||||||
return(zbar_scanner_get_width(_scanner));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last scanned color.
|
|
||||||
/// see zbar_scanner_get_color()
|
|
||||||
zbar_color_t get_color () const
|
|
||||||
{
|
|
||||||
return(zbar_scanner_get_color(_scanner));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last scan result.
|
|
||||||
zbar_symbol_type_t get_type () const
|
|
||||||
{
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C scanner
|
|
||||||
operator zbar_scanner_t* () const
|
|
||||||
{
|
|
||||||
return(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve C scanner
|
|
||||||
const zbar_scanner_t *get_c_scanner () const
|
|
||||||
{
|
|
||||||
return(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_scanner_t *_scanner;
|
|
||||||
zbar_symbol_type_t _type;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,541 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_SYMBOL_H_
|
|
||||||
#define _ZBAR_SYMBOL_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Symbol C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Symbol.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
|
||||||
#include <ostream>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
class SymbolIterator;
|
|
||||||
|
|
||||||
/// container for decoded result symbols associated with an image
|
|
||||||
/// or a composite symbol.
|
|
||||||
|
|
||||||
class SymbolSet {
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
SymbolSet (const zbar_symbol_set_t *syms = NULL)
|
|
||||||
: _syms(syms)
|
|
||||||
{
|
|
||||||
ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
SymbolSet (const SymbolSet& syms)
|
|
||||||
: _syms(syms._syms)
|
|
||||||
{
|
|
||||||
ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// destructor.
|
|
||||||
~SymbolSet ()
|
|
||||||
{
|
|
||||||
ref(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
SymbolSet& operator= (const SymbolSet& syms)
|
|
||||||
{
|
|
||||||
syms.ref();
|
|
||||||
ref(-1);
|
|
||||||
_syms = syms._syms;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// truth testing.
|
|
||||||
bool operator! () const
|
|
||||||
{
|
|
||||||
return(!_syms || !get_size());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// manipulate reference count.
|
|
||||||
void ref (int delta = 1) const
|
|
||||||
{
|
|
||||||
if(_syms)
|
|
||||||
zbar_symbol_set_ref((zbar_symbol_set_t*)_syms, delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C symbol set.
|
|
||||||
operator const zbar_symbol_set_t* () const
|
|
||||||
{
|
|
||||||
return(_syms);
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_size () const
|
|
||||||
{
|
|
||||||
return((_syms) ? zbar_symbol_set_get_size(_syms) : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// create a new SymbolIterator over decoded results.
|
|
||||||
SymbolIterator symbol_begin() const;
|
|
||||||
|
|
||||||
/// return a SymbolIterator suitable for ending iteration.
|
|
||||||
const SymbolIterator symbol_end() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const zbar_symbol_set_t *_syms;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// decoded barcode symbol result object. stores type, data, and
|
|
||||||
/// image location of decoded symbol
|
|
||||||
|
|
||||||
class Symbol {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// image pixel location (x, y) coordinate tuple.
|
|
||||||
class Point {
|
|
||||||
public:
|
|
||||||
int x; ///< x-coordinate.
|
|
||||||
int y; ///< y-coordinate.
|
|
||||||
|
|
||||||
Point () { }
|
|
||||||
|
|
||||||
Point(int x, int y)
|
|
||||||
: x(x), y(y)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
Point (const Point& pt)
|
|
||||||
: x(pt.x),
|
|
||||||
y(pt.y)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
Point& operator= (const Point& pt)
|
|
||||||
{
|
|
||||||
x = pt.x;
|
|
||||||
y = pt.y;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// iteration over Point objects in a symbol location polygon.
|
|
||||||
class PointIterator
|
|
||||||
: public std::iterator<std::input_iterator_tag, Point> {
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
PointIterator (const Symbol *sym = NULL,
|
|
||||||
int index = 0)
|
|
||||||
: _sym(sym),
|
|
||||||
_index(index)
|
|
||||||
{
|
|
||||||
if(sym)
|
|
||||||
sym->ref(1);
|
|
||||||
if(!sym ||
|
|
||||||
(unsigned)_index >= zbar_symbol_get_loc_size(*_sym))
|
|
||||||
_index = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
PointIterator (const PointIterator& iter)
|
|
||||||
: _sym(iter._sym),
|
|
||||||
_index(iter._index)
|
|
||||||
{
|
|
||||||
if(_sym)
|
|
||||||
_sym->ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// destructor.
|
|
||||||
~PointIterator ()
|
|
||||||
{
|
|
||||||
if(_sym)
|
|
||||||
_sym->ref(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
PointIterator& operator= (const PointIterator& iter)
|
|
||||||
{
|
|
||||||
if(iter._sym)
|
|
||||||
iter._sym->ref();
|
|
||||||
if(_sym)
|
|
||||||
_sym->ref(-1);
|
|
||||||
_sym = iter._sym;
|
|
||||||
_index = iter._index;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// truth testing.
|
|
||||||
bool operator! () const
|
|
||||||
{
|
|
||||||
return(!_sym || _index < 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// advance iterator to next Point.
|
|
||||||
PointIterator& operator++ ()
|
|
||||||
{
|
|
||||||
unsigned int i = ++_index;
|
|
||||||
if(!_sym || i >= zbar_symbol_get_loc_size(*_sym))
|
|
||||||
_index = -1;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve currently referenced Point.
|
|
||||||
const Point operator* () const
|
|
||||||
{
|
|
||||||
assert(!!*this);
|
|
||||||
if(!*this)
|
|
||||||
return(Point());
|
|
||||||
return(Point(zbar_symbol_get_loc_x(*_sym, _index),
|
|
||||||
zbar_symbol_get_loc_y(*_sym, _index)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two iterators refer to the same Point in the same
|
|
||||||
/// Symbol.
|
|
||||||
bool operator== (const PointIterator& iter) const
|
|
||||||
{
|
|
||||||
return(_index == iter._index &&
|
|
||||||
((_index < 0) || _sym == iter._sym));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two iterators refer to the same Point in the same
|
|
||||||
/// Symbol.
|
|
||||||
bool operator!= (const PointIterator& iter) const
|
|
||||||
{
|
|
||||||
return(!(*this == iter));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const Symbol *_sym;
|
|
||||||
int _index;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Symbol (const zbar_symbol_t *sym = NULL)
|
|
||||||
: _xmlbuf(NULL),
|
|
||||||
_xmllen(0)
|
|
||||||
{
|
|
||||||
init(sym);
|
|
||||||
ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
Symbol (const Symbol& sym)
|
|
||||||
: _sym(sym._sym),
|
|
||||||
_type(sym._type),
|
|
||||||
_data(sym._data),
|
|
||||||
_xmlbuf(NULL),
|
|
||||||
_xmllen(0)
|
|
||||||
{
|
|
||||||
ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// destructor.
|
|
||||||
~Symbol () {
|
|
||||||
if(_xmlbuf)
|
|
||||||
free(_xmlbuf);
|
|
||||||
ref(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
Symbol& operator= (const Symbol& sym)
|
|
||||||
{
|
|
||||||
sym.ref(1);
|
|
||||||
ref(-1);
|
|
||||||
_sym = sym._sym;
|
|
||||||
_type = sym._type;
|
|
||||||
_data = sym._data;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Symbol& operator= (const zbar_symbol_t *sym)
|
|
||||||
{
|
|
||||||
if(sym)
|
|
||||||
zbar_symbol_ref(sym, 1);
|
|
||||||
ref(-1);
|
|
||||||
init(sym);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// truth testing.
|
|
||||||
bool operator! () const
|
|
||||||
{
|
|
||||||
return(!_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ref (int delta = 1) const
|
|
||||||
{
|
|
||||||
if(_sym)
|
|
||||||
zbar_symbol_ref((zbar_symbol_t*)_sym, delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C symbol.
|
|
||||||
operator const zbar_symbol_t* () const
|
|
||||||
{
|
|
||||||
return(_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two Symbol objects refer to the same C symbol.
|
|
||||||
bool operator== (const Symbol& sym) const
|
|
||||||
{
|
|
||||||
return(_sym == sym._sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two Symbol objects refer to the same C symbol.
|
|
||||||
bool operator!= (const Symbol& sym) const
|
|
||||||
{
|
|
||||||
return(!(*this == sym));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve type of decoded symbol.
|
|
||||||
zbar_symbol_type_t get_type () const
|
|
||||||
{
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the string name of the symbol type.
|
|
||||||
const std::string get_type_name () const
|
|
||||||
{
|
|
||||||
return(zbar_get_symbol_name(_type));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the string name for any addon.
|
|
||||||
/// @deprecated in 0.11
|
|
||||||
const std::string get_addon_name () const
|
|
||||||
{
|
|
||||||
return(zbar_get_addon_name(_type));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve data decoded from symbol.
|
|
||||||
const std::string get_data () const
|
|
||||||
{
|
|
||||||
return(_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve length of binary data
|
|
||||||
unsigned get_data_length () const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_data_length(_sym) : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve inter-frame coherency count.
|
|
||||||
/// see zbar_symbol_get_count()
|
|
||||||
/// @since 0.5
|
|
||||||
int get_count () const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_count(_sym) : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve loosely defined relative quality metric.
|
|
||||||
/// see zbar_symbol_get_quality()
|
|
||||||
/// @since 0.11
|
|
||||||
int get_quality () const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_quality(_sym) : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
SymbolSet get_components () const
|
|
||||||
{
|
|
||||||
return(SymbolSet((_sym) ? zbar_symbol_get_components(_sym) : NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// create a new PointIterator at the start of the location
|
|
||||||
/// polygon.
|
|
||||||
PointIterator point_begin() const
|
|
||||||
{
|
|
||||||
return(PointIterator(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return a PointIterator suitable for ending iteration.
|
|
||||||
const PointIterator point_end() const
|
|
||||||
{
|
|
||||||
return(PointIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_get_loc_size().
|
|
||||||
int get_location_size () const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_loc_size(_sym) : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_get_loc_x().
|
|
||||||
int get_location_x (unsigned index) const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_loc_x(_sym, index) : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_get_loc_y().
|
|
||||||
int get_location_y (unsigned index) const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_loc_y(_sym, index) : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_get_orientation().
|
|
||||||
/// @since 0.11
|
|
||||||
int get_orientation () const
|
|
||||||
{
|
|
||||||
return(zbar_symbol_get_orientation(_sym));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_xml().
|
|
||||||
const std::string xml () const
|
|
||||||
{
|
|
||||||
if(!_sym)
|
|
||||||
return("");
|
|
||||||
return(zbar_symbol_xml(_sym, (char**)&_xmlbuf, (unsigned*)&_xmllen));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/// (re)initialize Symbol from C symbol object.
|
|
||||||
void init (const zbar_symbol_t *sym = NULL)
|
|
||||||
{
|
|
||||||
_sym = sym;
|
|
||||||
if(sym) {
|
|
||||||
_type = zbar_symbol_get_type(sym);
|
|
||||||
_data = std::string(zbar_symbol_get_data(sym),
|
|
||||||
zbar_symbol_get_data_length(sym));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_type = ZBAR_NONE;
|
|
||||||
_data = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const zbar_symbol_t *_sym;
|
|
||||||
zbar_symbol_type_t _type;
|
|
||||||
std::string _data;
|
|
||||||
char *_xmlbuf;
|
|
||||||
unsigned _xmllen;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// iteration over Symbol result objects in a scanned Image or SymbolSet.
|
|
||||||
class SymbolIterator
|
|
||||||
: public std::iterator<std::input_iterator_tag, Symbol> {
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// default constructor.
|
|
||||||
SymbolIterator ()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
SymbolIterator (const SymbolSet &syms)
|
|
||||||
: _syms(syms)
|
|
||||||
{
|
|
||||||
const zbar_symbol_set_t *zsyms = _syms;
|
|
||||||
if(zsyms)
|
|
||||||
_sym = zbar_symbol_set_first_symbol(zsyms);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
SymbolIterator (const SymbolIterator& iter)
|
|
||||||
: _syms(iter._syms)
|
|
||||||
{
|
|
||||||
const zbar_symbol_set_t *zsyms = _syms;
|
|
||||||
if(zsyms)
|
|
||||||
_sym = zbar_symbol_set_first_symbol(zsyms);
|
|
||||||
}
|
|
||||||
|
|
||||||
~SymbolIterator ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
SymbolIterator& operator= (const SymbolIterator& iter)
|
|
||||||
{
|
|
||||||
_syms = iter._syms;
|
|
||||||
_sym = iter._sym;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator! () const
|
|
||||||
{
|
|
||||||
return(!_syms || !_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// advance iterator to next Symbol.
|
|
||||||
SymbolIterator& operator++ ()
|
|
||||||
{
|
|
||||||
if(!!_sym)
|
|
||||||
_sym = zbar_symbol_next(_sym);
|
|
||||||
else if(!!_syms)
|
|
||||||
_sym = zbar_symbol_set_first_symbol(_syms);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve currently referenced Symbol.
|
|
||||||
const Symbol operator* () const
|
|
||||||
{
|
|
||||||
return(_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// access currently referenced Symbol.
|
|
||||||
const Symbol* operator-> () const
|
|
||||||
{
|
|
||||||
return(&_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two iterators refer to the same Symbol
|
|
||||||
bool operator== (const SymbolIterator& iter) const
|
|
||||||
{
|
|
||||||
// it is enough to test the symbols, as they belong
|
|
||||||
// to only one set (also simplifies invalid case)
|
|
||||||
return(_sym == iter._sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two iterators refer to the same Symbol
|
|
||||||
bool operator!= (const SymbolIterator& iter) const
|
|
||||||
{
|
|
||||||
return(!(*this == iter));
|
|
||||||
}
|
|
||||||
|
|
||||||
const SymbolIterator end () const {
|
|
||||||
return(SymbolIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
SymbolSet _syms;
|
|
||||||
Symbol _sym;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline SymbolIterator SymbolSet::symbol_begin () const {
|
|
||||||
return(SymbolIterator(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const SymbolIterator SymbolSet::symbol_end () const {
|
|
||||||
return(SymbolIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @relates Symbol
|
|
||||||
/// stream the string representation of a Symbol.
|
|
||||||
static inline std::ostream& operator<< (std::ostream& out,
|
|
||||||
const Symbol& sym)
|
|
||||||
{
|
|
||||||
out << sym.get_type_name() << ":" << sym.get_data();
|
|
||||||
return(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_VIDEO_H_
|
|
||||||
#define _ZBAR_VIDEO_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Video Input C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Video.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Image.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// mid-level video source abstraction.
|
|
||||||
/// captures images from a video device
|
|
||||||
|
|
||||||
class Video {
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
Video (zbar_video_t *video = NULL)
|
|
||||||
{
|
|
||||||
if(video)
|
|
||||||
_video = video;
|
|
||||||
else
|
|
||||||
_video = zbar_video_create();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Video (std::string& device)
|
|
||||||
{
|
|
||||||
_video = zbar_video_create();
|
|
||||||
open(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Video ()
|
|
||||||
{
|
|
||||||
zbar_video_destroy(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C video object.
|
|
||||||
operator zbar_video_t* () const
|
|
||||||
{
|
|
||||||
return(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// open and probe a video device.
|
|
||||||
void open (std::string& device)
|
|
||||||
{
|
|
||||||
if(zbar_video_open(_video, device.c_str()))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// close video device if open.
|
|
||||||
void close ()
|
|
||||||
{
|
|
||||||
if(zbar_video_open(_video, NULL))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// initialize video using a specific format for debug.
|
|
||||||
/// see zbar_video_init()
|
|
||||||
void init (unsigned long fourcc)
|
|
||||||
{
|
|
||||||
if(zbar_video_init(_video, fourcc))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// initialize video using a specific format for debug.
|
|
||||||
/// see zbar_video_init()
|
|
||||||
void init (std::string& format)
|
|
||||||
{
|
|
||||||
unsigned int fourcc = zbar_fourcc_parse(format.c_str());
|
|
||||||
if(zbar_video_init(_video, fourcc))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve file descriptor associated with open *nix video device.
|
|
||||||
/// see zbar_video_get_fd()
|
|
||||||
int get_fd ()
|
|
||||||
{
|
|
||||||
return(zbar_video_get_fd(_video));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve current output image width.
|
|
||||||
/// see zbar_video_get_width()
|
|
||||||
int get_width ()
|
|
||||||
{
|
|
||||||
return(zbar_video_get_width(_video));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve current output image height.
|
|
||||||
/// see zbar_video_get_height()
|
|
||||||
int get_height ()
|
|
||||||
{
|
|
||||||
return(zbar_video_get_height(_video));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// start/stop video capture.
|
|
||||||
/// see zbar_video_enable()
|
|
||||||
void enable (bool enable = true)
|
|
||||||
{
|
|
||||||
if(zbar_video_enable(_video, enable))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve next captured image.
|
|
||||||
/// see zbar_video_next_image()
|
|
||||||
Image next_image ()
|
|
||||||
{
|
|
||||||
zbar_image_t *img = zbar_video_next_image(_video);
|
|
||||||
if(!img)
|
|
||||||
throw_exception(_video);
|
|
||||||
return(Image(img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred size for the video image from the device.
|
|
||||||
/// see zbar_video_request_size()
|
|
||||||
/// @since 0.6
|
|
||||||
void request_size (int width, int height)
|
|
||||||
{
|
|
||||||
zbar_video_request_size(_video, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred driver interface version for debug/testing.
|
|
||||||
/// see zbar_video_request_interface()
|
|
||||||
/// @since 0.6
|
|
||||||
void request_interface (int version)
|
|
||||||
{
|
|
||||||
zbar_video_request_interface(_video, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred I/O mode for debug/testing.
|
|
||||||
/// see zbar_video_request_iomode()
|
|
||||||
/// @since 0.7
|
|
||||||
void request_iomode (int iomode)
|
|
||||||
{
|
|
||||||
if(zbar_video_request_iomode(_video, iomode))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_video_t *_video;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_WINDOW_H_
|
|
||||||
#define _ZBAR_WINDOW_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Output Window C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Window.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Image.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// mid-level output window abstraction.
|
|
||||||
/// displays images to user-specified platform specific output window
|
|
||||||
|
|
||||||
class Window {
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
Window (zbar_window_t *window = NULL)
|
|
||||||
{
|
|
||||||
if(window)
|
|
||||||
_window = window;
|
|
||||||
else
|
|
||||||
_window = zbar_window_create();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Window (void *x11_display_w32_hwnd,
|
|
||||||
unsigned long x11_drawable)
|
|
||||||
{
|
|
||||||
_window = zbar_window_create();
|
|
||||||
attach(x11_display_w32_hwnd, x11_drawable);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Window ()
|
|
||||||
{
|
|
||||||
zbar_window_destroy(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C window object.
|
|
||||||
operator zbar_window_t* () const
|
|
||||||
{
|
|
||||||
return(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// associate reader with an existing platform window.
|
|
||||||
/// see zbar_window_attach()
|
|
||||||
void attach (void *x11_display_w32_hwnd,
|
|
||||||
unsigned long x11_drawable = 0)
|
|
||||||
{
|
|
||||||
if(zbar_window_attach(_window,
|
|
||||||
x11_display_w32_hwnd, x11_drawable) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// control content level of the reader overlay.
|
|
||||||
/// see zbar_window_set_overlay()
|
|
||||||
void set_overlay (int level)
|
|
||||||
{
|
|
||||||
zbar_window_set_overlay(_window, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve current content level of reader overlay.
|
|
||||||
/// see zbar_window_get_overlay()
|
|
||||||
|
|
||||||
/// draw a new image into the output window.
|
|
||||||
/// see zbar_window_draw()
|
|
||||||
void draw (Image& image)
|
|
||||||
{
|
|
||||||
if(zbar_window_draw(_window, image) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// clear the image from the output window.
|
|
||||||
/// see zbar_window_draw()
|
|
||||||
void clear ()
|
|
||||||
{
|
|
||||||
if(zbar_window_draw(_window, NULL) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// redraw the last image.
|
|
||||||
/// zbar_window_redraw()
|
|
||||||
void redraw ()
|
|
||||||
{
|
|
||||||
if(zbar_window_redraw(_window) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// resize the image window.
|
|
||||||
/// zbar_window_resize()
|
|
||||||
void resize (unsigned width, unsigned height)
|
|
||||||
{
|
|
||||||
if(zbar_window_resize(_window, width, height) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_window_t *_window;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// select a compatible format between video input and output window.
|
|
||||||
/// see zbar_negotiate_format()
|
|
||||||
static inline void negotiate_format (Video& video, Window& window)
|
|
||||||
{
|
|
||||||
if(zbar_negotiate_format(video, window) < 0)
|
|
||||||
throw_exception(video);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
Before Width: | Height: | Size: 319 B |
@@ -1,88 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<!--
|
|
||||||
Copyright 2009-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
All Rights Reserved
|
|
||||||
-->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Barcode Reader Help</title>
|
|
||||||
<style type="text/css">
|
|
||||||
html, body { margin: 0; padding: 0; background: black; color: white; font-family: sans-serif; font-size: 16px }
|
|
||||||
h1 { margin: .5em 0; text-align: center; font-size: 28px }
|
|
||||||
h2 { font-size: 24px }
|
|
||||||
hr { margin: 1em 0; height: 0; border: none; border-top: solid 1px #666 }
|
|
||||||
.smaller { font-size: 85% }
|
|
||||||
p { margin: .5em }
|
|
||||||
a { color: #8af }
|
|
||||||
p.cen { text-align: center }
|
|
||||||
p.title { margin: 1em; clear: both; text-align: center }
|
|
||||||
div.col { width: 50% }
|
|
||||||
.clear { clear: both }
|
|
||||||
.iconlist { position: relative; clear: both; margin: 4px 0; padding: 1px 0 }
|
|
||||||
.icon { width: 64px; height: 64px; overflow: hidden; margin: 12px 16px; padding: 0; background: url("zbar-helpicons.png") no-repeat; font: bold 56px "Marker Felt"; text-align: center }
|
|
||||||
.sample { display: block; height: 96px; overflow: hidden; margin: 12px auto; padding: 0; background: url("zbar-samples.png") no-repeat; text-align: center}
|
|
||||||
.left { float: left }
|
|
||||||
.right { float: right }
|
|
||||||
.iconlist > p { margin: 10px }
|
|
||||||
.iconlist > h2 { margin: 10px }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="title" style="color: #f88">Barcode Reader Help</h1>
|
|
||||||
<hr/>
|
|
||||||
<p class="title">Recognized barcodes should look like</p>
|
|
||||||
<div class="col left">
|
|
||||||
<a class="sample" style="width: 118px; background-position: -96px" href="http://wikipedia.org/wiki/EAN-13"></a>
|
|
||||||
<p class="cen"><a href="http://wikipedia.org/wiki/EAN-13">EAN/UPC<br/>Product Codes</a></p>
|
|
||||||
</div>
|
|
||||||
<div class="col right">
|
|
||||||
<a class="sample" style="width: 96px" href="http://wikipedia.org/wiki/QR_Code"></a>
|
|
||||||
<p class="cen"><a href="http://wikipedia.org/wiki/QR_Code">QR Codes</a></p>
|
|
||||||
</div>
|
|
||||||
<p class="clear cen smaller">Also recognized, but not shown:
|
|
||||||
<a href="http://wikipedia.org/wiki/Code_128">Code 128</a>,
|
|
||||||
<a href="http://wikipedia.org/wiki/DataBar">DataBar (RSS)</a>,
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Code_93">Code 93</a>,
|
|
||||||
<a href="http://wikipedia.org/wiki/Code_39">Code 39</a> and
|
|
||||||
<a href="http://wikipedia.org/wiki/Interleaved_2_of_5">Interleaved 2 of 5</a></p>
|
|
||||||
<hr/>
|
|
||||||
<p class="clear title">Hints for successful scanning</p>
|
|
||||||
<div class="iconlist">
|
|
||||||
<div class="icon left"></div>
|
|
||||||
<p>Ensure there is plenty of</p>
|
|
||||||
<h2 style="color: #ff4">Light</h2>
|
|
||||||
</div>
|
|
||||||
<div class="iconlist">
|
|
||||||
<div class="icon left" style="background: none; color: #2d4">4"</div>
|
|
||||||
<h2 style="color: #4f6">Distance</h2>
|
|
||||||
<p>should be about 3 to 5 inches</p>
|
|
||||||
</div>
|
|
||||||
<div class="iconlist">
|
|
||||||
<div class="icon left" style="background-position: 0 -64px"></div>
|
|
||||||
<h2 style="color: #3ee">Shake</h2>
|
|
||||||
<p>to force the camera to focus</p>
|
|
||||||
</div>
|
|
||||||
<div class="iconlist">
|
|
||||||
<div class="icon left" style="background-position: 0 -128px"></div>
|
|
||||||
<h2 style="color: #59f">Wait</h2>
|
|
||||||
<p>for the autofocus to finish</p>
|
|
||||||
</div>
|
|
||||||
<div class="iconlist">
|
|
||||||
<div class="icon left" style="background-position: 0 -192px"></div>
|
|
||||||
<h2 style="color: #d5f">Hold Still</h2>
|
|
||||||
<p>while the barcode is scanned</p>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
function onZBarHelp(argv) {
|
|
||||||
var title;
|
|
||||||
switch(argv.reason) {
|
|
||||||
case "INFO": break;
|
|
||||||
case "FAIL": title = "No Barcode Detected"; break;
|
|
||||||
}
|
|
||||||
if(title) document.getElementById('title').textContent = title;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
@@ -1,45 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2010-2011 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
@class ZBarReaderView;
|
|
||||||
|
|
||||||
// hack around missing simulator support for AVCapture interfaces
|
|
||||||
|
|
||||||
@interface ZBarCameraSimulator
|
|
||||||
: NSObject
|
|
||||||
< UINavigationControllerDelegate,
|
|
||||||
UIImagePickerControllerDelegate,
|
|
||||||
UIPopoverControllerDelegate >
|
|
||||||
{
|
|
||||||
UIViewController *viewController;
|
|
||||||
ZBarReaderView *readerView;
|
|
||||||
UIImagePickerController *picker;
|
|
||||||
UIPopoverController *pickerPopover;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) initWithViewController: (UIViewController*) viewController;
|
|
||||||
- (void) takePicture;
|
|
||||||
|
|
||||||
@property (nonatomic, assign) ZBarReaderView *readerView;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <CoreGraphics/CoreGraphics.h>
|
|
||||||
#import "ZBarImageScanner.h"
|
|
||||||
|
|
||||||
@class AVCaptureVideoDataOutput, AVCaptureOutput;
|
|
||||||
@class ZBarCaptureReader, ZBarCVImage;
|
|
||||||
|
|
||||||
@protocol ZBarCaptureDelegate <NSObject>
|
|
||||||
|
|
||||||
// called when a new barcode is detected. the image refers to the
|
|
||||||
// video buffer and must not be retained for long
|
|
||||||
- (void) captureReader: (ZBarCaptureReader*) captureReader
|
|
||||||
didReadNewSymbolsFromImage: (ZBarImage*) image;
|
|
||||||
|
|
||||||
@optional
|
|
||||||
// called when a potential/uncertain barcode is detected. will also
|
|
||||||
// be called *after* captureReader:didReadNewSymbolsFromImage:
|
|
||||||
// when good barcodes are detected
|
|
||||||
- (void) captureReader: (ZBarCaptureReader*) captureReader
|
|
||||||
didTrackSymbols: (ZBarSymbolSet*) symbols;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface ZBarCaptureReader
|
|
||||||
: NSObject
|
|
||||||
{
|
|
||||||
#if !TARGET_IPHONE_SIMULATOR
|
|
||||||
AVCaptureVideoDataOutput *captureOutput;
|
|
||||||
id<ZBarCaptureDelegate> captureDelegate;
|
|
||||||
ZBarImageScanner *scanner;
|
|
||||||
CGRect scanCrop;
|
|
||||||
CGSize size;
|
|
||||||
CGFloat framesPerSecond;
|
|
||||||
BOOL enableCache;
|
|
||||||
|
|
||||||
dispatch_queue_t queue;
|
|
||||||
ZBarImage *image;
|
|
||||||
ZBarCVImage *result;
|
|
||||||
volatile uint32_t state;
|
|
||||||
int framecnt;
|
|
||||||
unsigned width, height;
|
|
||||||
uint64_t t_frame, t_fps, t_scan;
|
|
||||||
CGFloat dt_frame;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// supply a pre-configured image scanner
|
|
||||||
- (id) initWithImageScanner: (ZBarImageScanner*) imageScanner;
|
|
||||||
|
|
||||||
// this must be called before the session is started
|
|
||||||
- (void) willStartRunning;
|
|
||||||
|
|
||||||
// this must be called *before* the session is stopped
|
|
||||||
- (void) willStopRunning;
|
|
||||||
|
|
||||||
// clear the internal result cache
|
|
||||||
- (void) flushCache;
|
|
||||||
|
|
||||||
// capture the next frame after processing. the captured image will
|
|
||||||
// follow the same delegate path as an image with decoded symbols.
|
|
||||||
- (void) captureFrame;
|
|
||||||
|
|
||||||
// the capture output. add this to an instance of AVCaptureSession
|
|
||||||
@property (nonatomic, readonly) AVCaptureOutput *captureOutput;
|
|
||||||
|
|
||||||
// delegate is notified of decode results and symbol tracking.
|
|
||||||
@property (nonatomic, assign) id<ZBarCaptureDelegate> captureDelegate;
|
|
||||||
|
|
||||||
// access to image scanner for configuration.
|
|
||||||
@property (nonatomic, readonly) ZBarImageScanner *scanner;
|
|
||||||
|
|
||||||
// region of image to scan in normalized coordinates.
|
|
||||||
// NB horizontal crop currently ignored...
|
|
||||||
@property (nonatomic, assign) CGRect scanCrop;
|
|
||||||
|
|
||||||
// size of video frames.
|
|
||||||
@property (nonatomic, readonly) CGSize size;
|
|
||||||
|
|
||||||
// (quickly) gate the reader function without interrupting the video
|
|
||||||
// stream. also flushes the cache when enabled. defaults to *NO*
|
|
||||||
@property (nonatomic) BOOL enableReader;
|
|
||||||
|
|
||||||
// current frame rate (for debug/optimization).
|
|
||||||
// only valid when running
|
|
||||||
@property (nonatomic, readonly) CGFloat framesPerSecond;
|
|
||||||
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
@class ZBarHelpController;
|
|
||||||
|
|
||||||
@protocol ZBarHelpDelegate
|
|
||||||
@optional
|
|
||||||
|
|
||||||
- (void) helpControllerDidFinish: (ZBarHelpController*) help;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
// failure dialog w/a few useful tips
|
|
||||||
|
|
||||||
@interface ZBarHelpController : UIViewController
|
|
||||||
< UIWebViewDelegate,
|
|
||||||
UIAlertViewDelegate >
|
|
||||||
{
|
|
||||||
NSString *reason;
|
|
||||||
id delegate;
|
|
||||||
UIWebView *webView;
|
|
||||||
UIToolbar *toolbar;
|
|
||||||
UIBarButtonItem *doneBtn, *backBtn, *space;
|
|
||||||
NSURL *linkURL;
|
|
||||||
NSUInteger orientations;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (nonatomic, assign) id<ZBarHelpDelegate> delegate;
|
|
||||||
|
|
||||||
// designated initializer
|
|
||||||
- (id) initWithReason: (NSString*) reason;
|
|
||||||
|
|
||||||
- (BOOL) isInterfaceOrientationSupported: (UIInterfaceOrientation) orientation;
|
|
||||||
- (void) setInterfaceOrientation: (UIInterfaceOrientation) orientation
|
|
||||||
supported: (BOOL) supported;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "zbar.h"
|
|
||||||
#import "ZBarSymbol.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
using namespace zbar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Obj-C wrapper for ZBar image
|
|
||||||
|
|
||||||
@interface ZBarImage : NSObject
|
|
||||||
{
|
|
||||||
zbar_image_t *zimg;
|
|
||||||
double t_convert;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (nonatomic) unsigned long format;
|
|
||||||
@property (nonatomic) unsigned sequence;
|
|
||||||
@property (nonatomic) CGSize size;
|
|
||||||
@property (nonatomic) CGRect crop;
|
|
||||||
@property (readonly, nonatomic) const void *data;
|
|
||||||
@property (readonly, nonatomic) unsigned long dataLength;
|
|
||||||
@property (copy, nonatomic) ZBarSymbolSet *symbols;
|
|
||||||
@property (readonly, nonatomic) zbar_image_t *zbarImage;
|
|
||||||
@property (readonly, nonatomic) UIImage *UIImage;
|
|
||||||
|
|
||||||
- (id) initWithImage: (zbar_image_t*) image;
|
|
||||||
- (id) initWithCGImage: (CGImageRef) image;
|
|
||||||
- (id) initWithCGImage: (CGImageRef) image
|
|
||||||
size: (CGSize) size;
|
|
||||||
- (id) initWithCGImage: (CGImageRef) image
|
|
||||||
crop: (CGRect) crop
|
|
||||||
size: (CGSize) size;
|
|
||||||
|
|
||||||
- (void) setData: (const void*) data
|
|
||||||
withLength: (unsigned long) length;
|
|
||||||
- (UIImage*) UIImageWithOrientation: (UIImageOrientation) imageOrientation;
|
|
||||||
- (void) cleanup;
|
|
||||||
|
|
||||||
+ (unsigned long) fourcc: (NSString*) format;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
- convertToFormat: (unsigned long) format;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import "zbar.h"
|
|
||||||
#import "ZBarImage.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
using namespace zbar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Obj-C wrapper for ZBar image scanner
|
|
||||||
|
|
||||||
@interface ZBarImageScanner : NSObject
|
|
||||||
{
|
|
||||||
zbar_image_scanner_t *scanner;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
@property (readonly, nonatomic) ZBarSymbolSet *results;
|
|
||||||
|
|
||||||
// decoder configuration
|
|
||||||
- (void) parseConfig: (NSString*) configStr;
|
|
||||||
- (void) setSymbology: (zbar_symbol_type_t) symbology
|
|
||||||
config: (zbar_config_t) config
|
|
||||||
to: (int) value;
|
|
||||||
|
|
||||||
// image scanning interface
|
|
||||||
- (NSInteger) scanImage: (ZBarImage*) image;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "ZBarImageScanner.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
using namespace zbar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
// default interface provided by UIImagePickerController - user manually
|
|
||||||
// captures an image by pressing a button
|
|
||||||
ZBarReaderControllerCameraModeDefault = 0,
|
|
||||||
|
|
||||||
// automatically scan by taking screenshots with UIGetScreenImage().
|
|
||||||
// resolution is limited by the screen, so this is inappropriate for
|
|
||||||
// longer codes
|
|
||||||
ZBarReaderControllerCameraModeSampling,
|
|
||||||
|
|
||||||
// automatically scan by rapidly taking pictures with takePicture.
|
|
||||||
// tradeoff resolution with frame rate by adjusting the crop, and size
|
|
||||||
// properties of the reader along with the density configs of the image
|
|
||||||
// scanner
|
|
||||||
ZBarReaderControllerCameraModeSequence,
|
|
||||||
|
|
||||||
} ZBarReaderControllerCameraMode;
|
|
||||||
|
|
||||||
|
|
||||||
@class ZBarReaderController, ZBarHelpController;
|
|
||||||
|
|
||||||
@protocol ZBarReaderDelegate <UIImagePickerControllerDelegate>
|
|
||||||
@optional
|
|
||||||
|
|
||||||
// called when no barcode is found in an image selected by the user.
|
|
||||||
// if retry is NO, the delegate *must* dismiss the controller
|
|
||||||
- (void) readerControllerDidFailToRead: (ZBarReaderController*) reader
|
|
||||||
withRetry: (BOOL) retry;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
@interface ZBarReaderController
|
|
||||||
: UIImagePickerController
|
|
||||||
< UINavigationControllerDelegate,
|
|
||||||
UIImagePickerControllerDelegate >
|
|
||||||
{
|
|
||||||
ZBarImageScanner *scanner;
|
|
||||||
ZBarHelpController *help;
|
|
||||||
UIView *overlay, *boxView;
|
|
||||||
CALayer *boxLayer;
|
|
||||||
|
|
||||||
UIToolbar *toolbar;
|
|
||||||
UIBarButtonItem *cancelBtn, *scanBtn, *space[3];
|
|
||||||
UIButton *infoBtn;
|
|
||||||
|
|
||||||
id <ZBarReaderDelegate> readerDelegate;
|
|
||||||
BOOL showsZBarControls, showsHelpOnFail, takesPicture, enableCache;
|
|
||||||
ZBarReaderControllerCameraMode cameraMode;
|
|
||||||
CGRect scanCrop;
|
|
||||||
NSInteger maxScanDimension;
|
|
||||||
|
|
||||||
BOOL hasOverlay, sampling;
|
|
||||||
uint64_t t_frame;
|
|
||||||
double dt_frame;
|
|
||||||
|
|
||||||
ZBarSymbol *symbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
// access to configure image scanner
|
|
||||||
@property (readonly, nonatomic) ZBarImageScanner *scanner;
|
|
||||||
|
|
||||||
// barcode result recipient (NB don't use delegate)
|
|
||||||
@property (nonatomic, assign) id <ZBarReaderDelegate> readerDelegate;
|
|
||||||
|
|
||||||
// whether to use alternate control set
|
|
||||||
@property (nonatomic) BOOL showsZBarControls;
|
|
||||||
|
|
||||||
// whether to display helpful information when decoding fails
|
|
||||||
@property (nonatomic) BOOL showsHelpOnFail;
|
|
||||||
|
|
||||||
// how to use the camera (when sourceType == Camera)
|
|
||||||
@property (nonatomic) ZBarReaderControllerCameraMode cameraMode;
|
|
||||||
|
|
||||||
// whether to outline symbols with the green tracking box.
|
|
||||||
@property (nonatomic) BOOL tracksSymbols;
|
|
||||||
|
|
||||||
// whether to automatically take a full picture when a barcode is detected
|
|
||||||
// (when cameraMode == Sampling)
|
|
||||||
@property (nonatomic) BOOL takesPicture;
|
|
||||||
|
|
||||||
// whether to use the "cache" for realtime modes (default YES). this can be
|
|
||||||
// used to safely disable the inter-frame consistency and duplicate checks,
|
|
||||||
// speeding up recognition, iff:
|
|
||||||
// 1. the controller is dismissed when a barcode is read and
|
|
||||||
// 2. unreliable symbologies are disabled (all EAN/UPC variants and I2/5)
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
|
|
||||||
// crop images for scanning. the original image will be cropped to this
|
|
||||||
// rectangle before scanning. the rectangle is normalized to the image size
|
|
||||||
// and aspect ratio; useful values will place the rectangle between 0 and 1
|
|
||||||
// on each axis, where the x-axis corresponds to the image major axis.
|
|
||||||
// defaults to the full image (0, 0, 1, 1).
|
|
||||||
@property (nonatomic) CGRect scanCrop;
|
|
||||||
|
|
||||||
// scale image to scan. after cropping, the image will be scaled if
|
|
||||||
// necessary, such that neither of its dimensions exceed this value.
|
|
||||||
// defaults to 640.
|
|
||||||
@property (nonatomic) NSInteger maxScanDimension;
|
|
||||||
|
|
||||||
// display the built-in help browser. for use with custom overlays if
|
|
||||||
// you don't also want to create your own help view. only send this
|
|
||||||
// message when the reader is displayed. the argument will be passed
|
|
||||||
// to the onZBarHelp() javascript function.
|
|
||||||
- (void) showHelpWithReason: (NSString*) reason;
|
|
||||||
|
|
||||||
// direct scanner interface - scan UIImage and return something enumerable
|
|
||||||
- (id <NSFastEnumeration>) scanImage: (CGImageRef) image;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
extern NSString* const ZBarReaderControllerResults;
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "ZBarImageScanner.h"
|
|
||||||
|
|
||||||
@class AVCaptureSession, AVCaptureDevice;
|
|
||||||
@class CALayer;
|
|
||||||
@class ZBarImageScanner, ZBarCaptureReader, ZBarReaderView;
|
|
||||||
|
|
||||||
// delegate is notified of decode results.
|
|
||||||
|
|
||||||
@protocol ZBarReaderViewDelegate < NSObject >
|
|
||||||
|
|
||||||
- (void) readerView: (ZBarReaderView*) readerView
|
|
||||||
didReadSymbols: (ZBarSymbolSet*) symbols
|
|
||||||
fromImage: (UIImage*) image;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
// read barcodes from the displayed video preview. the view maintains
|
|
||||||
// a complete video capture session feeding a ZBarCaptureReader and
|
|
||||||
// presents the associated preview with symbol tracking annotations.
|
|
||||||
|
|
||||||
@interface ZBarReaderView
|
|
||||||
: UIView
|
|
||||||
{
|
|
||||||
id<ZBarReaderViewDelegate> readerDelegate;
|
|
||||||
ZBarCaptureReader *captureReader;
|
|
||||||
CGRect scanCrop, effectiveCrop;
|
|
||||||
CGAffineTransform previewTransform;
|
|
||||||
CGFloat zoom, zoom0, maxZoom;
|
|
||||||
UIColor *trackingColor;
|
|
||||||
BOOL tracksSymbols, showsFPS;
|
|
||||||
NSInteger torchMode;
|
|
||||||
UIInterfaceOrientation interfaceOrientation;
|
|
||||||
NSTimeInterval animationDuration;
|
|
||||||
|
|
||||||
CALayer *preview, *overlay, *tracking, *cropLayer;
|
|
||||||
UIView *fpsView;
|
|
||||||
UILabel *fpsLabel;
|
|
||||||
UIPinchGestureRecognizer *pinch;
|
|
||||||
CGFloat imageScale;
|
|
||||||
CGSize imageSize;
|
|
||||||
BOOL started, running;
|
|
||||||
}
|
|
||||||
|
|
||||||
// supply a pre-configured image scanner.
|
|
||||||
- (id) initWithImageScanner: (ZBarImageScanner*) imageScanner;
|
|
||||||
|
|
||||||
// start the video stream and barcode reader.
|
|
||||||
- (void) start;
|
|
||||||
|
|
||||||
// stop the video stream and barcode reader.
|
|
||||||
- (void) stop;
|
|
||||||
|
|
||||||
// clear the internal result cache
|
|
||||||
- (void) flushCache;
|
|
||||||
|
|
||||||
// compensate for device/camera/interface orientation
|
|
||||||
- (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) orient
|
|
||||||
duration: (NSTimeInterval) duration;
|
|
||||||
|
|
||||||
// delegate is notified of decode results.
|
|
||||||
@property (nonatomic, assign) id<ZBarReaderViewDelegate> readerDelegate;
|
|
||||||
|
|
||||||
// access to image scanner for configuration.
|
|
||||||
@property (nonatomic, readonly) ZBarImageScanner *scanner;
|
|
||||||
|
|
||||||
// whether to display the tracking annotation for uncertain barcodes
|
|
||||||
// (default YES).
|
|
||||||
@property (nonatomic) BOOL tracksSymbols;
|
|
||||||
|
|
||||||
// color of the tracking box (default green)
|
|
||||||
@property (nonatomic, retain) UIColor *trackingColor;
|
|
||||||
|
|
||||||
// enable pinch gesture recognition for zooming the preview/decode
|
|
||||||
// (default YES).
|
|
||||||
@property (nonatomic) BOOL allowsPinchZoom;
|
|
||||||
|
|
||||||
// torch mode to set automatically (default Auto).
|
|
||||||
@property (nonatomic) NSInteger torchMode;
|
|
||||||
|
|
||||||
// whether to display the frame rate for debug/configuration
|
|
||||||
// (default NO).
|
|
||||||
@property (nonatomic) BOOL showsFPS;
|
|
||||||
|
|
||||||
// zoom scale factor applied to video preview *and* scanCrop.
|
|
||||||
// also updated by pinch-zoom gesture. clipped to range [1,maxZoom],
|
|
||||||
// defaults to 1.25
|
|
||||||
@property (nonatomic) CGFloat zoom;
|
|
||||||
- (void) setZoom: (CGFloat) zoom
|
|
||||||
animated: (BOOL) animated;
|
|
||||||
|
|
||||||
// maximum settable zoom factor.
|
|
||||||
@property (nonatomic) CGFloat maxZoom;
|
|
||||||
|
|
||||||
// the region of the image that will be scanned. normalized coordinates.
|
|
||||||
@property (nonatomic) CGRect scanCrop;
|
|
||||||
|
|
||||||
// additional transform applied to video preview.
|
|
||||||
// (NB *not* applied to scan crop)
|
|
||||||
@property (nonatomic) CGAffineTransform previewTransform;
|
|
||||||
|
|
||||||
// specify an alternate capture device.
|
|
||||||
@property (nonatomic, retain) AVCaptureDevice *device;
|
|
||||||
|
|
||||||
// direct access to the capture session. warranty void if opened...
|
|
||||||
@property (nonatomic, readonly) AVCaptureSession *session;
|
|
||||||
@property (nonatomic, readonly) ZBarCaptureReader *captureReader;
|
|
||||||
|
|
||||||
// this flag still works, but its use is deprecated
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "ZBarReaderController.h"
|
|
||||||
|
|
||||||
// orientation set support
|
|
||||||
#define ZBarOrientationMask(orient) (1 << orient)
|
|
||||||
#define ZBarOrientationMaskAll \
|
|
||||||
(ZBarOrientationMask(UIInterfaceOrientationPortrait) | \
|
|
||||||
ZBarOrientationMask(UIInterfaceOrientationPortraitUpsideDown) | \
|
|
||||||
ZBarOrientationMask(UIInterfaceOrientationLandscapeLeft) | \
|
|
||||||
ZBarOrientationMask(UIInterfaceOrientationLandscapeRight))
|
|
||||||
|
|
||||||
@class ZBarReaderView, ZBarCameraSimulator;
|
|
||||||
|
|
||||||
// drop in video scanning replacement for ZBarReaderController.
|
|
||||||
// this is a thin controller around a ZBarReaderView that adds the UI
|
|
||||||
// controls and select functionality offered by ZBarReaderController.
|
|
||||||
// Automatically falls back to a ZBarReaderController if video APIs
|
|
||||||
// are unavailable (eg for OS < 4.0)
|
|
||||||
|
|
||||||
@interface ZBarReaderViewController
|
|
||||||
: UIViewController
|
|
||||||
{
|
|
||||||
ZBarImageScanner *scanner;
|
|
||||||
id <ZBarReaderDelegate> readerDelegate;
|
|
||||||
ZBarReaderView *readerView;
|
|
||||||
UIView *cameraOverlayView;
|
|
||||||
CGAffineTransform cameraViewTransform;
|
|
||||||
CGRect scanCrop;
|
|
||||||
NSUInteger supportedOrientationsMask;
|
|
||||||
UIImagePickerControllerCameraDevice cameraDevice;
|
|
||||||
UIImagePickerControllerCameraFlashMode cameraFlashMode;
|
|
||||||
UIImagePickerControllerQualityType videoQuality;
|
|
||||||
BOOL showsZBarControls, tracksSymbols, enableCache;
|
|
||||||
|
|
||||||
ZBarHelpController *helpController;
|
|
||||||
UIView *controls;
|
|
||||||
BOOL didHideStatusBar, rotating;
|
|
||||||
ZBarCameraSimulator *cameraSim;
|
|
||||||
}
|
|
||||||
|
|
||||||
// access to configure image scanner
|
|
||||||
@property (nonatomic, readonly) ZBarImageScanner *scanner;
|
|
||||||
|
|
||||||
// barcode result recipient
|
|
||||||
@property (nonatomic, assign) id <ZBarReaderDelegate> readerDelegate;
|
|
||||||
|
|
||||||
// whether to use alternate control set
|
|
||||||
@property (nonatomic) BOOL showsZBarControls;
|
|
||||||
|
|
||||||
// whether to show the green tracking box. note that, even when
|
|
||||||
// enabled, the box will only be visible when scanning EAN and I2/5.
|
|
||||||
@property (nonatomic) BOOL tracksSymbols;
|
|
||||||
|
|
||||||
// interface orientation support. bit-mask of accepted orientations.
|
|
||||||
// see eg ZBarOrientationMask() and ZBarOrientationMaskAll
|
|
||||||
@property (nonatomic) NSUInteger supportedOrientationsMask;
|
|
||||||
|
|
||||||
// crop images for scanning. the image will be cropped to this
|
|
||||||
// rectangle before scanning. the rectangle is normalized to the
|
|
||||||
// image size and aspect ratio; useful values will place the rectangle
|
|
||||||
// between 0 and 1 on each axis, where the x-axis corresponds to the
|
|
||||||
// image major axis. defaults to the full image (0, 0, 1, 1).
|
|
||||||
@property (nonatomic) CGRect scanCrop;
|
|
||||||
|
|
||||||
// provide a custom overlay. note that this can be used with
|
|
||||||
// showsZBarControls enabled (but not if you want backward compatibility)
|
|
||||||
@property (nonatomic, retain) UIView *cameraOverlayView;
|
|
||||||
|
|
||||||
// transform applied to the preview image.
|
|
||||||
@property (nonatomic) CGAffineTransform cameraViewTransform;
|
|
||||||
|
|
||||||
// display the built-in help browser. the argument will be passed to
|
|
||||||
// the onZBarHelp() javascript function.
|
|
||||||
- (void) showHelpWithReason: (NSString*) reason;
|
|
||||||
|
|
||||||
// capture the next frame and send it over the usual delegate path.
|
|
||||||
- (void) takePicture;
|
|
||||||
|
|
||||||
// these attempt to emulate UIImagePickerController
|
|
||||||
+ (BOOL) isCameraDeviceAvailable: (UIImagePickerControllerCameraDevice) cameraDevice;
|
|
||||||
+ (BOOL) isFlashAvailableForCameraDevice: (UIImagePickerControllerCameraDevice) cameraDevice;
|
|
||||||
+ (NSArray*) availableCaptureModesForCameraDevice: (UIImagePickerControllerCameraDevice) cameraDevice;
|
|
||||||
@property(nonatomic) UIImagePickerControllerCameraDevice cameraDevice;
|
|
||||||
@property(nonatomic) UIImagePickerControllerCameraFlashMode cameraFlashMode;
|
|
||||||
@property(nonatomic) UIImagePickerControllerCameraCaptureMode cameraCaptureMode;
|
|
||||||
@property(nonatomic) UIImagePickerControllerQualityType videoQuality;
|
|
||||||
|
|
||||||
// direct access to the ZBarReaderView
|
|
||||||
@property (nonatomic, readonly) ZBarReaderView *readerView;
|
|
||||||
|
|
||||||
// this flag still works, but its use is deprecated
|
|
||||||
@property (nonatomic) BOOL enableCache;
|
|
||||||
|
|
||||||
// these are present only for backward compatibility.
|
|
||||||
// they will error if inappropriate/unsupported values are set
|
|
||||||
@property (nonatomic) UIImagePickerControllerSourceType sourceType; // Camera
|
|
||||||
@property (nonatomic) BOOL allowsEditing; // NO
|
|
||||||
@property (nonatomic) BOOL allowsImageEditing; // NO
|
|
||||||
@property (nonatomic) BOOL showsCameraControls; // NO
|
|
||||||
@property (nonatomic) BOOL showsHelpOnFail; // ignored
|
|
||||||
@property (nonatomic) ZBarReaderControllerCameraMode cameraMode; // Sampling
|
|
||||||
@property (nonatomic) BOOL takesPicture; // NO
|
|
||||||
@property (nonatomic) NSInteger maxScanDimension; // ignored
|
|
||||||
|
|
||||||
+ (BOOL) isSourceTypeAvailable: (UIImagePickerControllerSourceType) sourceType;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
/*------------------------------------------------------------------------
|
|
||||||
* Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* This file is part of the ZBar Bar Code Reader.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser Public License
|
|
||||||
* along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* http://sourceforge.net/projects/zbar
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#import "zbar.h"
|
|
||||||
|
|
||||||
#import "ZBarSymbol.h"
|
|
||||||
#import "ZBarImage.h"
|
|
||||||
#import "ZBarImageScanner.h"
|
|
||||||
#import "ZBarReaderView.h"
|
|
||||||
#import "ZBarReaderViewController.h"
|
|
||||||
#import "ZBarReaderController.h"
|
|
||||||
#import "ZBarCaptureReader.h"
|
|
||||||
#import "ZBarHelpController.h"
|
|
||||||
#import "ZBarCameraSimulator.h"
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2009-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import <CoreGraphics/CoreGraphics.h>
|
|
||||||
#import "zbar.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
using namespace zbar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Obj-C wrapper for ZBar result types
|
|
||||||
|
|
||||||
@interface ZBarSymbolSet
|
|
||||||
: NSObject <NSFastEnumeration>
|
|
||||||
{
|
|
||||||
const zbar_symbol_set_t *set;
|
|
||||||
BOOL filterSymbols;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (readonly, nonatomic) int count;
|
|
||||||
@property (readonly, nonatomic) const zbar_symbol_set_t *zbarSymbolSet;
|
|
||||||
@property (nonatomic) BOOL filterSymbols;
|
|
||||||
|
|
||||||
- (id) initWithSymbolSet: (const zbar_symbol_set_t*) set;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
@interface ZBarSymbol : NSObject
|
|
||||||
{
|
|
||||||
const zbar_symbol_t *symbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property (readonly, nonatomic) zbar_symbol_type_t type;
|
|
||||||
@property (readonly, nonatomic) NSString *typeName;
|
|
||||||
@property (readonly, nonatomic) NSUInteger configMask;
|
|
||||||
@property (readonly, nonatomic) NSUInteger modifierMask;
|
|
||||||
@property (readonly, nonatomic) NSString *data;
|
|
||||||
@property (readonly, nonatomic) int quality;
|
|
||||||
@property (readonly, nonatomic) int count;
|
|
||||||
@property (readonly, nonatomic) zbar_orientation_t orientation;
|
|
||||||
@property (readonly, nonatomic) ZBarSymbolSet *components;
|
|
||||||
@property (readonly, nonatomic) const zbar_symbol_t *zbarSymbol;
|
|
||||||
@property (readonly, nonatomic) CGRect bounds;
|
|
||||||
|
|
||||||
- (id) initWithSymbol: (const zbar_symbol_t*) symbol;
|
|
||||||
|
|
||||||
+ (NSString*) nameForType: (zbar_symbol_type_t) type;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_DECODER_H_
|
|
||||||
#define _ZBAR_DECODER_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Decoder C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Decoder.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// low-level bar width stream decoder interface.
|
|
||||||
/// identifies symbols and extracts encoded data
|
|
||||||
|
|
||||||
class Decoder {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Decoder result handler.
|
|
||||||
/// applications should subtype this and pass an instance to
|
|
||||||
/// set_handler() to implement result processing
|
|
||||||
class Handler {
|
|
||||||
public:
|
|
||||||
virtual ~Handler() { }
|
|
||||||
|
|
||||||
/// invoked by the Decoder as decode results become available.
|
|
||||||
virtual void decode_callback(Decoder &decoder) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Decoder ()
|
|
||||||
: _handler(NULL)
|
|
||||||
{
|
|
||||||
_decoder = zbar_decoder_create();
|
|
||||||
}
|
|
||||||
|
|
||||||
~Decoder ()
|
|
||||||
{
|
|
||||||
zbar_decoder_destroy(_decoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// clear all decoder state.
|
|
||||||
/// see zbar_decoder_reset()
|
|
||||||
void reset ()
|
|
||||||
{
|
|
||||||
zbar_decoder_reset(_decoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// mark start of a new scan pass.
|
|
||||||
/// see zbar_decoder_new_scan()
|
|
||||||
void new_scan ()
|
|
||||||
{
|
|
||||||
zbar_decoder_new_scan(_decoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next bar/space width from input stream.
|
|
||||||
/// see zbar_decode_width()
|
|
||||||
zbar_symbol_type_t decode_width (unsigned width)
|
|
||||||
{
|
|
||||||
return(zbar_decode_width(_decoder, width));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next bar/space width from input stream.
|
|
||||||
/// see zbar_decode_width()
|
|
||||||
Decoder& operator<< (unsigned width)
|
|
||||||
{
|
|
||||||
zbar_decode_width(_decoder, width);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve color of @em next element passed to Decoder.
|
|
||||||
/// see zbar_decoder_get_color()
|
|
||||||
zbar_color_t get_color () const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_color(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decoded symbol type.
|
|
||||||
/// see zbar_decoder_get_type()
|
|
||||||
zbar_symbol_type_t get_type () const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_type(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve string name of last decoded symbol type.
|
|
||||||
/// see zbar_get_symbol_name()
|
|
||||||
const char *get_symbol_name () const
|
|
||||||
{
|
|
||||||
return(zbar_get_symbol_name(zbar_decoder_get_type(_decoder)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve string name for last decode addon.
|
|
||||||
/// see zbar_get_addon_name()
|
|
||||||
/// @deprecated in 0.11
|
|
||||||
const char *get_addon_name () const
|
|
||||||
{
|
|
||||||
return(zbar_get_addon_name(zbar_decoder_get_type(_decoder)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decoded data in ASCII format as a char array.
|
|
||||||
/// see zbar_decoder_get_data()
|
|
||||||
const char *get_data_chars() const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_data(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decoded data as a std::string.
|
|
||||||
/// see zbar_decoder_get_data()
|
|
||||||
const std::string get_data_string() const
|
|
||||||
{
|
|
||||||
return(std::string(zbar_decoder_get_data(_decoder),
|
|
||||||
zbar_decoder_get_data_length(_decoder)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decoded data as a std::string.
|
|
||||||
/// see zbar_decoder_get_data()
|
|
||||||
const std::string get_data() const
|
|
||||||
{
|
|
||||||
return(get_data_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve length of decoded binary data.
|
|
||||||
/// see zbar_decoder_get_data_length()
|
|
||||||
int get_data_length() const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_data_length(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last decode direction.
|
|
||||||
/// see zbar_decoder_get_direction()
|
|
||||||
/// @since 0.11
|
|
||||||
int get_direction() const
|
|
||||||
{
|
|
||||||
return(zbar_decoder_get_direction(_decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// setup callback to handle result data.
|
|
||||||
void set_handler (Handler &handler)
|
|
||||||
{
|
|
||||||
_handler = &handler;
|
|
||||||
zbar_decoder_set_handler(_decoder, _cb);
|
|
||||||
zbar_decoder_set_userdata(_decoder, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config for indicated symbology (0 for all) to specified value.
|
|
||||||
/// @see zbar_decoder_set_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (zbar_symbol_type_t symbology,
|
|
||||||
zbar_config_t config,
|
|
||||||
int value)
|
|
||||||
{
|
|
||||||
return(zbar_decoder_set_config(_decoder, symbology, config, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config parsed from configuration string.
|
|
||||||
/// @see zbar_decoder_parse_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (std::string cfgstr)
|
|
||||||
{
|
|
||||||
return(zbar_decoder_parse_config(_decoder, cfgstr.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class Scanner;
|
|
||||||
zbar_decoder_t *_decoder;
|
|
||||||
Handler *_handler;
|
|
||||||
|
|
||||||
static void _cb (zbar_decoder_t *cdcode)
|
|
||||||
{
|
|
||||||
Decoder *dcode = (Decoder*)zbar_decoder_get_userdata(cdcode);
|
|
||||||
if(dcode && dcode->_handler)
|
|
||||||
dcode->_handler->decode_callback(*dcode);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_EXCEPTION_H_
|
|
||||||
#define _ZBAR_EXCEPTION_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// C++ Exception definitions
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Exception.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <exception>
|
|
||||||
#include <new>
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// base class for exceptions defined by this API.
|
|
||||||
class Exception : public std::exception {
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
Exception (const void *obj = NULL)
|
|
||||||
: std::exception(),
|
|
||||||
_obj(obj)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
~Exception () throw() { }
|
|
||||||
|
|
||||||
/// retrieve error message
|
|
||||||
virtual const char* what () const throw()
|
|
||||||
{
|
|
||||||
if(!_obj)
|
|
||||||
return("zbar library unspecified generic error");
|
|
||||||
return(_zbar_error_string(_obj, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const void *_obj;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// internal library error.
|
|
||||||
class InternalError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
InternalError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// unsupported request.
|
|
||||||
class UnsupportedError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
UnsupportedError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// invalid request.
|
|
||||||
class InvalidError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
InvalidError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// failed system call.
|
|
||||||
class SystemError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
SystemError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// locking error.
|
|
||||||
class LockingError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
LockingError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// all resources busy.
|
|
||||||
class BusyError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
BusyError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// X11 display error.
|
|
||||||
class XDisplayError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
XDisplayError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// X11 protocol error.
|
|
||||||
class XProtoError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
XProtoError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// output window is closed.
|
|
||||||
class ClosedError : public Exception {
|
|
||||||
public:
|
|
||||||
/// create exception from C library error
|
|
||||||
ClosedError (const void *obj)
|
|
||||||
: Exception(obj)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// image format error
|
|
||||||
class FormatError : public Exception {
|
|
||||||
// FIXME needs c equivalent
|
|
||||||
|
|
||||||
virtual const char* what () const throw()
|
|
||||||
{
|
|
||||||
// FIXME what format?
|
|
||||||
return("unsupported format");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @internal
|
|
||||||
|
|
||||||
/// extract error information and create exception.
|
|
||||||
static inline std::exception throw_exception (const void *obj)
|
|
||||||
{
|
|
||||||
switch(_zbar_get_error_code(obj)) {
|
|
||||||
case ZBAR_ERR_NOMEM:
|
|
||||||
throw std::bad_alloc();
|
|
||||||
case ZBAR_ERR_INTERNAL:
|
|
||||||
throw InternalError(obj);
|
|
||||||
case ZBAR_ERR_UNSUPPORTED:
|
|
||||||
throw UnsupportedError(obj);
|
|
||||||
case ZBAR_ERR_INVALID:
|
|
||||||
throw InvalidError(obj);
|
|
||||||
case ZBAR_ERR_SYSTEM:
|
|
||||||
throw SystemError(obj);
|
|
||||||
case ZBAR_ERR_LOCKING:
|
|
||||||
throw LockingError(obj);
|
|
||||||
case ZBAR_ERR_BUSY:
|
|
||||||
throw BusyError(obj);
|
|
||||||
case ZBAR_ERR_XDISPLAY:
|
|
||||||
throw XDisplayError(obj);
|
|
||||||
case ZBAR_ERR_XPROTO:
|
|
||||||
throw XProtoError(obj);
|
|
||||||
case ZBAR_ERR_CLOSED:
|
|
||||||
throw ClosedError(obj);
|
|
||||||
default:
|
|
||||||
throw Exception(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,321 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_IMAGE_H_
|
|
||||||
#define _ZBAR_IMAGE_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Image C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Image.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <iterator>
|
|
||||||
#include "Symbol.h"
|
|
||||||
#include "Exception.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
class Video;
|
|
||||||
|
|
||||||
/// stores image data samples along with associated format and size
|
|
||||||
/// metadata
|
|
||||||
|
|
||||||
class Image {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// general Image result handler.
|
|
||||||
/// applications should subtype this and pass an instance to
|
|
||||||
/// eg. ImageScanner::set_handler() to implement result processing
|
|
||||||
class Handler {
|
|
||||||
public:
|
|
||||||
virtual ~Handler() { }
|
|
||||||
|
|
||||||
/// invoked by library when Image should be processed
|
|
||||||
virtual void image_callback(Image &image) = 0;
|
|
||||||
|
|
||||||
/// cast this handler to the C handler
|
|
||||||
operator zbar_image_data_handler_t* () const
|
|
||||||
{
|
|
||||||
return(_cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void _cb (zbar_image_t *zimg,
|
|
||||||
const void *userdata)
|
|
||||||
{
|
|
||||||
if(userdata) {
|
|
||||||
Image *image = (Image*)zbar_image_get_userdata(zimg);
|
|
||||||
if(image)
|
|
||||||
((Handler*)userdata)->image_callback(*image);
|
|
||||||
else {
|
|
||||||
Image tmp(zimg, 1);
|
|
||||||
((Handler*)userdata)->image_callback(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SymbolIterator : public zbar::SymbolIterator {
|
|
||||||
public:
|
|
||||||
/// default constructor.
|
|
||||||
SymbolIterator ()
|
|
||||||
: zbar::SymbolIterator()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
SymbolIterator (const SymbolSet &syms)
|
|
||||||
: zbar::SymbolIterator(syms)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
SymbolIterator (const SymbolIterator& iter)
|
|
||||||
: zbar::SymbolIterator(iter)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
/// create a new Image with the specified parameters
|
|
||||||
Image (unsigned width = 0,
|
|
||||||
unsigned height = 0,
|
|
||||||
const std::string& format = "",
|
|
||||||
const void *data = NULL,
|
|
||||||
unsigned long length = 0)
|
|
||||||
: _img(zbar_image_create())
|
|
||||||
{
|
|
||||||
zbar_image_set_userdata(_img, this);
|
|
||||||
if(width && height)
|
|
||||||
set_size(width, height);
|
|
||||||
if(format.length())
|
|
||||||
set_format(format);
|
|
||||||
if(data && length)
|
|
||||||
set_data(data, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Image ()
|
|
||||||
{
|
|
||||||
set_data(NULL, 0);
|
|
||||||
zbar_image_set_userdata(_img, NULL);
|
|
||||||
zbar_image_ref(_img, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C image object
|
|
||||||
operator const zbar_image_t* () const
|
|
||||||
{
|
|
||||||
return(_img);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C image object
|
|
||||||
operator zbar_image_t* ()
|
|
||||||
{
|
|
||||||
return(_img);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the image format.
|
|
||||||
/// see zbar_image_get_format()
|
|
||||||
unsigned long get_format () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_format(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// specify the fourcc image format code for image sample data.
|
|
||||||
/// see zbar_image_set_format()
|
|
||||||
void set_format (unsigned long format)
|
|
||||||
{
|
|
||||||
zbar_image_set_format(_img, format);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// specify the fourcc image format code for image sample data.
|
|
||||||
/// see zbar_image_set_format()
|
|
||||||
void set_format (const std::string& format)
|
|
||||||
{
|
|
||||||
unsigned long fourcc = zbar_fourcc_parse(format.c_str());
|
|
||||||
zbar_image_set_format(_img, fourcc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve a "sequence" (page/frame) number associated with this
|
|
||||||
/// image.
|
|
||||||
/// see zbar_image_get_sequence()
|
|
||||||
/// @since 0.6
|
|
||||||
unsigned get_sequence () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_sequence(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// associate a "sequence" (page/frame) number with this image.
|
|
||||||
/// see zbar_image_set_sequence()
|
|
||||||
/// @since 0.6
|
|
||||||
void set_sequence (unsigned sequence_num)
|
|
||||||
{
|
|
||||||
zbar_image_set_sequence(_img, sequence_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the width of the image.
|
|
||||||
/// see zbar_image_get_width()
|
|
||||||
unsigned get_width () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_width(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the height of the image.
|
|
||||||
/// see zbar_image_get_height()
|
|
||||||
unsigned get_height () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_height(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve both dimensions of the image.
|
|
||||||
/// see zbar_image_get_size()
|
|
||||||
/// @since 0.11
|
|
||||||
void get_size (unsigned &width,
|
|
||||||
unsigned &height) const
|
|
||||||
{
|
|
||||||
zbar_image_get_size(_img, &width, &height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// specify the pixel size of the image.
|
|
||||||
/// see zbar_image_set_size()
|
|
||||||
void set_size (unsigned width,
|
|
||||||
unsigned height)
|
|
||||||
{
|
|
||||||
zbar_image_set_size(_img, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the scan crop rectangle.
|
|
||||||
/// see zbar_image_get_crop()
|
|
||||||
void get_crop (unsigned &x,
|
|
||||||
unsigned &y,
|
|
||||||
unsigned &width,
|
|
||||||
unsigned &height) const
|
|
||||||
{
|
|
||||||
zbar_image_get_crop(_img, &x, &y, &width, &height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set the scan crop rectangle.
|
|
||||||
/// see zbar_image_set_crop()
|
|
||||||
void set_crop (unsigned x,
|
|
||||||
unsigned y,
|
|
||||||
unsigned width,
|
|
||||||
unsigned height)
|
|
||||||
{
|
|
||||||
zbar_image_set_crop(_img, x, y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return the image sample data.
|
|
||||||
/// see zbar_image_get_data()
|
|
||||||
const void *get_data () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_data(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return the size of the image sample data.
|
|
||||||
/// see zbar_image_get_data_length()
|
|
||||||
/// @since 0.6
|
|
||||||
unsigned long get_data_length () const
|
|
||||||
{
|
|
||||||
return(zbar_image_get_data_length(_img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// specify image sample data.
|
|
||||||
/// see zbar_image_set_data()
|
|
||||||
void set_data (const void *data,
|
|
||||||
unsigned long length)
|
|
||||||
{
|
|
||||||
zbar_image_set_data(_img, data, length, _cleanup);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// image format conversion.
|
|
||||||
/// see zbar_image_convert()
|
|
||||||
Image convert (unsigned long format) const
|
|
||||||
{
|
|
||||||
zbar_image_t *img = zbar_image_convert(_img, format);
|
|
||||||
if(img)
|
|
||||||
return(Image(img));
|
|
||||||
throw FormatError();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// image format conversion with crop/pad.
|
|
||||||
/// see zbar_image_convert_resize()
|
|
||||||
/// @since 0.4
|
|
||||||
Image convert (unsigned long format,
|
|
||||||
unsigned width,
|
|
||||||
unsigned height) const
|
|
||||||
{
|
|
||||||
zbar_image_t *img =
|
|
||||||
zbar_image_convert_resize(_img, format, width, height);
|
|
||||||
if(img)
|
|
||||||
return(Image(img));
|
|
||||||
throw FormatError();
|
|
||||||
}
|
|
||||||
|
|
||||||
const SymbolSet get_symbols () const {
|
|
||||||
return(SymbolSet(zbar_image_get_symbols(_img)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_symbols (const SymbolSet &syms) {
|
|
||||||
zbar_image_set_symbols(_img, syms);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// create a new SymbolIterator over decoded results.
|
|
||||||
SymbolIterator symbol_begin () const {
|
|
||||||
return(SymbolIterator(get_symbols()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return a SymbolIterator suitable for ending iteration.
|
|
||||||
SymbolIterator symbol_end () const {
|
|
||||||
return(SymbolIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
friend class Video;
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
/// @internal
|
|
||||||
/// create a new Image from a zbar_image_t C object
|
|
||||||
Image (zbar_image_t *src,
|
|
||||||
int refs = 0)
|
|
||||||
: _img(src)
|
|
||||||
{
|
|
||||||
if(refs)
|
|
||||||
zbar_image_ref(_img, refs);
|
|
||||||
zbar_image_set_userdata(_img, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// default data cleanup (noop)
|
|
||||||
/// @internal
|
|
||||||
static void _cleanup (zbar_image_t *img)
|
|
||||||
{
|
|
||||||
// by default nothing is cleaned
|
|
||||||
assert(img);
|
|
||||||
assert(zbar_image_get_userdata(img));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_image_t *_img;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_IMAGE_SCANNER_H_
|
|
||||||
#define _ZBAR_IMAGE_SCANNER_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Image Scanner C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/ImageScanner.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Image.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// mid-level image scanner interface.
|
|
||||||
/// reads barcodes from a 2-D Image
|
|
||||||
|
|
||||||
class ImageScanner {
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
ImageScanner (zbar_image_scanner_t *scanner = NULL)
|
|
||||||
{
|
|
||||||
if(scanner)
|
|
||||||
_scanner = scanner;
|
|
||||||
else
|
|
||||||
_scanner = zbar_image_scanner_create();
|
|
||||||
}
|
|
||||||
|
|
||||||
~ImageScanner ()
|
|
||||||
{
|
|
||||||
zbar_image_scanner_destroy(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C image_scanner object
|
|
||||||
operator zbar_image_scanner_t* () const
|
|
||||||
{
|
|
||||||
return(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// setup result handler callback.
|
|
||||||
void set_handler (Image::Handler &handler)
|
|
||||||
{
|
|
||||||
zbar_image_scanner_set_data_handler(_scanner, handler, &handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config for indicated symbology (0 for all) to specified value.
|
|
||||||
/// @see zbar_image_scanner_set_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (zbar_symbol_type_t symbology,
|
|
||||||
zbar_config_t config,
|
|
||||||
int value)
|
|
||||||
{
|
|
||||||
return(zbar_image_scanner_set_config(_scanner, symbology,
|
|
||||||
config, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config parsed from configuration string.
|
|
||||||
/// @see zbar_image_scanner_parse_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (std::string cfgstr)
|
|
||||||
{
|
|
||||||
return(zbar_image_scanner_parse_config(_scanner, cfgstr.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// enable or disable the inter-image result cache.
|
|
||||||
/// see zbar_image_scanner_enable_cache()
|
|
||||||
void enable_cache (bool enable = true)
|
|
||||||
{
|
|
||||||
zbar_image_scanner_enable_cache(_scanner, enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// remove previous results from scanner and image.
|
|
||||||
/// @see zbar_image_scanner_recycle_image()
|
|
||||||
/// @since 0.10
|
|
||||||
void recycle_image (Image &image)
|
|
||||||
{
|
|
||||||
zbar_image_scanner_recycle_image(_scanner, image);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve decode results for last scanned image.
|
|
||||||
/// @see zbar_image_scanner_get_results()
|
|
||||||
/// @since 0.10
|
|
||||||
const SymbolSet get_results () const {
|
|
||||||
return(SymbolSet(zbar_image_scanner_get_results(_scanner)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// scan for symbols in provided image.
|
|
||||||
/// see zbar_scan_image()
|
|
||||||
int scan (Image& image)
|
|
||||||
{
|
|
||||||
return(zbar_scan_image(_scanner, image));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// scan for symbols in provided image.
|
|
||||||
/// see zbar_scan_image()
|
|
||||||
ImageScanner& operator<< (Image& image)
|
|
||||||
{
|
|
||||||
scan(image);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_image_scanner_t *_scanner;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,223 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_PROCESSOR_H_
|
|
||||||
#define _ZBAR_PROCESSOR_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Processor C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Processor.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Exception.h"
|
|
||||||
#include "Image.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// high-level self-contained image processor.
|
|
||||||
/// processes video and images for barcodes, optionally displaying
|
|
||||||
/// images to a library owned output window
|
|
||||||
|
|
||||||
class Processor {
|
|
||||||
public:
|
|
||||||
/// value to pass for no timeout.
|
|
||||||
static const int FOREVER = -1;
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Processor (bool threaded = true,
|
|
||||||
const char *video_device = "",
|
|
||||||
bool enable_display = true)
|
|
||||||
{
|
|
||||||
_processor = zbar_processor_create(threaded);
|
|
||||||
if(!_processor)
|
|
||||||
throw std::bad_alloc();
|
|
||||||
init(video_device, enable_display);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Processor ()
|
|
||||||
{
|
|
||||||
zbar_processor_destroy(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C processor object.
|
|
||||||
operator zbar_processor_t* ()
|
|
||||||
{
|
|
||||||
return(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// opens a video input device and/or prepares to display output.
|
|
||||||
/// see zbar_processor_init()
|
|
||||||
void init (const char *video_device = "",
|
|
||||||
bool enable_display = true)
|
|
||||||
{
|
|
||||||
if(zbar_processor_init(_processor, video_device, enable_display))
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// setup result handler callback.
|
|
||||||
/// see zbar_processor_set_data_handler()
|
|
||||||
void set_handler (Image::Handler& handler)
|
|
||||||
{
|
|
||||||
zbar_processor_set_data_handler(_processor, handler, &handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config for indicated symbology (0 for all) to specified value.
|
|
||||||
/// @see zbar_processor_set_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (zbar_symbol_type_t symbology,
|
|
||||||
zbar_config_t config,
|
|
||||||
int value)
|
|
||||||
{
|
|
||||||
return(zbar_processor_set_config(_processor, symbology,
|
|
||||||
config, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// set config parsed from configuration string.
|
|
||||||
/// @see zbar_processor_parse_config()
|
|
||||||
/// @since 0.4
|
|
||||||
int set_config (std::string cfgstr)
|
|
||||||
{
|
|
||||||
return(zbar_processor_parse_config(_processor, cfgstr.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the current state of the ouput window.
|
|
||||||
/// see zbar_processor_is_visible()
|
|
||||||
bool is_visible ()
|
|
||||||
{
|
|
||||||
int rc = zbar_processor_is_visible(_processor);
|
|
||||||
if(rc < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
return(rc != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// show or hide the display window owned by the library.
|
|
||||||
/// see zbar_processor_set_visible()
|
|
||||||
void set_visible (bool visible = true)
|
|
||||||
{
|
|
||||||
if(zbar_processor_set_visible(_processor, visible) < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// control the processor in free running video mode.
|
|
||||||
/// see zbar_processor_set_active()
|
|
||||||
void set_active (bool active = true)
|
|
||||||
{
|
|
||||||
if(zbar_processor_set_active(_processor, active) < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve decode results for last scanned image.
|
|
||||||
/// @see zbar_processor_get_results()
|
|
||||||
/// @since 0.10
|
|
||||||
const SymbolSet get_results () const {
|
|
||||||
return(SymbolSet(zbar_processor_get_results(_processor)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// wait for input to the display window from the user.
|
|
||||||
/// see zbar_processor_user_wait()
|
|
||||||
int user_wait (int timeout = FOREVER)
|
|
||||||
{
|
|
||||||
int rc = zbar_processor_user_wait(_processor, timeout);
|
|
||||||
if(rc < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
return(rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process from the video stream until a result is available.
|
|
||||||
/// see zbar_process_one()
|
|
||||||
void process_one (int timeout = FOREVER)
|
|
||||||
{
|
|
||||||
if(zbar_process_one(_processor, timeout) < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process the provided image for barcodes.
|
|
||||||
/// see zbar_process_image()
|
|
||||||
void process_image (Image& image)
|
|
||||||
{
|
|
||||||
if(zbar_process_image(_processor, image) < 0)
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process the provided image for barcodes.
|
|
||||||
/// see zbar_process_image()
|
|
||||||
Processor& operator<< (Image& image)
|
|
||||||
{
|
|
||||||
process_image(image);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// force specific input and output formats for debug/testing.
|
|
||||||
/// see zbar_processor_force_format()
|
|
||||||
void force_format (unsigned long input_format,
|
|
||||||
unsigned long output_format)
|
|
||||||
{
|
|
||||||
if(zbar_processor_force_format(_processor, input_format,
|
|
||||||
output_format))
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// force specific input and output formats for debug/testing.
|
|
||||||
/// see zbar_processor_force_format()
|
|
||||||
void force_format (std::string& input_format,
|
|
||||||
std::string& output_format)
|
|
||||||
{
|
|
||||||
unsigned long ifourcc = zbar_fourcc_parse(input_format.c_str());
|
|
||||||
unsigned long ofourcc = zbar_fourcc_parse(output_format.c_str());
|
|
||||||
if(zbar_processor_force_format(_processor, ifourcc, ofourcc))
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred size for the video image from the device.
|
|
||||||
/// see zbar_processor_request_size()
|
|
||||||
/// @since 0.6
|
|
||||||
void request_size (int width, int height)
|
|
||||||
{
|
|
||||||
zbar_processor_request_size(_processor, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred driver interface version for debug/testing.
|
|
||||||
/// see zbar_processor_request_interface()
|
|
||||||
/// @since 0.6
|
|
||||||
void request_interface (int version)
|
|
||||||
{
|
|
||||||
zbar_processor_request_interface(_processor, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred I/O mode for debug/testing.
|
|
||||||
/// see zbar_processor_request_iomode()
|
|
||||||
/// @since 0.7
|
|
||||||
void request_iomode (int iomode)
|
|
||||||
{
|
|
||||||
if(zbar_processor_request_iomode(_processor, iomode))
|
|
||||||
throw_exception(_processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_processor_t *_processor;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_SCANNER_H_
|
|
||||||
#define _ZBAR_SCANNER_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Scanner C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Scanner.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// low-level linear intensity sample stream scanner interface.
|
|
||||||
/// identifies "bar" edges and measures width between them.
|
|
||||||
/// optionally passes to bar width Decoder
|
|
||||||
|
|
||||||
class Scanner {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
/// @param decoder reference to a Decoder instance which will
|
|
||||||
/// be passed scan results automatically
|
|
||||||
Scanner (Decoder& decoder)
|
|
||||||
{
|
|
||||||
_scanner = zbar_scanner_create(decoder._decoder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
/// @param decoder pointer to a Decoder instance which will
|
|
||||||
/// be passed scan results automatically
|
|
||||||
Scanner (Decoder* decoder = NULL)
|
|
||||||
{
|
|
||||||
zbar_decoder_t *zdcode = NULL;
|
|
||||||
if(decoder)
|
|
||||||
zdcode = decoder->_decoder;
|
|
||||||
_scanner = zbar_scanner_create(zdcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Scanner ()
|
|
||||||
{
|
|
||||||
zbar_scanner_destroy(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// clear all scanner state.
|
|
||||||
/// see zbar_scanner_reset()
|
|
||||||
void reset ()
|
|
||||||
{
|
|
||||||
zbar_scanner_reset(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// mark start of a new scan pass.
|
|
||||||
/// see zbar_scanner_new_scan()
|
|
||||||
zbar_symbol_type_t new_scan ()
|
|
||||||
{
|
|
||||||
_type = zbar_scanner_new_scan(_scanner);
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// flush scanner pipeline.
|
|
||||||
/// see zbar_scanner_flush()
|
|
||||||
zbar_symbol_type_t flush ()
|
|
||||||
{
|
|
||||||
_type = zbar_scanner_flush(_scanner);
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next sample intensity value.
|
|
||||||
/// see zbar_scan_y()
|
|
||||||
zbar_symbol_type_t scan_y (int y)
|
|
||||||
{
|
|
||||||
_type = zbar_scan_y(_scanner, y);
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next sample intensity value.
|
|
||||||
/// see zbar_scan_y()
|
|
||||||
Scanner& operator<< (int y)
|
|
||||||
{
|
|
||||||
_type = zbar_scan_y(_scanner, y);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next sample from RGB (or BGR) triple.
|
|
||||||
/// see zbar_scan_rgb24()
|
|
||||||
zbar_symbol_type_t scan_rgb24 (unsigned char *rgb)
|
|
||||||
{
|
|
||||||
_type = zbar_scan_rgb24(_scanner, rgb);
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// process next sample from RGB (or BGR) triple.
|
|
||||||
/// see zbar_scan_rgb24()
|
|
||||||
Scanner& operator<< (unsigned char *rgb)
|
|
||||||
{
|
|
||||||
_type = zbar_scan_rgb24(_scanner, rgb);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last scanned width.
|
|
||||||
/// see zbar_scanner_get_width()
|
|
||||||
unsigned get_width () const
|
|
||||||
{
|
|
||||||
return(zbar_scanner_get_width(_scanner));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last scanned color.
|
|
||||||
/// see zbar_scanner_get_color()
|
|
||||||
zbar_color_t get_color () const
|
|
||||||
{
|
|
||||||
return(zbar_scanner_get_color(_scanner));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve last scan result.
|
|
||||||
zbar_symbol_type_t get_type () const
|
|
||||||
{
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C scanner
|
|
||||||
operator zbar_scanner_t* () const
|
|
||||||
{
|
|
||||||
return(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve C scanner
|
|
||||||
const zbar_scanner_t *get_c_scanner () const
|
|
||||||
{
|
|
||||||
return(_scanner);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_scanner_t *_scanner;
|
|
||||||
zbar_symbol_type_t _type;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,528 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_SYMBOL_H_
|
|
||||||
#define _ZBAR_SYMBOL_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Symbol C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Symbol.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
|
||||||
#include <ostream>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
class SymbolIterator;
|
|
||||||
|
|
||||||
/// container for decoded result symbols associated with an image
|
|
||||||
/// or a composite symbol.
|
|
||||||
|
|
||||||
class SymbolSet {
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
SymbolSet (const zbar_symbol_set_t *syms = NULL)
|
|
||||||
: _syms(syms)
|
|
||||||
{
|
|
||||||
ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
SymbolSet (const SymbolSet& syms)
|
|
||||||
: _syms(syms._syms)
|
|
||||||
{
|
|
||||||
ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// destructor.
|
|
||||||
~SymbolSet ()
|
|
||||||
{
|
|
||||||
ref(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
SymbolSet& operator= (const SymbolSet& syms)
|
|
||||||
{
|
|
||||||
syms.ref();
|
|
||||||
ref(-1);
|
|
||||||
_syms = syms._syms;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// truth testing.
|
|
||||||
bool operator! () const
|
|
||||||
{
|
|
||||||
return(!_syms || !get_size());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// manipulate reference count.
|
|
||||||
void ref (int delta = 1) const
|
|
||||||
{
|
|
||||||
if(_syms)
|
|
||||||
zbar_symbol_set_ref((zbar_symbol_set_t*)_syms, delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C symbol set.
|
|
||||||
operator const zbar_symbol_set_t* () const
|
|
||||||
{
|
|
||||||
return(_syms);
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_size () const
|
|
||||||
{
|
|
||||||
return((_syms) ? zbar_symbol_set_get_size(_syms) : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// create a new SymbolIterator over decoded results.
|
|
||||||
SymbolIterator symbol_begin() const;
|
|
||||||
|
|
||||||
/// return a SymbolIterator suitable for ending iteration.
|
|
||||||
const SymbolIterator symbol_end() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const zbar_symbol_set_t *_syms;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// decoded barcode symbol result object. stores type, data, and
|
|
||||||
/// image location of decoded symbol
|
|
||||||
|
|
||||||
class Symbol {
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// image pixel location (x, y) coordinate tuple.
|
|
||||||
class Point {
|
|
||||||
public:
|
|
||||||
int x; ///< x-coordinate.
|
|
||||||
int y; ///< y-coordinate.
|
|
||||||
|
|
||||||
Point () { }
|
|
||||||
|
|
||||||
Point(int x, int y)
|
|
||||||
: x(x), y(y)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
Point (const Point& pt)
|
|
||||||
: x(pt.x),
|
|
||||||
y(pt.y)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
Point& operator= (const Point& pt)
|
|
||||||
{
|
|
||||||
x = pt.x;
|
|
||||||
y = pt.y;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// iteration over Point objects in a symbol location polygon.
|
|
||||||
class PointIterator
|
|
||||||
: public std::iterator<std::input_iterator_tag, Point> {
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
PointIterator (const Symbol *sym = NULL,
|
|
||||||
int index = 0)
|
|
||||||
: _sym(sym),
|
|
||||||
_index(index)
|
|
||||||
{
|
|
||||||
sym->ref(1);
|
|
||||||
if(!sym ||
|
|
||||||
(unsigned)_index >= zbar_symbol_get_loc_size(*_sym))
|
|
||||||
_index = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
PointIterator (const PointIterator& iter)
|
|
||||||
: _sym(iter._sym),
|
|
||||||
_index(iter._index)
|
|
||||||
{
|
|
||||||
_sym->ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// destructor.
|
|
||||||
~PointIterator ()
|
|
||||||
{
|
|
||||||
_sym->ref(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
PointIterator& operator= (const PointIterator& iter)
|
|
||||||
{
|
|
||||||
iter._sym->ref();
|
|
||||||
_sym->ref(-1);
|
|
||||||
_sym = iter._sym;
|
|
||||||
_index = iter._index;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// truth testing.
|
|
||||||
bool operator! () const
|
|
||||||
{
|
|
||||||
return(!_sym || _index < 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// advance iterator to next Point.
|
|
||||||
PointIterator& operator++ ()
|
|
||||||
{
|
|
||||||
unsigned int i = ++_index;
|
|
||||||
if(i >= zbar_symbol_get_loc_size(*_sym))
|
|
||||||
_index = -1;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve currently referenced Point.
|
|
||||||
const Point operator* () const
|
|
||||||
{
|
|
||||||
assert(!!*this);
|
|
||||||
if(!*this)
|
|
||||||
return(Point());
|
|
||||||
return(Point(zbar_symbol_get_loc_x(*_sym, _index),
|
|
||||||
zbar_symbol_get_loc_y(*_sym, _index)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two iterators refer to the same Point in the same
|
|
||||||
/// Symbol.
|
|
||||||
bool operator== (const PointIterator& iter) const
|
|
||||||
{
|
|
||||||
return(_index == iter._index &&
|
|
||||||
((_index < 0) || _sym == iter._sym));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two iterators refer to the same Point in the same
|
|
||||||
/// Symbol.
|
|
||||||
bool operator!= (const PointIterator& iter) const
|
|
||||||
{
|
|
||||||
return(!(*this == iter));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const Symbol *_sym;
|
|
||||||
int _index;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Symbol (const zbar_symbol_t *sym = NULL)
|
|
||||||
: _xmlbuf(NULL),
|
|
||||||
_xmllen(0)
|
|
||||||
{
|
|
||||||
init(sym);
|
|
||||||
ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
Symbol (const Symbol& sym)
|
|
||||||
: _sym(sym._sym),
|
|
||||||
_type(sym._type),
|
|
||||||
_data(sym._data),
|
|
||||||
_xmlbuf(NULL),
|
|
||||||
_xmllen(0)
|
|
||||||
{
|
|
||||||
ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// destructor.
|
|
||||||
~Symbol () {
|
|
||||||
if(_xmlbuf)
|
|
||||||
free(_xmlbuf);
|
|
||||||
ref(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
Symbol& operator= (const Symbol& sym)
|
|
||||||
{
|
|
||||||
sym.ref(1);
|
|
||||||
ref(-1);
|
|
||||||
_sym = sym._sym;
|
|
||||||
_type = sym._type;
|
|
||||||
_data = sym._data;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Symbol& operator= (const zbar_symbol_t *sym)
|
|
||||||
{
|
|
||||||
if(sym)
|
|
||||||
zbar_symbol_ref(sym, 1);
|
|
||||||
ref(-1);
|
|
||||||
init(sym);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// truth testing.
|
|
||||||
bool operator! () const
|
|
||||||
{
|
|
||||||
return(!_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ref (int delta = 1) const
|
|
||||||
{
|
|
||||||
if(_sym)
|
|
||||||
zbar_symbol_ref((zbar_symbol_t*)_sym, delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C symbol.
|
|
||||||
operator const zbar_symbol_t* () const
|
|
||||||
{
|
|
||||||
return(_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two Symbol objects refer to the same C symbol.
|
|
||||||
bool operator== (const Symbol& sym) const
|
|
||||||
{
|
|
||||||
return(_sym == sym._sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two Symbol objects refer to the same C symbol.
|
|
||||||
bool operator!= (const Symbol& sym) const
|
|
||||||
{
|
|
||||||
return(!(*this == sym));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve type of decoded symbol.
|
|
||||||
zbar_symbol_type_t get_type () const
|
|
||||||
{
|
|
||||||
return(_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the string name of the symbol type.
|
|
||||||
const std::string get_type_name () const
|
|
||||||
{
|
|
||||||
return(zbar_get_symbol_name(_type));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve the string name for any addon.
|
|
||||||
/// @deprecated in 0.11
|
|
||||||
const std::string get_addon_name () const
|
|
||||||
{
|
|
||||||
return(zbar_get_addon_name(_type));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve data decoded from symbol.
|
|
||||||
const std::string get_data () const
|
|
||||||
{
|
|
||||||
return(_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve length of binary data
|
|
||||||
unsigned get_data_length () const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_data_length(_sym) : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve inter-frame coherency count.
|
|
||||||
/// see zbar_symbol_get_count()
|
|
||||||
/// @since 1.5
|
|
||||||
int get_count () const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_count(_sym) : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SymbolSet get_components () const
|
|
||||||
{
|
|
||||||
return(SymbolSet((_sym) ? zbar_symbol_get_components(_sym) : NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// create a new PointIterator at the start of the location
|
|
||||||
/// polygon.
|
|
||||||
PointIterator point_begin() const
|
|
||||||
{
|
|
||||||
return(PointIterator(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// return a PointIterator suitable for ending iteration.
|
|
||||||
const PointIterator point_end() const
|
|
||||||
{
|
|
||||||
return(PointIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_get_loc_size().
|
|
||||||
int get_location_size () const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_loc_size(_sym) : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_get_loc_x().
|
|
||||||
int get_location_x (unsigned index) const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_loc_x(_sym, index) : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_get_loc_y().
|
|
||||||
int get_location_y (unsigned index) const
|
|
||||||
{
|
|
||||||
return((_sym) ? zbar_symbol_get_loc_y(_sym, index) : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_get_orientation().
|
|
||||||
/// @since 0.11
|
|
||||||
int get_orientation () const
|
|
||||||
{
|
|
||||||
return(zbar_symbol_get_orientation(_sym));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// see zbar_symbol_xml().
|
|
||||||
const std::string xml () const
|
|
||||||
{
|
|
||||||
if(!_sym)
|
|
||||||
return("");
|
|
||||||
return(zbar_symbol_xml(_sym, (char**)&_xmlbuf, (unsigned*)&_xmllen));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/// (re)initialize Symbol from C symbol object.
|
|
||||||
void init (const zbar_symbol_t *sym = NULL)
|
|
||||||
{
|
|
||||||
_sym = sym;
|
|
||||||
if(sym) {
|
|
||||||
_type = zbar_symbol_get_type(sym);
|
|
||||||
_data = std::string(zbar_symbol_get_data(sym),
|
|
||||||
zbar_symbol_get_data_length(sym));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_type = ZBAR_NONE;
|
|
||||||
_data = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const zbar_symbol_t *_sym;
|
|
||||||
zbar_symbol_type_t _type;
|
|
||||||
std::string _data;
|
|
||||||
char *_xmlbuf;
|
|
||||||
unsigned _xmllen;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// iteration over Symbol result objects in a scanned Image or SymbolSet.
|
|
||||||
class SymbolIterator
|
|
||||||
: public std::iterator<std::input_iterator_tag, Symbol> {
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// default constructor.
|
|
||||||
SymbolIterator ()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
SymbolIterator (const SymbolSet &syms)
|
|
||||||
: _syms(syms)
|
|
||||||
{
|
|
||||||
const zbar_symbol_set_t *zsyms = _syms;
|
|
||||||
if(zsyms)
|
|
||||||
_sym = zbar_symbol_set_first_symbol(zsyms);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// copy constructor.
|
|
||||||
SymbolIterator (const SymbolIterator& iter)
|
|
||||||
: _syms(iter._syms)
|
|
||||||
{
|
|
||||||
const zbar_symbol_set_t *zsyms = _syms;
|
|
||||||
if(zsyms)
|
|
||||||
_sym = zbar_symbol_set_first_symbol(zsyms);
|
|
||||||
}
|
|
||||||
|
|
||||||
~SymbolIterator ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// assignment.
|
|
||||||
SymbolIterator& operator= (const SymbolIterator& iter)
|
|
||||||
{
|
|
||||||
_syms = iter._syms;
|
|
||||||
_sym = iter._sym;
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator! () const
|
|
||||||
{
|
|
||||||
return(!_syms || !_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// advance iterator to next Symbol.
|
|
||||||
SymbolIterator& operator++ ()
|
|
||||||
{
|
|
||||||
if(!!_sym)
|
|
||||||
_sym = zbar_symbol_next(_sym);
|
|
||||||
else if(!!_syms)
|
|
||||||
_sym = zbar_symbol_set_first_symbol(_syms);
|
|
||||||
return(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve currently referenced Symbol.
|
|
||||||
const Symbol operator* () const
|
|
||||||
{
|
|
||||||
return(_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// access currently referenced Symbol.
|
|
||||||
const Symbol* operator-> () const
|
|
||||||
{
|
|
||||||
return(&_sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two iterators refer to the same Symbol
|
|
||||||
bool operator== (const SymbolIterator& iter) const
|
|
||||||
{
|
|
||||||
// it is enough to test the symbols, as they belong
|
|
||||||
// to only one set (also simplifies invalid case)
|
|
||||||
return(_sym == iter._sym);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// test if two iterators refer to the same Symbol
|
|
||||||
bool operator!= (const SymbolIterator& iter) const
|
|
||||||
{
|
|
||||||
return(!(*this == iter));
|
|
||||||
}
|
|
||||||
|
|
||||||
const SymbolIterator end () const {
|
|
||||||
return(SymbolIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
SymbolSet _syms;
|
|
||||||
Symbol _sym;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline SymbolIterator SymbolSet::symbol_begin () const {
|
|
||||||
return(SymbolIterator(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const SymbolIterator SymbolSet::symbol_end () const {
|
|
||||||
return(SymbolIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @relates Symbol
|
|
||||||
/// stream the string representation of a Symbol.
|
|
||||||
static inline std::ostream& operator<< (std::ostream& out,
|
|
||||||
const Symbol& sym)
|
|
||||||
{
|
|
||||||
out << sym.get_type_name() << ":" << sym.get_data();
|
|
||||||
return(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_VIDEO_H_
|
|
||||||
#define _ZBAR_VIDEO_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Video Input C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Video.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Image.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// mid-level video source abstraction.
|
|
||||||
/// captures images from a video device
|
|
||||||
|
|
||||||
class Video {
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
Video (zbar_video_t *video = NULL)
|
|
||||||
{
|
|
||||||
if(video)
|
|
||||||
_video = video;
|
|
||||||
else
|
|
||||||
_video = zbar_video_create();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Video (std::string& device)
|
|
||||||
{
|
|
||||||
_video = zbar_video_create();
|
|
||||||
open(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Video ()
|
|
||||||
{
|
|
||||||
zbar_video_destroy(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C video object.
|
|
||||||
operator zbar_video_t* () const
|
|
||||||
{
|
|
||||||
return(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// open and probe a video device.
|
|
||||||
void open (std::string& device)
|
|
||||||
{
|
|
||||||
if(zbar_video_open(_video, device.c_str()))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// close video device if open.
|
|
||||||
void close ()
|
|
||||||
{
|
|
||||||
if(zbar_video_open(_video, NULL))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// initialize video using a specific format for debug.
|
|
||||||
/// see zbar_video_init()
|
|
||||||
void init (unsigned long fourcc)
|
|
||||||
{
|
|
||||||
if(zbar_video_init(_video, fourcc))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// initialize video using a specific format for debug.
|
|
||||||
/// see zbar_video_init()
|
|
||||||
void init (std::string& format)
|
|
||||||
{
|
|
||||||
unsigned int fourcc = zbar_fourcc_parse(format.c_str());
|
|
||||||
if(zbar_video_init(_video, fourcc))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve file descriptor associated with open *nix video device.
|
|
||||||
/// see zbar_video_get_fd()
|
|
||||||
int get_fd ()
|
|
||||||
{
|
|
||||||
return(zbar_video_get_fd(_video));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve current output image width.
|
|
||||||
/// see zbar_video_get_width()
|
|
||||||
int get_width ()
|
|
||||||
{
|
|
||||||
return(zbar_video_get_width(_video));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve current output image height.
|
|
||||||
/// see zbar_video_get_height()
|
|
||||||
int get_height ()
|
|
||||||
{
|
|
||||||
return(zbar_video_get_height(_video));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// start/stop video capture.
|
|
||||||
/// see zbar_video_enable()
|
|
||||||
void enable (bool enable = true)
|
|
||||||
{
|
|
||||||
if(zbar_video_enable(_video, enable))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve next captured image.
|
|
||||||
/// see zbar_video_next_image()
|
|
||||||
Image next_image ()
|
|
||||||
{
|
|
||||||
zbar_image_t *img = zbar_video_next_image(_video);
|
|
||||||
if(!img)
|
|
||||||
throw_exception(_video);
|
|
||||||
return(Image(img));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred size for the video image from the device.
|
|
||||||
/// see zbar_video_request_size()
|
|
||||||
/// @since 0.6
|
|
||||||
void request_size (int width, int height)
|
|
||||||
{
|
|
||||||
zbar_video_request_size(_video, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred driver interface version for debug/testing.
|
|
||||||
/// see zbar_video_request_interface()
|
|
||||||
/// @since 0.6
|
|
||||||
void request_interface (int version)
|
|
||||||
{
|
|
||||||
zbar_video_request_interface(_video, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// request a preferred I/O mode for debug/testing.
|
|
||||||
/// see zbar_video_request_iomode()
|
|
||||||
/// @since 0.7
|
|
||||||
void request_iomode (int iomode)
|
|
||||||
{
|
|
||||||
if(zbar_video_request_iomode(_video, iomode))
|
|
||||||
throw_exception(_video);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_video_t *_video;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
//
|
|
||||||
// This file is part of the ZBar Bar Code Reader.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
// and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2.1 of
|
|
||||||
// the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser Public License
|
|
||||||
// along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
// Boston, MA 02110-1301 USA
|
|
||||||
//
|
|
||||||
// http://sourceforge.net/projects/zbar
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
#ifndef _ZBAR_WINDOW_H_
|
|
||||||
#define _ZBAR_WINDOW_H_
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
/// Output Window C++ wrapper
|
|
||||||
|
|
||||||
#ifndef _ZBAR_H_
|
|
||||||
# error "include zbar.h in your application, **not** zbar/Window.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Image.h"
|
|
||||||
|
|
||||||
namespace zbar {
|
|
||||||
|
|
||||||
/// mid-level output window abstraction.
|
|
||||||
/// displays images to user-specified platform specific output window
|
|
||||||
|
|
||||||
class Window {
|
|
||||||
public:
|
|
||||||
/// constructor.
|
|
||||||
Window (zbar_window_t *window = NULL)
|
|
||||||
{
|
|
||||||
if(window)
|
|
||||||
_window = window;
|
|
||||||
else
|
|
||||||
_window = zbar_window_create();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// constructor.
|
|
||||||
Window (void *x11_display_w32_hwnd,
|
|
||||||
unsigned long x11_drawable)
|
|
||||||
{
|
|
||||||
_window = zbar_window_create();
|
|
||||||
attach(x11_display_w32_hwnd, x11_drawable);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Window ()
|
|
||||||
{
|
|
||||||
zbar_window_destroy(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// cast to C window object.
|
|
||||||
operator zbar_window_t* () const
|
|
||||||
{
|
|
||||||
return(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// associate reader with an existing platform window.
|
|
||||||
/// see zbar_window_attach()
|
|
||||||
void attach (void *x11_display_w32_hwnd,
|
|
||||||
unsigned long x11_drawable = 0)
|
|
||||||
{
|
|
||||||
if(zbar_window_attach(_window,
|
|
||||||
x11_display_w32_hwnd, x11_drawable) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// control content level of the reader overlay.
|
|
||||||
/// see zbar_window_set_overlay()
|
|
||||||
void set_overlay (int level)
|
|
||||||
{
|
|
||||||
zbar_window_set_overlay(_window, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// retrieve current content level of reader overlay.
|
|
||||||
/// see zbar_window_get_overlay()
|
|
||||||
|
|
||||||
/// draw a new image into the output window.
|
|
||||||
/// see zbar_window_draw()
|
|
||||||
void draw (Image& image)
|
|
||||||
{
|
|
||||||
if(zbar_window_draw(_window, image) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// clear the image from the output window.
|
|
||||||
/// see zbar_window_draw()
|
|
||||||
void clear ()
|
|
||||||
{
|
|
||||||
if(zbar_window_draw(_window, NULL) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// redraw the last image.
|
|
||||||
/// zbar_window_redraw()
|
|
||||||
void redraw ()
|
|
||||||
{
|
|
||||||
if(zbar_window_redraw(_window) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// resize the image window.
|
|
||||||
/// zbar_window_resize()
|
|
||||||
void resize (unsigned width, unsigned height)
|
|
||||||
{
|
|
||||||
if(zbar_window_resize(_window, width, height) < 0)
|
|
||||||
throw_exception(_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
zbar_window_t *_window;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// select a compatible format between video input and output window.
|
|
||||||
/// see zbar_negotiate_format()
|
|
||||||
static inline void negotiate_format (Video& video, Window& window)
|
|
||||||
{
|
|
||||||
if(zbar_negotiate_format(video, window) < 0)
|
|
||||||
throw_exception(video);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
Before Width: | Height: | Size: 319 B |
@@ -1,88 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<!--
|
|
||||||
Copyright 2009-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
All Rights Reserved
|
|
||||||
-->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Barcode Reader Help</title>
|
|
||||||
<style type="text/css">
|
|
||||||
html, body { margin: 0; padding: 0; background: black; color: white; font-family: sans-serif; font-size: 16px }
|
|
||||||
h1 { margin: .5em 0; text-align: center; font-size: 28px }
|
|
||||||
h2 { font-size: 24px }
|
|
||||||
hr { margin: 1em 0; height: 0; border: none; border-top: solid 1px #666 }
|
|
||||||
.smaller { font-size: 85% }
|
|
||||||
p { margin: .5em }
|
|
||||||
a { color: #8af }
|
|
||||||
p.cen { text-align: center }
|
|
||||||
p.title { margin: 1em; clear: both; text-align: center }
|
|
||||||
div.col { width: 50% }
|
|
||||||
.clear { clear: both }
|
|
||||||
.iconlist { position: relative; clear: both; margin: 4px 0; padding: 1px 0 }
|
|
||||||
.icon { width: 64px; height: 64px; overflow: hidden; margin: 12px 16px; padding: 0; background: url("zbar-helpicons.png") no-repeat; font: bold 56px "Marker Felt"; text-align: center }
|
|
||||||
.sample { display: block; height: 96px; overflow: hidden; margin: 12px auto; padding: 0; background: url("zbar-samples.png") no-repeat; text-align: center}
|
|
||||||
.left { float: left }
|
|
||||||
.right { float: right }
|
|
||||||
.iconlist > p { margin: 10px }
|
|
||||||
.iconlist > h2 { margin: 10px }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 id="title" style="color: #f88">Barcode Reader Help</h1>
|
|
||||||
<hr/>
|
|
||||||
<p class="title">Recognized barcodes should look like</p>
|
|
||||||
<div class="col left">
|
|
||||||
<a class="sample" style="width: 118px; background-position: -96px" href="http://wikipedia.org/wiki/EAN-13"></a>
|
|
||||||
<p class="cen"><a href="http://wikipedia.org/wiki/EAN-13">EAN/UPC<br/>Product Codes</a></p>
|
|
||||||
</div>
|
|
||||||
<div class="col right">
|
|
||||||
<a class="sample" style="width: 96px" href="http://wikipedia.org/wiki/QR_Code"></a>
|
|
||||||
<p class="cen"><a href="http://wikipedia.org/wiki/QR_Code">QR Codes</a></p>
|
|
||||||
</div>
|
|
||||||
<p class="clear cen smaller">Also recognized, but not shown:
|
|
||||||
<a href="http://wikipedia.org/wiki/Code_128">Code 128</a>,
|
|
||||||
<a href="http://wikipedia.org/wiki/DataBar">DataBar (RSS)</a>,
|
|
||||||
<a href="http://en.wikipedia.org/wiki/Code_93">Code 93</a>,
|
|
||||||
<a href="http://wikipedia.org/wiki/Code_39">Code 39</a> and
|
|
||||||
<a href="http://wikipedia.org/wiki/Interleaved_2_of_5">Interleaved 2 of 5</a></p>
|
|
||||||
<hr/>
|
|
||||||
<p class="clear title">Hints for successful scanning</p>
|
|
||||||
<div class="iconlist">
|
|
||||||
<div class="icon left"></div>
|
|
||||||
<p>Ensure there is plenty of</p>
|
|
||||||
<h2 style="color: #ff4">Light</h2>
|
|
||||||
</div>
|
|
||||||
<div class="iconlist">
|
|
||||||
<div class="icon left" style="background: none; color: #2d4">4"</div>
|
|
||||||
<h2 style="color: #4f6">Distance</h2>
|
|
||||||
<p>should be about 3 to 5 inches</p>
|
|
||||||
</div>
|
|
||||||
<div class="iconlist">
|
|
||||||
<div class="icon left" style="background-position: 0 -64px"></div>
|
|
||||||
<h2 style="color: #3ee">Shake</h2>
|
|
||||||
<p>to force the camera to focus</p>
|
|
||||||
</div>
|
|
||||||
<div class="iconlist">
|
|
||||||
<div class="icon left" style="background-position: 0 -128px"></div>
|
|
||||||
<h2 style="color: #59f">Wait</h2>
|
|
||||||
<p>for the autofocus to finish</p>
|
|
||||||
</div>
|
|
||||||
<div class="iconlist">
|
|
||||||
<div class="icon left" style="background-position: 0 -192px"></div>
|
|
||||||
<h2 style="color: #d5f">Hold Still</h2>
|
|
||||||
<p>while the barcode is scanned</p>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
function onZBarHelp(argv) {
|
|
||||||
var title;
|
|
||||||
switch(argv.reason) {
|
|
||||||
case "INFO": break;
|
|
||||||
case "FAIL": title = "No Barcode Detected"; break;
|
|
||||||
}
|
|
||||||
if(title) document.getElementById('title').textContent = title;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |