1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #include "StdAfx.h"
- #include "IdentifyWorker.h"
- CIdentifyWorker::CIdentifyWorker(void):m_identify_state(IS_WAITING)
- {
- }
- CIdentifyWorker::~CIdentifyWorker(void)
- {
- }
- void CIdentifyWorker::SetUseQr(bool bUseQr, const std::string&strQr)
- {
- m_Identifier.SetUseQr(bUseQr, strQr);
- }
- ServiceState CIdentifyWorker::OnRunning( void )
- {
- if(m_identify_state == IS_WAITING){
- ServiceState nextState = IService::OnRunning();
- if(nextState != running) return nextState;
- Sleep(10);
- return running;
- }
- if (m_identify_task_type == ITT_NORMARL || m_identify_task_type == ITT_MANUALMATCH)
- m_Identifier.Identify2(m_img, m_out_result);
- //if(m_identify_task_type == ITT_MANUALMATCH)m_Identifier.Identify3(m_img,m_schema_index,m_muban,m_shijuan,m_out_result);
- *m_presult_buffer_state = identified;
- cvReleaseImage(&m_img);
- m_identify_state = IS_WAITING;
- return running;
- }
- BOOL CIdentifyWorker::Start(void)
- {
- return __super::Start();
- }
- ServiceState CIdentifyWorker::OnStarting( void )
- {
- m_identify_state = IS_WAITING;
- return IService::OnStarting();
- }
- BOOL CIdentifyWorker::Identify(const IplImage * img, OMR_RESULT * out_result, result_buffer_state * presult_buffer_state)
- {
- if(m_identify_state == IS_IDENTIFING)return FALSE;
- m_img =(IplImage * )img;
- m_out_result =out_result;
- m_presult_buffer_state = presult_buffer_state;
- m_identify_task_type = ITT_NORMARL;
- m_identify_state = IS_IDENTIFING;
- return TRUE;
- }
- BOOL CIdentifyWorker::Identify(const IplImage * img, OMR_RESULT * out_result, result_buffer_state * presult_buffer_state, int schema_index, const std::vector<Point2f>& muban, const std::vector<Point2f>& shijuan)
- {
- if (m_identify_state == IS_IDENTIFING)return FALSE;
- m_img = (IplImage *)img;
- m_out_result = out_result;
- m_presult_buffer_state = presult_buffer_state;
- m_schema_index = schema_index;
- m_muban = muban;
- m_shijuan = shijuan;
- m_identify_task_type = ITT_MANUALMATCH;
- m_identify_state = IS_IDENTIFING;
- return TRUE;
- }
- void CIdentifyWorker::LoadSchema(const boost::shared_ptr<const ISCH_Schema>& schema)
- {
- m_Identifier.LoadMuban2(schema);
- }
|