You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			509 lines
		
	
	
		
			19 KiB
		
	
	
	
		
			C++
		
	
			
		
		
	
	
			509 lines
		
	
	
		
			19 KiB
		
	
	
	
		
			C++
		
	
| #include "StdAfx.h"
 | |
| #include "Camera.h"
 | |
| #include "Propertie.h"
 | |
| #include "PropertieMgr.h"
 | |
| #include "LogMgr.h"
 | |
| #include "AuthorityMgr.h"
 | |
| #include "GlobalDrawMgr.h"
 | |
| #include "DrawSimpleShape.h"
 | |
| #include "PlatformXY.h"
 | |
| #include "ExceptionMsg.h"
 | |
| 
 | |
| CCamera::CCamera(void)
 | |
| {
 | |
|      m_OnePixDis = 1;//一个像素对应的实际尺寸(mm/pix)
 | |
|      m_bIni = false;//是否初始化成功
 | |
|      m_bRotatoPtByAngle = false;//是否根据相机的安装角度修正抓取结果
 | |
|      m_Angle = 0;
 | |
|      m_bUse = true;//是否使用
 | |
|      m_bLeftTop = true;//基准点是否为左上角(false 为左下角)
 | |
|      m_bPixCoord = true;//相机抓取的是否为像素坐标(基恩士返回的是mm 单位的值)
 | |
|      m_bCatch = true;//实际抓取
 | |
|      m_CatchFrontDelay = 100;//抓取前延时ms
 | |
|      m_CatchWaitDelay = 200;//抓取等待延时ms
 | |
| }
 | |
| CCamera::~CCamera(void)
 | |
| {
 | |
| }
 | |
| CMFCPropertyGridProperty *CCamera::CreatGridProperty()
 | |
| {
 | |
|       CString PropertyName;//属性名称
 | |
|       CString Description;//描述
 | |
|       CString Path = _T("Camera");;//存储路径
 | |
|       CString Name;
 | |
| //-------------------------------------------------------------------------------//
 | |
|       PropertyName = _T("共通设定");
 | |
|       CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
 | |
| //-------------------------------------------------------------------------------//
 | |
|       if(gAuthorityMgr->CheckAuthority(_FACTORY))
 | |
|       {
 | |
|              {
 | |
|                   //添加属性变量映射
 | |
|                   Name = _T("m_bUse");//变量名字
 | |
|                   CPropertie *pPropertie = new CPropertie;
 | |
|                   pPropertie->SetpVal((void*)&m_bUse);
 | |
|                   pPropertie->SetType(_PROP_TYPE_BOOL );
 | |
|                   pPropertie->SetpModule(this);
 | |
|                   pPropertie->SetPath(Path);
 | |
|                   pPropertie->SetName(Name);      
 | |
|                   pPropertie->WriteRead(true);//读取保存的属性
 | |
|                   
 | |
|                   //添加属性显示
 | |
|                   PropertyName = _T("是否使用");
 | |
|                   Description = _T("是否使用camera");
 | |
|                   CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bUse, Description);
 | |
|                   pGroup->AddSubItem(p1);
 | |
|             
 | |
|                   gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|              }
 | |
|              {
 | |
|                   //添加属性变量映射
 | |
|                   Name = _T("m_bCatch");//变量名字
 | |
|                   CPropertie *pPropertie = new CPropertie;
 | |
|                   pPropertie->SetpVal((void*)&m_bCatch);
 | |
|                   pPropertie->SetType(_PROP_TYPE_BOOL );
 | |
|                   pPropertie->SetpModule(this);
 | |
|                   pPropertie->SetPath(Path);
 | |
|                   pPropertie->SetName(Name);      
 | |
|                   pPropertie->WriteRead(true);//读取保存的属性
 | |
|                   
 | |
|                   //添加属性显示
 | |
|                   PropertyName = _T("是否抓取");
 | |
|                   Description = _T("FALSE 的时候返回0,但是不报错");
 | |
|                   CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bCatch, Description);
 | |
|                   pGroup->AddSubItem(p1);
 | |
|             
 | |
|                   gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|              }
 | |
|              {
 | |
|                   //添加属性变量映射
 | |
|                   Name = _T("m_CatchFrontDelay");//变量名字
 | |
|                   CPropertie *pPropertie = new CPropertie;
 | |
|                   pPropertie->SetpVal((void*)&m_CatchFrontDelay);
 | |
|                   pPropertie->SetType(_PROP_TYPE_INT);
 | |
|                   pPropertie->SetpModule(this);
 | |
|                   pPropertie->SetPath(Path);
 | |
|                   pPropertie->SetName(Name);      
 | |
|                   pPropertie->WriteRead(true);//读取保存的属性
 | |
|                   
 | |
|                   //添加属性显示
 | |
|                   PropertyName = _T("抓取前延时");
 | |
|                   Description = _T("相机抓取前的延时ms");
 | |
|                   CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_CatchFrontDelay, Description);
 | |
|                   pGroup->AddSubItem(p1);
 | |
|             
 | |
|                   gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|              }
 | |
|              {
 | |
|                   //添加属性变量映射
 | |
|                   Name = _T("m_CatchWaitDelay");//变量名字
 | |
|                   CPropertie *pPropertie = new CPropertie;
 | |
|                   pPropertie->SetpVal((void*)&m_CatchWaitDelay);
 | |
|                   pPropertie->SetType(_PROP_TYPE_INT);
 | |
|                   pPropertie->SetpModule(this);
 | |
|                   pPropertie->SetPath(Path);
 | |
|                   pPropertie->SetName(Name);      
 | |
|                   pPropertie->WriteRead(true);//读取保存的属性
 | |
|                   
 | |
|                   //添加属性显示
 | |
|                   PropertyName = _T("抓取等待延时");
 | |
|                   Description = _T("识别触发后等待数据传到ocx 的延时ms");
 | |
|                   CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_CatchWaitDelay, Description);
 | |
|                   pGroup->AddSubItem(p1);
 | |
|             
 | |
|                   gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|              }
 | |
|              {
 | |
|                   //添加属性变量映射
 | |
|                   Name = _T("m_bRotatoPtByAngle");//变量名字
 | |
|                   CPropertie *pPropertie = new CPropertie;
 | |
|                   pPropertie->SetpVal((void*)&m_bRotatoPtByAngle);
 | |
|                   pPropertie->SetType(_PROP_TYPE_BOOL );
 | |
|                   pPropertie->SetpModule(this);
 | |
|                   pPropertie->SetPath(Path);
 | |
|                   pPropertie->SetName(Name); 
 | |
|                   pPropertie->WriteRead(true);//读取保存的属性
 | |
|                   
 | |
|                   //添加属性显示
 | |
|                   PropertyName = _T("角度修正");
 | |
|                   Description = _T("是否根据相机的安装角度修正抓取结果");
 | |
|                   CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bRotatoPtByAngle, Description);
 | |
|                   pGroup->AddSubItem(p1);
 | |
|                   gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|              }
 | |
|              {
 | |
|                   //添加属性变量映射
 | |
|                   Name = _T("m_Angle");//变量名字
 | |
|                   CPropertie *pPropertie = new CPropertie;
 | |
|                   pPropertie->SetpVal((void*)&m_Angle);
 | |
|                   pPropertie->SetType(_PROP_TYPE_DOUBLE);
 | |
|                   pPropertie->SetpModule(this);
 | |
|                   pPropertie->SetPath(Path);
 | |
|                   pPropertie->SetName(Name);      
 | |
|                   pPropertie->WriteRead(true);//读取保存的属性
 | |
|                   
 | |
|                   //添加属性显示
 | |
|                   PropertyName = _T("安装角度");
 | |
|                   Description = _T("CCD X 方向相对于电机X 轴的角度");
 | |
|                   CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Angle, Description);
 | |
|                   pGroup->AddSubItem(p1);
 | |
|                   gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|              }
 | |
|              {
 | |
|                  //添加属性变量映射
 | |
|                  Name = _T("m_bLeftTop");//变量名字
 | |
|                  CPropertie *pPropertie = new CPropertie;
 | |
|                  pPropertie->SetpVal((void*)&m_bLeftTop);
 | |
|                  pPropertie->SetType(_PROP_TYPE_BOOL );
 | |
|                  pPropertie->SetpModule(this);
 | |
|                  pPropertie->SetPath(Path);
 | |
|                  pPropertie->SetName(Name);      
 | |
|                  pPropertie->WriteRead(true);//读取保存的属性
 | |
|                  
 | |
|                  //添加属性显示
 | |
|                  PropertyName = _T("左上角基准");
 | |
|                  Description = _T("基准点是否为左上角(false 为左下角)");
 | |
|                  CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bLeftTop, Description);
 | |
|                  pGroup->AddSubItem(p1);
 | |
|                  gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|              }
 | |
|              {
 | |
|                  //添加属性变量映射
 | |
|                  Name = _T("m_bPixCoord");//变量名字
 | |
|                  CPropertie *pPropertie = new CPropertie;
 | |
|                  pPropertie->SetpVal((void*)&m_bPixCoord);
 | |
|                  pPropertie->SetType(_PROP_TYPE_BOOL );
 | |
|                  pPropertie->SetpModule(this);
 | |
|                  pPropertie->SetPath(Path);
 | |
|                  pPropertie->SetName(Name);      
 | |
|                  pPropertie->WriteRead(true);//读取保存的属性
 | |
|                  
 | |
|                  //添加属性显示
 | |
|                  PropertyName = _T("像素坐标");
 | |
|                  Description = _T("相机抓取的是否为像素坐标");
 | |
|                  CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bPixCoord, Description);
 | |
|                  pGroup->AddSubItem(p1);
 | |
|                  gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|              }
 | |
|              {
 | |
|                 //添加属性变量映射
 | |
|                 Name = _T("m_OnePixDis");//变量名字
 | |
|                 CPropertie *pPropertie = new CPropertie;
 | |
|                 pPropertie->SetpVal((void*)&m_OnePixDis);
 | |
|                 pPropertie->SetType(_PROP_TYPE_DOUBLE);
 | |
|                 pPropertie->SetpModule(this);
 | |
|                 pPropertie->SetPath(Path);
 | |
|                 pPropertie->SetName(Name);      
 | |
|                 pPropertie->WriteRead(true);//读取保存的属性
 | |
|                 
 | |
|                 //添加属性显示
 | |
|                 PropertyName = _T("像素尺寸");
 | |
|                 Description = _T("一个像素对应的实际尺寸单位是(mm/像素)");
 | |
|                 CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_OnePixDis, Description);
 | |
|                 pGroup->AddSubItem(p1);
 | |
|           
 | |
|                 gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|             }
 | |
| 
 | |
| 
 | |
|              {
 | |
|                  //添加属性变量映射
 | |
|                  Name = _T("m_Coord_x");//变量名字
 | |
|                  CPropertie *pPropertie = new CPropertie;
 | |
|                  pPropertie->SetpVal((void*)&m_Coord.x);
 | |
|                  pPropertie->SetType(_PROP_TYPE_DOUBLE);
 | |
|                  pPropertie->SetpModule(this);
 | |
|                  pPropertie->SetPath(Path);
 | |
|                  pPropertie->SetName(Name);      
 | |
|                  pPropertie->WriteRead(true);//读取保存的属性
 | |
|                  
 | |
|                  //添加属性显示
 | |
|                  PropertyName = _T("视场基准坐标x");
 | |
|                  Description = _T("CCD 的视场基准点相对于平台原点的坐标(单位:mm)");
 | |
|                  CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Coord.x, Description);
 | |
|                  pGroup->AddSubItem(p1);
 | |
|            
 | |
|                  gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|              }
 | |
|              {
 | |
|                  //添加属性变量映射
 | |
|                  Name = _T("m_Coord_y");//变量名字
 | |
|                  CPropertie *pPropertie = new CPropertie;
 | |
|                  pPropertie->SetpVal((void*)&m_Coord.y);
 | |
|                  pPropertie->SetType(_PROP_TYPE_DOUBLE);
 | |
|                  pPropertie->SetpModule(this);
 | |
|                  pPropertie->SetPath(Path);
 | |
|                  pPropertie->SetName(Name);      
 | |
|                  pPropertie->WriteRead(true);//读取保存的属性
 | |
|                  
 | |
|                  //添加属性显示
 | |
|                  PropertyName = _T("视场基准坐标y");
 | |
|                  Description = _T("CCD 的视场基准点相对于平台原点的坐标(单位:mm)");
 | |
|                  CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Coord.y, Description);
 | |
|                  pGroup->AddSubItem(p1);
 | |
|            
 | |
|                  gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|              }
 | |
| 
 | |
| 
 | |
| 			 {
 | |
| 				 //添加属性变量映射
 | |
| 				 Name = _T("m_Coord2_x");//变量名字
 | |
| 				 CPropertie *pPropertie = new CPropertie;
 | |
| 				 pPropertie->SetpVal((void*)&m_Coord2.x);
 | |
| 				 pPropertie->SetType(_PROP_TYPE_DOUBLE);
 | |
| 				 pPropertie->SetpModule(this);
 | |
| 				 pPropertie->SetPath(Path);
 | |
| 				 pPropertie->SetName(Name);
 | |
| 				 pPropertie->WriteRead(true);//读取保存的属性
 | |
| 
 | |
| 											 //添加属性显示
 | |
| 				 PropertyName = _T("视场2相对坐标x");
 | |
| 				 Description = _T("CCD2 的视场中心相对于CCD1中心的坐标(单位:mm)");
 | |
| 				 CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Coord2.x, Description);
 | |
| 				 pGroup->AddSubItem(p1);
 | |
| 
 | |
| 				 gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
| 			 }
 | |
| 			 {
 | |
| 				 //添加属性变量映射
 | |
| 				 Name = _T("m_Coord2_y");//变量名字
 | |
| 				 CPropertie *pPropertie = new CPropertie;
 | |
| 				 pPropertie->SetpVal((void*)&m_Coord2.y);
 | |
| 				 pPropertie->SetType(_PROP_TYPE_DOUBLE);
 | |
| 				 pPropertie->SetpModule(this);
 | |
| 				 pPropertie->SetPath(Path);
 | |
| 				 pPropertie->SetName(Name);
 | |
| 				 pPropertie->WriteRead(true);//读取保存的属性
 | |
| 
 | |
| 											 //添加属性显示
 | |
| 				 PropertyName = _T("视场2相对坐标y");
 | |
| 				 Description = _T("CCD2 的视场中心相对于CCD1中心的坐标(单位:mm)");
 | |
| 				 CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Coord2.y, Description);
 | |
| 				 pGroup->AddSubItem(p1);
 | |
| 
 | |
| 				 gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
| 			 }
 | |
| 
 | |
| 
 | |
|              {
 | |
|                  //添加属性变量映射
 | |
|                  Name = _T("m_Size_w_pix");//变量名字
 | |
|                  CPropertie *pPropertie = new CPropertie;
 | |
|                  pPropertie->SetpVal((void*)&m_Size.w);
 | |
|                  pPropertie->SetType(_PROP_TYPE_DOUBLE);
 | |
|                  pPropertie->SetpModule(this);
 | |
|                  pPropertie->SetPath(Path);
 | |
|                  pPropertie->SetName(Name);      
 | |
|                  pPropertie->WriteRead(true);//读取保存的属性
 | |
|                  
 | |
|                  //添加属性显示
 | |
|                  PropertyName = _T("视场宽度");
 | |
|                  Description = _T("CCD 视场的实际像素宽度(单位:像素)");
 | |
|                  CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Size.w, Description);
 | |
|                  pGroup->AddSubItem(p1);
 | |
|            
 | |
|                  gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|              }
 | |
|              {
 | |
|                  //添加属性变量映射
 | |
|                  Name = _T("m_Size_h_pix");//变量名字
 | |
|                  CPropertie *pPropertie = new CPropertie;
 | |
|                  pPropertie->SetpVal((void*)&m_Size.h);
 | |
|                  pPropertie->SetType(_PROP_TYPE_DOUBLE);
 | |
|                  pPropertie->SetpModule(this);
 | |
|                  pPropertie->SetPath(Path);
 | |
|                  pPropertie->SetName(Name);      
 | |
|                  pPropertie->WriteRead(true);//读取保存的属性
 | |
|                  
 | |
|                  //添加属性显示
 | |
|                  PropertyName = _T("视场高度");
 | |
|                  Description = _T("CCD 视场的实际像素高度(单位:像素)");
 | |
|                  CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Size.h, Description);
 | |
|                  pGroup->AddSubItem(p1);
 | |
|            
 | |
|                  gDevicePropertieMgr.Insert(p1, pPropertie);
 | |
|              }
 | |
|       }
 | |
| //-------------------------------------------------------------------------------//
 | |
|     return pGroup;
 | |
| }
 | |
| void CCamera::ExportPar(ofstream  *pFile)
 | |
| {
 | |
|     (*pFile)<<"[模块] [Camera]------------------------------------------------"<<endl;
 | |
|     (*pFile)<<"[CCD 坐标x][m_Coord.x] = "<<m_Coord.x<<endl;
 | |
|     (*pFile)<<"[CCD 坐标y][m_Coord.y] = "<<m_Coord.y<<endl;
 | |
|     (*pFile)<<"[像素尺寸(mm/pix) ][m_OnePixDis] = "<<m_OnePixDis<<endl;
 | |
|     
 | |
| }
 | |
| void CCamera::Draw(CDC* pDC)
 | |
| {
 | |
|      if(gDraw->IsShowPlatformPos())
 | |
|      {
 | |
|           DbRect Rect(m_Coord,gDraw->GetCatchNodeSize());
 | |
|           DrawCrossX(pDC,gDraw->GetMarkPointPen(),Rect);
 | |
|      }
 | |
| }
 | |
| //设置CCD 的坐标
 | |
| void CCamera::SetCoord(Dbxy pt)
 | |
| {
 | |
|     m_Coord = pt;
 | |
| 	gDevicePropertieMgr.ChangePropertieByVal(&m_Coord.x, pt.x);
 | |
| 	gDevicePropertieMgr.ChangePropertieByVal(&m_Coord.y, pt.y);
 | |
| 	//m_Coord2=pt+
 | |
|     //强制保存所有的属性到文件
 | |
|     //gDevicePropertieMgr.SaveAllPropertie();
 | |
| }
 | |
| //获取CCD 的中心点坐标(一般用来移动到CCD 观察)
 | |
| Dbxy CCamera::GetCenterPt()
 | |
| {
 | |
| 	Dbxy ValidCoord = m_Coord;//实际使用的坐标
 | |
| 	if (m_CamIndex!=0)
 | |
| 	{
 | |
| 		ValidCoord = m_Coord2;
 | |
| 	}
 | |
| 
 | |
|       Dbxy CenterPt;
 | |
|       CenterPt.x = ValidCoord.x + m_Size.w/2;
 | |
|       if(m_bLeftTop)
 | |
|       {
 | |
|             CenterPt.y = ValidCoord.y - m_Size.h/2;
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|             CenterPt.y = ValidCoord.y + m_Size.h/2;
 | |
|       }
 | |
|       return CenterPt;
 | |
| }
 | |
| 
 | |
| Dbxy CCamera::GetCoord()
 | |
| {
 | |
| 	if (m_CamIndex != 0)
 | |
| 	{
 | |
| 		return m_Coord+m_Coord2;
 | |
| 	}
 | |
| 	else
 | |
| 	{
 | |
| 		return m_Coord;
 | |
| 	}
 | |
| }
 | |
| 
 | |
| Dbxy CCamera::CCDpt2Platcoord(Dbxy CCDpt)
 | |
| {
 | |
| 	Dbxy ValidCoord = m_Coord;//实际使用的坐标
 | |
| 	if (m_CamIndex != 0)
 | |
| 	{
 | |
| 		ValidCoord = m_Coord2;
 | |
| 	}
 | |
| 	
 | |
|      Dbxy pt;
 | |
|      pt.x = ValidCoord.x + CCDpt.x;
 | |
|      
 | |
|      if(m_bLeftTop)//根据CCD 的基准点,y 值不一样
 | |
|           pt.y = ValidCoord.y - CCDpt.y;
 | |
|      else
 | |
|           pt.y = ValidCoord.y + CCDpt.y;
 | |
|      return pt;
 | |
| }
 | |
| //将CCD 抓取坐标转换为相对于平台原点的坐标
 | |
| //CCDpt 是CCD 抓取的坐标(相对于CCD 原点的值)
 | |
| Dbxy CCamera::CCDcoord2Platformcoord(Dbxy CCDpt)
 | |
| {
 | |
|     CString LogStr;
 | |
|     LogStr.Format(_T("CCDcoord2Platformcoord : CCD 返回值[x] = [%0.3f] ,[y] = [%0.3f]"),CCDpt.x,CCDpt.y);
 | |
|     gLogMgr->WriteDebugLog(LogStr);
 | |
|     
 | |
|     if(((CCDpt.x<0)||(CCDpt.x>m_Size.w))||((CCDpt.y<0)||(CCDpt.y>m_Size.h)))//避免错误的返回值
 | |
|     {
 | |
|           CString str = _T("定位抓取失败");
 | |
|           CExceptionMsg Msg;
 | |
|           Msg.SetMsg(str);
 | |
|           throw Msg;
 | |
|     }
 | |
| 	//像素坐标转换为mm 单位坐标-----------------------
 | |
| 	if (m_bPixCoord)
 | |
| 	{
 | |
| 		CCDpt.x = CCDpt.x - (m_Size.w / 2);
 | |
| 		CCDpt.y = (m_Size.h / 2)- CCDpt.y;
 | |
| 
 | |
| 		CCDpt.x *= m_OnePixDis;
 | |
| 		CCDpt.y *= m_OnePixDis;
 | |
| 	}
 | |
|     LogStr.Format(_T("[MM_Coordx] = [%0.3f] ,[MM_Coordy] = [%0.3f]"),CCDpt.x,CCDpt.y);
 | |
|     gLogMgr->WriteDebugLog(LogStr);
 | |
|     
 | |
|     //换算为平台 坐标-------------------------------------------
 | |
|     #if 0
 | |
|     Dbxy pt = CCDpt2Platcoord(CCDpt);
 | |
|     
 | |
|     LogStr.Format(_T("[m_Coordx] = [%0.3f] ,[m_Coordy] = [%0.3f]"),m_Coord.x,m_Coord.y);
 | |
|     gLogMgr->WriteDebugLog(LogStr);
 | |
|     
 | |
|     
 | |
|     //结果抵消平台当前的移动量,才是实际测量点的坐标
 | |
|     Dbxy PlatformPt = gPlatformXY->GetCoord();
 | |
|     LogStr.Format(_T("[PlatformPtx] = [%0.3f] ,[PlatformPty] = [%0.3f]"),PlatformPt.x,PlatformPt.y);
 | |
|     gLogMgr->WriteDebugLog(LogStr);
 | |
|     
 | |
|     pt.x -= PlatformPt.x;
 | |
|     pt.y -= PlatformPt.y;
 | |
|     #else
 | |
| 	Dbxy CameraCoord = GetCoord(); //GetCenterPt();
 | |
| 	/*if (m_CamIndex != 0)
 | |
| 	{
 | |
| 		CameraCoord = m_Coord2;
 | |
| 	}*/
 | |
| 
 | |
|     LogStr.Format(_T("[CameraCoord.x] = [%0.3f] ,[CameraCoord.y] = [%0.3f]"),CameraCoord.x,CameraCoord.y);
 | |
|     gLogMgr->WriteDebugLog(LogStr);
 | |
|     Dbxy PlatformPt = gPlatformXY->GetCoord();
 | |
| 	if (gLogMgr->IsDebuging())
 | |
| 	{
 | |
| 		PlatformPt=gLogMgr->LastTargetCoord;
 | |
| 	}
 | |
|     LogStr.Format(_T("[PlatformCoord.x] = [%0.3f] ,[PlatformCoord.y] = [%0.3f]"),PlatformPt.x,PlatformPt.y);
 | |
|     gLogMgr->WriteDebugLog(LogStr);
 | |
| 
 | |
| 	Dbxy TheoryPt;
 | |
| 	TheoryPt.x = CameraCoord.x - PlatformPt.x;
 | |
| 	TheoryPt.y = CameraCoord.y + PlatformPt.y;
 | |
| 
 | |
|     LogStr.Format(_T("[TheoryPtCoord_Now.x] = [%0.3f] ,[TheoryPtCoord_Now.y] = [%0.3f]"),CameraCoord.x,CameraCoord.y);
 | |
|     gLogMgr->WriteDebugLog(LogStr);
 | |
| 
 | |
|     Dbxy pt;
 | |
|     pt.x = TheoryPt.x + CCDpt.x;
 | |
|     pt.y = TheoryPt.y + CCDpt.y;
 | |
| 
 | |
|     LogStr.Format(_T("[CatchPt.x] = [%0.3f] ,[CatchPt.y] = [%0.3f]"),pt.x,pt.y);
 | |
|     gLogMgr->WriteDebugLog(LogStr);
 | |
|     #endif
 | |
|     return pt;
 | |
| }
 | |
| //抓取点, 并转换为平台坐标(pt 保存抓取的结果)
 | |
| bool CCamera::CatchPtToPlatformcoord(Dbxy &pt)
 | |
| {
 | |
|     Dbxy CatchPt;
 | |
|     bool ret;
 | |
|     if(!m_bCatch)//不实际抓取
 | |
|     {
 | |
|          ret = true;
 | |
| 		CatchPt.x = 1296;
 | |
| 		CatchPt.y = 972;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|          ret = CatchPoint(CatchPt);
 | |
|     }
 | |
|     if(IsDbxyZero(CatchPt))
 | |
|          return false;
 | |
|     
 | |
|     if(ret)
 | |
|     {
 | |
|          pt = CCDcoord2Platformcoord(CatchPt);
 | |
|     } 
 | |
|     return ret;
 | |
| }
 | |
| 
 | |
| 
 |