@imagowave/vision-ocr 0.0.1 → 0.0.3
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.
- package/README.md +3 -36
- package/{NitroVisionOcr.podspec → VisionOCR.podspec} +2 -2
- package/android/src/main/java/com/margelo/nitro/visionocr/{VisionOcr.kt → HybridVisionOCR.kt} +1 -1
- package/ios/{VisionOCR.swift → HybridVisionOCR.swift} +1 -1
- package/nitro.json +22 -17
- package/nitrogen/generated/android/{NitroVisionOcr+autolinking.cmake → VisionOCR+autolinking.cmake} +9 -9
- package/nitrogen/generated/android/{NitroVisionOcr+autolinking.gradle → VisionOCR+autolinking.gradle} +3 -3
- package/nitrogen/generated/android/VisionOCROnLoad.cpp +54 -0
- package/nitrogen/generated/android/{NitroVisionOcrOnLoad.hpp → VisionOCROnLoad.hpp} +3 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/visionocr/{NitroVisionOcrOnLoad.kt → VisionOCROnLoad.kt} +8 -8
- package/nitrogen/generated/ios/{NitroVisionOcr+autolinking.rb → VisionOCR+autolinking.rb} +4 -4
- package/nitrogen/generated/ios/{NitroVisionOcr-Swift-Cxx-Bridge.cpp → VisionOCR-Swift-Cxx-Bridge.cpp} +5 -5
- package/nitrogen/generated/ios/{NitroVisionOcr-Swift-Cxx-Bridge.hpp → VisionOCR-Swift-Cxx-Bridge.hpp} +2 -2
- package/nitrogen/generated/ios/{NitroVisionOcr-Swift-Cxx-Umbrella.hpp → VisionOCR-Swift-Cxx-Umbrella.hpp} +9 -9
- package/nitrogen/generated/ios/VisionOCRAutolinking.mm +33 -0
- package/nitrogen/generated/ios/VisionOCRAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridVisionOCRSpecSwift.hpp +5 -5
- package/nitrogen/generated/ios/swift/HybridVisionOCRSpec_cxx.swift +1 -1
- package/package.json +2 -7
- package/nitrogen/generated/android/NitroVisionOcrOnLoad.cpp +0 -41
package/README.md
CHANGED
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @imagowave/vision-ocr
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Inspired by @bear-block/vision-camera-ocr but updated to work with Vision Camera 5. (as a nitro module)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Clone this repo, and change all `$$*$$` names according to your `nitro.json` file.
|
|
8
|
-
|
|
9
|
-
## Contributing
|
|
10
|
-
|
|
11
|
-
Contribute a change to this template to update it for newer React Native versions.
|
|
12
|
-
|
|
13
|
-
## Structure
|
|
14
|
-
|
|
15
|
-
- [`android/`](android): All your `android`-specific implementations.
|
|
16
|
-
- [`build.gradle`](android/build.gradle): The gradle build file. This contains four important pieces:
|
|
17
|
-
1. Standard react-native library boilerplate code
|
|
18
|
-
2. Configures Kotlin (`apply plugin: 'org.jetbrains.kotlin.android'`)
|
|
19
|
-
3. Adds all Nitrogen files (`apply from: '.../NitroVisionOcr+autolinking.gradle'`)
|
|
20
|
-
4. Triggers the native C++ build (via CMake/`externalNativeBuild`)
|
|
21
|
-
- [`CMakeLists.txt`](android/CMakeLists.txt): The CMake build file to build C++ code. This contains four important pieces:
|
|
22
|
-
1. Creates a library called `NitroVisionOcr` (same as in `nitro.json`)
|
|
23
|
-
2. Adds all Nitrogen files (`include(.../NitroVisionOcr+autolinking.cmake)`)
|
|
24
|
-
3. Adds all custom C++ files (only `HybridTestObjectCpp.cpp`)
|
|
25
|
-
4. Adds a `cpp-adapter.cpp` file, which autolinks all C++ HybridObjects (only `HybridTestObjectCpp`)
|
|
26
|
-
- [`src/main/java/com/margelo/nitro/visionocr/`](android/src/main/java/com/margelo/nitro/visionocr/): All Kotlin implementations.
|
|
27
|
-
- [`NitroVisionOcrPackage.kt`](android/src/main/java/com/margelo/nitro/visionocr/NitroVisionOcrPackage.kt): The react-native package. You need this because the react-native CLI only adds libraries if they have a `*Package.kt` file. In here, you can autolink all Kotlin HybridObjects.
|
|
28
|
-
- [`cpp/`](cpp): All your cross-platform implementations. (only `HybridTestObjectCpp.cpp`)
|
|
29
|
-
- [`ios/`](ios): All your iOS-specific implementations.
|
|
30
|
-
- [`nitrogen/`](nitrogen): All files generated by nitrogen. You should commit this folder to git.
|
|
31
|
-
- [`src/`](src): The TypeScript codebase. This defines all HybridObjects and loads them at runtime.
|
|
32
|
-
- [`specs/`](src/specs): All HybridObject types. Nitrogen will run on all `*.nitro.ts` files.
|
|
33
|
-
- [`nitro.json`](nitro.json): The configuration file for nitrogen. This will define all native namespaces, as well as the library name.
|
|
34
|
-
- [`NitroVisionOcr.podspec`](NitroVisionOcr.podspec): The iOS podspec build file to build the iOS code. This contains three important pieces:
|
|
35
|
-
1. Specifies the Pod's name. This must be identical to the name specified in `nitro.json`.
|
|
36
|
-
2. Adds all of your `.swift` or `.cpp` files (implementations).
|
|
37
|
-
3. Adds all Nitrogen files (`add_nitrogen_files(s)`)
|
|
38
|
-
- [`package.json`](package.json): The npm package.json file. `react-native-nitro-modules` should be a `peerDependency`.
|
|
5
|
+
Android side has not been tested.
|
|
@@ -3,7 +3,7 @@ require "json"
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
4
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
|
-
s.name = "
|
|
6
|
+
s.name = "VisionOCR"
|
|
7
7
|
s.version = package["version"]
|
|
8
8
|
s.summary = package["description"]
|
|
9
9
|
s.homepage = package["homepage"]
|
|
@@ -22,7 +22,7 @@ Pod::Spec.new do |s|
|
|
|
22
22
|
"cpp/**/*.{hpp,cpp}",
|
|
23
23
|
]
|
|
24
24
|
|
|
25
|
-
load 'nitrogen/generated/ios/
|
|
25
|
+
load 'nitrogen/generated/ios/VisionOCR+autolinking.rb'
|
|
26
26
|
add_nitrogen_files(s)
|
|
27
27
|
|
|
28
28
|
s.dependency 'React-jsi'
|
package/android/src/main/java/com/margelo/nitro/visionocr/{VisionOcr.kt → HybridVisionOCR.kt}
RENAMED
|
@@ -16,7 +16,7 @@ import com.mrousavy.camera.frameprocessors.FrameProcessorPlugin
|
|
|
16
16
|
import com.mrousavy.camera.frameprocessors.VisionCameraProxy
|
|
17
17
|
import java.util.HashMap
|
|
18
18
|
|
|
19
|
-
class
|
|
19
|
+
class HybridVisionOCR : HybridVisionOCRSpec() {
|
|
20
20
|
private val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
|
|
21
21
|
|
|
22
22
|
override fun call(frame: Frame, arguments: Map<String, Any>?): HashMap<String, Any>? {
|
|
@@ -5,7 +5,7 @@ import ImageIO
|
|
|
5
5
|
import Vision
|
|
6
6
|
import VisionCamera
|
|
7
7
|
|
|
8
|
-
class
|
|
8
|
+
class HybridVisionOCR : HybridVisionOCRSpec {
|
|
9
9
|
func call(frame: (any HybridFrameSpec), options: OcrOptions?) throws -> OcrResult? {
|
|
10
10
|
let includeBoxes = options?.includeBoxes ?? false
|
|
11
11
|
let includeConfidence = options?.includeConfidence ?? false
|
package/nitro.json
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
"$schema": "https://nitro.margelo.com/nitro.schema.json",
|
|
3
|
+
"cxxNamespace": ["visionocr"],
|
|
4
|
+
"ios": {
|
|
5
|
+
"iosModuleName": "VisionOCR"
|
|
6
|
+
},
|
|
7
|
+
"android": {
|
|
8
|
+
"androidNamespace": ["visionocr"],
|
|
9
|
+
"androidCxxLibName": "VisionOCR"
|
|
10
|
+
},
|
|
11
|
+
"autolinking": {
|
|
12
|
+
"VisionOCR": {
|
|
13
|
+
"ios": {
|
|
14
|
+
"language": "swift",
|
|
15
|
+
"implementationClassName": "HybridVisionOCR"
|
|
16
|
+
},
|
|
17
|
+
"android": {
|
|
18
|
+
"language": "kotlin",
|
|
19
|
+
"implementationClassName": "HybridVisionOCR"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"ignorePaths": ["**/node_modules"]
|
|
19
24
|
}
|
package/nitrogen/generated/android/{NitroVisionOcr+autolinking.cmake → VisionOCR+autolinking.cmake}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
#
|
|
2
|
+
# VisionOCR+autolinking.cmake
|
|
3
3
|
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
# https://github.com/mrousavy/nitro
|
|
5
5
|
# Copyright © Marc Rousavy @ Margelo
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
#
|
|
11
11
|
# To use it, add this to your CMakeLists.txt:
|
|
12
12
|
# ```cmake
|
|
13
|
-
# include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/
|
|
13
|
+
# include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/VisionOCR+autolinking.cmake)
|
|
14
14
|
# ```
|
|
15
15
|
|
|
16
16
|
# Define a flag to check if we are building properly
|
|
17
|
-
add_definitions(-
|
|
17
|
+
add_definitions(-DBUILDING_VISIONOCR_WITH_GENERATED_CMAKE_PROJECT)
|
|
18
18
|
|
|
19
19
|
# Enable Raw Props parsing in react-native (for Nitro Views)
|
|
20
20
|
add_definitions(-DRN_SERIALIZABLE_STATE)
|
|
@@ -29,9 +29,9 @@ include_directories(
|
|
|
29
29
|
# Add all .cpp sources that were generated by Nitrogen
|
|
30
30
|
target_sources(
|
|
31
31
|
# CMake project name (Android C++ library name)
|
|
32
|
-
|
|
32
|
+
VisionOCR PRIVATE
|
|
33
33
|
# Autolinking Setup
|
|
34
|
-
../nitrogen/generated/android/
|
|
34
|
+
../nitrogen/generated/android/VisionOCROnLoad.cpp
|
|
35
35
|
# Shared Nitrogen C++ sources
|
|
36
36
|
../nitrogen/generated/shared/c++/HybridVisionOCRSpec.cpp
|
|
37
37
|
# Android-specific Nitrogen C++ sources
|
|
@@ -41,7 +41,7 @@ target_sources(
|
|
|
41
41
|
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
42
42
|
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
43
43
|
target_compile_definitions(
|
|
44
|
-
|
|
44
|
+
VisionOCR PRIVATE
|
|
45
45
|
-DFOLLY_NO_CONFIG=1
|
|
46
46
|
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
47
47
|
-DFOLLY_USE_LIBCPP=1
|
|
@@ -61,7 +61,7 @@ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all Hybri
|
|
|
61
61
|
|
|
62
62
|
# Link all libraries together
|
|
63
63
|
target_link_libraries(
|
|
64
|
-
|
|
64
|
+
VisionOCR
|
|
65
65
|
fbjni::fbjni # <-- Facebook C++ JNI helpers
|
|
66
66
|
ReactAndroid::jsi # <-- RN: JSI
|
|
67
67
|
react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
|
|
@@ -70,12 +70,12 @@ target_link_libraries(
|
|
|
70
70
|
# Link react-native (different prefab between RN 0.75 and RN 0.76)
|
|
71
71
|
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
72
72
|
target_link_libraries(
|
|
73
|
-
|
|
73
|
+
VisionOCR
|
|
74
74
|
ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
|
|
75
75
|
)
|
|
76
76
|
else()
|
|
77
77
|
target_link_libraries(
|
|
78
|
-
|
|
78
|
+
VisionOCR
|
|
79
79
|
ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
|
|
80
80
|
)
|
|
81
81
|
endif()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// VisionOCR+autolinking.gradle
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
///
|
|
11
11
|
/// To use it, add this to your build.gradle:
|
|
12
12
|
/// ```gradle
|
|
13
|
-
/// apply from: '../nitrogen/generated/android/
|
|
13
|
+
/// apply from: '../nitrogen/generated/android/VisionOCR+autolinking.gradle'
|
|
14
14
|
/// ```
|
|
15
15
|
|
|
16
|
-
logger.warn("[NitroModules] 🔥
|
|
16
|
+
logger.warn("[NitroModules] 🔥 VisionOCR is boosted by nitro!")
|
|
17
17
|
|
|
18
18
|
android {
|
|
19
19
|
sourceSets {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// VisionOCROnLoad.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#ifndef BUILDING_VISIONOCR_WITH_GENERATED_CMAKE_PROJECT
|
|
9
|
+
#error VisionOCROnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "VisionOCROnLoad.hpp"
|
|
13
|
+
|
|
14
|
+
#include <jni.h>
|
|
15
|
+
#include <fbjni/fbjni.h>
|
|
16
|
+
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
|
+
|
|
18
|
+
#include "JHybridVisionOCRSpec.hpp"
|
|
19
|
+
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::visionocr {
|
|
22
|
+
|
|
23
|
+
int initialize(JavaVM* vm) {
|
|
24
|
+
return facebook::jni::initialize(vm, []() {
|
|
25
|
+
::margelo::nitro::visionocr::registerAllNatives();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
struct JHybridVisionOCRSpecImpl: public jni::JavaClass<JHybridVisionOCRSpecImpl, JHybridVisionOCRSpec::JavaPart> {
|
|
30
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/visionocr/HybridVisionOCR;";
|
|
31
|
+
static std::shared_ptr<JHybridVisionOCRSpec> create() {
|
|
32
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridVisionOCRSpecImpl::javaobject()>();
|
|
33
|
+
jni::local_ref<JHybridVisionOCRSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
34
|
+
return javaPart->getJHybridVisionOCRSpec();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
void registerAllNatives() {
|
|
39
|
+
using namespace margelo::nitro;
|
|
40
|
+
using namespace margelo::nitro::visionocr;
|
|
41
|
+
|
|
42
|
+
// Register native JNI methods
|
|
43
|
+
margelo::nitro::visionocr::JHybridVisionOCRSpec::CxxPart::registerNatives();
|
|
44
|
+
|
|
45
|
+
// Register Nitro Hybrid Objects
|
|
46
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
47
|
+
"VisionOCR",
|
|
48
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
49
|
+
return JHybridVisionOCRSpecImpl::create();
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
} // namespace margelo::nitro::visionocr
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// VisionOCROnLoad.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
@@ -15,14 +15,14 @@ namespace margelo::nitro::visionocr {
|
|
|
15
15
|
int initialize(JavaVM* vm);
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Register the native (C++) part of
|
|
18
|
+
* Register the native (C++) part of VisionOCR, and autolinks all Hybrid Objects.
|
|
19
19
|
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
|
|
20
20
|
* inside a `facebook::jni::initialize(vm, ...)` call.
|
|
21
21
|
* Example:
|
|
22
22
|
* ```cpp (cpp-adapter.cpp)
|
|
23
23
|
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
24
24
|
* return facebook::jni::initialize(vm, []() {
|
|
25
|
-
* // register all
|
|
25
|
+
* // register all VisionOCR HybridObjects
|
|
26
26
|
* margelo::nitro::visionocr::registerNatives();
|
|
27
27
|
* // any other custom registrations go here.
|
|
28
28
|
* });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// VisionOCROnLoad.kt
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
@@ -9,24 +9,24 @@ package com.margelo.nitro.visionocr
|
|
|
9
9
|
|
|
10
10
|
import android.util.Log
|
|
11
11
|
|
|
12
|
-
internal class
|
|
12
|
+
internal class VisionOCROnLoad {
|
|
13
13
|
companion object {
|
|
14
|
-
private const val TAG = "
|
|
14
|
+
private const val TAG = "VisionOCROnLoad"
|
|
15
15
|
private var didLoad = false
|
|
16
16
|
/**
|
|
17
|
-
* Initializes the native part of "
|
|
17
|
+
* Initializes the native part of "VisionOCR".
|
|
18
18
|
* This method is idempotent and can be called more than once.
|
|
19
19
|
*/
|
|
20
20
|
@JvmStatic
|
|
21
21
|
fun initializeNative() {
|
|
22
22
|
if (didLoad) return
|
|
23
23
|
try {
|
|
24
|
-
Log.i(TAG, "Loading
|
|
25
|
-
System.loadLibrary("
|
|
26
|
-
Log.i(TAG, "Successfully loaded
|
|
24
|
+
Log.i(TAG, "Loading VisionOCR C++ library...")
|
|
25
|
+
System.loadLibrary("VisionOCR")
|
|
26
|
+
Log.i(TAG, "Successfully loaded VisionOCR C++ library!")
|
|
27
27
|
didLoad = true
|
|
28
28
|
} catch (e: Error) {
|
|
29
|
-
Log.e(TAG, "Failed to load
|
|
29
|
+
Log.e(TAG, "Failed to load VisionOCR C++ library! Is it properly installed and linked? " +
|
|
30
30
|
"Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
|
|
31
31
|
throw e
|
|
32
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
#
|
|
2
|
+
# VisionOCR+autolinking.rb
|
|
3
3
|
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
# https://github.com/mrousavy/nitro
|
|
5
5
|
# Copyright © Marc Rousavy @ Margelo
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
# # ...
|
|
15
15
|
#
|
|
16
16
|
# # Add all files generated by Nitrogen
|
|
17
|
-
# load 'nitrogen/generated/ios/
|
|
17
|
+
# load 'nitrogen/generated/ios/VisionOCR+autolinking.rb'
|
|
18
18
|
# add_nitrogen_files(spec)
|
|
19
19
|
# end
|
|
20
20
|
# ```
|
|
21
21
|
|
|
22
22
|
def add_nitrogen_files(spec)
|
|
23
|
-
Pod::UI.puts "[NitroModules] 🔥
|
|
23
|
+
Pod::UI.puts "[NitroModules] 🔥 VisionOCR is boosted by nitro!"
|
|
24
24
|
|
|
25
25
|
spec.dependency "NitroModules"
|
|
26
26
|
|
|
@@ -37,7 +37,7 @@ def add_nitrogen_files(spec)
|
|
|
37
37
|
# Generated specs
|
|
38
38
|
"nitrogen/generated/shared/**/*.{h,hpp}",
|
|
39
39
|
# Swift to C++ bridging helpers
|
|
40
|
-
"nitrogen/generated/ios/
|
|
40
|
+
"nitrogen/generated/ios/VisionOCR-Swift-Cxx-Bridge.hpp"
|
|
41
41
|
]
|
|
42
42
|
|
|
43
43
|
current_private_header_files = Array(spec.attributes_hash['private_header_files'])
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// VisionOCR-Swift-Cxx-Bridge.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "VisionOCR-Swift-Cxx-Bridge.hpp"
|
|
9
9
|
|
|
10
10
|
// Include C++ implementation defined types
|
|
11
11
|
#include "HybridVisionOCRSpecSwift.hpp"
|
|
12
|
-
#include "
|
|
12
|
+
#include "VisionOCR-Swift-Cxx-Umbrella.hpp"
|
|
13
13
|
#include <NitroModules/NitroDefines.hpp>
|
|
14
14
|
#include <VisionCamera/VisionCamera-Swift-Cxx-Bridge.hpp>
|
|
15
15
|
|
|
@@ -27,7 +27,7 @@ namespace margelo::nitro::visionocr::bridge::swift {
|
|
|
27
27
|
|
|
28
28
|
// pragma MARK: std::shared_ptr<HybridVisionOCRSpec>
|
|
29
29
|
std::shared_ptr<HybridVisionOCRSpec> create_std__shared_ptr_HybridVisionOCRSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
30
|
-
|
|
30
|
+
VisionOCR::HybridVisionOCRSpec_cxx swiftPart = VisionOCR::HybridVisionOCRSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
31
31
|
return std::make_shared<margelo::nitro::visionocr::HybridVisionOCRSpecSwift>(swiftPart);
|
|
32
32
|
}
|
|
33
33
|
void* NON_NULL get_std__shared_ptr_HybridVisionOCRSpec_(std__shared_ptr_HybridVisionOCRSpec_ cppType) {
|
|
@@ -37,7 +37,7 @@ namespace margelo::nitro::visionocr::bridge::swift {
|
|
|
37
37
|
throw std::runtime_error("Class \"HybridVisionOCRSpec\" is not implemented in Swift!");
|
|
38
38
|
}
|
|
39
39
|
#endif
|
|
40
|
-
|
|
40
|
+
VisionOCR::HybridVisionOCRSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
41
41
|
return swiftPart.toUnsafe();
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// VisionOCR-Swift-Cxx-Bridge.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
@@ -31,7 +31,7 @@ namespace margelo::nitro::visionocr { enum class RLevel; }
|
|
|
31
31
|
// Forward declaration of `HybridFrameSpec_cxx` to properly resolve imports.
|
|
32
32
|
namespace VisionCamera { class HybridFrameSpec_cxx; }
|
|
33
33
|
// Forward declaration of `HybridVisionOCRSpec_cxx` to properly resolve imports.
|
|
34
|
-
namespace
|
|
34
|
+
namespace VisionOCR { class HybridVisionOCRSpec_cxx; }
|
|
35
35
|
|
|
36
36
|
// Include C++ defined types
|
|
37
37
|
#include "HybridVisionOCRSpec.hpp"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// VisionOCR-Swift-Cxx-Umbrella.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
@@ -45,7 +45,7 @@ namespace margelo::nitro::visionocr { enum class RLevel; }
|
|
|
45
45
|
#include <vector>
|
|
46
46
|
|
|
47
47
|
// C++ helpers for Swift
|
|
48
|
-
#include "
|
|
48
|
+
#include "VisionOCR-Swift-Cxx-Bridge.hpp"
|
|
49
49
|
|
|
50
50
|
// Common C++ types used in Swift
|
|
51
51
|
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
@@ -57,16 +57,16 @@ namespace margelo::nitro::visionocr { enum class RLevel; }
|
|
|
57
57
|
// Forward declaration of `HybridFrameSpec_cxx` to properly resolve imports.
|
|
58
58
|
namespace VisionCamera { class HybridFrameSpec_cxx; }
|
|
59
59
|
// Forward declaration of `HybridVisionOCRSpec_cxx` to properly resolve imports.
|
|
60
|
-
namespace
|
|
60
|
+
namespace VisionOCR { class HybridVisionOCRSpec_cxx; }
|
|
61
61
|
|
|
62
62
|
// Include Swift defined types
|
|
63
|
-
#if __has_include("
|
|
63
|
+
#if __has_include("VisionOCR-Swift.h")
|
|
64
64
|
// This header is generated by Xcode/Swift on every app build.
|
|
65
|
-
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "
|
|
66
|
-
#include "
|
|
65
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "VisionOCR".
|
|
66
|
+
#include "VisionOCR-Swift.h"
|
|
67
67
|
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
68
|
-
#elif __has_include(<
|
|
69
|
-
#include <
|
|
68
|
+
#elif __has_include(<VisionOCR/VisionOCR-Swift.h>)
|
|
69
|
+
#include <VisionOCR/VisionOCR-Swift.h>
|
|
70
70
|
#else
|
|
71
|
-
#error
|
|
71
|
+
#error VisionOCR's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "VisionOCR", and try building the app first.
|
|
72
72
|
#endif
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// VisionOCRAutolinking.mm
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
+
#import "VisionOCR-Swift-Cxx-Umbrella.hpp"
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridVisionOCRSpecSwift.hpp"
|
|
14
|
+
|
|
15
|
+
@interface VisionOCRAutolinking : NSObject
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation VisionOCRAutolinking
|
|
19
|
+
|
|
20
|
+
+ (void) load {
|
|
21
|
+
using namespace margelo::nitro;
|
|
22
|
+
using namespace margelo::nitro::visionocr;
|
|
23
|
+
|
|
24
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
+
"VisionOCR",
|
|
26
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
+
std::shared_ptr<HybridVisionOCRSpec> hybridObject = VisionOCR::VisionOCRAutolinking::createVisionOCR();
|
|
28
|
+
return hybridObject;
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// VisionOCRAutolinking.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
// TODO: Use empty enums once Swift supports exporting them as namespaces
|
|
11
|
+
// See: https://github.com/swiftlang/swift/pull/83616
|
|
12
|
+
public final class VisionOCRAutolinking {
|
|
13
|
+
public typealias bridge = margelo.nitro.visionocr.bridge.swift
|
|
14
|
+
|
|
15
|
+
public static func createVisionOCR() -> bridge.std__shared_ptr_HybridVisionOCRSpec_ {
|
|
16
|
+
let hybridObject = HybridVisionOCR()
|
|
17
|
+
return { () -> bridge.std__shared_ptr_HybridVisionOCRSpec_ in
|
|
18
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
19
|
+
return __cxxWrapped.getCxxPart()
|
|
20
|
+
}()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public static func isVisionOCRRecyclable() -> Bool {
|
|
24
|
+
return HybridVisionOCR.self is any RecyclableView.Type
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
#include "HybridVisionOCRSpec.hpp"
|
|
11
11
|
|
|
12
12
|
// Forward declaration of `HybridVisionOCRSpec_cxx` to properly resolve imports.
|
|
13
|
-
namespace
|
|
13
|
+
namespace VisionOCR { class HybridVisionOCRSpec_cxx; }
|
|
14
14
|
|
|
15
15
|
// Forward declaration of `OcrResult` to properly resolve imports.
|
|
16
16
|
namespace margelo::nitro::visionocr { struct OcrResult; }
|
|
@@ -42,7 +42,7 @@ namespace margelo::nitro::visionocr { enum class RLevel; }
|
|
|
42
42
|
#include "OcrOptions.hpp"
|
|
43
43
|
#include "RLevel.hpp"
|
|
44
44
|
|
|
45
|
-
#include "
|
|
45
|
+
#include "VisionOCR-Swift-Cxx-Umbrella.hpp"
|
|
46
46
|
|
|
47
47
|
namespace margelo::nitro::visionocr {
|
|
48
48
|
|
|
@@ -59,13 +59,13 @@ namespace margelo::nitro::visionocr {
|
|
|
59
59
|
class HybridVisionOCRSpecSwift: public virtual HybridVisionOCRSpec {
|
|
60
60
|
public:
|
|
61
61
|
// Constructor from a Swift instance
|
|
62
|
-
explicit HybridVisionOCRSpecSwift(const
|
|
62
|
+
explicit HybridVisionOCRSpecSwift(const VisionOCR::HybridVisionOCRSpec_cxx& swiftPart):
|
|
63
63
|
HybridObject(HybridVisionOCRSpec::TAG),
|
|
64
64
|
_swiftPart(swiftPart) { }
|
|
65
65
|
|
|
66
66
|
public:
|
|
67
67
|
// Get the Swift part
|
|
68
|
-
inline
|
|
68
|
+
inline VisionOCR::HybridVisionOCRSpec_cxx& getSwiftPart() noexcept {
|
|
69
69
|
return _swiftPart;
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -102,7 +102,7 @@ namespace margelo::nitro::visionocr {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
private:
|
|
105
|
-
|
|
105
|
+
VisionOCR::HybridVisionOCRSpec_cxx _swiftPart;
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
} // namespace margelo::nitro::visionocr
|
|
@@ -20,7 +20,7 @@ import VisionCamera
|
|
|
20
20
|
open class HybridVisionOCRSpec_cxx {
|
|
21
21
|
/**
|
|
22
22
|
* The Swift <> C++ bridge's namespace (`margelo::nitro::visionocr::bridge::swift`)
|
|
23
|
-
* from `
|
|
23
|
+
* from `VisionOCR-Swift-Cxx-Bridge.hpp`.
|
|
24
24
|
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
25
25
|
*/
|
|
26
26
|
public typealias bridge = margelo.nitro.visionocr.bridge.swift
|
package/package.json
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imagowave/vision-ocr",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A React Native module for performing OCR using the Vision framework on iOS and ML Kit on Android.",
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "lib/index",
|
|
7
|
-
"types": "lib/types.ts",
|
|
8
|
-
"react-native": "src/index",
|
|
9
|
-
"source": "src/index",
|
|
5
|
+
"main": "src/index",
|
|
10
6
|
"files": [
|
|
11
7
|
"src",
|
|
12
8
|
"react-native.config.js",
|
|
@@ -33,7 +29,6 @@
|
|
|
33
29
|
"clean": "rm -rf android/build node_modules/**/android/build lib",
|
|
34
30
|
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
|
|
35
31
|
"lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
|
|
36
|
-
"typescript": "tsc",
|
|
37
32
|
"specs": "tsc --noEmit false && nitrogen --logLevel=\"debug\""
|
|
38
33
|
},
|
|
39
34
|
"keywords": [
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// NitroVisionOcrOnLoad.cpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#ifndef BUILDING_NITROVISIONOCR_WITH_GENERATED_CMAKE_PROJECT
|
|
9
|
-
#error NitroVisionOcrOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
|
|
10
|
-
#endif
|
|
11
|
-
|
|
12
|
-
#include "NitroVisionOcrOnLoad.hpp"
|
|
13
|
-
|
|
14
|
-
#include <jni.h>
|
|
15
|
-
#include <fbjni/fbjni.h>
|
|
16
|
-
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
|
-
|
|
18
|
-
#include "JHybridVisionOCRSpec.hpp"
|
|
19
|
-
|
|
20
|
-
namespace margelo::nitro::visionocr {
|
|
21
|
-
|
|
22
|
-
int initialize(JavaVM* vm) {
|
|
23
|
-
return facebook::jni::initialize(vm, []() {
|
|
24
|
-
::margelo::nitro::visionocr::registerAllNatives();
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
void registerAllNatives() {
|
|
31
|
-
using namespace margelo::nitro;
|
|
32
|
-
using namespace margelo::nitro::visionocr;
|
|
33
|
-
|
|
34
|
-
// Register native JNI methods
|
|
35
|
-
margelo::nitro::visionocr::JHybridVisionOCRSpec::CxxPart::registerNatives();
|
|
36
|
-
|
|
37
|
-
// Register Nitro Hybrid Objects
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
} // namespace margelo::nitro::visionocr
|