提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:胡涛|2022-08-05 10:37:01.977|阅读 275 次
概述:在本文中,我们将学习如何使用 C# 开发基于 GUI 的 OMR Sheet Reader 应用程序。在本文中,我们将学习如何使用 C# 开发基于 GUI 的 OMR Sheet Reader 应用程序。在本文中,我们将学习如何使用 C# 开发基于 GUI 的 OMR Sheet Reader 应用程序。
#慧都22周年庆大促·界面/图表报表/文档/IDE/IOT/测试等千款热门软控件火热促销中>>
相关链接:
光学标记识别 (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@hmdbvip.cn




在现代软件开发过程中,自动化单元测试是确保代码质量与可靠性的关键环节。尤其对于特定框架(如MFC)的代码,测试复杂度显著增加,常因依赖外部资源或交互操作而难以在静默环境中顺利执行。Parasoft C/C++test作为专业的软件测试工具,致力于帮助开发团队高效实施自动化测试,通过其强大的桩函数功能,能够有效模拟依赖组件的行为,从而实现对复杂逻辑的隔离测试。
本文将为大家介绍如何在MyEclipse中使用XDoclet开发EJB 2 Session Bean,欢迎下载最新版体验!
如果能将 CSV 自动转换为 PDF ,就能快速生成清晰、美观的报表,既节省手动排版时间,又能保持数据的专业呈现。本文将介绍如何使用 Spire.XLS for Java 实现这一过程——从加载 CSV 到输出高质量 PDF,仅需数行代码即可完成。
Parasoft C/C++test是一款专为C/C++代码设计的自动化测试工具,通过静态代码分析、单元测试和运行时错误检测等功能,帮助开发团队在早期发现并修复缺陷,提升代码质量和开发效率 。在实际使用中,尤其是在VC6此类旧版开发环境中执行单元测试时,可能会因环境兼容性问题触发链接错误。
相关产品
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@hmdbvip.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
永利最大(官方)网站