Skip to content

Commit

Permalink
Updated projects
Browse files Browse the repository at this point in the history
  • Loading branch information
ci-bot committed Sep 5, 2023
1 parent fe2572d commit 99662ee
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class MainViewController: UIViewController {
var imagePicker = UIImagePickerController()
private var sectionsData: [CustomizationSection] = []
private var pickerImages: [UIImage] = []
private var selectedScenario: String?

var isCustomUILayerEnabled: Bool = false
lazy var animationTimer = Timer.scheduledTimer(timeInterval: 1.0/60, target: self, selector: #selector(fireTimer), userInfo: nil, repeats: true)
Expand Down Expand Up @@ -342,12 +343,15 @@ class MainViewController: UIViewController {
tableView.isHidden = false
settingsBarButton.isEnabled = true
if let scenario = DocReader.shared.availableScenarios.first {
DocReader.shared.processParams.scenario = scenario.identifier
selectedScenario = scenario.identifier
}
}

private func showScannerForManualMultipage() {
DocReader.shared.showScanner(self) { [weak self] (action, result, error) in
let config = DocReader.ScannerConfig()
config.scenario = selectedScenario

DocReader.shared.showScanner(presenter: self, config:config) { [weak self] (action, result, error) in
guard let self = self else { return }
switch action {
case .cancel:
Expand Down Expand Up @@ -386,8 +390,11 @@ class MainViewController: UIViewController {
let whiteInput = DocReader.ImageInput(image: whiteImage!, light: .white, pageIndex: 0)
let uvInput = DocReader.ImageInput(image: uvImage!, light: .UV, pageIndex: 0)
let irInput = DocReader.ImageInput(image: irImage!, light: .infrared, pageIndex: 0)
let imageInputs = [whiteInput, irInput, uvInput]

DocReader.shared.recognizeImages(with: [whiteInput, irInput, uvInput]) { action, results, error in
let config = DocReader.RecognizeConfig(imageInputs: imageInputs)
config.scenario = selectedScenario
DocReader.shared.recognize(config:config) { action, results, error in
switch action {
case .cancel:
self.stopCustomUIChanges()
Expand Down Expand Up @@ -532,7 +539,10 @@ class MainViewController: UIViewController {
}

private func showCameraViewController() {
DocReader.shared.showScanner(self) { [weak self] (action, result, error) in
let config = DocReader.ScannerConfig()
config.scenario = selectedScenario

DocReader.shared.showScanner(presenter: self, config:config) { [weak self] (action, result, error) in
guard let self = self else { return }

switch action {
Expand Down Expand Up @@ -859,7 +869,7 @@ extension MainViewController: UIPickerViewDelegate, UIPickerViewDataSource {

public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
guard DocReader.shared.availableScenarios.indices.contains(row) else { return }
DocReader.shared.processParams.scenario = DocReader.shared.availableScenarios[row].identifier
selectedScenario = DocReader.shared.availableScenarios[row].identifier
}
}

Expand All @@ -880,7 +890,9 @@ extension MainViewController: UIImagePickerControllerDelegate, UINavigationContr
self.present(self.imagePicker, animated: true, completion: nil)
}
let recognizeAction = UIAlertAction(title: "No", style: .default) { _ in
DocReader.shared.recognizeImages(self.pickerImages, completion: { [weak self] (action, results, error) in
let config = DocReader.RecognizeConfig(images:self.pickerImages)
config.scenario = self.selectedScenario
DocReader.shared.recognize(config: config, completion: { [weak self] (action, results, error) in
guard let self = self else { return }
if action == .complete {
guard let results = results else {
Expand Down
4 changes: 2 additions & 2 deletions Advanced/DocumentReader-Swift/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ platform :ios, '11.0'
use_frameworks!

target 'DocumentReader-Swift' do
pod 'DocumentReader', '~> 6.8'
pod 'DocumentReaderFullRFID', '~> 6.8'
pod 'DocumentReader', '~> 6.9'
pod 'DocumentReaderFullRFID', '~> 6.9'
end
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ - (void)captureOutput:(AVCaptureOutput *)output didOutputSampleBuffer:(CMSampleB
if (dispatch_semaphore_wait(self.scanningSemaphore, DISPATCH_TIME_NOW) == 0) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
dispatch_async(self.scaningQueue, ^{
[RGLDocReader.shared recognizeImage:image cameraMode:YES completion:^(RGLDocReaderAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error) {
[RGLDocReader.shared recognizeVideoFrame:image completion:^(RGLDocReaderAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (action == RGLDocReaderActionComplete || action == RGLDocReaderActionMorePagesAvailable) {
[self.delegate recognizeDidFinishedWith:results viewController:self];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ @interface ViewController () <UIPickerViewDelegate, UIPickerViewDataSource,

@property (strong, nonatomic) UIImagePickerController *imagePicker;

@property (strong, nonatomic) NSString *selectedScenario;

@end

@implementation ViewController
Expand Down Expand Up @@ -65,7 +67,7 @@ - (void)initializationReader {

RGLScenario *scenario = [RGLDocReader shared].availableScenarios.firstObject;
if (scenario) {
[RGLDocReader shared].processParams.scenario = scenario.identifier;
self.selectedScenario = scenario.identifier;
}
[RGLDocReader shared].functionality.singleResult = YES;

Expand All @@ -88,7 +90,10 @@ - (void)initializationReader {
}

- (IBAction)useCameraViewController:(UIButton *)sender {
[RGLDocReader.shared showScanner:self completion:^(enum RGLDocReaderAction action, RGLDocumentReaderResults * _Nullable result, NSError * _Nullable error) {
RGLScannerConfig *config = [[RGLScannerConfig alloc] init];
config.scenario = self.selectedScenario;

[RGLDocReader.shared showScannerFromPresenter:self config:config completion:^(enum RGLDocReaderAction action, RGLDocumentReaderResults * _Nullable result, NSError * _Nullable error) {
switch (action) {
case RGLDocReaderActionCancel: {
NSLog(@"Cancelled by user");
Expand Down Expand Up @@ -165,7 +170,9 @@ - (void)getImageFromGallery {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Gallery Unavailable" message:message preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction: [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Settings" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[UIApplication.sharedApplication openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
[UIApplication.sharedApplication openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]
options:@{}
completionHandler:nil];
}]];
[self presentViewController:alertController animated:YES completion:nil];
}
Expand Down Expand Up @@ -203,7 +210,8 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
UIImage *image = info[UIImagePickerControllerOriginalImage];
[self dismissViewControllerAnimated:YES completion:^{

[RGLDocReader.shared recognizeImage:image cameraMode:NO completion:^(RGLDocReaderAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error) {
RGLRecognizeConfig *config = [[RGLRecognizeConfig alloc] initWithImage:image];
[RGLDocReader.shared recognizeWithConfig:config completion:^(RGLDocReaderAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error) {
if (action == RGLDocReaderActionComplete) {
if (results != nil) {
NSLog(@"Completed");
Expand Down Expand Up @@ -231,7 +239,7 @@ - (nullable NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInte
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
RGLDocReader.shared.processParams.scenario = RGLDocReader.shared.availableScenarios[row].identifier;
self.selectedScenario = RGLDocReader.shared.availableScenarios[row].identifier;
}

- (void)recognizeDidFinishedWith:(RGLDocumentReaderResults *)results viewController:(RGRecognizeImageViewController *)viewController {
Expand Down
4 changes: 2 additions & 2 deletions Basic/DocumentReaderObjectiveC-sample/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
platform :ios, '11.0'

target 'DocumentReaderFullObjectiveC-sample' do
pod 'DocumentReader', '~> 6.8'
pod 'DocumentReaderFullRFID', '~> 6.8'
pod 'DocumentReader', '~> 6.9'
pod 'DocumentReaderFullRFID', '~> 6.9'
end
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class ViewController: UIViewController {

var imagePicker = UIImagePickerController()

private var selectedScenario: String?

override func viewDidLoad() {
super.viewDidLoad()
initializationReader()
Expand Down Expand Up @@ -64,7 +66,7 @@ class ViewController: UIViewController {

//set scenario
if let firstScenario = DocReader.shared.availableScenarios.first {
DocReader.shared.processParams.scenario = firstScenario.identifier
self.selectedScenario = firstScenario.identifier
}

} else {
Expand All @@ -86,7 +88,10 @@ class ViewController: UIViewController {
}

@IBAction func useCameraViewController(_ sender: UIButton) {
DocReader.shared.showScanner(self) { (action, result, error) in
let config = DocReader.ScannerConfig()
config.scenario = selectedScenario

DocReader.shared.showScanner(presenter: self, config: config) { (action, result, error) in
if action == .complete {
print("Completed")
if self.readRFID.isOn && result?.chipPage != 0 {
Expand Down Expand Up @@ -204,8 +209,9 @@ extension ViewController: UIImagePickerControllerDelegate, UINavigationControlle

if let image = info[convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey.originalImage)] as? UIImage {
self.dismiss(animated: true, completion: {

DocReader.shared.recognizeImage(image, completion: { (action, result, error) in
let config = DocReader.RecognizeConfig(image: image)
config.scenario = self.selectedScenario
DocReader.shared.recognize(config: config) { (action, result, error) in
if action == .complete {
if result != nil {
print("Completed")
Expand All @@ -219,7 +225,7 @@ extension ViewController: UIImagePickerControllerDelegate, UINavigationControlle
guard let error = error else { return }
print("Eror: \(error)")
}
})
}

})
} else {
Expand All @@ -245,7 +251,7 @@ extension ViewController: UIPickerViewDelegate {
}

public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
DocReader.shared.processParams.scenario = DocReader.shared.availableScenarios[row].identifier
selectedScenario = DocReader.shared.availableScenarios[row].identifier
}
}

Expand Down
4 changes: 2 additions & 2 deletions Basic/DocumentReaderSwift-sample/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ platform :ios, '11.0'
use_frameworks!

target 'DocumentReaderFullSwift-sample' do
pod 'DocumentReader', '~> 6.8'
pod 'DocumentReaderFullRFID', '~> 6.8'
pod 'DocumentReader', '~> 6.9'
pod 'DocumentReaderFullRFID', '~> 6.9'
end
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ extension DocReader {
}.eraseToAnyPublisher()
}

func recognizeImage(image: UIImage) -> AnyPublisher<DocumentReaderResults, Error> {
func recognize(config: DocReader.RecognizeConfig) -> AnyPublisher<DocumentReaderResults, Error> {
Deferred {
Future<DocumentReaderResults, Error> { promise in
DocReader.shared.recognizeImage(image) { _, results, error in
DocReader.shared.recognize(config: config) { _, results, error in
if let error = error {
promise(.failure(error))
} else if let results = results {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,11 @@ class ReaderFacade: ObservableObject {

private func recognize(image: UIImage) -> AnyPublisher<DocumentReaderResults, Error> {
isProcessing = true
let config = DocReader.RecognizeConfig(image: image)
config.scenario = selectedScenario

let recognize = DocReader.shared
.recognizeImage(image: image)
.recognize(config: config)
.mapError { error in
self.isProcessing = false
return error
Expand Down
4 changes: 2 additions & 2 deletions Basic/DocumentReaderSwiftUI-sample/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ target 'DocumentReaderSwiftUI-sample' do
use_frameworks!

# Pods for DocumentReaderSwiftUI-sample
pod 'DocumentReader', '~> 6.8'
pod 'DocumentReaderFullRFID', '~> 6.8'
pod 'DocumentReader', '~> 6.9'
pod 'DocumentReaderFullRFID', '~> 6.9'
end
4 changes: 2 additions & 2 deletions BleDevice/DocumentReaderSwiftBleLicense/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ platform :ios, '11.0'
use_frameworks!

target 'DocumentReaderSwiftBleLicense' do
pod 'DocumentReader', '~> 6.8'
pod 'DocumentReaderFullAuthRFID', '~> 6.8'
pod 'DocumentReader', '~> 6.9'
pod 'DocumentReaderFullAuthRFID', '~> 6.9'
pod 'BTDevice', '~> 6.8'
end
4 changes: 2 additions & 2 deletions RfidCertificates/RfidCertificates-Default-Swift/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ platform :ios, '11.0'
use_frameworks!

target 'RfidCertificates-Default-Swift' do
pod 'DocumentReader', '~> 6.8'
pod 'DocumentReaderFullRFID', '~> 6.8'
pod 'DocumentReader', '~> 6.9'
pod 'DocumentReaderFullRFID', '~> 6.9'
end

0 comments on commit 99662ee

Please sign in to comment.