#include "stdafx.h" #include "OnlineCardIdentifyWorker.h" namespace OnLineCard{ COnlineCardIdentifyWorker::COnlineCardIdentifyWorker() { } COnlineCardIdentifyWorker::~COnlineCardIdentifyWorker() { } bool COnlineCardIdentifyWorker::OnLineCardIdentify(IplImage * img, void * out_result, int out_size, result_buffer_state * presult_buffer_state) { if (m_identify_state == identify_state::identifing)return false; m_identify_state = identify_state::identifing; m_img = img; m_out_result = out_result; m_out_size = out_size; m_presult_buffer_state = presult_buffer_state; return true; } ServiceState COnlineCardIdentifyWorker::OnStarting(void) { m_identify_state = identify_state::waiting; m_Identifier.resetflag(); return IService::OnStarting(); } void COnlineCardIdentifyWorker::SetTemplate(PaperTemplate*pT) { m_Identifier.SetTemplate(pT); } void COnlineCardIdentifyWorker::SetQr(bool bUseQr, const std::string&strQr) { m_Identifier.SetQr(bUseQr, strQr); } void COnlineCardIdentifyWorker::SetOnlineScanType(int nOnlineScanType) { m_Identifier.SetOnlineScanType(nOnlineScanType); } ServiceState COnlineCardIdentifyWorker::OnRunning(void) { if (m_identify_state == identify_state::waiting){ ServiceState nextState = IService::OnRunning(); if (nextState != ServiceState::running) return nextState; Sleep(10); return ServiceState::running; } // printf("Ïß³Ì%s: m_Identifier.Identify \n",std::to_string(GetCurrentThreadId()).c_str()); m_Identifier.Identify(m_img, m_out_result, m_out_size); // printf("Ïß³Ì%s: m_Identifier.Identify--end \n", std::to_string(GetCurrentThreadId()).c_str()); *m_presult_buffer_state = identified; m_identify_state = identify_state::waiting; cvReleaseImage(&m_img); return ServiceState::running; } }