void TrackedSceneObject::SerializeTracked( Serializer * ser ) { vtkMatrix4x4 * calibrationMat = vtkMatrix4x4::New(); m_calibrationTransform->GetMatrix( calibrationMat ); ::Serialize( ser, "CalibrationMatrix", calibrationMat ); if (ser->IsReader()) SetCalibrationMatrix( calibrationMat ); calibrationMat->Delete(); }
bool CameraObject::Import( QString & directory, QProgressDialog * progressDlg ) { bool success = true; // check that dir exists and is readable QFileInfo dirInfo( directory ); Q_ASSERT( dirInfo.exists() ); Q_ASSERT( dirInfo.isReadable() ); QString objectName = dirInfo.baseName(); this->SetName( objectName ); // read intrinsic params CameraIntrinsicParams params; SerializerReader reader; QString intrinsicParamsFilename = QString("%1/intrinsic_params.xml").arg( directory ); QFileInfo intrinsicParamsInfo( intrinsicParamsFilename ); if( !intrinsicParamsInfo.exists() || !intrinsicParamsInfo.isReadable() ) Application::GetInstance().Warning( "Camera import", "Intrinsic calibration params (intrinsic_params.xml) is missing or unreadable. Intrinsic camera params will be the default ones." ); else { reader.SetFilename( intrinsicParamsFilename.toUtf8().data() ); reader.Start(); ::Serialize( &reader, "IntrinsicParams", params ); reader.Finish(); } SetIntrinsicParams( params ); // Read calibration matrix QString calMatrixFilename = QString("%1/calibMat.xfm").arg( directory ); QFileInfo calMatrixInfo( calMatrixFilename ); vtkMatrix4x4 * calMatrix = vtkMatrix4x4::New(); if( !calMatrixInfo.exists() || !calMatrixInfo.isReadable() ) Application::GetInstance().Warning( "Camera import", "Calibration matrix file (calibMat.xfm) is missing or unreadable. Calibration matrix will be identity." ); else TrackedVideoBuffer::ReadMatrix( calMatrixFilename, calMatrix ); SetCalibrationMatrix( calMatrix ); calMatrix->Delete(); m_videoBuffer->Import( directory, progressDlg ); SetCurrentFrame( 0 ); m_videoInputSwitch->Update(); // Without this update, image is not displayed, but it shouldn't be needed // Update representation in view UpdateGeometricRepresentation(); return success; }
/** @addtogroup GLCD_CAL_Public_Functions * @{ */ void TSC2004_Cal_Init(MATRIX_Type *matrixPtr) { int n; COLORCFG_Type ClrCfg; MATRIX_Type matrix[4],avgmatrix; ts_event RTouch; ts_eventCal screenSample[5]; ts_eventCal displaySample[5] = { { 20, 20 }, { 300, 20 }, { 300, 220 }, { 20, 220 }, { 160, 120 }, }; ts_eventCal displaytriangle1[3] = {displaySample[0],displaySample[4],displaySample[1]}; ts_eventCal displaytriangle2[3] = {displaySample[1],displaySample[4],displaySample[2]}; ts_eventCal displaytriangle3[3] = {displaySample[2],displaySample[4],displaySample[3]}; ts_eventCal displaytriangle4[3] = {displaySample[3],displaySample[4],displaySample[0]}; GLCD_Clear(White); for(n=0; n<5; n++) { switch (n) { case 0: ClrCfg.bcolor = Red; ClrCfg.bndry = FALSE; ClrCfg.fill = TRUE; ClrCfg.fill_color = Red; GLCD_Circle(20,20,3,&ClrCfg); break; case 1: ClrCfg.bcolor = Red; ClrCfg.bndry = FALSE; ClrCfg.fill = TRUE; ClrCfg.fill_color = Red; GLCD_Circle(300,20,3,&ClrCfg); break; case 2: ClrCfg.bcolor = Red; ClrCfg.bndry = FALSE; ClrCfg.fill = TRUE; ClrCfg.fill_color = Red; GLCD_Circle(300,220,3,&ClrCfg); break; case 3: ClrCfg.bcolor = Red; ClrCfg.bndry = FALSE; ClrCfg.fill = TRUE; ClrCfg.fill_color = Red; GLCD_Circle(20,220,3,&ClrCfg); break; case 4: ClrCfg.bcolor = Red; ClrCfg.bndry = FALSE; ClrCfg.fill = TRUE; ClrCfg.fill_color = Red; GLCD_Circle(160,120,3,&ClrCfg); break; default: break; } //printf(LPC_UART0, "Touch point\n\r"); while(TReady == FALSE); // printf(LPC_UART0,"\x1b[8;1After While\n\r"); delay_ms(2000); screenSample[n].x = gTouch.x; screenSample[n].y = gTouch.y; // printf(LPC_UART0,"\x1b[3;1H gTouchx = %d08",gTouch.x); // printf(LPC_UART0,"\x1b[4;1H gTouchy = %d08",gTouch.y); TReady = FALSE; } CalTouch=FALSE; // printf(LPC_UART0,"line reached"); ts_eventCal screentriangle1[3] = {screenSample[0],screenSample[4],screenSample[1]}; ts_eventCal screentriangle2[3] = {screenSample[1],screenSample[4],screenSample[2]}; ts_eventCal screentriangle3[3] = {screenSample[2],screenSample[4],screenSample[3]}; ts_eventCal screentriangle4[3] = {screenSample[3],screenSample[4],screenSample[0]}; SetCalibrationMatrix(displaytriangle1, screentriangle1, &matrix[0]); SetCalibrationMatrix(displaytriangle2, screentriangle2, &matrix[1]); SetCalibrationMatrix(displaytriangle3, screentriangle3, &matrix[2]); SetCalibrationMatrix(displaytriangle4, screentriangle4, &matrix[3]); matrixPtr->An = ( matrix[0].An + matrix[1].An + matrix[2].An + matrix[3].An ) / 4; matrixPtr->Bn = ( matrix[0].Bn + matrix[1].Bn + matrix[2].Bn + matrix[3].Bn ) / 4; matrixPtr->Cn = ( matrix[0].Cn + matrix[1].Cn + matrix[2].Cn + matrix[3].Cn ) / 4; matrixPtr->Dn = ( matrix[0].Dn + matrix[1].Dn + matrix[2].Dn + matrix[3].Dn ) / 4; matrixPtr->En = ( matrix[0].En + matrix[1].En + matrix[2].En + matrix[3].En ) / 4; matrixPtr->Fn = ( matrix[0].Fn + matrix[1].Fn + matrix[2].Fn + matrix[3].Fn ) / 4; matrixPtr->Divider = ( matrix[0].Divider + matrix[1].Divider + matrix[2].Divider + matrix[3].Divider ) / 4; GLCD_Clear(White); }