Closed vdurif closed 9 years ago
Ok sorry, I've a problem with assets folder in Xamarin Studio. My files are note populated to my app I don't know why. But it explains why init function did not work in my case.
Just check if your tessdata folder is setup correctly. For Android tessdata folder should sit under the Assets folder and all files should have Build action set to AndroidAsset. For iOS folder with files marked as BundleResource should be in the Resources folder.
Yes I've done that. I got it work with "eng" language last week but now when I add files to my assets folder it is not deployed to my phone. So I try to remove all files and add them again in Assets/tessdata and now i don't have any files in Assets deployed to my phone (not even the tessdata folder).
Have you tried removing the app completely? I probably know about one issue that could cause problem like yours.
You mean removing the app from my phone ? I tried uninstall it, removing the "com.myapp" folder and reinstall it but I still got nothing in Assets folder. I really don't know where it comes from.
EDIT: I tried modifying a layout file in order to see if its modification was deployed after build and it was.
Which OS are you testing on?
Android 5.1.1 (on a Nexus 4 and Nexus 5)
Can you share your logs?
Do you mean my build logs ?
No, application logs (logcat).
[OpenCV] Trying to get library list [OpenCV] Library list: "" [OpenCV] First attempt to load libs [OpenCV] Trying to init OpenCV libs [OpenCV] Trying to load library opencv_java [OpenCV] Library opencv_java loaded [OpenCV] First attempt to load libs is OK [OpenCV] General configuration for OpenCV 2.4.9 ===================================== [OpenCV] Version control: 2.4.9 [OpenCV] Platform: [OpenCV] Host: Linux 3.2.0-56-generic x86_64 [OpenCV] Target: Linux 1 armv7-a [OpenCV] CMake: 2.8.12.1 [OpenCV] CMake generator: Ninja [OpenCV] CMake build tool: /usr/local/bin/ninja [OpenCV] Configuration: Release [OpenCV] C/C++: [OpenCV] Built as dynamic libs?: NO [OpenCV] C++ Compiler: /opt/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ (ver 4.6) [OpenCV] C++ flags (Release): -fexceptions -frtti -Wno-psabi --sysroot=/opt/android-ndk-r8c/platforms/android-8/arch-arm -fpic -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fdata-sections -ffunction-sections -Wa,--noexecstack -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -fdiagnostics-show-option -fomit-frame-pointer -mthumb -fomit-frame-pointer -fno-strict-aliasing -O3 -DNDEBUG -DNDEBUG [OpenCV] C++ flags (Debug): -fexceptions -frtti -Wno-psabi --sysroot=/opt/android-ndk-r8c/platforms/android-8/arch-arm -fpic -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fdata-sections -ffunction-sections -Wa,--noexecstack -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -fdiagnostics-show-option -fomit-frame-pointer -marm -fno-omit-frame-pointer -fno-strict-aliasing -O0 -g -DDEBUG -D_DEBUG -O0 -DDEBUG -D_DEBUG [OpenCV] C Compiler: /opt/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc [OpenCV] C flags (Release): -fexceptions -Wno-psabi --sysroot=/opt/android-ndk-r8c/platforms/android-8/arch-arm -fpic -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fdata-sections -ffunction-sections -Wa,--noexecstack -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -fomit-frame-pointer -mthumb -fomit-frame-pointer -fno-strict-aliasing -O3 -DNDEBUG -DNDEBUG [OpenCV] C flags (Debug): -fexceptions -Wno-psabi --sysroot=/opt/android-ndk-r8c/platforms/android-8/arch-arm -fpic -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fdata-sections -ffunction-sections -Wa,--noexecstack -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -fomit-frame-pointer -marm -fno-omit-frame-pointer -fno-strict-aliasing -O0 -g -DDEBUG -D_DEBUG -O0 -DDEBUG -D_DEBUG [OpenCV] Linker flags (Release): -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -fuse-ld=gold -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now [OpenCV] Linker flags (Debug): -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -fuse-ld=gold -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now [OpenCV] Precompiled headers: YES [OpenCV] OpenCV modules: [OpenCV] To be built: core androidcamera flann imgproc highgui features2d calib3d ml objdetect video contrib photo java legacy ocl stitching superres ts videostab [OpenCV] Disabled: gpu world [OpenCV] Disabled by dependency: - [OpenCV] Unavailable: dynamicuda nonfree python viz [OpenCV] Android: [OpenCV] Android ABI: armeabi-v7a [OpenCV] STL type: gnustl_static [OpenCV] Native API level: android-8 [OpenCV] SDK target: android-11 [OpenCV] Android NDK: /opt/android-ndk-r8c (toolchain: arm-linux-androideabi-4.6) [OpenCV] android tool: /opt/android-sdk-linux/tools/android (Android SDK Tools, revision 22.6.) [OpenCV] Google Play package: YES [OpenCV] Android examples: YES [OpenCV] GUI: [OpenCV] GTK+ 2.x: NO [OpenCV] GThread : NO [OpenCV] GtkGlExt: NO [OpenCV] OpenGL support: NO [OpenCV] VTK support: NO [OpenCV] Media I/O: [OpenCV] ZLib: z (ver 1.2.3) [OpenCV] JPEG: build (ver 62) [OpenCV] PNG: build (ver 1.5.12) [OpenCV] TIFF: build (ver 42 - 4.0.2) [OpenCV] JPEG 2000: build (ver 1.900.1) [OpenCV] OpenEXR: build (ver 1.7.1) [OpenCV] Video I/O: [OpenCV] AndroidNativeCamera: YES, use prebuilt libraries [OpenCV] Other third-party libraries: [OpenCV] Use IPP: NO [OpenCV] Use Eigen: YES (ver 3.1.2) [OpenCV] Use TBB: YES (ver 4.1 interface 6102) [OpenCV] Use OpenMP: NO [OpenCV] Use GCD NO [OpenCV] Use Concurrency NO [OpenCV] Use C=: NO [OpenCV] Use Cuda: NO [OpenCV] Use OpenCL: YES [OpenCV] OpenCL: [OpenCV] Version: dynamic [OpenCV] Include path: /home/reports/ci/slave_desktop/50-SDK/opencv/3rdparty/include/opencl/1.2 [OpenCV] Use AMD FFT: NO [OpenCV] Use AMD BLAS: NO [OpenCV] Python: [OpenCV] Interpreter: /usr/bin/python2 (ver 2.7.3) [OpenCV] Java: [OpenCV] ant: /usr/bin/ant (ver 1.8.2) [OpenCV] Java tests: NO [OpenCV] Documentation: [OpenCV] Build Documentation: YES [OpenCV] Sphinx: /usr/local/bin/sphinx-build (ver 1.1.3) [OpenCV] PdfLaTeX compiler: /usr/bin/pdflatex [OpenCV] Tests and samples: [OpenCV] Tests: NO [OpenCV] Performance tests: NO [OpenCV] C/C++ Examples: NO [OpenCV] Install path: /home/reports/ci/slave_desktop/50-SDK/build/builds/o4a/install [OpenCV] cvconfig.h is in: /home/reports/ci/slave_desktop/50-SDK/build/builds/o4a [OpenCV] -----------------------------------------------------------------
[[TesseractApi]] Copy assets to /storage/emulated/0/Android/data/com.mycompany.myapp/files
Thread started:
EDIT : Did not know which part of logs you wanted , I just put part of code throwing exception after init failed :D
Thanks, this is the log, that I need. Can you share your initailization code? Do you await TesseractApi.Init method? Result is true?
No I did not. I still don't know much .NET but when I use await it asks me to put an async on my function and I can't on my constructor (I suppose i could use a Task.run() or something like this but I don't really looked at it for now).
I add it to an async function and used await: it works. I used an explorer on my phone and tessdata is now fully deployed on my phone. Does it comes from await ? I thought that Assets folder will be filled during installation.
Anyway, thank you halkar for helping me :)
If you could share your code I will be able to suggest something :)
What I change : tesseractApi = new TesseractApi (Application.Context); bool success = await tesseractApi.Init ("ocrb"); if (success) { Log.Debug (TAG, "Tesseract success init"); tesseractApi.SetWhitelist ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ<"); tesseractApi.SetVariable ("load_system_dawg", "F"); tesseractApi.SetVariable ("load_freq_dawg", "F"); tesseractApi.SetVariable ("load_unambig_dawg", "F"); tesseractApi.SetVariable ("load_punc_dawg", "F"); tesseractApi.SetVariable ("load_number_dawg", "F"); tesseractApi.SetVariable ("load_fixed_length_dawgs", "F"); tesseractApi.SetVariable ("load_bigram_dawg", "F"); tesseractApi.SetVariable ("wordrec_enable_assoc", "F"); } else { Log.Debug (TAG, "Tesseract failed init"); }
How it was before :
tesseractApi = new TesseractApi (Application.Context);
tesseractApi.Init ("ocrb");tesseractApi.SetWhitelist ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ<");
tesseractApi.SetVariable ("load_system_dawg", "F");
tesseractApi.SetVariable ("load_freq_dawg", "F");
tesseractApi.SetVariable ("load_unambig_dawg", "F");
tesseractApi.SetVariable ("load_punc_dawg", "F");
tesseractApi.SetVariable ("load_number_dawg", "F");
tesseractApi.SetVariable ("load_fixed_length_dawgs", "F");
tesseractApi.SetVariable ("load_bigram_dawg", "F");
tesseractApi.SetVariable ("wordrec_enable_assoc", "F");
Your code looks fine. I wonder why not all files are deployed. Try uninstalling the app and deploing it again ;)
I wil ltry deploying it on another phone. I'll edit with result.
Thanks!
Ok I tried depolying it on a Nexus 5. I had to uninstall old app first if not it doesn't update my Assets folder but after that it works great. I think of Xamarin Studio issue :).
Cool!
Hello,
I'm trying to use custom trained data for OCR-B with Xamarin.Tesseract. I build my own ocrb.traineddata following https://reachsri.wordpress.com/2014/01/28/process-to-train-tesseract-ocr-3/
I put this traineddata in the assets folder and then I call "tesseractApi.Init ("ocrb");" but initialization fail. Have someone an idea about what happens ? I can share my trained data if required.
Hello Sir,
I am new to xamarin android development. I have eng.traineddata file and i am using this in xamarin android but scan always gives me very bad result. Can you please share with me your ocrb trained data.
Thanks and best regards
Hello,
I'm trying to use custom trained data for OCR-B with Xamarin.Tesseract. I build my own ocrb.traineddata following https://reachsri.wordpress.com/2014/01/28/process-to-train-tesseract-ocr-3/
I put this traineddata in the assets folder and then I call "tesseractApi.Init ("ocrb");" but initialization fail. Have someone an idea about what happens ? I can share my trained data if required.