How Use OCREngine 2 on PHP?

How do I use OCREngine 2 in Php?

I tried to change the engine by adding the parameter “OCREngine 2” as it says here:
Post OCREngine
but it didn’t work because the result is the same as when using engine 1 on the same image in ocr.space

function uploadToApi($target_file){
    require __DIR__ . '/vendor/autoload.php';
    $fileData = fopen($target_file, 'r');
    $client = new \GuzzleHttp\Client();
    try {
    $r = $client->request('POST', 'https://api.ocr.space/parse/image',[
        'headers' => [
        	'apiKey' => 'my_key',
        	'language' => 'por', 
        	'OCREngine' => 2
        ],
        'multipart' => [
            [
                'name' => 'file',
                'contents' => $fileData
            ]
        ]
    ], ['file' => $fileData]);
    $response =  json_decode($r->getBody(),true);
    if($response['ErrorMessage'] == "") {
...

Hi, does it work for you when you test it with Postman?

This works for me:
https://forum.ui.vision/uploads/db8324/original/2X/9/97c0e29444775d522cfb6fd01aabd6b29c4c37f9.jpeg

(image from this post: OCR Engine 2 not working )

…I am not good a PHP, but I think the language info and the ocrengine thing should not be in header, but in the body?

      [
    	'language' => 'por', 
    	'OCREngine' =>  '2',               
            'name' => 'file',
            'contents' => $fileData
        ]

Does that work?

Yes, I tried for postman, but i made the same mistake in the test as in the code, thanks a lot!

Hi guys! How do you use this OCR Engine 2 at all? I read so much about it and I still can’t understand! what are you using it for? and I also have a question about the postman, is there any program for recognizing the postcode? look at the site https://postcodefinder.net/scotland/glasgow, for example, is there a similar program? I want to use it for my site.

For the first question see here: https://ocr.space/ocrapi#ocrengine

Second question: Do you want to extract postcodes from this website? That seems like a text for web scraping, not OCR.