Last active
July 20, 2018 05:37
-
-
Save aspose-cloud/b0e9305b5be4b21598cfdd5dd21102cb to your computer and use it in GitHub Desktop.
The GIST contains .NET Examples of Aspose.OMR Cloud APIs.
This file contains 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
The GIST contains .NET Examples of Aspose.OMR Cloud APIs. |
This file contains 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
// Instantiate parameters class and pass JSON string with packed template file (.omr) | |
OMRFunctionParam param = new OMRFunctionParam(); | |
param.FunctionParam = packedTemplateJson; | |
// unfilled template image that is used to create template | |
string fileName = "AnswerSheet.png"; | |
string actionName = "CorrectTemplate"; | |
string storage = null; | |
string folder = null; | |
// call Omr Task with specified parameters | |
omrApi.PostRunOmrTask(fileName, actionName, param, storage, folder); |
This file contains 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
// template id string recieved after Template Correction | |
string templateId = "5b535525-72fe-453f-83e8-5a058569620e"; | |
// Instantiate parameters class and pass Template ID | |
OMRFunctionParam param = new OMRFunctionParam(); | |
param.FunctionParam = templateId; | |
// file with results of template correction (.omrcr) | |
string fileName = "AnswerSheet.omrcr"; | |
string actionName = "FinalizeTemplate"; | |
string storage = null; | |
string folder = null; | |
// call Omr Task with specified parameters | |
omrApi.PostRunOmrTask(fileName, actionName, param, storage, folder); |
This file contains 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
// Instantiate parameters class and pass JSON string with folder path to the images used in template description | |
OMRFunctionParam param = new OMRFunctionParam(); | |
param.FunctionParam = @"{ ""ExtraStoragePath"":""Logos""}"; | |
// txt file name that contains template description | |
string fileName = "AnswerSheet.txt"; | |
string actionName = "GenerateTemplate"; | |
string storage = null; | |
string folder = null; | |
// call Omr Task with specified parameters | |
omrApi.PostRunOmrTask(fileName, actionName, param, storage, folder); |
This file contains 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
// Instantiate API for accessing cloud storage for uploading files | |
StorageApi storageApi = new StorageApi(APIKEY, APPSID); | |
// Instantiate OMR API for accessing OMR functions | |
OmrApi omrApi = new OmrApi(APIKEY, APPSID, BASEPATH); | |
// Set the image file name | |
string fileName= "MyTestResults.dat"; | |
// Set task parameters | |
OMRFunctionParam param = new OMRFunctionParam(); | |
param.FunctionParam = rulesJson; | |
try | |
{ | |
// version of the file on the storage, for storages which support versioning, empty string is the default value | |
string versionId = ""; | |
// this parameter is used for specifing third party storages, leave empty string to use default Aspose storage | |
string storage = ""; | |
// Upload source file to aspose cloud storage | |
storageApi.PutCreate(name, versionId, storage, System.IO.File.ReadAllBytes(pathToResults + name)); | |
// specifies folder name on cloud storage where file is located, leave null if file is located in storage root directory | |
string folder = null; | |
// Invoke Aspose.OMR Cloud SDK API to run OMR task | |
Com.Aspose.OMR.Model.OMRResponse response = omrApi.PostRunOmrTask(name, "GradeAnswers", param, storage, folder); | |
// Get files containing task results | |
FileInfo[] resultFiles = response.Payload.Result.ResponseFiles; | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); | |
} |
This file contains 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
// Instantiate parameters class and pass rules JSON | |
OMRFunctionParam param = new OMRFunctionParam(); | |
param.FunctionParam = packedRules; | |
// .dat file with recognition results | |
string fileName = "AsposeForm.dat"; | |
string actionName = "GradeAnswers"; | |
string storage = null; | |
string folder = null; | |
// call Omr Task with specified parameters | |
omrApi.PostRunOmrTask(fileName, actionName, param, storage, folder); |
This file contains 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
// Instantiate API for accessing cloud storage for uploading files | |
StorageApi storageApi = new StorageApi(APIKEY, APPSID); | |
// Instantiate OMR API for accessing OMR functions | |
OmrApi omrApi = new OmrApi(APIKEY, APPSID, BASEPATH); | |
// Set the image file name | |
string name = "AnswerSheet.png"; | |
// Set task parameters | |
OMRFunctionParam param = new OMRFunctionParam(); | |
param.FunctionParam = packedTemplateJson; | |
try | |
{ | |
// version of the file on the storage, for storages which support versioning, empty string is the default value | |
string versionId = ""; | |
// this parameter is used for specifing third party storages, leave empty string to use default Aspose storage | |
string storage = ""; | |
// Upload source file to aspose cloud storage | |
storageApi.PutCreate(name, versionId, storage, System.IO.File.ReadAllBytes(pathToTheImage + name)); | |
// specifies folder name on cloud storage where file is located, leave null if file is located in storage root directory | |
string folder = null; | |
// Invoke Aspose.OMR Cloud SDK API to run OMR task | |
Com.Aspose.OMR.Model.OMRResponse response = omrApi.PostRunOmrTask(name, "CorrectTemplate", param, storage, folder); | |
// Get files containing task results | |
FileInfo[] resultFiles = response.Payload.Result.ResponseFiles; | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); | |
} |
This file contains 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
OmrResponse: | |
{ | |
int ErrorCode; | |
string ErrorText; | |
Payload | |
{ | |
Result | |
{ | |
string TemplateId; | |
double ExecutionTime; | |
ResponseFiles[] | |
{ | |
string Name; | |
long Size; | |
string Data; | |
} | |
Info | |
{ | |
string ResponseVersion; | |
int ProcessedTasksCount, | |
int SuccessfulTasksCount, | |
Details; | |
} | |
} | |
} | |
} |
This file contains 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
// For complete examples and data files, please go to https://github.com/aspose-omr-cloud/aspose-omr-cloud-dotnet | |
/// <summary> | |
/// Run specific OMR task | |
/// </summary> | |
/// <param name="name">Name of the file to recognize.</param> | |
/// <param name="actionName">Action name ['GenerateTemplate, 'CorrectTemplate', 'FinalizeTemplate', 'RecognizeImage']</param> | |
/// <param name="param">Function params, specific for each actionName</param> | |
/// <param name="storage">Image's storage.</param> | |
/// <param name="folder">Image's folder.</param> | |
/// <returns>Response data</returns> | |
public OMRResponse PostRunOmrTask(string name, string actionName, FromBody OMRFunctionParam param, string storage, string folder) |
This file contains 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
// template id string recieved after Template Correction | |
string templateId = "5b535525-72fe-453f-83e8-5a058569620e"; | |
// Instantiate parameters class and pass Template ID | |
OMRFunctionParam param = new OMRFunctionParam(); | |
param.FunctionParam = templateId; | |
// file with results of template correction (.omrcr) | |
string fileName = "photo.jpg"; | |
string actionName = "RecognizeImage"; | |
string storage = null; | |
string folder = null; | |
// call Omr Task with specified parameters | |
omrApi.PostRunOmrTask(fileName, actionName, param, storage, folder); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment