我在我的 iOS 项目中链接了 Anyline 框架。在框架的示例源代码中,我构建并运行应用程序时没有错误,但如果我尝试将其导入我的项目并运行应用程序,则会出现运行时错误 EXC_BAD_ACCESS。我尝试打印并阅读回溯,但看不到错误在哪里。你能帮助我吗?
这里是回溯的内容:
thread #12, queue = 'com.apple.avfoundation.videodataoutput.bufferqueue', stop reason = EXC_BAD_ACCESS (code=1, address=0x2b002010040)
frame #0: 0x000000010016f858 ARAMIS`cv::Mat::copyTo(cv::_OutputArray const&) const + 56
frame #1: 0x000000010062af30 ARAMIS`-[AnylineVideoView convertBGRABufferToImage:] + 1772
frame #2: 0x000000010062a11c ARAMIS`-[AnylineVideoView _processBufferFromDevice:] + 612
frame #3: 0x0000000100629e04 ARAMIS`-[AnylineVideoView captureOutput:didOutputSampleBuffer:fromConnection:] + 72
frame #4: 0x000000018bca1310 AVFoundation`-[AVCaptureVideoDataOutput _handleRemoteQueueOperation:] + 308
frame #5: 0x000000018bca114c AVFoundation`__47-[AVCaptureVideoDataOutput _updateRemoteQueue:]_block_invoke + 100
frame #6: 0x0000000186b71f68 CoreMedia`__FigRemoteOperationReceiverCreateMessageReceiver_block_invoke + 260
frame #7: 0x0000000186b90e9c CoreMedia`__FigRemoteQueueReceiverSetHandler_block_invoke.2 + 224
frame #8: 0x00000001022f9a10 libdispatch.dylib`_dispatch_client_callout + 16
frame #9: 0x0000000102305a84 libdispatch.dylib`_dispatch_continuation_pop + 552
frame #10: 0x00000001023141f8 libdispatch.dylib`_dispatch_source_latch_and_call + 204
frame #11: 0x00000001022fba60 libdispatch.dylib`_dispatch_source_invoke + 828
frame #12: 0x0000000102307128 libdispatch.dylib`_dispatch_queue_serial_drain + 692
frame #13: 0x00000001022fd634 libdispatch.dylib`_dispatch_queue_invoke + 852
frame #14: 0x0000000102307128 libdispatch.dylib`_dispatch_queue_serial_drain + 692
frame #15: 0x00000001022fd634 libdispatch.dylib`_dispatch_queue_invoke + 852
frame #16: 0x0000000102308358 libdispatch.dylib`_dispatch_root_queue_drain_deferred_item + 276
frame #17: 0x000000010231057c libdispatch.dylib`_dispatch_kevent_worker_thread + 764
frame #18: 0x0000000183312fbc libsystem_pthread.dylib`_pthread_wqthread + 772
frame #19: 0x0000000183312cac libsystem_pthread.dylib`start_wqthread + 4
这里的代码:
#import "ALISBNScanViewController.h"
#import <Anyline/Anyline.h>
NSString * const kISBNLicenseKey = Anyline_LICENSE_KEY;
@interface ALISBNScanViewController ()<AnylineOCRModuleDelegate>
// The Anyline module used for OCR
@property (nonatomic, strong) AnylineOCRModuleView *ocrModuleView;
@end
@implementation ALISBNScanViewController
/*
We will do our main setup in viewDidLoad. Its called once the view controller is getting ready to be displayed.
*/
- (void)viewDidLoad {
[super viewDidLoad];
// Set the background color to black to have a nicer transition
self.view.backgroundColor = [UIColor blackColor];
self.title = @"Text Recognition";
// Initializing the module. Its a UIView subclass. We set the frame to fill the whole screen
CGRect frame = [[UIScreen mainScreen] applicationFrame];
frame = CGRectMake(frame.origin.x, frame.origin.y + self.navigationController.navigationBar.frame.size.height, frame.size.width, frame.size.height - self.navigationController.navigationBar.frame.size.height);
self.ocrModuleView = [[AnylineOCRModuleView alloc] initWithFrame:frame];
ALOCRConfig *config = [[ALOCRConfig alloc] init];
config.tesseractLanguages = @[@"eng_no_dict", @"deu"];
config.charWhiteList = @"PMMDOBCPSKA1234_/ ";
config.scanMode = ALAuto;
NSError *error = nil;
BOOL success = [self.ocrModuleView setupWithLicenseKey:kISBNLicenseKey delegate:self ocrConfig:config error:&error];
if (!success) {
NSAssert(success, @"Setup Error: %@", error.debugDescription);
}
NSString *confPath = [[NSBundle mainBundle] pathForResource:@"isbn_config" ofType:@"json"];
ALUIConfiguration *isbnconf = [ALUIConfiguration cutoutConfigurationFromJsonFile:confPath];
self.ocrModuleView.currentConfiguration = isbnconf;
[self.view addSubview:self.ocrModuleView];
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self startAnyline];
}
/*
Cancel scanning to allow the module to clean up
*/
- (void)viewWillDisappear:(BOOL)animated {
[self.ocrModuleView cancelScanningAndReturnError:nil];
}
- (void)startAnyline {
NSError *error;
BOOL success = [self.ocrModuleView startScanningAndReturnError:&error];
if( !success ) {
NSAssert(success, @"Start Scanning Error: %@", error.debugDescription);
}
}
#pragma mark -- AnylineOCRModuleDelegate
/*
This is the main delegate method Anyline uses to report its results
*/
- (void)anylineOCRModuleView:(AnylineOCRModuleView *)anylineOCRModuleView
didFindResult:(ALOCRResult *)result {
NSString *label = result.result;
DLog(@"LABEL:%@",label);
NSString *message = [NSString stringWithFormat:@"Testo riconosciuto: %@",label];
UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"Testo riconosciuto" message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okBtn = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
[alert dismissViewControllerAnimated:YES completion:nil];
[self startAnyline];
}];
[alert addAction:okBtn];
[self presentViewController:alert animated:YES completion:nil];
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSError *error = nil;
BOOL success = [self.ocrModuleView startScanningAndReturnError:&error];
NSAssert(success, @"We failed starting: %@",error.debugDescription);
}
@end
谢谢