diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 00:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 00:06:44 +0000 |
commit | 44cf8ec67278bd1ab6c7f83a9993f7a5686a9541 (patch) | |
tree | 5eec4b0d1a3f163d279c3c27c03324ba49fa235a /iphone/include/ZBarSDK | |
parent | Initial commit. (diff) | |
download | zbar-upstream.tar.xz zbar-upstream.zip |
Adding upstream version 0.23.93.upstream/0.23.93upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'iphone/include/ZBarSDK')
-rw-r--r-- | iphone/include/ZBarSDK/ZBarCameraSimulator.h | 42 | ||||
-rw-r--r-- | iphone/include/ZBarSDK/ZBarCaptureReader.h | 109 | ||||
-rw-r--r-- | iphone/include/ZBarSDK/ZBarHelpController.h | 59 | ||||
-rw-r--r-- | iphone/include/ZBarSDK/ZBarImage.h | 64 | ||||
-rw-r--r-- | iphone/include/ZBarSDK/ZBarImageScanner.h | 50 | ||||
-rw-r--r-- | iphone/include/ZBarSDK/ZBarReaderController.h | 139 | ||||
-rw-r--r-- | iphone/include/ZBarSDK/ZBarReaderView.h | 137 | ||||
-rw-r--r-- | iphone/include/ZBarSDK/ZBarReaderViewController.h | 132 | ||||
-rw-r--r-- | iphone/include/ZBarSDK/ZBarSDK.h | 34 | ||||
-rw-r--r-- | iphone/include/ZBarSDK/ZBarSymbol.h | 67 |
10 files changed, 833 insertions, 0 deletions
diff --git a/iphone/include/ZBarSDK/ZBarCameraSimulator.h b/iphone/include/ZBarSDK/ZBarCameraSimulator.h new file mode 100644 index 0000000..7351d92 --- /dev/null +++ b/iphone/include/ZBarSDK/ZBarCameraSimulator.h @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------ +// 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 diff --git a/iphone/include/ZBarSDK/ZBarCaptureReader.h b/iphone/include/ZBarSDK/ZBarCaptureReader.h new file mode 100644 index 0000000..e496819 --- /dev/null +++ b/iphone/include/ZBarSDK/ZBarCaptureReader.h @@ -0,0 +1,109 @@ +//------------------------------------------------------------------------ +// 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 diff --git a/iphone/include/ZBarSDK/ZBarHelpController.h b/iphone/include/ZBarSDK/ZBarHelpController.h new file mode 100644 index 0000000..1733ebd --- /dev/null +++ b/iphone/include/ZBarSDK/ZBarHelpController.h @@ -0,0 +1,59 @@ +//------------------------------------------------------------------------ +// 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 <WebKit/WebKit.h> + +@class ZBarHelpController; + +@protocol ZBarHelpDelegate +@optional + +- (void)helpControllerDidFinish:(ZBarHelpController *)help; + +@end + +// failure dialog w/a few useful tips + +@interface ZBarHelpController + : UIViewController <WKNavigationDelegate, UIAlertViewDelegate> { + NSString *reason; + id delegate; + WKWebView *webView; + UIToolbar *toolbar; + UIBarButtonItem *doneBtn, *backBtn, *space; + NSURL *linkURL; + NSUInteger orientations; + UIView *controls; +} + +@property (nonatomic, assign) id<ZBarHelpDelegate> delegate; + +// designated initializer +- (id)initWithReason:(NSString *)reason; + +- (BOOL)isInterfaceOrientationSupported:(UIInterfaceOrientation)orientation; +- (void)setInterfaceOrientation:(UIInterfaceOrientation)orientation + supported:(BOOL)supported; + +@end diff --git a/iphone/include/ZBarSDK/ZBarImage.h b/iphone/include/ZBarSDK/ZBarImage.h new file mode 100644 index 0000000..5a9e5bc --- /dev/null +++ b/iphone/include/ZBarSDK/ZBarImage.h @@ -0,0 +1,64 @@ +//------------------------------------------------------------------------ +// 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 diff --git a/iphone/include/ZBarSDK/ZBarImageScanner.h b/iphone/include/ZBarSDK/ZBarImageScanner.h new file mode 100644 index 0000000..c3ce1a9 --- /dev/null +++ b/iphone/include/ZBarSDK/ZBarImageScanner.h @@ -0,0 +1,50 @@ +//------------------------------------------------------------------------ +// 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 diff --git a/iphone/include/ZBarSDK/ZBarReaderController.h b/iphone/include/ZBarSDK/ZBarReaderController.h new file mode 100644 index 0000000..84015b1 --- /dev/null +++ b/iphone/include/ZBarSDK/ZBarReaderController.h @@ -0,0 +1,139 @@ +//------------------------------------------------------------------------ +// 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; diff --git a/iphone/include/ZBarSDK/ZBarReaderView.h b/iphone/include/ZBarSDK/ZBarReaderView.h new file mode 100644 index 0000000..f07878b --- /dev/null +++ b/iphone/include/ZBarSDK/ZBarReaderView.h @@ -0,0 +1,137 @@ +//------------------------------------------------------------------------ +// 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 diff --git a/iphone/include/ZBarSDK/ZBarReaderViewController.h b/iphone/include/ZBarSDK/ZBarReaderViewController.h new file mode 100644 index 0000000..643ff1e --- /dev/null +++ b/iphone/include/ZBarSDK/ZBarReaderViewController.h @@ -0,0 +1,132 @@ +//------------------------------------------------------------------------ +// 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 diff --git a/iphone/include/ZBarSDK/ZBarSDK.h b/iphone/include/ZBarSDK/ZBarSDK.h new file mode 100644 index 0000000..902552b --- /dev/null +++ b/iphone/include/ZBarSDK/ZBarSDK.h @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------ + * 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 "ZBarCameraSimulator.h" +#import "ZBarCaptureReader.h" +#import "ZBarHelpController.h" +#import "ZBarImage.h" +#import "ZBarImageScanner.h" +#import "ZBarReaderController.h" +#import "ZBarReaderView.h" +#import "ZBarReaderViewController.h" +#import "ZBarSymbol.h" diff --git a/iphone/include/ZBarSDK/ZBarSymbol.h b/iphone/include/ZBarSDK/ZBarSymbol.h new file mode 100644 index 0000000..ab0557f --- /dev/null +++ b/iphone/include/ZBarSDK/ZBarSymbol.h @@ -0,0 +1,67 @@ +//------------------------------------------------------------------------ +// 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 <CoreGraphics/CoreGraphics.h> +#import <Foundation/Foundation.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 |