adamgf / react-native-opencv3

react-native-opencv3 wraps functionality from OpenCV Java SDK 3.4.4 + contrib modules and iOS OpenCV 3.4.1 + contrib modules for use in React-Native apps. Please enjoy!
Other
181 stars 61 forks source link

supporting expo.. or expo-opencv3 ? #17

Open albjeremias opened 4 years ago

albjeremias commented 4 years ago

Is there a way to run this module with expo? When I add this module in a expo project... `$ yarn add react-native-opencv3'

I get the error: Unable to resolve "react-native-fs" from "node_modules/react-native-opencv3/index.js"

then I install `$ yarn add react-native-fs'

reload again the app with expo.. and get the error:

TypeError: Cannot read property 'RNFSFileTypeRegular' of undefined
reportException @ ExceptionsManager.js:44
handleException @ ExceptionsManager.js:113
handleError @ setUpErrorHandling.js:23
_callee$ @ ErrorRecovery.fx.js:12
tryCatch @ runtime.js:45
invoke @ runtime.js:271
prototype.<computed> @ runtime.js:97
tryCatch @ runtime.js:45
invoke @ runtime.js:135
(anonymous) @ runtime.js:145
tryCallOne @ core.js:37
(anonymous) @ core.js:123
(anonymous) @ JSTimers.js:289
_callTimer @ JSTimers.js:146
_callImmediatesPass @ JSTimers.js:194
callImmediates @ JSTimers.js:458
__callImmediates @ MessageQueue.js:407
(anonymous) @ MessageQueue.js:143
__guard @ MessageQueue.js:384
flushedQueue @ MessageQueue.js:142
invokeCallbackAndReturnFlushedQueue @ MessageQueue.js:138
(anonymous) @ debuggerWorker.js:69

ExceptionsManager.js:44 Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
reportException @ ExceptionsManager.js:44
handleException @ ExceptionsManager.js:113
handleError @ setUpErrorHandling.js:23
_callee$ @ ErrorRecovery.fx.js:12
tryCatch @ runtime.js:45
invoke @ runtime.js:271
prototype.<computed> @ runtime.js:97
tryCatch @ runtime.js:45
invoke @ runtime.js:135
(anonymous) @ runtime.js:145
tryCallOne @ core.js:37
(anonymous) @ core.js:123
(anonymous) @ JSTimers.js:289
_callTimer @ JSTimers.js:146
_callImmediatesPass @ JSTimers.js:194
callImmediates @ JSTimers.js:458
__callImmediates @ MessageQueue.js:407
(anonymous) @ MessageQueue.js:143
__guard @ MessageQueue.js:384
flushedQueue @ MessageQueue.js:142
invokeCallbackAndReturnFlushedQueue @ MessageQueue.js:138
(anonymous) @ debuggerWorker.js:69
adamgf commented 4 years ago

Hi Albatross, Does react-native-fs install separately in expo could you try that first and then try to install react-native-opencv3? Best regards, Adam

On Fri, Feb 21, 2020 at 7:39 AM Albatroz Jeremias notifications@github.com wrote:

Is there a way to run this module with expo? When I add this module in a expo project... `$ yarn add react-native-opencv3'

I get the error: Unable to resolve "react-native-fs" from "node_modules/react-native-opencv3/index.js"

then I install `$ yarn add react-native-fs' and get the error:

TypeError: Cannot read property 'RNFSFileTypeRegular' of undefined reportException @ ExceptionsManager.js:44 handleException @ ExceptionsManager.js:113 handleError @ setUpErrorHandling.js:23 _callee$ @ ErrorRecovery.fx.js:12 tryCatch @ runtime.js:45 invoke @ runtime.js:271 prototype. @ runtime.js:97 tryCatch @ runtime.js:45 invoke @ runtime.js:135 (anonymous) @ runtime.js:145 tryCallOne @ core.js:37 (anonymous) @ core.js:123 (anonymous) @ JSTimers.js:289 _callTimer @ JSTimers.js:146 _callImmediatesPass @ JSTimers.js:194 callImmediates @ JSTimers.js:458 callImmediates @ MessageQueue.js:407 (anonymous) @ MessageQueue.js:143 guard @ MessageQueue.js:384 flushedQueue @ MessageQueue.js:142 invokeCallbackAndReturnFlushedQueue @ MessageQueue.js:138 (anonymous) @ debuggerWorker.js:69

ExceptionsManager.js:44 Invariant Violation: "main" has not been registered. This can happen if:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn't called. reportException @ ExceptionsManager.js:44 handleException @ ExceptionsManager.js:113 handleError @ setUpErrorHandling.js:23 _callee$ @ ErrorRecovery.fx.js:12 tryCatch @ runtime.js:45 invoke @ runtime.js:271 prototype. @ runtime.js:97 tryCatch @ runtime.js:45 invoke @ runtime.js:135 (anonymous) @ runtime.js:145 tryCallOne @ core.js:37 (anonymous) @ core.js:123 (anonymous) @ JSTimers.js:289 _callTimer @ JSTimers.js:146 _callImmediatesPass @ JSTimers.js:194 callImmediates @ JSTimers.js:458 callImmediates @ MessageQueue.js:407 (anonymous) @ MessageQueue.js:143 guard @ MessageQueue.js:384 flushedQueue @ MessageQueue.js:142 invokeCallbackAndReturnFlushedQueue @ MessageQueue.js:138 (anonymous) @ debuggerWorker.js:69

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adamgf/react-native-opencv3/issues/17?email_source=notifications&email_token=AAJ6V3ZEQ2L4HPPT7Z54F6DRD7YU7A5CNFSM4KZFMNG2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IPKWGYQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ6V34GWRWDWF2NG7OTESDRD7YU7ANCNFSM4KZFMNGQ .

pmgou commented 4 years ago

Ok, so the issue is that react-native-fs is not supported by expo.. not react-native-opencv3... there is also https://github.com/expo/exponent-react-native-fs would it be possible to change all calls to react-native-fs to this?

adamgf commented 4 years ago

Yes please change it to exponent-react-native-fs. I need help with this if others want to help out. I am too busy with other stuff to work on this.

pmgou commented 4 years ago

why not use opencv.js ? any reasons ? because thats the steps i took after all this troubles..

amardeepranu commented 4 years ago

hey @pmgou did you manage to get opencv.js running on expo?

pmgou commented 4 years ago

Hi, in the end i make it work with a webview. not with react-native, but react-native is js so it should not be a problem.

Anyway take into account that opencvjs does not implement all the functions of opencv, only some:

https://github.com/opencv/opencv/blob/master/platforms/js/opencv_js.config.py

And most of the code is kind of reverse engineering cause there aren't examples of everything. Here you can see how objects are created: https://github.com/opencv/opencv/blob/master/modules/js/src/core_bindings.cpp#L595

this also helps: https://github.com/opencv/opencv/tree/318cba4ce37319ba0b0870aab384d5dc066bb124/modules/js/test

amardeepranu commented 4 years ago

Thanks @pmgou what is your use case? Does that mean you launch a browser in the app, inject opencv.js and execute it inside safari/chrome within the app? Would love to see an example! Thanks

jiangshunke commented 3 years ago

@adamgf Finally, we also used the webview fumble to get