Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This guide provides an overview of setting target barcode types using the Aspose.BarCode.Cloud SDK for Dart. Using this SDK, you can specify the barcode types you want to recognize when sending requests, including formats like Aztec, QR, Pdf417, and many others.
RecognizeApi
The RecognizeApi
provides methods for recognizing barcodes from various data inputs. You can choose to send barcode recognition requests using either a file URL, a base64 encoded image, or a multipart form request. By specifying the barcode type and recognition settings, you can optimize the API to target the specific barcode formats your application needs.
The DecodeBarcodeType
enum allows for a variety of barcode types, including:
For full supported barcode list see the decode type github page
recognize
This method sends a GET request with the file URL and barcode type in the query parameters.
import 'dart:io';
import 'package:aspose_barcode_cloud/aspose_barcode_cloud.dart';
Configuration makeConfiguration() {
final jwtToken = Platform.environment['TEST_CONFIGURATION_ACCESS_TOKEN'];
if (jwtToken != null) {
return Configuration(accessToken: jwtToken);
} else {
return Configuration(
clientId: "Client Id from https://dashboard.aspose.cloud/applications",
clientSecret:
"Client Secret from https://dashboard.aspose.cloud/applications",
);
}
}
Future<void> main() async {
final config = makeConfiguration();
final recognizeApi = RecognizeApi(ApiClient(config));
final fileUrl =
"https://products.aspose.app/barcode/scan/img/how-to/scan/step2.png";
final BarcodeResponseList result =
await recognizeApi.recognize(DecodeBarcodeType.MostCommonlyUsed, fileUrl);
print(
"File '$fileUrl' recognized, result: '${result.barcodes[0].barcodeValue}'");
}
In this example, most commonly used barcode symbologies will be recognized from the provided image URL.
recognizeBase64
with multiple Barcode TypesFor base64-encoded images, use the recognizeBase64
method, which allows for flexible recognition across multiple barcode types.
import 'dart:convert';
import 'dart:io';
import 'package:aspose_barcode_cloud/aspose_barcode_cloud.dart';
Configuration makeConfiguration() {
final jwtToken = Platform.environment['TEST_CONFIGURATION_ACCESS_TOKEN'];
if (jwtToken != null) {
return Configuration(accessToken: jwtToken);
} else {
return Configuration(
clientId: "Client Id from https://dashboard.aspose.cloud/applications",
clientSecret:
"Client Secret from https://dashboard.aspose.cloud/applications",
);
}
}
Future<void> main() async {
final config = makeConfiguration();
final recognizeApi = RecognizeApi(ApiClient(config));
final fileName = File(
"${Directory.current.path}${Platform.pathSeparator}qr_and_code128.png")
.absolute
.path;
final fileBytes = File(fileName).readAsBytesSync();
final imageBase64 = base64Encode(fileBytes);
final recognizeBase64Request = RecognizeBase64Request(
[DecodeBarcodeType.QR, DecodeBarcodeType.Code128],
imageBase64,
);
final BarcodeResponseList result =
await recognizeApi.recognizeBase64(recognizeBase64Request);
print("File '$fileName' recognized, results: ");
for (final barcode in result.barcodes) {
print("Value: '${barcode.barcodeValue}', type: ${barcode.type}");
}
}
In this example, the API will target both QR and Pdf417 barcode types in the base64 image string.
recognizeMultipart
For recognizing barcodes from files in a form upload, use recognizeMultipart
. This method supports setting a single barcode type.
import 'dart:io';
import 'package:aspose_barcode_cloud/aspose_barcode_cloud.dart';
Configuration makeConfiguration() {
final jwtToken = Platform.environment['TEST_CONFIGURATION_ACCESS_TOKEN'];
if (jwtToken != null) {
return Configuration(accessToken: jwtToken);
} else {
return Configuration(
clientId: "Client Id from https://dashboard.aspose.cloud/applications",
clientSecret:
"Client Secret from https://dashboard.aspose.cloud/applications",
);
}
}
Future<void> main() async {
final config = makeConfiguration();
final recognizeApi = RecognizeApi(ApiClient(config));
final file =
await File("${Directory.current.path}${Platform.pathSeparator}Pdf417.png")
.readAsBytes();
final BarcodeResponseList result =
await recognizeApi.recognizeMultipart(DecodeBarcodeType.Pdf417, file);
print("File recognized, result: '${result.barcodes[0].barcodeValue}'");
}
This example sets the target type to Pdf417, recognizing only this type in the uploaded image file.
By specifying target barcode types in your RecognizeApi
requests, you can optimize performance and precision based on your application’s needs. Setting a DecodeBarcodeType
for your recognition tasks ensures that only specific barcode formats are detected, improving accuracy and efficiency.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.