Skip to content

Commit f5f3f26

Browse files
committed
Updated SDKs for Android and iOS.
1 parent 0475617 commit f5f3f26

File tree

4 files changed

+67
-75
lines changed

4 files changed

+67
-75
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.0.1
2+
- Updated SDKs for Android and iOS.
3+
14
## 2.0.0
25
- Updated the plugin with Dynamsoft Capture Vision SDK.
36

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ android {
4242
}
4343

4444
dependencies {
45-
implementation "com.dynamsoft:dynamsoftcapturevisionbundle:2.6.1003"
45+
implementation 'com.dynamsoft:capturevisionbundle:3.0.3000'
4646
}

android/src/main/java/com/dynamsoft/flutter_document_scan_sdk/FlutterDocumentScanSdkPlugin.java

Lines changed: 62 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@
3434
import com.dynamsoft.core.basic_structures.ImageData;
3535
import com.dynamsoft.core.basic_structures.Quadrilateral;
3636
import com.dynamsoft.core.basic_structures.EnumImagePixelFormat;
37-
import com.dynamsoft.ddn.NormalizedImageResultItem;
38-
import com.dynamsoft.ddn.DetectedQuadResultItem;
39-
import com.dynamsoft.ddn.NormalizedImagesResult;
40-
import com.dynamsoft.ddn.DetectedQuadsResult;
37+
import com.dynamsoft.ddn.EnhancedImageResultItem;
38+
import com.dynamsoft.ddn.ProcessedDocumentResult;
4139
import com.dynamsoft.ddn.EnumImageColourMode;
40+
import com.dynamsoft.ddn.DetectedQuadResultItem;
4241

4342
import android.graphics.Point;
4443

@@ -107,7 +106,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
107106

108107
String parameters = "";
109108
try {
110-
parameters = mRouter.outputSettings("");
109+
parameters = mRouter.outputSettings("", false);
111110
} catch (Exception e) {
112111
result.success(e.toString());
113112
return;
@@ -174,15 +173,6 @@ public void run() {
174173
final int y4 = call.argument("y4");
175174
final int rotation = call.argument("rotation");
176175
final int mode = call.argument("color");
177-
178-
// int colorMode = EnumImageColourMode.ICM_GRAYSCALE;
179-
// if (mode == 0) {
180-
// colorMode = EnumImageColourMode.ICM_COLOUR;
181-
// } else if (mode == 1) {
182-
// colorMode = EnumImageColourMode.ICM_GRAYSCALE;
183-
// } else if (mode == 2) {
184-
// colorMode = EnumImageColourMode.ICM_BINARY;
185-
// }
186176

187177
ImageData buffer = new ImageData();
188178
buffer.bytes = bytes;
@@ -311,61 +301,61 @@ List<Map<String, Object>> createContourList(CapturedResult result) {
311301
}
312302

313303
Map<String, Object> createNormalizedImage(CapturedResult result) {
314-
NormalizedImagesResult normalizedImageResult = result.getNormalizedImagesResult();
315-
Map<String, Object> map = new HashMap<>();
316-
317-
if (normalizedImageResult.getItems().length > 0) {
318-
NormalizedImageResultItem item = normalizedImageResult.getItems()[0];
319-
ImageData imageData = item.getImageData();
320-
321-
int width = imageData.width;
322-
int height = imageData.height;
323-
int stride = imageData.stride;
324-
int format = imageData.format;
325-
byte[] data = imageData.bytes;
326-
int length = imageData.bytes.length;
327-
int orientation = imageData.orientation;
328-
329-
map.put("width", width);
330-
map.put("height", height);
331-
map.put("stride", stride);
332-
map.put("format", format);
333-
map.put("orientation", orientation);
334-
map.put("length", length);
335-
336-
byte[] rgba = new byte[width * height * 4];
337-
338-
if (format == EnumImagePixelFormat.IPF_RGB_888) {
339-
int dataIndex = 0;
340-
for (int i = 0; i < height; i++)
341-
{
342-
for (int j = 0; j < width; j++)
343-
{
344-
int index = i * width + j;
345-
346-
rgba[index * 4] = data[dataIndex]; // red
347-
rgba[index * 4 + 1] = data[dataIndex + 1]; // green
348-
rgba[index * 4 + 2] = data[dataIndex + 2]; // blue
349-
rgba[index * 4 + 3] = (byte)255; // alpha
350-
dataIndex += 3;
351-
}
352-
}
353-
}
354-
else if (format == EnumImagePixelFormat.IPF_GRAYSCALED | format == EnumImagePixelFormat.IPF_BINARY_8_INVERTED | format == EnumImagePixelFormat.IPF_BINARY_8) {
355-
int dataIndex = 0;
356-
for (int i = 0; i < height; i++)
357-
{
358-
for (int j = 0; j < width; j++)
359-
{
360-
int index = i * width + j;
361-
rgba[index * 4] = data[dataIndex];
362-
rgba[index * 4 + 1] = data[dataIndex];
363-
rgba[index * 4 + 2] = data[dataIndex];
364-
rgba[index * 4 + 3] = (byte)255;
365-
dataIndex += 1;
366-
}
367-
}
368-
}
304+
ProcessedDocumentResult normalizedImageResult = result.getProcessedDocumentResult();
305+
Map<String, Object> map = new HashMap<>();
306+
307+
if (normalizedImageResult != null && normalizedImageResult.getEnhancedImageResultItems().length > 0) {
308+
EnhancedImageResultItem item = normalizedImageResult.getEnhancedImageResultItems()[0];
309+
ImageData imageData = item.getImageData();
310+
311+
int width = imageData.width;
312+
int height = imageData.height;
313+
int stride = imageData.stride;
314+
int format = imageData.format;
315+
byte[] data = imageData.bytes;
316+
int length = imageData.bytes.length;
317+
int orientation = imageData.orientation;
318+
319+
map.put("width", width);
320+
map.put("height", height);
321+
map.put("stride", stride);
322+
map.put("format", format);
323+
map.put("orientation", orientation);
324+
map.put("length", length);
325+
326+
byte[] rgba = new byte[width * height * 4];
327+
328+
if (format == EnumImagePixelFormat.IPF_RGB_888) {
329+
int dataIndex = 0;
330+
for (int i = 0; i < height; i++)
331+
{
332+
for (int j = 0; j < width; j++)
333+
{
334+
int index = i * width + j;
335+
336+
rgba[index * 4] = data[dataIndex]; // red
337+
rgba[index * 4 + 1] = data[dataIndex + 1]; // green
338+
rgba[index * 4 + 2] = data[dataIndex + 2]; // blue
339+
rgba[index * 4 + 3] = (byte)255; // alpha
340+
dataIndex += 3;
341+
}
342+
}
343+
}
344+
else if (format == EnumImagePixelFormat.IPF_GRAYSCALED | format == EnumImagePixelFormat.IPF_BINARY_8_INVERTED | format == EnumImagePixelFormat.IPF_BINARY_8) {
345+
int dataIndex = 0;
346+
for (int i = 0; i < height; i++)
347+
{
348+
for (int j = 0; j < width; j++)
349+
{
350+
int index = i * width + j;
351+
rgba[index * 4] = data[dataIndex];
352+
rgba[index * 4 + 1] = data[dataIndex];
353+
rgba[index * 4 + 2] = data[dataIndex];
354+
rgba[index * 4 + 3] = (byte)255;
355+
dataIndex += 1;
356+
}
357+
}
358+
}
369359
else if (format == EnumImagePixelFormat.IPF_BINARY) {
370360
byte[] grayscale = new byte[width * height];
371361
binary2grayscale(data, grayscale, width, height, stride, length);
@@ -384,12 +374,11 @@ else if (format == EnumImagePixelFormat.IPF_BINARY) {
384374
}
385375
}
386376
}
377+
map.put("data", rgba);
378+
}
387379

388-
map.put("data", rgba);
389-
}
390-
391380

392-
return map;
381+
return map;
393382
}
394383

395384
void binary2grayscale(byte[] data, byte[] output, int width, int height, int stride, int length) {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_document_scan_sdk
22
description: A wrapper for Dynamsoft Capture Vision SDK, capable of detecting document edges and rectifying documents.
3-
version: 2.0.0
3+
version: 2.0.1
44
homepage: https://github.com/yushulx/flutter_document_scan_sdk
55
repository: https://github.com/yushulx/flutter_document_scan_sdk
66

0 commit comments

Comments
 (0)