123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #pragma once
- typedef struct _IdentifyItem{
- float x, y, w, h;
- char name[8];
- _IdentifyItem(){
- x = 0; y = 0; w = 0; h = 0;
- memset(name, 0, sizeof(name) / sizeof(char));
- }
- }IdentifyItem;
- typedef struct _IdentifyGroup{
- bool mul; //是否是多选题
- char id[16]; // 题号
- int item_count; // 选项个数
- IdentifyItem* ptr_item;
- int *select;
- int select_count; //单选 1, 多选 n
- void init(int count, const char*id, bool mul){
- item_count = count;
- this->mul = mul;
- strcpy(this->id, id);
- if (item_count > 0){
- ptr_item = new IdentifyItem[item_count];
- select = new int[item_count];
- memset(select, 0, sizeof(int)*item_count);
- select_count = 0;
- }
- }
- _IdentifyGroup(){
- ptr_item = nullptr;
- select = nullptr;
- }
- ~_IdentifyGroup(){
- if (item_count > 0){
- if (ptr_item)delete[] ptr_item; ptr_item = nullptr;
- if (select) delete[] select; select = nullptr;
- }
- }
- IdentifyItem* get_item_by_index(int index){
- if (index < item_count){
- return ptr_item + index;
- }
- else{
- return nullptr;
- }
- }
- }IdentifyGroup;
- enum class GROUP_TYPE_IDENTIFY
- {
- NONE,
- TIANTUKAOHAO,
- KEGUANTI,
- QUEKAO,
- XUANZUOTI,
- };
- enum class IMG_ROTATION {
- ROTATION_0 = 1, // 模板同方向
- ROTATION_90 = 2, // 逆时针90°
- ROTATION_180 = 4, // 倒置180°
- ROTATION_270 = 8, // 顺时针90°
- };
- typedef struct _IdentifyArea {
- GROUP_TYPE_IDENTIFY type;
- bool btiantu; // 是否是填涂
- IMG_ROTATION dir; // 答题卡方向 2021.12.22
- int thresholdV; // 是否使用传入的阈值作为阈值分割 0:内部自己计算 >0: 使用传入值 2021.12.22
- int group_count;
- IdentifyGroup*ptr_group;
- _IdentifyArea(int count, bool btiantu = false, IMG_ROTATION dir = IMG_ROTATION::ROTATION_0, int thv = 0) {
- this->btiantu = btiantu;
- group_count = count;
- this->dir = dir;
- this->thresholdV = thv;
- if (group_count > 0) {
- ptr_group = new IdentifyGroup[group_count];
- }
- }
- ~_IdentifyArea() {
- if (group_count > 0) {
- delete[] ptr_group;
- ptr_group = nullptr;
- }
- }
- IdentifyGroup* get_group_by_index(int index) {
- if (index < group_count) {
- return ptr_group + index;
- }
- else {
- return nullptr;
- }
- }
- }IdentifyArea;
- enum CodeType
- {
- CODE_UNKNOW = 0, /// 未知类型
- CODE_QR = 1, /// 二维码类型
- CODE_BAR = 2, /// 条码类型
- };
- __declspec(dllimport) int api_ttpd_analysis_part(cv::Mat&image, IdentifyArea * pArea);
- __declspec(dllimport) int api_parse_barcode_qrcode(cv::Mat _img, int type, char * szRes, int size);
- std::string get_str_by_identify_group(int omr_out_type, IdentifyGroup*ptr_group, char option_spacer);
|