使用 Java 从文本标记创建 OMR 模板

OMR 模板可通过光学标记识别 (OMR) 软件或 API 读取。 OMR 软件读取人们在调查、测试和其他纸质文件上标记/填写的信息。我们可以通过编程方式从文本标记轻松生成 OMR 调查、测验或答题卡。在本文中,我们将学习如何在 Java 中创建 OMR 调查或答题纸。

本文将涵盖以下主题:

用于创建 OMR 调查或答题卡的 Java API

为了从文本标记创建 OMR 模板,我们将使用 Aspose.OMR for Java API。它允许设计、创建和识别答题纸、测试、MCQ 试卷、测验、反馈表、调查和选票。请下载 API 的 JAR 或在基于 Maven 的 Java 应用程序中添加以下 pom.xml 配置。

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>http://repository.aspose.com/repo/</url>
</repository>
<dependency>
     <groupId>com.aspose</groupId>
     <artifactId>aspose-omr</artifactId>
     <version>19.12</version>
</dependency>

使用 Java 从文本标记创建 OMR 调查表

我们可以按照以下步骤从文本标记创建调查表:

  • 首先,创建一个 OmrEngine 类的实例。
  • 接下来,使用文本标记文件路径作为参数调用 GenerateTemplate 方法。
  • 之后,将结果作为 GenerationResult 类的对象。
  • 最后调用Save方法保存模板图片和OMR模板。它将本地磁盘文件夹的路径和模板的名称作为参数。

以下代码示例演示了如何使用 Java 从文本标记创建 OMR 调查模板。

// 此代码示例演示如何从文本标记生成调查图像和 OMR。
// 带有模板标记的文本文件的路径
String markupPath = "D:\\Files\\OMR\\SimpleSurvey.txt";

// 初始化 OMR 引擎
OmrEngine engine = new OmrEngine();

// 生成模板
GenerationResult res = engine.generateTemplate(markupPath);

// 保存到本地磁盘
res.save("D:\\Files\\OMR\\", "SimpleSurvey");

我们在上面提到的代码示例中使用了以下文本标记。

?text=Welcome to Sample Survey 

?text=March 30, 2022

#What is Aspose.OMR main function?
	() OCR () Capture human-marked data
	() There is no main function () Enhance images
#Can Aspose.OMR process not only scans, but also photos?
	() Yes, indeed! () No
#Aspose.OMR is available on any platform, because it is:
	() Cross-platform code () Cloud service
#Aspose.OMR works with any kind of OMR forms: tests, exams, questionnaires, surveys, etc.
	() Yes, indeed! () No
#Excellent recognition results can be achieved only for filled bubbles at least for:
	() 40% () 60% () 75% () 98%
#Does Aspose.OMR support bubbles mapping to any key names?
	() No () Partially () Yes, any key names
#Do you have to mark up every question on the page?
	(Yes) Yes, that will help a lot! (No) No
#Rate your preference from 0 to 9 with "0" being preference towards performance 
  and "9" being preference towards flexibility.
	(0) (1) (2) (3) (4) (5) (6) (7) (8) (9)
#I found aspose omr to be a useful tool. (5 - strongly agree, 1 - strongly disagree)
	(5) (4) (3) (2) (1)
来自文本标记的 OMR 调查

来自文本标记的 OMR 调查

使用 Java 从文本标记创建 OMR 测试

我们可以按照前面提到的步骤创建测验或测试。但是,我们只需要为此目的使用以下文本标记。

?text=Name__________________________________ Date____________

?grid=ID
	sections_count=8

#What is Aspose.OMR main function?
	() OCR () Capture human-marked data
	() There is no main function () Enhance images
#Can Aspose.OMR process not only scans, but also photos?
	() Yes, indeed! () No
#Aspose.OMR is available on any platform, because it is:
	() Cross-platform code () Cloud service
#Aspose.OMR works with any kind of OMR forms: tests, exams, questionnaires, surveys, etc.
	() Yes, indeed! () No
#Excellent recognition results can be achieved only for filled bubbles at least for:
	() 40% () 60% () 75% () 98%
#Do you have to mark up every question on the page?
	(Yes) Yes, that will help a lot! (No) No
#Rate your preference from 0 to 9 with "0" being preference towards performance
and "9" being preference towards flexibility.
	(0) (1) (2) (3) (4) (5) (6) (7) (8) (9)
#I found aspose omr to be a useful tool. (5 - strongly agree, 1 - strongly disagree)
	(5) (4) (3) (2) (1)


?text=Sign________________________________
来自文本标记的 OMR 测试

来自文本标记的 OMR 测试

使用 Java 从文本标记生成 OMR 答案表

我们可以按照前面提到的步骤创建一个准备打印的 OMR 答案表。但是,我们只需要为此目的使用以下文本标记。

?answer_sheet=MainQuestions
	elements_count=200
	columns_count=5
来自文本标记的 OMR 答案表

来自文本标记的 OMR 答案表。

获得免费许可证

您可以获得免费的临时许可证 试用该库而不受评估限制。

结论

在本文中,我们学习了如何从文本标记创建 OMR 调查模板并生成调查图像。我们还看到了如何以编程方式从文本标记生成测验和答题纸。此外,您可以使用 文档 了解更多关于 Aspose.OMR for Java API 的信息。如有任何歧义,请随时在 论坛 上与我们联系。

也可以看看