Read from a Specific Area
Set a Scan Region on Camera
- Objective-C
- Swift
DSRect *region = [[DSRect alloc] init]; region.left = 0.15; region.top = 0.25; region.right = 0.85; region.bottom = 0.65; [self.dce setScanRegion:region error:nil];let region = Rect() region.left = 0.15 region.top = 0.25 region.right = 0.85 region.bottom = 0.65 try? dce.setScanRegion(region)
Related APIs
Set an ROI via Simplified Settings
Simplified Settings are only available for the Foundational APIs.
- Objective-C
- Swift
NSError *error = nil; DSSimplifiedCaptureVisionSettings *captureVisionSettings = [self.cvr getSimplifiedSettings:DSPresetTemplateReadBarcodes error:&error]; NSArray<NSValue *> *points = @[ [NSValue valueWithCGPoint:CGPointMake(15, 30)], [NSValue valueWithCGPoint:CGPointMake(85, 30)], [NSValue valueWithCGPoint:CGPointMake(85, 70)], [NSValue valueWithCGPoint:CGPointMake(15, 70)] ]; DSQuadrilateral *roiQuad = [[DSQuadrilateral alloc] initWithPointArray:points]; captureVisionSettings.roi = roiQuad; captureVisionSettings.roiMeasuredInPercentage = YES; [self.cvr updateSettings:DSPresetTemplateReadBarcodes settings:captureVisionSettings error:&error];let captureVisionSettings = try cvr.getSimplifiedSettings(PresetTemplate.readBarcodes.rawValue) let point0 = CGPoint(x: 15, y: 30) as NSValue let point1 = CGPoint(x: 85, y: 30) as NSValue let point2 = CGPoint(x: 85, y: 55) as NSValue let point3 = CGPoint(x: 15, y: 55) as NSValue let roiQuad = Quadrilateral.init(pointArray: [point0,point1,point2,point3]) captureVisionSettings.roi = roiQuad captureVisionSettings.roiMeasuredInPercentage = true do { try cvr.updateSettings(PresetTemplate.readBarcodes.rawValue, settings: captureVisionSettings) } catch { }
Set ROIs in Customized Template
Define a single ROI:
{
"CaptureVisionTemplates": [
{
"Name" : "CV_0",
"ImageROIProcessingNameArray": ["barcode-decoding-roi-1" ]
}
],
"TargetROIDefOptions" : [
{
"Name" : "barcode-decoding-roi-1",
"TaskSettingNameArray": ["barcode-decoding-task-1"],
"Location":
{
"Offset": {
"MeasuredByPercentage" : 1,
"FirstPoint" : [ 15, 30 ],
"SecondPoint" : [ 85, 30 ],
"ThirdPoint" : [ 85, 70 ],
"FourthPoint" : [ 15, 70 ],
}
}
}
]
}
You can define multiple ROIs in TargetROIDefOptions. For each ROI, you can assign a different task or reuse the same task.
{
"CaptureVisionTemplates": [
{
"Name" : "CV_0",
"ImageROIProcessingNameArray": ["barcode-decoding-roi-1","barcode-decoding-roi-2" ]
}
],
"TargetROIDefOptions" : [
{
"Name" : "barcode-decoding-roi-1",
"TaskSettingNameArray": ["barcode-decoding-task-1"],
"Location":
{
"Offset": {
"MeasuredByPercentage" : 1,
"FirstPoint" : [ 15, 20 ],
"SecondPoint" : [ 85, 40 ],
"ThirdPoint" : [ 85, 40 ],
"FourthPoint" : [ 15, 20 ]
}
}
},{
"Name" : "barcode-decoding-roi-2",
"TaskSettingNameArray": ["barcode-decoding-task-1"],
"Location":
{
"Offset": {
"MeasuredByPercentage" : 1,
"FirstPoint" : [ 15, 60 ],
"SecondPoint" : [ 85, 80 ],
"ThirdPoint" : [ 85, 80 ],
"FourthPoint" : [ 15, 60 ]
}
}
}
]
}