Click here to Skip to main content
15,845,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an OCR engine to extract characters from images which was written in Python and I have a restful API server in PHP running on nginx.

I like to receive a image file from the end user on PHP API server and send the image to OCR engine to read letters and get back to PHP server with extracted characters. So I can respond the users with the result.

This should be fast. As for the quality of the service, speed is the one of the most important things in API. So I wonder what is the best way to set up this process.

I've thought about the following solutions:

1. Since OCR engine was written in Python, I should build a Python Flask API server to communicate with PHP API server. In case, I just send a request API call from PHP server to Flask server.

2. I deploy the OCR engine on the same server (PHP API server) and use shell command in PHP to run the OCR engine. In this case, I don't have to keep running OCR engine all the time.

I think that running another API server costs more response time and resources of the machine. So I think deploying OCR engine at the same server is better way than communicating b/w two API server.

Anyhow, I am not quite sure about that.

Which is the best and fastest way to handle this process?
Any advice would be appreciated. Thanks.

What I have tried:

I deployed two servers, php api server and python flask api server which communicate with ocr engine. In this case, php sends a request to flask api server.

Data flow is like this:

Request
User > php > flask > ocr engine
Response
ocr > flask > php > user

It's simple, but it takes time because I have to request another call via network.
So I am thinking to deploy OCR on the php server to get the fastest response from it.
Posted
Comments
Gerry Schmitz 3-Feb-22 13:12pm    
It only has to be "fast" if someone is paying for the service (good, fast and cheap: pick 2). And you won't know fast until you benchmark. Usually the problem is a lack of options; a problem which you don't seem to have.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900