Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
When working with barcodes in applications, optimizing recognition quality and speed is essential. The RecognitionMode
setting in the Aspose.BarCode.Cloud SDK for .NET offers a way to adjust these parameters, making it possible to prioritize either quality or speed during barcode recognition.
The RecognitionMode
parameter can be set to the following values to control the recognition process:
The IRecognizeApi
interface provides methods to recognize barcodes from files using different HTTP request types. Below are the available methods:
BarcodeRecognizeGetAsync
: Recognizes barcode from a file on the server using a GET
request.BarcodeRecognizeBodyPostAsync
: Recognizes barcode from a file provided in the request body using a POST
request with JSON or XML format.BarcodeRecognizeMultipartPostAsync
: Recognizes barcode from a file provided in the request body using a POST
request with multipart/form-data
.BarcodeRecognizeGetAsync
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace RecgonizeSnippets;
internal static class Program
{
private static Configuration MakeConfiguration()
{
var config = new Configuration();
string? envToken = Environment.GetEnvironmentVariable("TEST_CONFIGURATION_ACCESS_TOKEN");
if (string.IsNullOrEmpty(envToken))
{
config.ClientId = "Client Id from https://dashboard.aspose.cloud/applications";
config.ClientSecret = "Client Secret from https://dashboard.aspose.cloud/applications";
}
else
{
config.JwtToken = envToken;
}
return config;
}
public static async Task Main(string[] args)
{
var recognizeApi = new RecognizeApi(MakeConfiguration());
BarcodeResponseList result = await recognizeApi.RecognizeAsync(DecodeBarcodeType.QR,
"https://products.aspose.app/barcode/scan/img/how-to/scan/step2.png",
recognitionMode: RecognitionMode.Fast,
recognitionImageKind: RecognitionImageKind.Photo);
Console.WriteLine($"File recognized, result: '{result.Barcodes[0].BarcodeValue}'");
}
}
BarcodeRecognizeBodyPostAsync
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace RecognizeSnippets;
internal static class Program
{
private static Configuration MakeConfiguration()
{
var config = new Configuration();
string? envToken = Environment.GetEnvironmentVariable("TEST_CONFIGURATION_ACCESS_TOKEN");
if (string.IsNullOrEmpty(envToken))
{
config.ClientId = "Client Id from https://dashboard.aspose.cloud/applications";
config.ClientSecret = "Client Secret from https://dashboard.aspose.cloud/applications";
}
else
{
config.JwtToken = envToken;
}
return config;
}
public static async Task Main(string[] args)
{
var recognizeApi = new RecognizeApi(MakeConfiguration());
string fileName = Path.GetFullPath(Path.Join("Tests", "test_data",
"Pdf417.png"
));
byte[] imageBytes = await File.ReadAllBytesAsync(fileName);
string imageBase64 = Convert.ToBase64String(imageBytes);
var request = new RecognizeBase64Request
{
FileBase64 = imageBase64,
RecognitionMode = RecognitionMode.Excellent,
BarcodeTypes = new List<DecodeBarcodeType> { DecodeBarcodeType.Pdf417 }
};
BarcodeResponseList result = await recognizeApi.RecognizeBase64Async(request);
Console.WriteLine($"File '{fileName}' recognized, result: '{result.Barcodes[0].BarcodeValue}'");
}
}
BarcodeRecognizeMultipartPostAsync
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace RecognizeSnippets;
internal static class Program
{
private static Configuration MakeConfiguration()
{
var config = new Configuration();
string? envToken = Environment.GetEnvironmentVariable("TEST_CONFIGURATION_ACCESS_TOKEN");
if (string.IsNullOrEmpty(envToken))
{
config.ClientId = "Client Id from https://dashboard.aspose.cloud/applications";
config.ClientSecret = "Client Secret from https://dashboard.aspose.cloud/applications";
}
else
{
config.JwtToken = envToken;
}
return config;
}
public static async Task Main(string[] args)
{
var recognizeApi = new RecognizeApi(MakeConfiguration());
string fileName = Path.GetFullPath(Path.Join("Tests", "test_data",
"aztec.png"
));
using var fileStream = File.OpenRead(fileName);
BarcodeResponseList result = await recognizeApi.RecognizeMultipartAsync(DecodeBarcodeType.Aztec, fileStream,
recognitionMode: RecognitionMode.Normal,
recognitionImageKind: RecognitionImageKind.ScannedDocument
);
Console.WriteLine($"File '{fileName}' recognized, result: '{result.Barcodes[0].BarcodeValue}'");
}
}
Choosing the appropriate RecognitionMode
is essential in tailoring barcode recognition to the specific needs of your application. Whether prioritizing speed or accuracy, the examples provided demonstrate how to use the IRecognizeApi
interface to adjust settings for optimal performance. By fine-tuning RecognitionMode
and RecognitionImageKind
, you can enhance both efficiency and accuracy, making your barcode processing solution robust across various use cases.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.