OnLineCardSchemaStruct.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. #pragma once
  2. #include <string>
  3. #include <vector>
  4. #include <windows.h>
  5. namespace OnLineCard{
  6. //旋转角 枚举各旋转角
  7. enum class ROTATION{
  8. ROTATION_0 = 1,
  9. ROTATION_90 = 2,
  10. ROTATION_180 = 4,
  11. ROTATION_270 = 8
  12. };
  13. //顶点位移 枚举各顶点信息在数组中的偏移位置
  14. enum class VERTEX_OFFSET{
  15. LEFT_TOP = 0,
  16. LEFT_BOTTOM = 1,
  17. RIGHT_TOP = 2,
  18. RIGHT_BOTTOM = 3,
  19. };
  20. //方向位移 枚举各方向信息在数组中的偏移位置
  21. enum class DIR_OFFSET{
  22. DIR_OFFSET_UP = 0,
  23. DIR_OFFSET_DOWN = 1,
  24. DIR_OFFSET_LEFT = 2,
  25. DIR_OFFSET_RIGHT = 3
  26. };
  27. //方向标记
  28. enum class DIR_FLAG{
  29. DIR_FLAG_UP = 1,
  30. DIR_FLAG_DOWN = 2,
  31. DIR_FLAG_LEFT = 4,
  32. DIR_FLAG_RIGHT = 8
  33. };
  34. //主观题类型
  35. enum class QUESTION_SCORE_TYPE{
  36. SINGLE_SCORE,
  37. MUTIL_SCORE,
  38. MUTIL_SCORE2,
  39. MUTIL_SCORE3,//附加必做题
  40. MUTIL_SCORE4,//打分模式
  41. };
  42. //客观题输出类型
  43. enum class OMR_OUT_TYPE{
  44. OMR_OUT_TYPE_SINGLE_NONSTRICT_ERROR,// 输出一个或*号,若解析中有0个、2个或2个以上涂点被填涂,输出*号
  45. OMR_OUT_TYPE_SINGLE_NONSTRICT,// 输出一个,若解析中有2个或2个以上涂点被填涂,则从中选出一个作为该组结果
  46. OMR_OUT_TYPE_SINGLE_STRICT,// 输出一个,若解析中有2个或2个以上涂点被填涂,则认为用户多选,输出多选字符
  47. OMR_OUT_TYPE_MUTIL_STRICT,//输出多选字符
  48. OMR_OUT_TYPE_MUTIL_STRICT_EX,//不定项选择
  49. };
  50. struct SCHEMA_RECT_FIELD{
  51. int centerx;
  52. int centery;
  53. int width;
  54. int height;
  55. };
  56. struct KEGUANTI_QUESTION_LOCATEPOINT_INDEX{
  57. int indexs[4];
  58. int &operator[](int index){
  59. return indexs[index];
  60. }
  61. };
  62. struct question_basic{
  63. std::string question_code;
  64. int question_index;
  65. };
  66. struct SCHEMA_ELEMENT_FIELD :SCHEMA_RECT_FIELD{
  67. int index;
  68. };
  69. struct SchemaLocatePoint :SCHEMA_ELEMENT_FIELD{//定位点
  70. };
  71. struct SchemaLocateArea :SCHEMA_ELEMENT_FIELD{//区域定位点
  72. };
  73. struct SchemaLoacteCross :SCHEMA_ELEMENT_FIELD{//交叉点定位
  74. };
  75. struct SchemaCode :SCHEMA_ELEMENT_FIELD{//条码、二维码
  76. int nQrOrBar;
  77. bool isXuanZhuan;
  78. std::string strContent;
  79. bool is_stu_id;
  80. };
  81. struct SchemaItem :SCHEMA_ELEMENT_FIELD{//填涂项
  82. //填涂项输出字符
  83. unsigned char OutChar;
  84. int keguanti_question_locate_point_index;
  85. };
  86. struct SchemaGroup :SCHEMA_ELEMENT_FIELD, question_basic{//填涂组
  87. //本组涂点涂点数量
  88. int itemCount;
  89. //记录本组涂点位置索引
  90. std::vector<int> itemIndex;
  91. //OMR 输出类型
  92. OMR_OUT_TYPE omr_out_type;
  93. };
  94. // 切割区域
  95. struct SchemaCutArea :SCHEMA_ELEMENT_FIELD{
  96. bool isfirst; //是否该题第一个区域
  97. std::string area_name; //裁切区域名称(当isfirst为真时有效)
  98. int iscut; //是否需要剪切
  99. int question_index;
  100. int marktype;
  101. };
  102. struct Pos
  103. {
  104. double x, y, w, h;
  105. Pos(double x = 0, double y = 0, double w = 0, double h = 0){ this->x = x; this->y = y; this->w = w; this->h = h; }
  106. };
  107. // 打分区域
  108. struct ScoreBox
  109. {
  110. int type; //类型 3: [2 ,4,5] 1: 1-16 2: 49/29(个位十位)
  111. int nCount; //题目个数 类型3专有
  112. std::vector<int> vctScore; //类型3专有
  113. int limit; //类型1 2 专有
  114. bool bPoint; //最后的格子是否代表0.5 true是 false 否
  115. bool bXuanZuoTi; //是否是选做题
  116. double maxsorce; //每个小题最大分值(没有小题就是0分)
  117. Pos pos;
  118. ScoreBox(){
  119. memset(&pos, 0, sizeof(Pos));
  120. type = 0; nCount = 1; limit = 0; bPoint = false; bXuanZuoTi = false;
  121. }
  122. };
  123. //题目分数
  124. struct SchemaQuestionScore :SCHEMA_ELEMENT_FIELD, question_basic{
  125. QUESTION_SCORE_TYPE type;
  126. struct Point{
  127. int x;
  128. int y;
  129. }lt, rt, lb, rb;
  130. //填涂框数量
  131. int count;
  132. int questionLocatePointIndex[4];
  133. int valid_option_count;
  134. // 附加题区域,暂定4个选项
  135. SchemaItem item[4];
  136. int countItemSelete; //要求选择个数
  137. int countNum; //选择总数
  138. int mintype;
  139. // 在线答题卡
  140. ScoreBox scoreBox;
  141. std::string question_code_all;
  142. std::string question_code_temp;
  143. };
  144. struct CLIP_RESULT{
  145. //在原试卷的位置
  146. //图像数据地址
  147. unsigned char* img_data;
  148. //图像数据大小
  149. unsigned long img_data_size;
  150. //编号
  151. int index;
  152. //区域名称
  153. char area_name[20];
  154. };
  155. struct RESULT_RECT{
  156. int x;
  157. int y;
  158. int width;
  159. int height;
  160. };
  161. struct RECT_GROUP_HEADER{
  162. int count;
  163. RESULT_RECT* rects;
  164. };
  165. //对象结果(基础结构体)
  166. struct OBJ_RESULT{
  167. unsigned int obj_id;//对象ID
  168. };
  169. //对象位置区域描述
  170. template<class T> struct OBJ_RECT{
  171. T centerx;
  172. T centery;
  173. T width;
  174. T height;
  175. double angle;
  176. };
  177. //定位点识别结果
  178. struct LOCATE_POINT_RESULT :OBJ_RESULT, OBJ_RECT<float>{
  179. };
  180. //二维码识别结果
  181. struct QR_RESULT :OBJ_RESULT, OBJ_RECT<float>{
  182. char * qr_str;
  183. int nQrOrBar;
  184. };
  185. struct SchemaPage{
  186. int subject;
  187. //模板页面/索引 第几页
  188. int index;
  189. //试卷id
  190. int qrFlag;
  191. bool is_same_exam_id;//从二维码识别得来的考试号
  192. bool is_front_page;
  193. bool is_use_qr_code;
  194. bool examid_by_qr_code; // 是否识别二维码
  195. //识别二维码情况(1识别成功,0:未进入,-1识别失败)
  196. char paper_id[64];
  197. //考号、学号、阅卷方式
  198. char student_code[64];
  199. bool is_stu_id;
  200. //模板类型
  201. int mode_type;
  202. //模板图像宽
  203. int width;
  204. //模板图像高
  205. int height;
  206. //存储模板定位点(目前存储最上最大的定位点)
  207. std::vector<SchemaLocatePoint> locatePoints;
  208. //定位点数量 (暂不用了)
  209. int locatePointCount;
  210. //存储题目定位点
  211. std::vector<SchemaLocatePoint> questionLocatePoints;
  212. //客观题题目定位点的索引
  213. std::vector<KEGUANTI_QUESTION_LOCATEPOINT_INDEX> keguantiQuestionLocatePointIndexs;
  214. //交叉点定位(无用)
  215. std::vector<SchemaLoacteCross> locateCrosses;
  216. //交叉点定位数量(无用)
  217. int locateCrossCount;
  218. //定位区定位(无用)
  219. std::vector<SchemaLocateArea> locateAreas;
  220. //定位区定位数量(无用)
  221. int locateAreaCount;
  222. //条码/二维码 位置
  223. std::vector<SchemaCode> codes;
  224. //条码/二维码 位置(数量)
  225. int codeCount;
  226. //学号分组
  227. std::vector<SchemaGroup> stuGroups;
  228. int stuGroupsCount;
  229. //学号选项
  230. std::vector<SchemaItem> stuItems;
  231. int stuItemCount;
  232. int schoolCardStatus;
  233. //学号定位点索引
  234. std::vector<KEGUANTI_QUESTION_LOCATEPOINT_INDEX> stuQuestionLocatePointIndex;
  235. //选择题选项组,一个题目一个组
  236. std::vector<SchemaGroup> groups;
  237. int groupCount;
  238. //选择题选项
  239. std::vector<SchemaItem> items;
  240. int itemCount;
  241. //切割区域
  242. std::vector<SchemaCutArea> cutAreas;
  243. int cutAreaCount;
  244. //黑度整体浮动系数(无用)
  245. int user_float_heidu;
  246. //黑度选中灵敏度(无用)
  247. int worthwhileBlk;
  248. //多个选项之间的间隔字符(无用)
  249. char option_spacer;
  250. //选择题没有选择时的输出字符(无用)
  251. char unselect_char;
  252. //两组选择题之间的间隔字符(无用)
  253. char group_spacer;
  254. //主观题、填空题位置
  255. std::vector<SchemaQuestionScore > question_score;
  256. int question_score_count;
  257. int hei_du_ling_min_du;
  258. //缺考参数
  259. //缺考定位点索引
  260. std::vector<KEGUANTI_QUESTION_LOCATEPOINT_INDEX> quekaoLocatePointIndex;
  261. bool isQuekao;
  262. SCHEMA_RECT_FIELD quekao;
  263. int quekaoItemCount;
  264. bool isZaiXianDaTiKa; //是否在线答题卡
  265. SchemaPage(){
  266. isZaiXianDaTiKa = false;
  267. }
  268. };
  269. enum class PaperDirection{
  270. DIR_H,
  271. DIR_V
  272. };
  273. struct Location
  274. {
  275. Pos pos;
  276. int type;
  277. };
  278. struct CutArea
  279. {
  280. Pos pos;
  281. int linkparm;
  282. };
  283. struct Opt
  284. {
  285. Pos pos;
  286. std::string optName;
  287. };
  288. typedef std::vector<std::vector<Opt>> fill_code;
  289. struct question
  290. {
  291. int type; // 题型
  292. int marktype;// 逻辑题型
  293. std::string answer; // 答案-选择题
  294. double score;
  295. int smallQtNo; //判断是否有小题和小题序号。-1没有小题,0-X表示小题序号
  296. std::string id;
  297. std::string all_id;
  298. std::vector<Opt> opt; // 选择题的选项位置等
  299. std::string direction;
  300. ScoreBox scoreBox; // 打分框
  301. CutArea cut; // 剪裁区域
  302. int selTotal;
  303. int selItem;
  304. string name;
  305. };
  306. struct PageTemplate
  307. {
  308. int pageNo;
  309. std::vector<Location> location; // 定位点位置
  310. Pos studentcode_bar; // 条形码位置
  311. fill_code studentcode_fill; // 填涂考号
  312. Pos absent; // 缺号标记
  313. Pos QrCode; // 二维码
  314. double w, h; // 宽高
  315. std::vector<question> vctQuestions;
  316. };
  317. enum item_type
  318. {
  319. type_absent,// 缺考标记
  320. type_tiaoxingma, // 条形码
  321. type_tiantukaohao, // 填涂考号
  322. type_qrbar,//二维码
  323. type_question_keguan,// 题目-单选题
  324. type_question_keguan_d,// 题目-多选题
  325. type_question_keguan_b,// 题目-不定项选择
  326. type_question_zhuguan,// 题目-主观题
  327. type_question_xuanzuo,// 题目-选做题
  328. type_dingweidian_range_top, //上定位点范围
  329. type_dingweidian_rang_buttom,// 下定位点范围
  330. type_dingweidian_w_max_rate,
  331. type_dingweidian_w_min_rate,
  332. type_dingweidian_h_max_rate,
  333. type_dingweidian_h_min_rate,
  334. };
  335. struct Item_Pos_offset_Info{
  336. item_type type;
  337. int x_offset, y_offset, w_offset, h_offset;
  338. int x_offset_score, y_offset_score, w_offset_score, h_offset_score;
  339. int x_offset_opt, y_offset_opt, w_offset_opt, h_offset_opt;
  340. std::string question_id;
  341. int link_param;
  342. std::map<int, Item_Pos_offset_Info> _child_info;// 选做题的选项
  343. Item_Pos_offset_Info(){
  344. x_offset = 0; y_offset = 0; w_offset = 0; h_offset = 0;
  345. x_offset_score = 0; y_offset_score = 0; w_offset_score = 0; h_offset_score = 0;
  346. x_offset_opt = 0; y_offset_opt = 0; w_offset_opt = 0; h_offset_opt = 0;
  347. link_param = -1;
  348. }
  349. };
  350. struct PaperTemplate
  351. {
  352. int totalPage; // 总页数
  353. bool useQrCode; // 是否使用二维码 使用:包含学生信息 不使用: 不包含学生信息
  354. int schoolCardStatus;
  355. std::map<int, PageTemplate> pages;
  356. int subject_id;
  357. bool config_offset;
  358. std::map<std::string, Item_Pos_offset_Info> _map_offset_info;
  359. bool open_save_debug_img;
  360. int dingweidian_range_top; //上定位点范围
  361. int dingweidian_rang_buttom;// 下定位点范围
  362. float dingweidian_w_max_rate;
  363. float dingweidian_w_min_rate;
  364. float dingweidian_h_max_rate;
  365. float dingweidian_h_min_rate;
  366. std::string _version;
  367. string exam_name;
  368. string subject_name;
  369. };
  370. } // end namespace OnLineCard