henrivain / TesseractOcrMaui

Tesseract wrapper for Windows, Android and iOS for .NET MAUI
Apache License 2.0
37 stars 4 forks source link

iOS #11

Closed JTrotta closed 8 months ago

JTrotta commented 1 year ago

Will you upgrade this library to use both Andorid & iOS? Thank you

JTrotta commented 1 year ago

I read better the readme file. Do you accept pull request for iOS?

henrivain commented 1 year ago

Yes, If you can build the libraries and add them to TesseractOcrMAUI/lib/iOS/[architechtures]/[libraries] with needed cpu architechtures the library should work with only small changes. You can find information from microsoft docs.

For other platforms I have built libraries form these repositories tesseract leptonica libpng libjpeg

Windows also needed zlib

Use latest versions of these libraries.

I you want to add iOS support, please, fork the main branch. I don't have iOS devices myself, so I can't debug myself. I can still try to help if you have any problems.

FerdiMarti commented 1 year ago

@JTrotta, I see you've already forked the project. Were you able to build the libraries for iOS and does it work for you?

I am currently struggling to build the libraries without errors.

Thanks!

henrivain commented 1 year ago

Hello @FerdiMarti,

As said I am not familiar with Apple devices and tools, so I can't probably help much, but here are some links.

Tessdoc

You have probably tried steps from tessdoc?

Instructions under title macOS with MacPorts seem to have possibility to work, at least Windows build had some similar steps.

You should be able to pass path parameters to ./configure so that you can point make install/library directory to folder of your choice.

Github actions

Check also macos test github action, it seems to build the library before running tests.

This action also builds with cmake.

My build experiences

I also had a lot of problems when building for Android, because up to date information was hard to find. Also Android was missing dependencies like google cpu features. I gathered my Windows and Android build commands to this repository. No macos or ios of course, but sometimes they might help.

Hope this has any help to you!

FerdiMarti commented 1 year ago

Hi @henrivain,

Thank you for your help and great work with gathering the stuff for Android/ Windows!

After many hours of trying last week and looking into multiple build scripts, etc., I was able to build some smaller libraries including Leptonica, but I finally gave up at Tesseract itself. I have no trouble building it for MacOs, but I run into unfamiliar issues for iOS. It is the first time I ever built libraries myself and so I might need to read more about it.

The project I need it for is somewhat time critical atm and so I found a different way to solve my problem. Unfortunately, I can't put more work days into building Tesseract right now. I do want to revisit this in some weeks though, because most of the OCR libraries I find for iOS/ MAUI are commercial tools, even though they are probably built on Tesseract. It would be great to have a free, open-source alternative.

CRebeloCSS commented 1 year ago

Hi @henrivain,

Thank you for your help and great work with gathering the stuff for Android/ Windows!

After many hours of trying last week and looking into multiple build scripts, etc., I was able to build some smaller libraries including Leptonica, but I finally gave up at Tesseract itself. I have no trouble building it for MacOs, but I run into unfamiliar issues for iOS. It is the first time I ever built libraries myself and so I might need to read more about it.

The project I need it for is somewhat time critical atm and so I found a different way to solve my problem. Unfortunately, I can't put more work days into building Tesseract right now. I do want to revisit this in some weeks though, because most of the OCR libraries I find for iOS/ MAUI are commercial tools, even though they are probably built on Tesseract. It would be great to have a free, open-source alternative.

Would you be willing to share how you found a different way to solve your problem? I would like to use an OCR that allows for custom trained data for both iOS and Android devices and I am curious if your solution would allow for the functionality I require.

FerdiMarti commented 1 year ago

Hi @CRebeloCSS, my use case involved 7-segment-displays and my initial plan was to use Tesseract with custom trained data as well. I realised, that even with custom trained data, Tesseract's accuracy is not that good for 7-segment-displays and preprocessing has to be handled by myself anyways. So now my approach is to parse the pixels and do my own detection. For these kind of displays, it's not as hard as other writing. I guess it could also be achieved with some kind of OpenVC processing.

ThomasMunch commented 9 months ago

Hi @henrivain I think its great you started working on this iOS-branch - My project is for Android and later on for iPhone. I have tried using the Tesseract-nuget (Not yours) and it work fine for my project but it only works in Windows. For my project i found that running Tesseract with enginemode: EngineMode.TesseractOnly was better than default and Lstm. Is it possible to add EngineMode (TesseractOnly, LstmOnly, TesseractAndLstm and Default)to your tesseractOcrMaui.EngineConfiguration? Regards

henrivain commented 8 months ago

Support added in latest update v1.1.0

New supported runtimes Platform Architechture
iOS emulator x86_64
iOS emulator Arm64
iOS physical device Arm64

To get started with iOS

Add package to your csproj with package reference

<PackageReference Include="TesseractOcrMaui" Version="1.1.0" />

Thanks to @sivanmg who helped with package iOS development