没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:胡涛|2022-08-05 10:37:01.977|阅读 266 次
概述:在本文中,我们将学习如何使用 C# 开发基于 GUI 的 OMR Sheet Reader 应用程序。在本文中,我们将学习如何使用 C# 开发基于 GUI 的 OMR Sheet Reader 应用程序。在本文中,我们将学习如何使用 C# 开发基于 GUI 的 OMR Sheet Reader 应用程序。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
光学标记识别 (OMR) 是一种自动捕获和分析标记在特殊类型文档表单上的数据的过程。这种特殊类型的文件可以由人们在调查表、测试表和其他纸质文件上标记/填写。在本文中,我们将学习如何使用 C# 开发基于 GUI 的 OMR Sheet Reader 应用程序。我们的解决方案将扫描的 OMR 表图像作为本地磁盘的输入,然后识别标记,最后以CSV格式导出标记的注册号和阴影答案。完成上述步骤后,我们将拥有.NET 中的 C# 光学标记识别 (OMR) 软件。那么让我们开始吧。
我们的光学标记识别 (OMR) 软件将具有以下功能:
Aspose.OMR for .NET API 允许设计、创建和识别答题卡、测试、MCQ 试卷、测验、反馈表、调查和选票。此外,它还提供了一个图形用户界面控件,可以添加到 .NET UI 应用程序中。我们将在 .NET UI 应用程序中集成 Aspose.OMR for .NET UI 控件,以开发 OMR 扫描仪/阅读器应用程序。请下载API 的 DLL 或使用NuGet安装它。
PM> Install-Package Aspose.OMR
我们可以按照以下步骤开发基于 GUI 的 OMR 扫描仪/阅读器应用程序:
internal class DialogHelper
{
/// <summary>
/// The filter string for the dialog that opens template images.
/// </summary>
private static readonly string ImageFilesFilterPrompt = "Image files |*.jpg; *.jpeg; *.png; *.gif; *.tif; *.tiff;";
/// <summary>
/// The filter string for the dialog that saves recognition results
/// </summary>
private static readonly string DataExportFilesFilterPrompt = "Comma-Separated Values (*.csv)" + " | *.csv";
/// <summary>
/// Shows Open Image file dialog.
/// </summary>
/// <returns>Path to selected file, or <c>null</c> if no file was selected.</returns>
public static string ShowOpenImageDialog(string suggestedDir = null)
{
OpenFileDialog dialog = new OpenFileDialog();
return ShowDialog(dialog, ImageFilesFilterPrompt, suggestedDir);
}
/// <summary>
/// Shows Save Recognition Results file dialog.
/// </summary>
/// <returns>Path to selected file, or <c>null</c> if no file was selected.</returns>
public static string ShowSaveDataDialog(string suggestedName)
{
SaveFileDialog dialog = new SaveFileDialog();
return ShowDialog(dialog, DataExportFilesFilterPrompt, suggestedName);
}
/// <summary>
/// Displays given dialog and returns its result as a <c>string</c>.
/// </summary>
/// <param name="dialog">The dialog to show.</param>
/// <param name="filter">File type filter string.</param>
/// <param name="suggestedDir">Suggested dialog initial directory</param>
/// <param name="suggestedName">Suggested file name</param>
/// <returns>Path to selected file, or <c>null</c> if no file was selected.</returns>
private static string ShowDialog(FileDialog dialog, string filter, string suggestedDir = null, string suggestedName = null)
{
string fileName = null;
dialog.Filter = filter;
dialog.RestoreDirectory = true;
if (suggestedName != null)
{
dialog.FileName = suggestedName;
}
if (suggestedDir != null)
{
dialog.InitialDirectory = suggestedDir;
}
bool? result = dialog.ShowDialog();
if (result == true)
{
fileName = dialog.FileName;
}
return fileName;
}
}
<Window x:Class="OMR_APP.MainWindow"
xmlns="//schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="//schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="//schemas.microsoft.com/expression/blend/2008"
xmlns:mc="//schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:OMR_APP"
mc:Ignorable="d"
Title="Aspose OMR Demo" Height="880" Width="1100">
<Grid Background="WhiteSmoke">
<Grid.RowDefinitions>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<ToolBar Grid.Row="0" Background="LightGray">
<TextBox Name="txtTemplatePath" Margin="5" Width="400" Height="30" Background="White"
HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
</TextBox>
<Button Margin="5" Width="100" Height="30" Background="White"
Content="Get control" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
Click="GetButtonClicked"/>
<Separator/>
<Button Margin="5" Width="100" Height="30" Background="White"
Content="Select Image" Click="SelectImageClicked"/>
<Button Margin="5" Width="100" Height="30" Background="White"
Content="Recognize Image" Click="RecognizeImageClicked"/>
<Button Margin="5" Width="100" Height="30" Background="White"
Content="Export Results" Click="ExportResultsClicked"/>
</ToolBar>
<ContentControl Grid.Row="1" x:Name="CustomContentControl"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Window>
view rawOMR-Software-CSharp_MainWindow.xaml hosted with ❤ by GitHub
之后,替换MainWindow.xaml.cs文件中的以下内容。
/// <summary>
/// Template for testing
/// </summary>
private static readonly string TemplateFilePath = @"C:\Files\OMR\Sheet.omr";
/// <summary>
/// Path to the license Aspose.OMR.NET.lic file
/// </summary>
private static readonly string LicensePath = @"";
private CorrectionControl control;
public MainWindow()
{
InitializeComponent();
// Set and show template file path
txtTemplatePath.Text = TemplateFilePath;
// Set license, provide License file Path and uncomment to test full results
//License lic = new License();
//lic.SetLicense(LicensePath);
}
public string UserImagePath { get; set; }
public string DataFolderPath { get; set; }
/// <summary>
/// Loads and displays CorrectionControl
/// </summary>
private void GetButtonClicked(object sender, RoutedEventArgs e)
{
string path = txtTemplatePath.Text;
try
{
OmrEngine engine = new OmrEngine();
TemplateProcessor processor = engine.GetTemplateProcessor(path);
control = engine.GetCorrectionControl(processor);
CustomContentControl.Content = control;
control.Initialize();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"Exception");
}
}
/// <summary>
/// Select and display image
/// </summary>
private void SelectImageClicked(object sender, RoutedEventArgs e)
{
if (control == null)
{
return;
}
string imagePath = DialogHelper.ShowOpenImageDialog(this.DataFolderPath);
if (string.IsNullOrEmpty(imagePath))
{
return;
}
this.UserImagePath = imagePath;
control.LoadAndDisplayImage(imagePath);
}
/// <summary>
/// Recognize loaded image
/// </summary>
private void RecognizeImageClicked(object sender, RoutedEventArgs e)
{
if (control == null)
{
return;
}
control.RecognizeImage();
}
/// <summary>
/// Export results to CSV
/// </summary>
private void ExportResultsClicked(object sender, RoutedEventArgs e)
{
if (control == null)
{
return;
}
string imageName = Path.GetFileNameWithoutExtension(this.UserImagePath);
string path = DialogHelper.ShowSaveDataDialog(imageName);
if (string.IsNullOrEmpty(path))
{
return;
}
control.ExportResults(path);
MessageBox.Show("The exported resultant CSV file can be found here : " + path, "Operation Successful");
}
以下是我们刚刚创建的 OMR Scanner/Reader 应用程序的演示。
在本文中,我们学习了如何
欢迎下载|体验更多Aspose产品
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@ke049m.cn




大型SaaS系统的自动化测试常常受制于界面变化快、结构复杂、加载机制多变等因素。从元素识别到脚本管理,SmartBear TestComplete帮助Salesforce建了可靠的自动化测试体系。
BarTender 标签管理系统,正是帮助企业轻松实现 GS1 标准化标签设计、编码生成与信息联动的强大工具。
Parasoft C/C++test 是一款功能强大的 C/C++ 软件测试工具,集成了静态代码分析、单元测试、集成测试和覆盖率分析等功能,单元测试作为其关键功能之一,为了适配多样化的目标部署环境,C/C++test 设计了灵活的测试结果收集机制。通过Socket通讯方式来收集单元测试结果,从而扩展其测试覆盖范围与应用场景。
Parasoft C/C++test作为一款功能全面的自动化代码质量保障工具,为C/C++开发者提供了静态分析、单元测试和运行时错误检测等核心功能。通过将其与轻量级且广受欢迎的VScode编辑器集成,开发团队可以在熟悉的编码环境中实时获得代码质量反馈,有效提升开发效率与代码可靠性。
相关产品
Aspose.OMR for .NET是一种光学标记识别API,可从多种图像格式中识别光学标记。
Aspose.Words for .NET无需Microsoft Word也可在任何平台上满足Word文档的一切操作需求。
Spire.Office for .NET专业的.NET Office套件,涵盖office文档创建、编辑、转换、管理和OCR内容识别等操作
最新文章 MORE
半岛外围网上直营相关的文章 MORE
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@ke049m.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
半岛外围网上直营