@mleonard9/vin-scanner 1.4.5 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -37,15 +37,26 @@
|
|
|
37
37
|
return self;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
- (
|
|
40
|
+
- (UIImage *)extractUIImage:(MLKVisionImage *)image {
|
|
41
|
+
// MLKVisionImage may not expose `.image` when created from CMSampleBuffer.
|
|
42
|
+
if ([image respondsToSelector:@selector(image)]) {
|
|
43
|
+
#pragma clang diagnostic push
|
|
44
|
+
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
|
45
|
+
return [image performSelector:@selector(image)];
|
|
46
|
+
#pragma clang diagnostic pop
|
|
47
|
+
}
|
|
48
|
+
return nil;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
- (NSDictionary*)cropImage:(MLKVisionImage*)image
|
|
41
52
|
withRegion:(NSDictionary*)scanRegion {
|
|
42
53
|
double x = [scanRegion[@"x"] doubleValue];
|
|
43
54
|
double y = [scanRegion[@"y"] doubleValue];
|
|
44
55
|
double width = [scanRegion[@"width"] doubleValue];
|
|
45
56
|
double height = [scanRegion[@"height"] doubleValue];
|
|
46
57
|
|
|
47
|
-
// Get image dimensions from the underlying UIImage
|
|
48
|
-
UIImage *uiImage = image
|
|
58
|
+
// Get image dimensions from the underlying UIImage if available
|
|
59
|
+
UIImage *uiImage = [self extractUIImage:image];
|
|
49
60
|
if (!uiImage) {
|
|
50
61
|
return @{@"image": image, @"offsetX": @(0), @"offsetY": @(0)};
|
|
51
62
|
}
|
|
@@ -78,6 +78,16 @@
|
|
|
78
78
|
return fallback;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
- (UIImage *)extractUIImage:(MLKVisionImage *)image {
|
|
82
|
+
if ([image respondsToSelector:@selector(image)]) {
|
|
83
|
+
#pragma clang diagnostic push
|
|
84
|
+
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
|
85
|
+
return [image performSelector:@selector(image)];
|
|
86
|
+
#pragma clang diagnostic pop
|
|
87
|
+
}
|
|
88
|
+
return nil;
|
|
89
|
+
}
|
|
90
|
+
|
|
81
91
|
- (NSDictionary*)cropImage:(MLKVisionImage*)image
|
|
82
92
|
withRegion:(NSDictionary*)scanRegion {
|
|
83
93
|
double x = [scanRegion[@"x"] doubleValue];
|
|
@@ -85,8 +95,8 @@
|
|
|
85
95
|
double width = [scanRegion[@"width"] doubleValue];
|
|
86
96
|
double height = [scanRegion[@"height"] doubleValue];
|
|
87
97
|
|
|
88
|
-
// Get image dimensions from the underlying UIImage
|
|
89
|
-
UIImage *uiImage = image
|
|
98
|
+
// Get image dimensions from the underlying UIImage if available
|
|
99
|
+
UIImage *uiImage = [self extractUIImage:image];
|
|
90
100
|
if (!uiImage) {
|
|
91
101
|
return @{@"image": image, @"offsetX": @(0), @"offsetY": @(0)};
|
|
92
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mleonard9/vin-scanner",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "High-performance VIN scanner for React Native Vision Camera powered by Google ML Kit barcode + text recognition.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -32,8 +32,7 @@
|
|
|
32
32
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
33
33
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
34
34
|
"prepare": "bob build",
|
|
35
|
-
"release": "release-it"
|
|
36
|
-
"publish": "npm publish"
|
|
35
|
+
"release": "release-it"
|
|
37
36
|
},
|
|
38
37
|
"keywords": [
|
|
39
38
|
"react-native",
|