maoyehu 2 years ago
parent
commit
43c16baba1
3 changed files with 10 additions and 5 deletions
  1. 3 0
      MFCApplication1/Config.cpp
  2. 2 0
      MFCApplication1/Config.h
  3. 5 5
      MFCApplication1/MFCApplication1Dlg.cpp

+ 3 - 0
MFCApplication1/Config.cpp

@@ -47,6 +47,9 @@ BOOL CConfig::LoadFromINI()
 	m_strImg = szData;
 	GetPrivateProfileString(_T("Set"), _T("Cut"), _T(""), szData, sizeof(szData), strIni);
 	m_strCut = szData;
+	GetPrivateProfileString(_T("Set"), _T("Token"), _T("24.086aba1dfaa5d4fdba74f2c62b591b35.2592000.1668825495.282335-21782130"), szData, sizeof(szData), strIni);
+	m_strToken = szData;
+
 	return TRUE;
 }
 

+ 2 - 0
MFCApplication1/Config.h

@@ -41,6 +41,8 @@ public:
 	CString m_strImg;
 	CString m_strCut;
 
+	CString m_strToken; // baidu token
+
 };
 
 #endif // !defined(AFX_CONFIG_H__FB63E5FE_85CD_4155_B44F_37652790F1D6__INCLUDED_)

+ 5 - 5
MFCApplication1/MFCApplication1Dlg.cpp

@@ -266,11 +266,6 @@ int handwriting(string strImage, std::string &json_result, const std::string &ac
 
 int IdentifyCallback(result::spinfo& pinfo, void* param)
 {
-	string strToken = "24.086aba1dfaa5d4fdba74f2c62b591b35.2592000.1668825495.282335-21782130";
-	string strResult;
-	string strEncode = GetImageEncodeString("d:\\202210122100_0001.jpg");
-	handwriting(strEncode, strResult, strToken);
-
 	CMFCApplication1Dlg* pWnd = (CMFCApplication1Dlg*)theApp.m_pMainWnd;
 	if (pinfo.choiceRes.size() < 3 || pinfo.vecUrlAPath.size() == 0)
 	{
@@ -295,6 +290,11 @@ int IdentifyCallback(result::spinfo& pinfo, void* param)
 			number += pow(2, length - 1 - i);
 	}
 
+	string strToken = CT2A(CConfig::Instance()->m_strToken);
+	string strResult;
+	string strEncode = GetImageEncodeString(pinfo.vecUrlAPath[0]);
+	handwriting(strEncode, strResult, strToken);
+
 	std::string strJsonDir = CT2A(CConfig::Instance()->m_strMode);
 	strJsonDir.append("/");
 	strJsonDir.append(std::to_string(number));