react-native-scan-doc
react-native-scan-doc copied to clipboard
Compilation error
Hello,
I've added "react-native-scan-doc": "git+https://[email protected]/beast/react-native-scan-doc.git" and npm install the package; I both tried manual and linking installation and it fail at compiling, it might something stupid to you but I'm not so used about Android.
Console output:
Scanning 696 folders for symlinks in /Users/xkraty/projects/bridge-mobile/node_modules (18ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Incremental java compilation is an incubating feature.
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/xkraty/projects/bridge-mobile/node_modules/react-native-scan-doc/android/build.gradle' line: 36
* What went wrong:
A problem occurred evaluating project ':react-native-scan-doc'.
> Project with path ':openCVLibrary320' could not be found in project ':react-native-scan-doc'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Thanks in advance Chris
Hi @xkraty. Thanks for opening the issue. This is something I wanted to add in the readme. Getting Opencv package to play nicely with RN out-of-box is almost impossible. Believe me I had tried make it as dummy as possible to the best of my knowledge. But the reality is setting up opencv to work nicely with Android itself is a challenging enough task. I suggest you look at a few examples to understand how OpenCV works with Android first then proceed to manual installation. https://blog.nishtahir.com/2015/11/11/setting-up-for-android-ndk-development/
Try out my Android Native Scan Doc sample if you want to first check out how the scan doc helps you to crop a doc in image.
Again, I am open to have some help from the community to improve the package documentation. Thanks for opening the issue. I understand most of the scan doc package out there cost a fortune but OpenCV is no easy thing to deal with and I would like to have some serious help.
I myself unfortunately is tied up with other work of my own. Will look into this seriously once I got time and resource. Thanks.
@xkraty Can you make it work? Thanks.
@ducpt2 no sorry, we dropped it in favor of scanbot even if it require a license
@xkraty I was asked to pay 20k Euro a year that is exactly why I started this repo...
@beast I am sorry I didn't mean minimize your work or blame you since you did a great job here, we just didn't have enough skill/time to dig into Android and the company wanted it fast, so they'll pay for.
@beast I was following this repo because I'm migrating mobile apps to react native and one feature the Android app has is a document Scanner done with OpenCV. I managed to get it to work in Android and we have released it. I could help if I can. What would you need?
I'm thinking that you probably need a installation instructions on how set up the OpenCV library in android and checking that it works ok, anything else? I will try to get into this as soon as I can.
@khrizt Yes. Please help on the installation instructions. That will be greatly appreciated. Another thing I was wondering is how to get OpenCV installation work with this package automatically. Thanks!
@beast Ok, I'll look into it and let you know.
@xkraty No offence taken. I did understand the frustration of people not able to get it working. Unfortunately I couldn't invest more time to explain how exactly this works due to my own work. Really hope I could get some help or I could manage to find some time for this.
@beast I very appreciated your work :) Thanks. @khrizt Hope you can help, thank you so much. I have try to bridge from this repo: https://github.com/Aniruddha-Tapas/Document-Scanner, but no luck, i am a iOS developer switch to React Native, i have no idea about Android. :(
Ok, I managed to compile and run the example but with a couple of errors, I found an error here: scanDocPackage.onActivityCreated(activity); because it says that the method is not found, what's the purpose of that?
Also have you considered using the camera built-in in OpenCV instead of a react native module?
Sorry I didn't mentioned you @beast
@khrizt thank you for your effort. Pls let us know if you can fix it :) Thanks.
@khrizt Thanks for the looking into this. It has been quite a while ago so it could be somewhere down the road of RN changes that this is no longer needed. I did it because back then I had a problem retrieving the activity from Android for RN consumption. I had seen built-in openCV like an iOS lib that does this but the edge detection was pretty bad when I mix with other objects. Anyway, I know my detection code is good in Native Android, see https://github.com/beast/android-opencv-scan-doc
And I had built RN lib before, but I am really not sure how to make openCV play nicely with RN. Do you mind sharing what you did with your own project? Thanks.
Sorry for the late reply, I had a busy week. The main difference between what I've seen in your project and mine is that I added the libopencv_java3.so files for all supported platforms in the jniLibs folder inside my main project. Besides that the structure is the same. Then to instantiate the OpenCV library I added this code to the activity:
static {
if(!OpenCVLoader.initDebug()){
Log.d(TAG, "OpenCV not loaded");
// mostrar error
} else {
Log.d(TAG, "OpenCV loaded");
connected = true;
}
}
And use OpenCV methods normally. As I said in a previous comment I use the org.opencv.android.JavaCameraView extending it to be able to take a picture programatically.
I think that's all, please tell me if you want me to test something, or if you need anything.
@xkraty @beast Can you update the Example? Thank you.
@khrizt @ducpt2 I will have a poke on it when I could free from my daily duty. Currently I am running a startup is experiencing high growth. If anyone got time, feel free to open a pull request. Thanks.
@beast Thank you, I'm waiting for it. @khrizt Can you open a pull request? Really hope you can fix this. :)
Hi,
Today I've been trying to apply my configuration to this project and so far I have been unsuccessful. I really don't understand what's wrong because gradle can't find OpenCV library in the react-native-scan-doc module, even I have it set up just like my project. I'll try some more today and tomorrow and will let you know.
@beast If I can't make it work, would it be ok for you if I create a new project and set it up again, with newer react and opencv versions and try your code inside?
@khrizt I'm very appreciated your effort. Can you make a video how to set things up? I will learn a lot from this video (like bridge, setup opencv...)? Thank you so much.
@khrizt Actually that was the same problem I was facing. I always had hit and misses when I try on my own. So I was not 100% sure what was wrong. Because as you could tell that my android native one will always certainly work...
@beast There's something there to find out :) I'll try it again soon and try to make some sense of the situation. EDIT: by the way, I found someone who has compiled OpenCV and uploaded to maven, maybe it's something worth trying deeply. I tried with my fork of your project and gave me the same error but that was after 2 hours of struggling with the error we are talking about, so maybe... who knows.
@ducpt2 I found a tutorial for setting up OpenCV with android native that works, has video and article: https://www.learn2crack.com/2016/03/setup-opencv-sdk-android-studio.html
@khrizt oh, many thanks. 👍
@khrizt really thanks for the link, also if anyone wants more details ragarding native android opencv integration: https://stackoverflow.com/questions/27406303/opencv-in-android-studio
Anyone still work on this project?
any update on this?
I've found a opencv react native tutorial that may be of some help, if someone wants to take a look: https://brainhub.eu/blog/opencv-react-native-image-processing/
@beast @ducpt2 guys, does this package work?i am also struggling to scan the doc