30 #include "Image/ByteImage.h"
31 #include "Image/ImageProcessor.h"
32 #include "Image/IplImageAdaptor.h"
34 #include <opencv2/opencv.hpp>
45 providerName = getProperty<std::string>(
"ImageProviderAdapterName").getValue();
48 const int cornersPerRow = getProperty<int>(
"NumberOfRows").getValue() - 1;
49 const int cornersPerColumn = getProperty<int>(
"NumberOfColumns").getValue() - 1;
50 const int cornersPerImage = cornersPerColumn * cornersPerRow;
51 const double squareSize = getProperty<double>(
"PatternSquareSize").getValue();
53 m_pCorners2DFloat =
new CvPoint2D32f[cornersPerImage];
54 m_pCorners2D =
new CvPoint2D64f[cornersPerImage];
55 m_pCorners3D =
new CvPoint3D64f[cornersPerImage];
57 waitingIntervalBetweenImages = getProperty<int>(
"WaitingIntervalBetweenImages").getValue();
58 m_sCameraParameterFileName = getProperty<std::string>(
"OutputFileName").getValue();
59 desiredNumberOfImages = getProperty<int>(
"NumberOfImages").getValue();
60 numberOfCapturedImages = 0;
64 ARMARX_INFO <<
"Calibration pattern with " << cornersPerColumn + 1 <<
" x " << cornersPerRow + 1 <<
" squares of size " << squareSize;
65 double etalonParams[3] = { double(cornersPerColumn + 1), double(cornersPerRow + 1), squareSize };
67 m_pCalibFilter->
SetFrames(desiredNumberOfImages);
82 imageProviderPrx = getProxy<ImageProviderInterfacePrx>(providerName);
84 cameraImages =
new CByteImage*[2];
88 startingTime = IceUtil::Time::now();
89 timeOfLastCapture = IceUtil::Time::now();
102 delete cameraImages[0];
103 delete cameraImages[1];
104 delete[] cameraImages;
105 delete m_pCalibFilter;
106 delete[] m_pCorners3D;
107 delete[] m_pCorners2D;
108 delete[] m_pCorners2DFloat;
117 long timeSinceStart = (IceUtil::Time::now() - startingTime).toMilliSeconds();
119 if (timeSinceStart < 10000)
121 ARMARX_VERBOSE <<
"Time until start of capture: " << timeSinceStart - 10000 <<
" ms";
133 int nNumberImages =
getImages(cameraImages);
136 if ((IceUtil::Time::now() - timeOfLastCapture).toMilliSeconds() > waitingIntervalBetweenImages)
138 ARMARX_INFO <<
"Capturing image " << numberOfCapturedImages + 1 <<
" of " << desiredNumberOfImages;
139 IplImage* ppIplImages[2] = { IplImageAdaptor::Adapt(cameraImages[0]), IplImageAdaptor::Adapt(cameraImages[1]) };
144 numberOfCapturedImages++;
146 m_pCalibFilter->
Push();
147 timeOfLastCapture = IceUtil::Time::now();
149 if (numberOfCapturedImages == desiredNumberOfImages)
155 ARMARX_INFO <<
"Saving camera calibration to file " << m_sCameraParameterFileName;