このハウツートピックでは、C#でOMR回答シートチェッカーを作成する方法を紹介します。このステップバイステップガイドの後、C#コードで多肢選択式の解答用紙をスキャンできるようになります。このトピックは、C#アプリケーションの光学式マーク認識を画像に適用するのに役立ちます。
C#でOMR回答シートチェッカーを作成する手順
- NuGet.orgからAspose.OMR for .NETパッケージをインストールします
- Aspose.OMRおよびAspose.OMR.Api名前空間を使用して、C#で解答用紙をスキャンします
- SetLicenseメソッドを使用して.NETAPIライセンスのAspose.OMRを設定します
- OmrEngine classを使用してOMRテンプレートをTemplateProcessor objectに読み込みます
- PNG画像をスキャンして認識し、結果をCSVデータとして抽出します
- 抽出したCSVデータを出力CSVファイルとして保存します
上記の手順は、C#で選択式の解答用紙をすばやく簡単に読むのに役立ちます。 C#アプリケーションで解答用紙を読むために外部ソフトウェアは必要ありません。 Aspose.OMR for .NETは、この問題を解決できます。
C#でOMR回答シートチェッカーを作成するためのコード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
//Add reference to Aspose.OMR for .NET API | |
//Use following namespaces to create OMR answer sheet checker | |
using Aspose.OMR; | |
using Aspose.OMR.Api; | |
namespace CreateOMRAnswerSheetChecker | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//Set Aspose license before creating OMR answer sheet checker | |
//using Aspose.OMR for .NET | |
Aspose.OMR.License AsposeOMRLicense = new Aspose.OMR.License(); | |
AsposeOMRLicense.SetLicense(@"c:\asposelicense\license.lic"); | |
//Load template file into template processor | |
OmrEngine OMREngine = new OmrEngine(); | |
TemplateProcessor OMRTemplateProcessor = OMREngine.GetTemplateProcessor("OMRTemplate.omr"); | |
//Get CSV values from the actual image | |
String ExtractedCSVFromImage = OMRTemplateProcessor.RecognizeImage("AnswerSheetImageToOMR.png").GetCsv(); | |
//Save output as CSV | |
File.WriteAllText("OutputExtractedCSVValues.csv", ExtractedCSVFromImage); | |
} | |
} | |
} |
上記のコードでは、PNG画像にoptical mark recognitionを適用し、C#で解答用紙を読みました。多肢選択式の解答用紙を認識するためにOMRテンプレートを使用していることに注意してください。最後に、抽出したデータをCSVファイルに保存しました。