Simple example source of handwriting recognition for Windows using C#
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
/*! | |
* @brief example source of handwriting recognition | |
* @date 2019/12/10 | |
* @file HandwritingSimpleExample.cs | |
* @author SELVAS AI | |
* | |
* Copyright 2019. SELVAS AI Inc. All Rights Reserved. | |
*/ | |
using System; | |
using Selvasai; | |
namespace HwrExample | |
{ | |
class Program | |
{ | |
// points of 'a' | |
// -1, 0 : end of stroke | |
// -1, -1 : end of ink | |
// (x0, y0), (x1, y1), ... (-1, 0) ... (xn, yn) .... (-1, 0), (-1, -1) | |
static int[] ink_a = {271, 97, 270, 95, 266, 94, 262, 94, 256, 94, 249, 94, 243, 96, 234, 100, 226, | |
107, 216, 118, 208, 127, 203, 137, 195, 147, 191, 156, 188, 163, 188, 169, 188, 172, 191, 175, | |
195, 176, 202, 176, 210, 176, 218, 176, 227, 173, 237, 170, 246, 166, 253, 161, 258, 156, 261, | |
153, 264, 148, 265, 144, 267, 139, 267, 135, 268, 131, 268, 128, 268, 123, 268, 122, 268, 120, | |
268, 117, 268, 116, 268, 119, 273, 126, 278, 133, 284, 140, 291, 145, 294, 150, 299, 153, 301, | |
156, 303, 159, 306, 160, 307, 163, 308, 163, -1, 0, -1, -1 | |
}; | |
// points of 'good morning' | |
static int[] ink_good_morning = {242, 382, 233, 372, 209, 385, 176, 425, 174, 438, 195, 447, 216, | |
427, 223, 411, 231, 379, 233, 382, 233, 405, 234, 456, 232, 512, 227, 534, 200, 569, 167, 569, 154, | |
543, 161, 513, 173, 500, 220, 476, 266, 464, 278, 458, 282, 458, -1, 0, 303, 398, 292, 403, 285, | |
426, 307, 437, 319, 430, 330, 397, 311, 385, 291, 391, 297, 401, -1, 0, 369, 383, 363, 386, 358, | |
415, 385, 421, 411, 402, 418, 388, 406, 370, 372, 380, 362, 402, 368, 406, -1, 0, 496, 385, 497, | |
384, 495, 377, 471, 383, 457, 391, 438, 418, 463, 424, 482, 416, 510, 386, 516, 343, 511, 315, | |
508, 302, 510, 306, 513, 336, 518, 384, 528, 419, 534, 425, 533, 419, -1, 0, 626, 365, 629, 370, | |
633, 392, 635, 405, 634, 421, 630, 420, 638, 389, 644, 378, 658, 371, 671, 393, 673, 412, 673, 416, | |
673, 409, 678, 389, 684, 378, 704, 366, 715, 377, 720, 397, 723, 409, 723, 411, 725, 409, 730, 402, | |
-1, 0, 756, 374, 750, 375, 749, 401, 776, 400, 788, 391, 797, 373, 766, 366, 750, 373, 763, 375, | |
-1, 0, 814, 350, 814, 347, 823, 358, 836, 390, 838, 406, 835, 409, 833, 397, 837, 389, 855, 368, | |
875, 356, 894, 354, 900, 355, 899, 365, -1, 0, 911, 342, 917, 357, 916, 370, 918, 398, 917, 401, | |
917, 384, 929, 351, 946, 341, 955, 354, 958, 366, 961, 389, 964, 401, 959, 380, -1, 0, 983, 327, | |
991, 326, 1005, 330, 1005, 338, -1, 0, 991, 362, 992, 366, 999, 393, 1001, 400, -1, 0, 1032, 344, | |
1039, 350, 1045, 376, 1046, 396, 1049, 388, 1053, 378, 1067, 355, 1079, 352, 1086, 374, 1092, 398, | |
1095, 404, 1097, 403, 1099, 398, -1, 0, 1146, 345, 1149, 350, 1140, 356, 1127, 375, 1142, 384, | |
1160, 359, 1155, 342, 1151, 343, 1164, 366, 1180, 403, 1181, 439, 1176, 457, 1153, 486, 1113, 488, | |
1089, 463, 1101, 443, 1116, 434, 1162, 417, 1219, 409, 1229, 416, 1228, 417, -1, 0, -1, -1 | |
}; | |
// points of '4' | |
static int[] ink_4 = {273, 69, 270, 72, 267, 78, 261, 88, 253, 103, 245, 115, 236, 127, 231, 137, 227, | |
144, 226, 146, 230, 146, 238, 146, 252, 146, 271, 145, 291, 143, 313, 141, 329, 139, 341, 137, | |
352, 137, 358, 137, 362, 137, 364, 136, -1, 0, 300, 105, 300, 106, 300, 112, 298, 121, 298, 132, | |
296, 143, 296, 154, 296, 163, 296, 169, 296, 177, 296, 181, 295, 186, 295, 189, 295, 190, -1, 0, | |
-1, -1 | |
}; | |
// points of '안녕하세요' | |
static int[] ink_annyeonghaseyo = {182, 315, 185, 316, 183, 316, 182, 318, 180, 320, 173, 330, 159, | |
356, 149, 384, 149, 406, 157, 426, 175, 440, 200, 451, 230, 446, 250, 431, 259, 411, 268, 384, | |
266, 357, 258, 341, 244, 330, 229, 327, 215, 326, 204, 328, 195, 332, 192, 339, -1, 0, 357, | |
269, 355, 268, 355, 271, 354, 281, 355, 317, 359, 360, 363, 403, 365, 430, 364, 443, 362, 443, | |
-1, 0, 363, 377, 368, 370, 371, 370, 381, 370, 400, 371, 424, 376, 431, 377, -1, 0, 275, 502, | |
270, 504, 268, 508, 267, 515, 268, 527, 272, 541, 281, 556, 299, 571, 324, 575, 357, 569, 387, | |
555, 408, 533, -1, 0, 506, 301, 498, 296, 497, 302, 492, 327, 484, 364, 479, 401, 478, 432, | |
482, 453, 489, 467, 502, 470, 518, 471, 551, 468, 571, 454, 574, 450, -1, 0, 552, 334, 554, | |
319, 559, 323, 574, 320, 604, 317, 635, 315, 650, 316, 659, 320, 656, 322, -1, 0, 591, 377, | |
589, 377, 598, 375, 622, 371, 650, 363, 678, 353, 683, 348, -1, 0, 701, 300, 698, 300, 697, | |
301, 696, 307, 694, 318, 692, 347, 688, 378, 682, 412, 678, 442, 678, 449, -1, 0, 621, 515, | |
606, 520, 603, 526, 600, 536, 602, 546, 616, 558, 649, 562, 674, 556, 682, 546, 679, 538, 666, | |
531, 621, 518, 594, 526, -1, 0, 790, 282, 789, 278, 789, 279, 790, 282, 799, 288, 829, 304, | |
854, 318, 871, 330, 872, 331, -1, 0, 793, 386, 787, 383, 786, 383, 785, 384, 792, 384, 827, | |
385, 861, 385, 878, 387, -1, 0, 828, 436, 807, 448, 796, 457, 783, 471, 777, 487, 778, 501, | |
790, 506, 825, 507, 847, 496, 851, 487, 850, 477, 844, 471, 830, 465, 804, 460, 792, 459, -1, | |
0, 937, 294, 936, 290, 935, 292, 933, 298, 931, 315, 930, 359, 931, 407, 935, 453, 939, 488, | |
942, 518, 942, 536, 939, 550, 936, 554, -1, 0, 939, 408, 946, 399, 947, 402, 967, 401, 997, | |
402, 1013, 405, -1, 0, 1145, 319, 1134, 315, 1135, 318, 1129, 326, 1105, 362, 1080, 403, 1058, | |
446, 1041, 476, 1030, 496, 1030, 494, -1, 0, 1069, 430, 1071, 425, 1073, 427, 1079, 433, 1092, | |
449, 1106, 471, 1114, 486, -1, 0, 1106, 416, 1104, 404, 1116, 407, 1146, 403, 1179, 399, 1206, | |
391, 1209, 389, -1, 0, 1228, 352, 1225, 357, 1224, 361, 1222, 374, 1222, 404, 1223, 431, 1226, | |
452, 1226, 466, 1225, 463, -1, 0, 1269, 345, 1268, 343, 1267, 347, 1265, 360, 1265, 398, 1267, | |
434, 1269, 466, 1272, 484, 1276, 490, -1, 0, 1373, 342, 1369, 342, 1368, 345, 1368, 354, 1372, | |
366, 1382, 376, 1404, 385, 1431, 377, 1445, 360, 1451, 334, 1446, 321, 1432, 321, 1400, 326, | |
1369, 341, 1358, 359, 1353, 380, 1357, 402, 1363, 421, 1370, 440, 1376, 459, 1377, 479, 1374, | |
497, 1369, 509, 1363, 516, 1361, 514, -1, 0, 1426, 413, 1432, 407, 1432, 408, 1434, 416, 1429, | |
442, 1413, 476, 1388, 503, 1358, 526, 1334, 534, 1319, 536, 1318, 533, 1342, 523, 1417, 503, | |
1477, 495, 1525, 497, -1, 0, -1, -1 | |
}; | |
// points of '上海' | |
static int[] ink_shanghai = {487, 526, 487, 528, 498, 526, 529, 527, 584, 517, 608, 506, 603, 501, 589, | |
498, -1, 0, 484, 421, 479, 420, 470, 424, 469, 464, 479, 529, 483, 571, 482, 589, 474, 618, -1, 0, | |
387, 630, 370, 628, 378, 633, 406, 634, 449, 630, 479, 628, 553, 623, 594, 621, 612, 624, 614, 623, | |
-1, 0, 783, 389, 784, 389, 787, 384, 799, 387, 809, 405, -1, 0, 751, 459, 749, 465, 768, 471, 777, | |
474, -1, 0, 739, 699, 740, 686, 763, 636, 790, 605, 810, 583, 820, 569, -1, 0, 933, 352, 934, 352, | |
932, 385, 918, 433, 910, 452, -1, 0, 920, 420, 925, 415, 966, 416, 1028, 412, 1092, 406, 1109, 405, | |
1118, 412, -1, 0, 964, 470, 955, 466, 943, 485, 927, 527, 914, 566, 904, 596, 903, 609, 919, 628, | |
967, 636, 1016, 637, 1048, 636, 1054, 635, 1044, 625, -1, 0, 939, 487, 939, 485, 961, 472, 993, 476, | |
1020, 486, 1033, 515, 1030, 533, 1008, 596, 986, 646, 969, 683, 959, 696, 957, 682, -1, 0, 855, 556, | |
849, 551, 861, 554, 901, 554, 981, 551, 1043, 548, 1079, 547, 1087, 547, 1085, 548, 1075, 548, -1, 0, | |
961, 512, 955, 510, 957, 513, 962, 519, 962, 523, -1, 0, 960, 583, 965, 589, 973, 595, 978, 596, -1, | |
0, -1, -1 | |
}; | |
// points of 'ありがとう' | |
static int[] ink_arigatou = {272, 331, 265, 338, 311, 340, 400, 328, 455, 306, 470, 282, -1, 0, 354, | |
236, 342, 243, 342, 305, 357, 394, 374, 462, 386, 499, 384, 479, -1, 0, 444, 350, 435, 388, 416, | |
412, 349, 454, 299, 459, 278, 439, 325, 391, 411, 373, 457, 392, 456, 452, 451, 463, 455, 454, -1, | |
0, 569, 310, 570, 327, 571, 365, 570, 380, 569, 370, -1, 0, 619, 280, 620, 280, 632, 309, 639, 357, | |
638, 386, 620, 447, 591, 505, 585, 516, 596, 489, -1, 0, 706, 315, 705, 310, 735, 308, 794, 308, | |
827, 327, 826, 388, 808, 437, 790, 459, 785, 441, -1, 0, 816, 251, 803, 248, 772, 302, 739, 364, | |
723, 426, 723, 468, 740, 450, 747, 441, -1, 0, 839, 294, 851, 303, 859, 330, 861, 344, 858, 338, | |
-1, 0, 869, 235, 874, 240, 876, 249, 878, 263, 872, 259, -1, 0, 887, 223, 892, 227, 902, 249, 906, | |
264, -1, 0, 970, 266, 979, 288, 994, 314, 1015, 320, -1, 0, 1075, 272, 1078, 276, 1021, 338, 962, | |
391, 940, 432, 946, 458, 971, 482, 1029, 487, 1069, 475, 1090, 463, -1, 0, 1181, 234, 1223, 256, | |
1237, 262, 1249, 270, -1, 0, 1151, 336, 1146, 340, 1193, 320, 1246, 320, 1285, 337, 1290, 387, | |
1246, 448, 1203, 494, 1204, 486, -1, 0, -1, -1 | |
}; | |
static int MAX_CANDIDATES = 10; | |
static IntPtr inkObj = IntPtr.Zero; | |
static IntPtr settingObj = IntPtr.Zero; | |
static IntPtr resultObj = IntPtr.Zero; | |
static void MakeInputEvent(IntPtr ink, int[] inputs) | |
{ | |
Hwr.InkClear(ink); | |
int i = 0; | |
while (true) | |
{ | |
if (inputs[i + 0] == -1 && inputs[i + 1] == -1) // if end of ink | |
{ | |
break; | |
} | |
else if (inputs[i + 0] == -1 && inputs[i + 1] == 0) // if end of stroke | |
{ | |
Hwr.EndStroke(ink); | |
} | |
else | |
{ | |
Hwr.AddPoint(ink, inputs[i + 0], inputs[i + 1]); | |
} | |
i += 2; | |
} | |
} | |
static String getCandidates(IntPtr result) | |
{ | |
String output = ""; | |
bool exit = false; | |
int length = 0; | |
int lineSize = Hwr.GetLineSize(result); | |
if (lineSize == 0) | |
{ | |
output = "result empty"; | |
return output; | |
} | |
for (int i = 0; i < MAX_CANDIDATES; i++) | |
{ | |
for (int j = 0; j < lineSize; j++) | |
{ | |
IntPtr line = Hwr.GetLine(result, j); | |
int blockSize = Hwr.GetBlockSize(line); | |
for (int k = 0; k < blockSize; k++) | |
{ | |
IntPtr block = Hwr.GetBlock(line, k); | |
if (Hwr.GetCandidateSize(block) <= i) | |
{ | |
exit = true; | |
break; | |
} | |
output += "[" + (i + 1) + "] "; | |
output += Hwr.GetCandidate(block, i, ref length); | |
if (k + 1 < blockSize) | |
{ | |
output += " "; | |
} | |
} | |
if (exit) | |
{ | |
break; | |
} | |
if (j + 1 < lineSize) | |
{ | |
output += "\n"; | |
} | |
} | |
if (exit) | |
{ | |
break; | |
} | |
output += "\n"; | |
} | |
return output; | |
} | |
static void PrintResult(String title, int status) | |
{ | |
if (status == Hwr.ERR_SUCCESS) | |
{ | |
Console.WriteLine("{0} ...Success", title); | |
Console.WriteLine("Recognized Text: \n{0}", getCandidates(resultObj)); | |
} | |
else | |
{ | |
Console.WriteLine("{0} ...Failed ({1})", title, status); | |
} | |
} | |
static void TestKorean() | |
{ | |
Hwr.ClearLanguage(settingObj); | |
Hwr.AddLanguage(settingObj, Hwr.DLANG_KOREAN, Hwr.DTYPE_KOREAN); | |
Hwr.SetAttribute(settingObj); | |
MakeInputEvent(inkObj, ink_annyeonghaseyo); | |
int status = Hwr.Recognize(inkObj, resultObj); | |
PrintResult("Korean Test", status); | |
} | |
static void TestEnglish() | |
{ | |
Hwr.ClearLanguage(settingObj); | |
Hwr.AddLanguage(settingObj, Hwr.DLANG_ENGLISH, Hwr.DTYPE_UPPERCASE | Hwr.DTYPE_LOWERCASE); | |
Hwr.SetAttribute(settingObj); | |
MakeInputEvent(inkObj, ink_good_morning); | |
int status = Hwr.Recognize(inkObj, resultObj); | |
PrintResult("English Test", status); | |
} | |
static void TestChinese() | |
{ | |
Hwr.ClearLanguage(settingObj); | |
Hwr.AddLanguage(settingObj, Hwr.DLANG_CHINA, Hwr.DTYPE_SIMP); | |
Hwr.SetAttribute(settingObj); | |
MakeInputEvent(inkObj, ink_shanghai); | |
int status = Hwr.Recognize(inkObj, resultObj); | |
PrintResult("Chinese Test", status); | |
} | |
static void TestJapanese() | |
{ | |
Hwr.ClearLanguage(settingObj); | |
Hwr.AddLanguage(settingObj, Hwr.DLANG_JAPANESE, Hwr.DTYPE_HIRAGANA); | |
Hwr.SetAttribute(settingObj); | |
MakeInputEvent(inkObj, ink_arigatou); | |
int status = Hwr.Recognize(inkObj, resultObj); | |
PrintResult("Japanese Test", status); | |
} | |
static int InitializeEngine() | |
{ | |
int status = Hwr.Create("./license_key/license.key"); | |
if (inkObj == IntPtr.Zero) | |
{ | |
inkObj = Hwr.CreateInkObject(); | |
} | |
if (settingObj == IntPtr.Zero) | |
{ | |
settingObj = Hwr.CreateSettingObject(); | |
} | |
if (resultObj == IntPtr.Zero) | |
{ | |
resultObj = Hwr.CreateResultObject(); | |
} | |
Hwr.SetExternalResourcePath("./hdb/"); | |
Hwr.SetExternalLibraryPath("./lib/"); | |
Hwr.SetRecognitionMode(settingObj, Hwr.MULTICHAR); | |
Hwr.SetCandidateSize(settingObj, MAX_CANDIDATES); | |
Console.WriteLine("HWR SDK Revision: {0}", Hwr.GetRevision()); | |
Console.WriteLine("Initialize Engine ...{0}", status == Hwr.ERR_SUCCESS ? "Success" : "Failed"); | |
return status; | |
} | |
static int DestroyEngine() | |
{ | |
int status = Hwr.Close(); | |
if (inkObj != IntPtr.Zero) | |
{ | |
Hwr.DestroyInkObject(inkObj); | |
} | |
if (settingObj != IntPtr.Zero) | |
{ | |
Hwr.DestroySettingObject(settingObj); | |
} | |
if (resultObj != IntPtr.Zero) | |
{ | |
Hwr.DestroyResultObject(resultObj); | |
} | |
Console.WriteLine("Destroy Engine ...{0}", status == Hwr.ERR_SUCCESS ? "Success" : "Failed"); | |
return status; | |
} | |
static void Main() | |
{ | |
InitializeEngine(); | |
TestKorean(); | |
TestEnglish(); | |
TestChinese(); | |
TestJapanese(); | |
DestroyEngine(); | |
} | |
} | |
} |
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
/*! | |
* @brief Handwriting APIs | |
* @date 2019/12/11 | |
* @file Hwr.cs | |
* @author samu.s.ko | |
* | |
* Copyright 2019. SELVAS AI Inc. All Rights Reserved. | |
*/ | |
using System; | |
using System.Runtime.InteropServices; | |
namespace Selvasai | |
{ | |
class Hwr | |
{ | |
// Gesture List -------------------------------------------------------- | |
public const int GESTURE_LTOR = 1; | |
public const int GESTURE_RTOL = 2; | |
public const int GESTURE_DELETE = 3; | |
public const int GESTURE_BLACK = 4; | |
public const int GESTURE_ENTER = 5; | |
public const int GESTURE_MERGE = 6; | |
public const int GESTURE_AWAY = 7; | |
public const int GESTURE_INSERT = 8; | |
// Error Code ---------------------------------------------------------- | |
/// <summary> | |
/// 성공 | |
/// </summary> | |
public const int ERR_SUCCESS = 0; | |
/// <summary> | |
/// 인식결과가 없음 | |
/// </summary> | |
public const int ERR_NORESULT = 1; | |
/// <summary> | |
/// Null Pointer를 참조함 | |
/// </summary> | |
public const int ERR_NULL_POINTER = 2; | |
/// <summary> | |
/// memory access 범위를 벗어남 fatal error | |
/// </summary> | |
public const int ERR_OUTOFMEMORY = 3; | |
/// <summary> | |
/// value or size 범위를 벗어남 exception | |
/// </summary> | |
public const int ERR_OUTOFRANGE = 4; | |
/// <summary> | |
/// 입력된 데이터가 없음 | |
/// </summary> | |
public const int ERR_EMPTY_INK = 5; | |
/// <summary> | |
/// 입력된 인자가 잘못됨 | |
/// </summary> | |
public const int ERR_INVALID_ARGUMENTS = 6; | |
/// <summary> | |
/// 설정된 인식모델이 비정상적임 | |
/// </summary> | |
public const int ERR_INVALID_MODEL = 7; | |
/// <summary> | |
/// 잘못된 객체에 접근 | |
/// </summary> | |
public const int ERR_INVALID_INSTANCE = 8; | |
/// <summary> | |
/// 데모 기간/횟수 만료 | |
/// </summary> | |
public const int ERR_EXPIRE_DEMO = 9; | |
/// <summary> | |
/// 엔진이 실행 중 | |
/// </summary> | |
public const int ERR_ENGINE_BUSY = 10; | |
/// <summary> | |
/// 인증 실패 | |
/// </summary> | |
public const int ERR_AUTHORIZATION_FAIL = 11; | |
/// <summary> | |
/// 엔진이 이미 존재함 | |
/// </summary> | |
public const int ERR_ALREADY_EXIST = 12; | |
// Recognition Mode ---------------------------------------------------- | |
/// <summary> | |
/// 낱자 인식 | |
/// </summary> | |
public const int SINGLECHAR = 0; | |
/// <summary> | |
/// 여러 글자 인식 | |
/// </summary> | |
public const int MULTICHAR = 1; | |
/// <summary> | |
/// 겹쳐 쓴 글자 인식 | |
/// </summary> | |
public const int OVERLAPCHAR = 2; | |
/// <summary> | |
/// 여러 줄로 된 글자 인식 | |
/// </summary> | |
public const int MULTILINE = 3; | |
// Language Mode ------------------------------------------------------- | |
public const int DLANG_ENGLISH = 0; | |
public const int DLANG_ENGLISH_UK = 1; | |
public const int DLANG_ENGLISH_CA = 2; | |
public const int DLANG_ALBANIAN = 3; | |
public const int DLANG_AUSTRIA = 4; | |
public const int DLANG_BASQUE = 5; | |
public const int DLANG_CATALAN = 6; | |
public const int DLANG_CROATIAN = 7; | |
public const int DLANG_CZECH = 8; | |
public const int DLANG_DANISH = 9; | |
public const int DLANG_DUTCH = 10; | |
public const int DLANG_ESTONIAN = 11; | |
public const int DLANG_FINNISH = 12; | |
public const int DLANG_FRENCH = 13; | |
public const int DLANG_SPANISH = 14; | |
public const int DLANG_SPANISH_MX = 15; | |
public const int DLANG_HUNGARIAN = 16; | |
public const int DLANG_ICELANDIC = 17; | |
public const int DLANG_ITALIAN = 18; | |
public const int DLANG_LATVIAN = 19; | |
public const int DLANG_LITHUANIAN = 20; | |
public const int DLANG_BOKMAL = 21; | |
public const int DLANG_POLISH = 22; | |
public const int DLANG_PORTUGUESE = 23; | |
public const int DLANG_PORTUGUESEB = 24; | |
public const int DLANG_ROMANIAN = 25; | |
public const int DLANG_SLOVAK = 26; | |
public const int DLANG_SLOVENIAN = 27; | |
public const int DLANG_SWEDISH = 28; | |
public const int DLANG_TURKISH = 29; | |
public const int DLANG_VIETNAMESE = 30; | |
public const int DLANG_BELARUSIAN = 31; | |
public const int DLANG_BULGARIAN = 32; | |
// Greek | |
public const int DLANG_GREEK = 33; | |
// Cyrillic | |
public const int DLANG_KAZAKH = 34; | |
public const int DLANG_MACEDONIAN = 35; | |
public const int DLANG_MONGOLIAN = 36; | |
public const int DLANG_RUSSIAN = 37; | |
public const int DLANG_UKRAINIAN = 38; | |
// Latin, Cyrillic | |
public const int DLANG_SERBIAN = 39; | |
public const int DLANG_TATAR = 40; | |
// Oceania | |
public const int DLANG_FIJIAN = 41; | |
public const int DLANG_MAORI = 42; | |
public const int DLANG_SAMOAN = 43; | |
public const int DLANG_TAITIAN = 44; | |
public const int DLANG_TONGAN = 45; | |
// Africa | |
public const int DLANG_OROMO = 46; | |
public const int DLANG_SOTHO = 47; | |
public const int DLANG_SWAHILI = 48; | |
public const int DLANG_SWATI = 49; | |
public const int DLANG_XHOSA = 50; | |
public const int DLANG_ZULU = 51; | |
public const int DLANG_INDONESIAN = 52; | |
public const int DLANG_MALAY = 53; | |
public const int DLANG_GALICIAN = 54; | |
public const int DLANG_GERMANY = 55; | |
public const int DLANG_IRISH = 56; | |
public const int DLANG_AFRIKAANS = 57; | |
public const int DLANG_NYNORSK = 58; | |
public const int DLANG_DUTCH_BE = 59; | |
public const int DLANG_AZERBAIJANI = 60; | |
// CJK | |
public const int DLANG_KOREAN = 101; | |
public const int DLANG_CHINA = 102; | |
public const int DLANG_TAIWAN = 103; | |
public const int DLANG_HONGKONG = 104; | |
public const int DLANG_JAPANESE = 105; | |
// ARABIC | |
public const int DLANG_ARABIC = 106; | |
public const int DLANG_FARSI = 107; | |
public const int DLANG_URDU = 108; | |
// Devanagari | |
public const int DLANG_HINDI = 109; | |
public const int DLANG_BENGALI = 110; | |
// etc | |
public const int DLANG_HEBREW = 111; | |
public const int DLANG_THAI = 112; | |
// max | |
public const int DLANG_MAX = 113; | |
// Language Type ------------------------------------------------------- | |
public const int DTYPE_NONE = (1 << 0); | |
public const int DTYPE_UPPERCASE = (1 << 1); | |
public const int DTYPE_LOWERCASE = (1 << 2); | |
public const int DTYPE_CONSONANT = (1 << 3); | |
public const int DTYPE_VOWEL = (1 << 4); | |
public const int DTYPE_TONE = (1 << 5); | |
public const int DTYPE_NUMERIC = (1 << 6); | |
public const int DTYPE_SIGN = (1 << 7); | |
// JAPANESE | |
public const int DTYPE_HIRAGANA = (1 << 8); | |
public const int DTYPE_KATAKANA = (1 << 9); | |
public const int DTYPE_KANJI = (1 << 10); | |
// CHINA, TAIWAN, HONGKONG | |
public const int DTYPE_SIMP = (1 << 11); | |
public const int DTYPE_TRAD = (1 << 12); | |
public const int DTYPE_RADICAL = (1 << 13); | |
// SERBIAN, TATAR | |
public const int DTYPE_LATIN = (1 << 14); | |
public const int DTYPE_CYRILLIC = (1 << 15); | |
// ARABIC, FARSI, URDU | |
public const int DTYPE_ARABIC = (1 << 16); | |
// HEBREW | |
public const int DTYPE_HEBREW = (1 << 17); | |
// BENGALI, HINDI | |
public const int DTYPE_DEVANAGARI = (1 << 18); | |
// KOREAN | |
public const int DTYPE_KOREAN = (1 << 19); | |
public const int DTYPE_HANJA = (1 << 20); | |
// gesture for editing (space, backspace 등) | |
public const int DTYPE_GESTURE = (1 << 21); | |
// Param type ---------------------------------------------------------- | |
public const int LOG_LEVEL = 0; | |
public const int LOG_CALLBACK = 1; | |
public const int WRITE_INK = 2; | |
public const int LANG_MODEL = 3; | |
// Log level ----------------------------------------------------------- | |
public const int LEVEL_NONE = 0; | |
public const int LEVEL_ERROR = 1; | |
public const int LEVEL_WARN = 2; | |
public const int LEVEL_INFO = 3; | |
public const int LEVEL_DEBUG = 4; | |
// Main APIs ----------------------------------------------------------- | |
/// <summary> | |
/// 인식엔진의 인스턴스를 생성함 | |
/// </summary> | |
/// <param name="keyPath">[in] 파일명을 포함한 License key 파일의 경로</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRCreate")] | |
public static extern int Create(String keyPath); | |
/// <summary> | |
/// 인식모드 속성 값을 설정함 | |
/// </summary> | |
/// <param name="setting">[in] setting 설정이 완료된 Setting Object</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRSetAttribute")] | |
public static extern int SetAttribute(IntPtr setting); | |
/// <summary> | |
/// 인식모드 속성 값에 따라 입력 데이터를 인식함 | |
/// </summary> | |
/// <param name="ink">[in] ink 좌표가 입력된 Ink Object</param> | |
/// <param name="result">[out] 인식된 결과가 저장된 Result Object</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRecognize")] | |
public static extern int Recognize(IntPtr ink, IntPtr result); | |
/// <summary> | |
/// 인식엔진의 인스턴스를 소멸시킴 | |
/// </summary> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRClose")] | |
public static extern int Close(); | |
// Optional APIs ------------------------------------------------------- | |
/// <summary> | |
/// 엔진내부에서 사용하는 외부리소스(언어모델 파일 등)의 경로 설정 | |
/// </summary> | |
/// <param name="path">[in] path 리소스 경로</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRSetExternalResourcePath")] | |
public static extern int SetExternalResourcePath(String path); | |
/// <summary> | |
/// 엔진내부에서 사용하는 외부라이브러리의 경로 설정 | |
/// </summary> | |
/// <param name="path">[in] path 외부라이브러리의 경로</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRSetExternalLibraryPath")] | |
public static extern int SetExternalLibraryPath(String path); | |
/// <summary> | |
/// 특정 타입의 파라미터 값을 가져옴 | |
/// </summary> | |
/// <param name="type">[in] 파라미터 타입</param> | |
/// <param name="param">[out] 특정 파리미터 타입의 포인터</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetParam")] | |
public static extern int GetParam(int type, [In, Out] ref int param); | |
/// <summary> | |
/// 특정 타입의 파라미터 값을 설정함 | |
/// </summary> | |
/// <param name="type">[in] 파라미터 타입</param> | |
/// <param name="param">[in] 특정 파리미터 타입의 포인터</param> | |
/// <returns></returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRSetParam")] | |
public static extern int SetParam(int type, [In, Out] ref int param); | |
/// <summary> | |
/// 엔진의 빌드넘버 스트링의 포인터를 가져옴 | |
/// </summary> | |
/// <param name="revision">[out] 엔진 빌드넘버</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetRevision")] | |
public static extern int GetRevisionPtr(IntPtr[] revision); | |
/// <summary> | |
/// 엔진의 빌드넘버 스트링을 반환 | |
/// </summary> | |
/// <returns>엔진의 빌드넘버 스트링</returns> | |
public static String GetRevision() | |
{ | |
IntPtr[] version = new IntPtr[1]; | |
Hwr.GetRevisionPtr(version); | |
return Marshal.PtrToStringAnsi(version[0]); | |
} | |
/// <summary> | |
/// License key에 설정된 엔진의 due date를 가져온다 | |
/// </summary> | |
/// <param name="due_date">[out] 년월일을 나타내는 8자리의 integer 값 (ex 20161206)</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetDueDate")] | |
public static extern int GetDueDate([In, Out] ref int due_date); | |
// SettingObject APIs -------------------------------------------------- | |
/// <summary> | |
/// 설정 오브젝트를 생성한다 | |
/// </summary> | |
/// <returns>설정 오브젝트</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRCreateSettingObject")] | |
public static extern IntPtr CreateSettingObject(); | |
/// <summary> | |
/// 설정 오브젝트를 제거한다 | |
/// </summary> | |
/// <param name="setting">[in] 설정 오브젝트</param> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRDestroySettingObject")] | |
public static extern void DestroySettingObject(IntPtr setting); | |
/// <summary> | |
/// 필기 인식 모드를 설정한다(낱자, 연속) | |
/// </summary> | |
/// <param name="setting"> [in] 설정 오브젝트</param> | |
/// <param name="mode">[in] 인식 모드</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRSetRecognitionMode")] | |
public static extern int SetRecognitionMode(IntPtr setting, int mode); | |
/// <summary> | |
/// 인식 후보 출력 크기를 설정한다 | |
/// </summary> | |
/// <param name="setting">[in] 설정 오브젝트</param> | |
/// <param name="size">[in] 후보수</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRSetCandidateSize")] | |
public static extern int SetCandidateSize(IntPtr setting, int size); | |
/// <summary> | |
/// 인식할 언어를 추가 한다 | |
/// </summary> | |
/// <param name="setting">[in] 설정 오브젝트</param> | |
/// <param name="language">[in] 언어 값</param> | |
/// <param name="option">[in] 따른 옵션</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRAddLanguage")] | |
public static extern int AddLanguage(IntPtr setting, int language, int option); | |
/// <summary> | |
/// 설정된 언어 크기를 가져온다 | |
/// </summary> | |
/// <param name="setting">[in] 설정 오브젝트</param> | |
/// <param name="size">[out] 크기</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetLanguageSize")] | |
public static extern int GetLanguageSize(IntPtr setting, [In, Out] ref int size); | |
/// <summary> | |
/// 설정된 언어를 초기화 한다 | |
/// </summary> | |
/// <param name="setting">[in] 설정 오브젝트</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRClearLanguage")] | |
public static extern int ClearLanguage(IntPtr setting); | |
/// <summary> | |
/// 인식할 심볼을 정의 | |
/// </summary> | |
/// <param name="setting">[in] 설정 오브젝트</param> | |
/// <param name="charset">[in] 인식할 심볼의 리스트</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRSetUserCharSet")] | |
public static extern int SetUserCharSet(IntPtr setting, [In] ushort[] charset); | |
// InkObject APIs ------------------------------------------------------ | |
/// <summary> | |
/// 잉크 오브젝트를 생성한다 | |
/// </summary> | |
/// <returns>잉크 오브젝트</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRCreateInkObject")] | |
public static extern IntPtr CreateInkObject(); | |
/// <summary> | |
/// 잉크 오브젝트를 제거한다 | |
/// </summary> | |
/// <param name="ink">[in] 잉크 오브젝트</param> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRDestroyInkObject")] | |
public static extern void DestroyInkObject(IntPtr ink); | |
/// <summary> | |
/// 인식엔진에서 인식할 터치 좌표(잉크 좌표)를 추가함 | |
/// </summary> | |
/// <param name="ink">[in] ink 잉크 오브젝트</param> | |
/// <param name="x">[in] x좌표</param> | |
/// <param name="y">[in] y좌표</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRAddPoint")] | |
public static extern int AddPoint(IntPtr ink, int x, int y); | |
/// <summary> | |
/// TouchUp 이벤트에 의해 한 획의 입력을 마쳤을 때 호출함 | |
/// </summary> | |
/// <param name="ink">[in] 잉크 오브젝트</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWREndStroke")] | |
public static extern int EndStroke(IntPtr ink); | |
/// <summary> | |
/// 입력한 좌표 데이터를 초기화함 | |
/// </summary> | |
/// <param name="ink">[in] 잉크 오브젝트</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRInkClear")] | |
public static extern int InkClear(IntPtr ink); | |
/// <summary> | |
/// 입력된 잉크 인덱스 값에 해당하는 잉크 좌표값을 받아옴 | |
/// </summary> | |
/// <param name="ink">[in] 잉크 오브젝트</param> | |
/// <param name="index">[in] 받아오고자 하는 잉크의 인덱스</param> | |
/// <param name="x">[out] 해당 잉크의 x좌표값</param> | |
/// <param name="y">[out] 해당 잉크의 y좌표값</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetInkPoint")] | |
public static extern int GetInkPoint(IntPtr ink, int index, [In, Out] ref int x, [In, Out] ref int y); | |
/// <summary> | |
/// 현재까지 입력된 잉크의 카운트 | |
/// </summary> | |
/// <param name="ink">[in] 잉크 오브젝트</param> | |
/// <param name="count">[out] 잉크 카운트</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetInkCount")] | |
public static extern int GetInkCount(IntPtr ink, [In, Out] ref int count); | |
// ResultObject APIs --------------------------------------------------- | |
/// <summary> | |
/// 결과 오브젝트를 생성한다 | |
/// </summary> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRCreateResultObject")] | |
public static extern IntPtr CreateResultObject(); | |
/// <summary> | |
/// 결과 오브젝트를 제거한다 | |
/// </summary> | |
/// <param name="result">[in] 결과 오브젝트</param> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRDestroyResultObject")] | |
public static extern void DestroyResultObject(IntPtr result); | |
/// <summary> | |
/// 결과 값의 라인 크기를 가져온다 | |
/// </summary> | |
/// <param name="ink">[in] 결과 오브젝트</param> | |
/// <returns>Line Size</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetLineSize")] | |
public static extern int GetLineSize(IntPtr ink); | |
/// <summary> | |
/// 지정된 인덱스의 라인 결과를 가져온다 | |
/// </summary> | |
/// <param name="result">[in] 결과 오브젝트</param> | |
/// <param name="index">[in] 라인 인덱스</param> | |
/// <returns>라인 결과</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetLine")] | |
public static extern IntPtr GetLine(IntPtr result, int index); | |
/// <summary> | |
/// 라인 결과 값의 블럭 크기를 가져온다 | |
/// </summary> | |
/// <param name="line">[in] 라인 결과 값</param> | |
/// <returns>Block Size</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetBlockSize")] | |
public static extern int GetBlockSize(IntPtr line); | |
/// <summary> | |
/// 라인 결과 값의 지정된 인덱스의 블럭 결과를 가져온다 | |
/// </summary> | |
/// <param name="line">[in] 라인</param> | |
/// <param name="index">[in] 블럭 인덱스</param> | |
/// <returns>블럭 결과</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetBlock")] | |
public static extern IntPtr GetBlock(IntPtr line, int index); | |
/// <summary> | |
/// 블럭 결과 값의 처리된 획의 개수를 얻어온다 | |
/// </summary> | |
/// <param name="block">[in] 블럭 결과 값</param> | |
/// <returns>Stroke Size</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetStrokeSize")] | |
public static extern int GetStrokeSize(IntPtr block); | |
/// <summary> | |
/// 블럭 결과값의 처리된 획의 인덱스들을 얻어온다 | |
/// </summary> | |
/// <param name="block">[in] 블럭 결과 값</param> | |
/// <param name="indices">[out] 인덱스 포인터</param> | |
/// <param name="size">[in] 인덱스 포인터 사이즈</param> | |
/// <returns>에러 코드 값</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetStrokeIndices")] | |
public static extern int GetStrokeIndices(IntPtr block, [In, Out] ref int indices, int size); | |
/// <summary> | |
/// 블럭 결과 값에서 후보 크기를 가져온다 | |
/// </summary> | |
/// <param name="block">[in] 블럭 결과 값</param> | |
/// <returns>Candidate Size</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetCandidateSize")] | |
public static extern int GetCandidateSize(IntPtr block); | |
/// <summary> | |
/// 블럭 결과 값에서 인식 후보문자의 포인터를 반환한다 | |
/// </summary> | |
/// <param name="block">[in] 블럭 결과 값</param> | |
/// <param name="index">[in] 후보 인덱스</param> | |
/// <param name="length">[out] 인식후보 문자열 크기</param> | |
/// <returns>후보문자의 포인터</returns> | |
[DllImport("libdhwr.dll", EntryPoint = "DHWRGetCandidate")] | |
public static extern IntPtr GetCandidatePtr(IntPtr block, int index, [In, Out] ref int length); | |
/// <summary> | |
/// 블럭 결과 값에서 인식된 후보문자를 반환한다 | |
/// </summary> | |
/// <param name="block">[in] 블럭 결과 값</param> | |
/// <param name="index">[in] 후보 인덱스</param> | |
/// <param name="length">[out] 인식후보 문자열 크기</param> | |
/// <returns>후보문자</returns> | |
public static String GetCandidate(IntPtr block, int index, [In, Out] ref int length) | |
{ | |
return Marshal.PtrToStringUni(GetCandidatePtr(block, index, ref length)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment