C# interface code
The C# SDK is now open source! https://github.com/Baidu-AIP/dotnet-sdk
This project is a basic OCR API test app as Visual Studio C# project.
https://github.com/A9T9/Baidu-OCR-API
The C# SDK is now open source! https://github.com/Baidu-AIP/dotnet-sdk
This project is a basic OCR API test app as Visual Studio C# project.
https://github.com/A9T9/Baidu-OCR-API
public void GeneralBasicDemo() {
var image = File.ReadAllBytes("Image file path");
// Calling universal text recognition, the image parameters are local images, and may throw an exception such as the network. Please use try/catch to capture
var result = client.GeneralBasic(image);
Console.WriteLine(result);
// If there are optional parameters
var options = new Dictionary<string, object>{
{"language_type", "CHN_ENG"},
{"detect_direction", "true"},
{"detect_language", "true"},
{"probability", "true"}
};
// Calling general text recognition with parameters, picture parameters are local images
result = client.GeneralBasic(image, options);
Console.WriteLine(result);
}
public void GeneralBasicUrlDemo() {
var url = "https//www.x.com/sample.jpg";
// Calling universal text recognition, the image parameter is a remote url image, and may throw an exception such as the network. Please use try/catch to capture
var result = client.GeneralBasicUrl(url);
Console.WriteLine(result);
// If there are optional parameters
var options = new Dictionary<string, object>{
{"language_type", "CHN_ENG"},
{"detect_direction", "true"},
{"detect_language", "true"},
{"probability", "true"}
};
// Calling general text recognition with parameters, image parameters are remote url images
result = client.GeneralBasicUrl(url, options);
Console.WriteLine(result);
}