Bladeren bron

【功能修改】适配校本新需求,变更预识别逻辑
【工作量】3h
【评审人】叶长城

huanggen 5 maanden geleden
bovenliggende
commit
7bf3765843
2 gewijzigde bestanden met toevoegingen van 22 en 10 verwijderingen
  1. 18 7
      app/src/main/cpp/paperPreIdentify.cpp
  2. 4 3
      app/src/main/cpp/paperPreIdentify.h

+ 18 - 7
app/src/main/cpp/paperPreIdentify.cpp

@@ -556,7 +556,7 @@ int paperPreIdentify::getBalckAreaCount(Mat& tMat)
 
 }
 
-PAPERIDENTIFYSTATUS paperPreIdentify::preIdentify(vector<string> papersVec, string strIp) {
+PAPERIDENTIFYSTATUS paperPreIdentify::preIdentify(vector<string>& papersVec, string strIp) {
     vector<PaperPage> tAllPaperList;
     int nPaperSize = papersVec.size();
     if(0 == nPaperSize || nPaperSize % 2 != 0)
@@ -566,6 +566,7 @@ PAPERIDENTIFYSTATUS paperPreIdentify::preIdentify(vector<string> papersVec, stri
     int nGetQrcodeFailCount = 0;
     string strFirPagePath;
     map<string, int> qrCodeCountMap;
+    map<string, int> qrCodeContentMap;
     for(int i = 0; i < nPaperSize; i++)
     {
         if(i % 2 == 0)
@@ -592,7 +593,14 @@ PAPERIDENTIFYSTATUS paperPreIdentify::preIdentify(vector<string> papersVec, stri
                 tAllPaperList.push_back(tPage);
                 continue;
             }
+            else
+                qrCodeContentMap[strQRCode] = 1;
             tPage.qrCode = strQRCode;
+
+            //前五份之内存在如果存在试卷夹带,中止扫描
+            if(i + 1 <= 10 && qrCodeContentMap.size() > 1)
+                return PAPERDOPING;
+
             if(qrCodeCountMap.count(strQRCode) == 0)
             {
                 //二维码能正确识别则根据识别出的答题卡ID获取模板信息
@@ -612,23 +620,28 @@ PAPERIDENTIFYSTATUS paperPreIdentify::preIdentify(vector<string> papersVec, stri
                 else
                 {
                     //仅记录能够成功获取模板信息的QrCode
+                    if(qrCodeCountMap.size() == 0)
+                        qrCodeCountMap[strQRCode] = 2;
                     qrCodeCountMap[strQRCode] = 1;
                 }
             }
             else
             {
-                int nCount = qrCodeCountMap[strQRCode];
-                nCount++;
-                qrCodeCountMap[strQRCode] = nCount;
+                //计数加1
+                if(qrCodeCountMap.size() == 1)
+                    qrCodeCountMap[strQRCode]++;
             }
+#if 0
+            //暂时屏蔽定位点识别逻辑
             //模板能正常获取继续走定位点识别流程
             bool bFind = findAnchors(tPage);
             if(!bFind)
                 tPage.ePaperStatus = PAPER_INVALIDANCHORS;
+#endif
             tAllPaperList.push_back(tPage);
         }
     }
-    map<string, int>::iterator iter = qrCodeCountMap.begin();
+    auto iter = qrCodeCountMap.begin();
     int nMaxCount;
     string strMaxCountQr = "";
     if(!qrCodeCountMap.empty())
@@ -649,7 +662,6 @@ PAPERIDENTIFYSTATUS paperPreIdentify::preIdentify(vector<string> papersVec, stri
     vector<PaperPage> invAncList;
     vector<PaperPage> invQrList;
     vector<PaperPage> cannotReadQrList;
-//    vector<PaperPage> cannotGetTmpList;
     //标记二维码异常(试卷夹带)答题卡
     //将异常类型分类存储至map中
     for(PaperPage tPaper : tAllPaperList)
@@ -666,7 +678,6 @@ PAPERIDENTIFYSTATUS paperPreIdentify::preIdentify(vector<string> papersVec, stri
     }
     m_abnPaperMap[PAPER_INVALIDQRCODE] = invQrList;
     m_abnPaperMap[PAPER_INVALIDANCHORS] = invAncList;
-//    m_abnPaperMap[PAPER_CANNOTGETTEMPLATE] = cannotGetTmpList;
     m_abnPaperMap[PAPER_CANNOTREADQRCODE] = cannotReadQrList;
     return FINISHPREIDENTIFY;
 }

+ 4 - 3
app/src/main/cpp/paperPreIdentify.h

@@ -26,7 +26,7 @@ enum PaperAbnormalType
     PAPER_NOERROR = 0,
     PAPER_INVALIDANCHORS,                                                                           //定位点异常
     PAPER_INVALIDQRCODE,                                                                            //二维码识别出的答题卡ID和同批次的其他答题卡不一样
-//    PAPER_CANNOTGETTEMPLATE,                                                                        //根据二维码识别出的答题卡ID,无法获取到模板信息
+//    PAPER_CANNOTGETTEMPLATE,                                                                      //根据二维码识别出的答题卡ID,无法获取到模板信息
     PAPER_CANNOTREADQRCODE                                                                          //二维码无法识别出答题卡ID
 };
 
@@ -35,7 +35,8 @@ enum PAPERIDENTIFYSTATUS
     PAPERNUMODD = 0,                                                                                //答题卡数量为奇数
     GETTEMPLATEFAILED,                                                                              //前五份答题卡的模板信息均获取失败,直接中止预识别流程
     GETQRCODEFAILED,                                                                                //前五份答题卡的二维码信息识别失败,中止预识别流程
-    FINISHPREIDENTIFY                                                                               //完成预识别流程
+    FINISHPREIDENTIFY,                                                                              //完成预识别流程
+    PAPERDOPING                                                                                     //前五份答题卡中存在试卷夹带,中止预识别流程
 };
 
 struct PaperPage
@@ -101,7 +102,7 @@ public:
     std::string getPaperCardId(){ return m_sCardId; }
 
 private:
-    PAPERIDENTIFYSTATUS preIdentify(std::vector<std::string> papersVec, std::string strIp);         //预识别主逻辑
+    PAPERIDENTIFYSTATUS preIdentify(std::vector<std::string>& papersVec, std::string strIp);        //预识别主逻辑
     bool findAnchors(PaperPage);                                                                    //查找答题卡图片定位点,成功返回true,失败返回false
     std::string readQrCode(PaperPage);                                                              //读取答题卡二维码信息
     void traverseDir(std::string strImgDir);                                                        //遍历图片文件夹