Extracts information from a business card. The method can be called with a POST Request to the following URL:
The following parameters are required unless indicated otherwise, and are used by all conversion and recognition API calls:
No additional parameters.
If performing a single-service call, a unique-identifier will be returned that can be used to query the progress of the extraction.
//Simple script to make and process the results of an ExtractCheck request to the LEADTOOLS CloudServices.
const request = require('request');
var servicesUrl = "https://azure.leadtools.com/api/";
//The first page in the file to mark for processing
var firstPage = 1;
//Sending a value of -1 will indicate to the services that the rest of the pages in the file should be processed.
var lastPage = -1;
//We will be uploading the file via a URL. Files can also be passed by adding a PostFile to the request. Only 1 file will be accepted per request.
//The services will use the following priority when determining what a request is trying to do GUID > URL > Request Body Content
var fileURL = 'http://demo.leadtools.com/images/cloud_samples/business_card_sample.jpg';
var recognitionUrl = servicesUrl + 'Recognition/ExtractBusinessCard?firstPage=' + firstPage + '&lastPage=' + lastPage + '&fileurl=' + fileURL;
request.post(getRequestOptions(recognitionUrl), recognitionCallback);
function recognitionCallback(error, response, body){
if(!error && response.statusCode == 200){
var guid = body;
console.log("Unique ID returned by the Services: " + guid);
}
}
function getRequestOptions(url){
//Function to generate and return HTTP request options.
var requestOptions ={
url: url,
headers: {
'Content-Length' : 0
},
auth: {
user:"Enter Application ID",
password:"Enter Application Password"
}
};
return requestOptions;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json.Linq;
namespace Azure_Code_Snippets.DocumentationSnippets
{
class CloudServices_ExtractCheck_Demo
{
private string hostedServicesUrl = "https://azure.leadtools.com/api/";
public async void ExtractCheck()
{
//The first page in the file to mark for processing
int firstPage = 1;
//Sending a value of -1 will indicate to the service that all pages in the file should be processed.
int lastPage = -1;
string fileURL = "http://demo.leadtools.com/images/cloud_samples/business_card_sample.jpg";
string recognitionUrl = string.Format("Recognition/ExtractBusinessCard?firstPage={0}&lastPage={1}&fileurl={2}", firstPage, lastPage, fileURL);
var client = InitClient();
var result = await client.PostAsync(recognitionUrl, null);
if (result.StatusCode == HttpStatusCode.OK)
{
//Unique ID returned by the services
string id = await result.Content.ReadAsStringAsync();
Console.WriteLine("Unique ID returned by the services: " + id);
}
else
Console.WriteLine("Request failed with the following response: " + result.StatusCode);
}
private HttpClient InitClient()
{
string AppId = "Enter Application ID";
string Password = "Enter Application Password";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(hostedServicesUrl);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
string authData = string.Format("{0}:{1}", AppId, Password);
string authHeaderValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(authData));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authHeaderValue);
return client;
}
}
}
#Simple script to make an ExtractCheck request to the LEADTOOLS CloudServices and parse the resulting JSON.
import requests, sys, time
servicesUrl = 'https://azure.leadtools.com/api/'
baseRecognitionUrl ='{}Recognition/ExtractBusinessCard?firstPage={}&lastPage={}&fileurl={}'
#The first page in the file to mark for processing
firstPage = 1
#Sending a value of -1 will indicate to the services that the rest of the pages in the file should be processed.
lastPage = -1
#We will be uploading the file via a URL. Files can also be passed by adding a PostFile to the request. Only 1 file will be accepted per request.
#The services will use the following priority when determining what a request is trying to do GUID > URL > Request Body Content
fileURL = 'http://demo.leadtools.com/images/cloud_samples/business_card_sample.jpg'
formattedRecognitionUrl = baseRecognitionUrl.format(servicesUrl,firstPage, lastPage, fileURL)
#The application ID.
appId = "Enter Application ID";
#The application password.
password = "Enter Application Password";
request = requests.post(formattedRecognitionUrl, auth=(appId, password))
if request.status_code != 200:
print("Error sending the conversion request")
print(request.text)
sys.exit()
#Grab the GUID from the Request
guid = request.text
print("Unique ID returned by the services: " + guid)
<?php
//Simple script to make an ExtractCheck request to the LEADTOOLS CloudServices and parse the resulting JSON.
$servicesBaseUrl = "https://azure.leadtools.com/api/";
$baseRecognitionURL = '%sRecognition/ExtractBusinessCard?firstPage=%s&lastPage=%s&fileurl=%s';
//The first page in the file to mark for processing
$firstPage = 1;
//Sending a value of -1 will indicate to the services that the rest of the pages in the file should be processed.
$lastPage = -1;
//We will be uploading the file via a URL. Files can also be passed by adding a PostFile to the request. Only 1 file will be accepted per request.
//The services will use the following priority when determining what a request is trying to do GUID > URL > Request Body Content
$fileURL = 'http://demo.leadtools.com/images/cloud_samples/business_card_sample.jpg';
$formattedConversionURL = sprintf($baseRecognitionURL, $servicesBaseUrl, $firstPage, $lastPage, $fileURL);
//HTTP Headers to be sent alongside the request.
$conversionRequestOptions = GeneratePostOptions($formattedConversionURL);
$request = curl_init();
curl_setopt_array($request, $conversionRequestOptions); //Set the request URL
if(!$guid = curl_exec($request))
{
echo "There was an error processing the request. \n\r";
echo $guid;
exit;
}
curl_close($request); //Close the request
echo "Unique ID returned by the services: $guid \n\r";
function GeneratePostOptions($url)
{
$appId = "Enter Application ID";
$password = "Enter Application Password";
$headers = array(
"Content-Length : 0"
);
$postOptions = array(
CURLOPT_POST => 1,
CURLOPT_URL => $url,
CURLOPT_FRESH_CONNECT => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_USERPWD => "$appId:$password",
CURLOPT_FORBID_REUSE => 1,
CURLOPT_HTTPHEADER => $headers
);
return $postOptions;
}
?>
#Simple script to make and process the results of an ExtractCheck request to the LEADTOOLS CloudServices.
use base 'HTTP::Message';
use LWP::UserAgent ();
require HTTP::Request;
require HTTP::Headers;
my $servicesUrl = "https://azure.leadtools.com/api/";
#The first page in the file to mark for processing
my $firstPage = 1;
#Sending a value of -1 will indicate to the services that the rest of the pages in the file should be processed.
my $lastPage = -1;
#We will be uploading the file via a URL. Files can also be passed by adding a PostFile to the request. Only 1 file will be accepted per request.
#The services will use the following priority when determining what a request is trying to do GUID > URL > Request Body Content
my $fileURL = 'http://demo.leadtools.com/images/cloud_samples/business_card_sample.jpg';
my $appId = 'Enter Application ID';
my $password = 'Enter Application Password';
my $headers = HTTP::Headers->new(
Content_Length => 0
);
$headers->authorization_basic($appId, $password);
#The User Agent to be used when making requests
my $ua = LWP::UserAgent->new;
#For the purposes of this script, we will be extracting info from a barcode.
my $recognitionUrl = $servicesUrl . 'Recognition/ExtractBusinessCard?firstPage=' . $firstPage . '&lastPage=' . $lastPage . '&fileurl=' . $fileURL;
my $request = HTTP::Request->new(POST => $recognitionUrl, $headers);
my $response = $ua->request($request);
if(!$response->is_success){
print STDERR $response->status_line, "\n";
exit;
}
$guid = $response->decoded_content;
print("Unique ID returned by the services: " . $guid . "\n");