HBLab Product Suite API

Ocr

ocrPost

Text recognition

Gets text recognization from an image file


/ocr

Samples Usages

curl -X POST "http://ocr-api.hblab.ai/api/ocr"
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.OcrApi;

import java.io.File;
import java.util.*;

public class OcrApiExample {

    public static void main(String[] args) {
        
        OcrApi apiInstance = new OcrApi();
        String apiToken = apiToken_example; // String | You can get API token in the user setting
        File image = /path/to/file.txt; // File | Image file to analyze
        try {
            apiInstance.ocrPost(apiToken, image);
        } catch (ApiException e) {
            System.err.println("Exception when calling OcrApi#ocrPost");
            e.printStackTrace();
        }
    }
}
import io.swagger.client.api.OcrApi;

public class OcrApiExample {

    public static void main(String[] args) {
        OcrApi apiInstance = new OcrApi();
        String apiToken = apiToken_example; // String | You can get API token in the user setting
        File image = /path/to/file.txt; // File | Image file to analyze
        try {
            apiInstance.ocrPost(apiToken, image);
        } catch (ApiException e) {
            System.err.println("Exception when calling OcrApi#ocrPost");
            e.printStackTrace();
        }
    }
}
String *apiToken = apiToken_example; // You can get API token in the user setting
File *image = /path/to/file.txt; // Image file to analyze

OcrApi *apiInstance = [[OcrApi alloc] init];

// Text recognition
[apiInstance ocrPostWith:apiToken
    image:image
              completionHandler: ^(NSError* error) {
                            if (error) {
                                NSLog(@"Error: %@", error);
                            }
                        }];
var HbLabProductSuiteApi = require('hb_lab_product_suite_api');

var api = new HbLabProductSuiteApi.OcrApi()

var apiToken = apiToken_example; // {String} You can get API token in the user setting

var image = /path/to/file.txt; // {File} Image file to analyze


var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully.');
  }
};
api.ocrPost(apiToken, image, callback);
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;

namespace Example
{
    public class ocrPostExample
    {
        public void main()
        {
            
            var apiInstance = new OcrApi();
            var apiToken = apiToken_example;  // String | You can get API token in the user setting
            var image = new File(); // File | Image file to analyze

            try
            {
                // Text recognition
                apiInstance.ocrPost(apiToken, image);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling OcrApi.ocrPost: " + e.Message );
            }
        }
    }
}
<?php
$filePath = yourimagefilepath; // String | Path to image file to analyze
$apiKey = yourapitoken; // String | You can get API token in the user setting

$fileName = basename($filePath);
$file = file_get_contents($filePath);
$mime = mime_content_type($filePath);
$boundary = '-----------BOUNDARY';

$postContent = "--$boundary\nContent-Disposition: form-data; name=\"api_token\"\n\n";
$postContent .= "$apiKey\n";
$postContent .= "--$boundary\nContent-Disposition: form-data; name=\"image\"; filename=\"$fileName\"\n";
$postContent .= "Content-Type: $mime\n\n";
$postContent .= "$file\n";
$postContent .= "--$boundary--";

// Call Api
$apiOptions = [
    'http' => [
        'header' => 'Content-type: multipart/form-data; boundary=' . $boundary,
        'method' => 'POST',
        'content' => $postContent,
    ]
];
$context = stream_context_create($apiOptions);
$http_response_header = null;
try {
    $jsonResult = file_get_contents('http://ocr-api.hblab.ai/api/ocr', false, $context);
} catch (\Exception $e) {
    return false;
}
echo $jsonResult;
use Data::Dumper;
use WWW::SwaggerClient::Configuration;
use WWW::SwaggerClient::OcrApi;

my $api_instance = WWW::SwaggerClient::OcrApi->new();
my $apiToken = apiToken_example; # String | You can get API token in the user setting
my $image = /path/to/file.txt; # File | Image file to analyze

eval { 
    $api_instance->ocrPost(apiToken => $apiToken, image => $image);
};
if ([email protected]) {
    warn "Exception when calling OcrApi->ocrPost: [email protected]\n";
}
from __future__ import print_statement
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = swagger_client.OcrApi()
apiToken = apiToken_example # String | You can get API token in the user setting
image = /path/to/file.txt # File | Image file to analyze

try: 
    # Text recognition
    api_instance.ocr_post(apiToken, image)
except ApiException as e:
    print("Exception when calling OcrApi->ocrPost: %s\n" % e)
var fs = require('fs');
var request = require("request");

var formData = {
    api_token: yourapitoken, // {String} You can get API token in the user setting
    image: fs.createReadStream(yourimagefilepath), // {String} (path) image file to analyze
};

request.post({ url: 'http://ocr-api.hblab.ai/api/ocr', formData: formData }, function(err, httpResponse, body) {
    if (err) {
        return console.error('upload failed:', err);
    }
    console.log('Upload successful!  Server responded with:', body);
});

Parameters

Form parameters
Name Description
api_token*
String
You can get API token in the user setting
Required
image*
File
Image file to analyze
Required

Responses

Status: 200 - successful result

Status: 415 - invalid input, image invalid