标定类的头文件和库文件在pilelibs目录下。头文件在backpages子目录。库文件(dll, lib)在bug子目录。
TabX提供手眼标定和镜头距离标定。两种标定都不可以不用专用标定板。标定的界面已经完成,应用程序只要通过相应的函数调用即可完成。
标定过程中,运动模块和相应的相机都应该在独占模式。
手眼标定主要完成图像坐标与机械坐标的对应关系。用于加工路径类的坐标转换。手眼标定的结果通过回调函数进行保存和读取。
如:
BOOL WINAPI SerializeCaliRsmResults (int id, CRobotSpaceMapE1* pRsmE1, BOOL bReadIn, UINT* pCaliId, time_t* stamp, RvPoint_f64* pCaliPos, void* pUserData)
{
CString strFileName = g_strAppPath + "\\cfg\\" + GLOBAL_LEFT_COORD_MAP_FILE;
if (bReadIn){
return ReadRsmFromFile(pRsmE1, pCaliId, stamp,pCaliPos, strFileName);}
else{
return WriteRsmToFile(pRsmE1, pCaliId, stamp,pCaliPos, strFileName);
}
return FALSE;}
读写函数使用KFC的CDiskHelper类进行读写。应用程序可以根据需要使用其它方式进行存储。关于CDiskHelper的使用方法请参考相关文档。
#define RSM_TAG 200604
#define RSM_VERSION ((1<<16) | 1)
BOOL ReadRsmFromFile(CRobotSpaceMapE1* pRsm , UINT* pId, time_t* pTimestamp, RvPoint_f64* pCaliPos, const char* strFilePath ){
ASSERT(pRsm && pId && pTimestamp && pCaliPos);
HANDLE hFile = CDiskHelper::OpenFile(strFilePath, NULL);
if (NULL == hFile) return FALSE;
DWORD tag = RSM_TAG;
int ver =RSM_VERSION;if (!CDiskHelper::BEGIN_OBJ_IN(hFile, tag)) goto ON_ERROR;
if (!CDiskHelper::Read(hFile, &ver)) goto ON_ERROR;
if (!CDiskHelper::Read(hFile, pId)) goto ON_ERROR;
if (!CDiskHelper::Read(hFile, pTimestamp, sizeof(time_t))) goto ON_ERROR;
//1.1增加校准位置
if (ver >= RSM_VERSION){if (!CDiskHelper::Read(hFile, pCaliPos)) goto ON_ERROR;
}
if (!pRsm->Serialze(hFile, TRUE)) goto ON_ERROR;
if (!CDiskHelper::END_OBJ_IN(hFile, tag)) goto ON_ERROR;
CDiskHelper::CloseFile(hFile);
return TRUE;
ON_ERROR:
CDiskHelper::CloseFile(hFile);
return FALSE;
}
BOOL WriteRsmToFile(CRobotSpaceMapE1* pRsm, UINT* pId, time_t* pTimestamp, RvPoint_f64* pCaliPos, const char* strFilePath)
{
ASSERT(pRsm && pId && pTimestamp && pCaliPos);
HANDLE hFile = CDiskHelper::CreateFile(strFilePath, FALSE, TRUE, NULL);if (NULL == hFile) return FALSE;
DWORD tag = RSM_TAG;
int ver =RSM_VERSION;
UINT id =0;
if (pRsm->IsValid()){
int cnt = pRsm->GetCtrlCount() * sizeof(double)/sizeof(int);
int* pArr = (int*)pRsm->GetMatrix();
for (int i=0; i id += pArr[i]; } } *pId =id; if (!CDiskHelper::BEGIN_OBJ_OUT(hFile, tag)) goto ON_ERROR; time_t now =time(NULL); *pTimestamp =now; if (!CDiskHelper::Write(hFile, ver)) goto ON_ERROR; if (!CDiskHelper::Write(hFile, id)) goto ON_ERROR;
//1.1增加校准位置
if (!CDiskHelper::Write(hFile, *pCaliPos)) goto ON_ERROR;
if (!pRsm->Serialze(hFile, FALSE)) goto ON_ERROR;
if (!CDiskHelper::END_OBJ_OUT(hFile, tag)) goto ON_ERROR;
CDiskHelper::CloseFile(hFile);
return TRUE;
ON_ERROR:
CDiskHelper::CloseFile(hFile);return FALSE;
}
下面代码为标定移动相机局部视场的主要代码:
CT_PARAMS mp ;
memset(&mp, 0, sizeof(CT_PARAMS));
mp.id = CT_MOBILE_LEFT;mp.fnRefreshSight = NULL;
mp.fnSerializeResults =SerializeCaliRsmResults;
mp.pSerializeResultsUserData =this;
mp.pRefreshSightUserData = NULL;
mp.bFixedCameraPos =FALSE;
mp.axisX = RM_AXIS_X;mp.axisY = RM_AXIS_Y;
mp.axisZ = RM_AXIS_Z;
//下面的标定位置必须实现规划好 mp.caliPosX = fodat.GetFloat(strSect, "left_edit_pos_x" );mp.caliPosY = fodat.GetFloat(strSect, "left_edit_pos_y" );
mp.caliPosZ= fodat.GetFloat(strSect, "left_edit_pos_z" );
mp.bImageFromSight =FALSE;
mp.bHideAuxCamViewer =FALSE;
bpgCalibrateCamera(pCam, strTitle, m_pRobMot, m_pWorkDesk, mp);
下面代码为标定全景相机视场的主要代码:
CT_PARAMS tp ;
CT_PARAMS tp ;
tp.id = CT_GLOBAL_LEFT;
tp.fnRefreshSight = NULL;//RefreshGlobalSight;
tp.fnSerializeResults =SerializeCaliRsmResults;// SerializeGlobalResults;
tp.pSerializeResultsUserData =this;
tp.pRefreshSightUserData = NULL;
tp.axisX = RM_AXIS_X;
tp.axisY = RM_AXIS_Y;
tp.axisZ = RM_AXIS_Z;
//下面的标定位置必须实现规划好
tp.caliPosX = fodat.GetFloat(strSect, "edit_pos_x" );
tp.caliPosY = fodat.GetFloat(strSect, "edit_pos_y" );
tp.caliPosZ = fodat.GetFloat(strSect, "edit_pos_z" );
tp.bImageFromSight =FALSE;
tp.bHideAuxCamViewer =FALSE;
bpgCalibrateCamera(pCam, strTitle, m_pRobMot, m_pWorkDesk, tp);
CLD_PARAMS cp;
memset(&cp, 0, sizeof(CLD_PARAMS));
cp.pUserData = this;
cp.bShowCamera =TRUE;
cp.bEnableStartTool = TRUE;
bpgCaliCamToToolDist(m_pRobMot, m_pWorkDesk, &m_arrCamera[camIdx], (dlg.m_bShowMoverWin? m_pMoverWnd: NULL), &cp, ( LPCSTR)strParamPath );
抖音视频号: 第一感机器视觉
微信公众号: 精浦科技
深圳市软云动力科技有限公司
东莞办事处: 广东省东莞市松湖智谷B6栋225b
公司地址: 广东省深圳市南山区桃园路金桃园大厦2191
深圳市软云动力科技有限公司 版权所有 鄂ICP备2022015826号-2