Browse Source

修复线上反馈bug

huanggen 7 months ago
parent
commit
fbf6f42ee1
3 changed files with 28 additions and 6 deletions
  1. 1 0
      .idea/.name
  2. 6 5
      app/src/main/cpp/CMakeLists.txt
  3. 21 1
      app/src/main/cpp/paperPreIdentify.cpp

+ 1 - 0
.idea/.name

@@ -0,0 +1 @@
+PaperIdentify

+ 6 - 5
app/src/main/cpp/CMakeLists.txt

@@ -10,7 +10,7 @@ cmake_minimum_required(VERSION 3.10.2)
 project("paperidentify")
 
 #opencv库
-#set(OpenCV F:/AndroidWorkSpace/PaperIdentify/app/src/main/cpp/opencv/sdk/native/jni)
+set(OpenCV_DIR F:/AndroidWorkSpace/PaperPreIdentify/app/src/main/cpp/opencv/sdk/native/jni)
 find_package(OpenCV REQUIRED java)
 
 # Creates and names a library, sets it as either STATIC
@@ -77,22 +77,22 @@ add_library( # Sets the name of the library.
         )
 
 include_directories(paperidentify
-        F:/AndroidWorkSpace/PaperIdentify/app/src/main/cpp/zbar/include)
+        F:/AndroidWorkSpace/PaperPreIdentify/app/src/main/cpp/zbar/include)
 
 add_library(curl STATIC IMPORTED)
 set_target_properties(curl
         PROPERTIES IMPORTED_LOCATION
-        F:/AndroidWorkSpace/PaperIdentify/app/src/main/cpp/curl/lib/${ANDROID_ABI}/libcurl.a)
+        F:/AndroidWorkSpace/PaperPreIdentify/app/src/main/cpp/curl/lib/${ANDROID_ABI}/libcurl.a)
 
 add_library(iconv SHARED IMPORTED)
 set_target_properties(iconv
         PROPERTIES IMPORTED_LOCATION
-        F:/AndroidWorkSpace/PaperIdentify/app/src/main/cpp/zbar/${ANDROID_ABI}/libiconv.so)
+        F:/AndroidWorkSpace/PaperPreIdentify/app/src/main/cpp/zbar/${ANDROID_ABI}/libiconv.so)
 
 add_library(zbar SHARED IMPORTED)
 set_target_properties(zbar
         PROPERTIES IMPORTED_LOCATION
-        F:/AndroidWorkSpace/PaperIdentify/app/src/main/cpp/zbar/${ANDROID_ABI}/libzbar.so)
+        F:/AndroidWorkSpace/PaperPreIdentify/app/src/main/cpp/zbar/${ANDROID_ABI}/libzbar.so)
 
 
 # Searches for a specified prebuilt library and stores the path as a
@@ -114,6 +114,7 @@ find_library( # Sets the name of the path variable.
 
 target_link_libraries( # Specifies the target library.
         paperidentify
+
         curl
         iconv
         zbar

+ 21 - 1
app/src/main/cpp/paperPreIdentify.cpp

@@ -194,7 +194,9 @@ bool paperPreIdentify::getCardTemplate(string strCardId, string strIp)
     if(strs.size() == 2)
         strTaskId = strs.at(1);
     string strSchoolId = to_string(m_nSchoolId);
-    string strUrl = strIp + "/teacher/third/card/location?cardId=" + strCardId + "&taskId=" + strTaskId + "&schoolId=" + strSchoolId;
+    if(!strIp.empty() && strIp[strIp.length() - 1] != '/')
+        strIp += "/";
+    string strUrl = strIp + "teacher/third/card/location?cardId=" + strCardId + "&taskId=" + strTaskId + "&schoolId=" + strSchoolId;
     //调用后端接口获取模板信息
     void* curl = curl_easy_init();
     curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
@@ -202,15 +204,21 @@ bool paperPreIdentify::getCardTemplate(string strCardId, string strIp)
     struct curl_slist *headers = NULL;
     headers = curl_slist_append(headers, "Accept: *,*/*");
     headers = curl_slist_append(headers, "Accept-Language: zh-cn");
+//    headers = curl_slist_append(headers, "Accept-Encoding: gzip, deflate");
     headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
     headers = curl_slist_append(headers, "Authorization:Basic ZnhiLXNoOmVDbGo0TlRoSHlMY05USE0wZWl3ZWpVUExCcGFlZQ==");
     curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
     string strJson;
     curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
     curl_easy_setopt(curl, CURLOPT_WRITEDATA, &strJson);
     CURLcode res = curl_easy_perform(curl);
     if (res != CURLE_OK)
+    {
+        string strError = curl_easy_strerror(res);
         return false;
+    }
     curl_easy_cleanup(curl);
     //解析json
     Json::Reader reader;
@@ -325,6 +333,18 @@ bool paperPreIdentify::findTopAnchors(Mat tMat)
         }
         CvRect rect;
         float k = 0, b = 0;
+        //剔除杂质点
+        if(list.size() > 3)
+        {
+            int nCount = list.size() - 3;
+            sort(list.begin(), list.end(), [](CvRect r1, CvRect r2){
+                return r1.y < r2.y;
+            });
+            if(abs(list[2].y - list[1].y) > 5)
+                nCount++;
+            while(nCount--)
+                list.pop_back();
+        }
         if (list.size() > 1)
         {
             bool bV = false;