12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #include "StdAfx.h"
- #include "CManualMatchFeeder.h"
- CManualMatchFeeder::CManualMatchFeeder(void)
- {
- m_img =NULL;
- InitializeCriticalSection(&m_img_lock);
- }
- CManualMatchFeeder::~CManualMatchFeeder(void)
- {
- DeleteCriticalSection(&m_img_lock);
- }
- BOOL CManualMatchFeeder::SupportPause()
- {
- return FALSE;
- }
- BOOL CManualMatchFeeder::SupportStop()
- {
- return FALSE;
- }
- bool CManualMatchFeeder::GetNext( BOOL wait,IplImage* & img, feeder_param& param )
- {
- do
- {
- BOOL isStoped = m_serviceState == stoped;
- if(m_img!=NULL){
- EnterCriticalSection(&m_img_lock);
- if(m_img!=NULL){
- img = m_img;
- param.type = identyfi_type_manualmatch;
- param.srcimg_type = SRC_IMG_HANDLE_TYPE_NONE;
- param.paper_id = m_param->paper_id;
- param.phy_number = m_param->phy_number;
- param.schema_index = m_param->schema_index;
- param.img_path = m_param->img_path;
- for (int i=0;i<3;i++)
- {
- param.x_m[i]=m_param->x_m[i];
- param.y_m[i]=m_param->y_m[i];
- param.x_s[i]=m_param->x_s[i];
- param.y_s[i]=m_param->y_s[i];
- }
- // printf("重新扫描加载图片: paper_id=%d phy_number=%d 路径:%s", param.paper_id, param.phy_number, param.img_path);
- m_img =NULL;
- LeaveCriticalSection(&m_img_lock);
- return true;
- }
- LeaveCriticalSection(&m_img_lock);
- }
- if(isStoped)return false;
- if(wait)Sleep(10);
- } while (wait);
- return false;
- }
- ServiceState CManualMatchFeeder::OnStarting( void )
- {
- m_img =NULL;
- m_post_count =0;
- return IService::OnStarting();
- }
- ServiceState CManualMatchFeeder::OnRunning( void )
- {
- ServiceState nextState = IService::OnRunning();
- if(nextState != running) return nextState;
- if(m_img==NULL){
- if(m_img_list.size()>m_post_count){
- m_img =cvLoadImage(m_img_list[m_post_count].img_path,1);
- m_param =&m_img_list[m_post_count];
- m_post_count++;
- return running;
- }
- return stoping;
- }else{
- Sleep(10);
- return running;
- }
- }
- void CManualMatchFeeder::SetImgList(const std::vector<img_param> & imgs )
- {
- m_img_list = imgs;
- }
|