captureDocument()

Description

Captures a document.

Syntax

- (void) captureDocument

Parameters

None

Return value

void

Remarks

The function is executed asynchronously. It will first trigger the event onPreCapture, then the capture operation, and finally, trigger the event onPostCapture. Before the event onPostCapture is triggered, the captured document will be added to the current DcsView buffer.

Make sure the current camera is open before calling this method. You can open the camera via preview method.

Exceptions

onCaptureFailure is fired under the following circumstances to receive exceptions.

Circumstance Exception
License verification failed. DcsLicenseVerificationFailedException
The capture mode is not DME_DOCUMENT. DcsOnlySupportedUnderDocumentModeException
The access to the camera is not authorized. DcsCameraNotAuthorizedException
The current camera is not open. DcsCameraNotOpenException

Example


@interface ViewController ()<DcsUIVideoViewDelegate>{
    DcsView *dcsView;
    UIButton *captureButton;
}
@end
 
@implementation ViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    dcsView = [[DcsView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
 
    [self.view addSubview:dcsView];
    //Sets the capture mode to document mode.
    self.dcsView.currentView = DVE_VIDEOVIEW
    self.dcsView.videoView.mode = DME_DOCUMENT;
    
    captureButton = [[UIButton alloc] initWithFrame:CGRectMake(self.view.center.x-100, self.view.center.y-20, 200, 40)];
    [captureButton setTitle:@"Capture Document" forState:normal];
    [captureButton setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
    [captureButton addTarget:self action:@selector(captureDocument) forControlEvents:UIControlEventTouchUpInside];
    [dcsView.videoView addSubview:captureButton];
}
- (void)captureDocument{
    [dcsView.videoView captureDocument];
}
@end
Is this page helpful?

Leave a Reply

Your email address will not be published.