49 cameraImageProviderName =
53 kinectImageProviderName =
58 const int cornersPerColumn =
getProperty<int>(
"NumberOfColumns").getValue() - 1;
61 waitingIntervalBetweenImages =
getProperty<int>(
"WaitingIntervalBetweenImages").getValue();
64 numberOfCapturedImages = 0;
68 ARMARX_INFO <<
"Calibration pattern with " << cornersPerColumn + 1 <<
" x "
69 << cornersPerRow + 1 <<
" squares of size " << squareSize;
70 etalonParams[0] = double(cornersPerColumn + 1);
71 etalonParams[1] = double(cornersPerRow + 1);
72 etalonParams[2] = squareSize;
73 m_pCalibFilter->SetCameraCount(2);
74 m_pCalibFilter->SetFrames(desiredNumberOfImages);
89 cameraImages =
new CByteImage*[2];
96 kinectImages =
new CByteImage*[kinectImageProviderPrx->getNumberImages()];
98 for (
int i = 0; i < kinectImageProviderPrx->getNumberImages(); i++)
101 kinectImageProviderPrx->getImageFormat().type);
104 startingTime = IceUtil::Time::now();
105 timeOfLastCapture = IceUtil::Time::now();
109 result.result =
false;
131 long timeSinceStart = (IceUtil::Time::now() - startingTime).toMilliSeconds();
133 if (timeSinceStart < 10000)
135 ARMARX_VERBOSE <<
"Time until start of capture: " << timeSinceStart - 10000
142 armarx::MetaInfoSizeBasePtr info;
143 int nNumberCameraImages =
getImages(cameraImageProviderName, cameraImages, info);
146 armarx::MetaInfoSizeBasePtr info2;
147 int nNumberKinectImages =
getImages(kinectImageProviderName, kinectImages, info2);
150 if (nNumberCameraImages > 0 && nNumberKinectImages > 0)
152 if ((IceUtil::Time::now() - timeOfLastCapture).toMilliSeconds() >
153 waitingIntervalBetweenImages)
155 ARMARX_INFO <<
"Capturing image " << numberOfCapturedImages + 1 <<
" of "
156 << desiredNumberOfImages;
157 IplImage* ppIplImages[2] = {IplImageAdaptor::Adapt(cameraImages[0]),
158 IplImageAdaptor::Adapt(kinectImages[0])};
160 if (m_pCalibFilter->FindEtalon(ppIplImages))
163 numberOfCapturedImages++;
164 timeOfLastCapture = IceUtil::Time::now();
165 m_pCalibFilter->DrawPoints(ppIplImages);
166 m_pCalibFilter->Push();
168 if (numberOfCapturedImages == desiredNumberOfImages)
173 if (m_pCalibFilter->IsCalibrated())
175 ARMARX_INFO <<
"Saving camera calibration to file "
176 << m_sCameraParameterFileName;
177 m_pCalibFilter->SaveCameraParams(
178 m_sCameraParameterFileName.c_str());
179 CStereoCalibration calibration;
180 calibration.LoadCameraParameters(
181 m_sCameraParameterFileName.c_str());
182 CCalibration cRight = *calibration.GetRightCalibration();
183 Vec3d translation = cRight.GetCameraParameters().translation;
184 ARMARX_INFO <<
"RightCalibration traslation; " << translation.x
185 <<
" " << translation.y <<
" " << translation.z;
186 Mat3d rotation = cRight.GetCameraParameters().rotation;
187 ARMARX_INFO <<
"RightCalibration rotation; " << rotation.r1
188 <<
" " << rotation.r2 <<
" " << rotation.r3 <<
" \n"
189 << rotation.r4 <<
" " << rotation.r5 <<
" "
190 << rotation.r6 <<
" \n"
191 << rotation.r7 <<
" " << rotation.r8 <<
" "
192 << rotation.r9 <<
" \n";
195 CCalibration cLeft = *calibration.GetLeftCalibration();
196 Vec3d translationLeft = cLeft.GetCameraParameters().translation;
198 << translationLeft.x <<
" " << translationLeft.y
199 <<
" " << translationLeft.z;
200 Mat3d rotationLeft = cLeft.GetCameraParameters().rotation;
201 ARMARX_INFO <<
"LeftCalibration rotation; " << rotationLeft.r1
202 <<
" " << rotationLeft.r2 <<
" " << rotationLeft.r3
204 << rotationLeft.r4 <<
" " << rotationLeft.r5 <<
" "
205 << rotationLeft.r6 <<
" \n"
206 << rotationLeft.r7 <<
" " << rotationLeft.r8 <<
" "
207 << rotationLeft.r9 <<
" \n";
210 result.result = finished;
211 result.transformation =
215 listenerPrx->reportCalibrationFinished(result.result);
235 startingTime = IceUtil::Time::now();