mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-03 01:50:24 +08:00
Changed all remaining IplImage to cv::Mat
This commit is contained in:
@@ -474,8 +474,7 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
// Generate the ground truth file
|
// Generate the ground truth file
|
||||||
printf("Generate ground truth to file %s, size of %d\n", GENERATED_GT_NAME, groundTruthMat.rows);
|
printf("Generate ground truth to file %s, size of %d\n", GENERATED_GT_NAME, groundTruthMat.rows);
|
||||||
IplImage img = groundTruthMat;
|
cv::imwrite(GENERATED_GT_NAME, groundTruthMat);
|
||||||
cvSaveImage(GENERATED_GT_NAME, &img);
|
|
||||||
printf(" Creating ground truth file = %fs\n", timer.ticks());
|
printf(" Creating ground truth file = %fs\n", timer.ticks());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,60 +94,42 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
std::string targetFilePath = targetDirectory+UDirectory::separator()+uNumber2Str(i++)+"."+ext;
|
std::string targetFilePath = targetDirectory+UDirectory::separator()+uNumber2Str(i++)+"."+ext;
|
||||||
|
|
||||||
IplImage * imageA = cvLoadImage(fileNameA.c_str(), CV_LOAD_IMAGE_COLOR);
|
cv::Mat imageA = cv::imread(fileNameA.c_str());
|
||||||
IplImage * imageB = cvLoadImage(fileNameB.c_str(), CV_LOAD_IMAGE_COLOR);
|
cv::Mat imageB = cv::imread(fileNameB.c_str());
|
||||||
|
|
||||||
fileNameA.clear();
|
fileNameA.clear();
|
||||||
fileNameB.clear();
|
fileNameB.clear();
|
||||||
|
|
||||||
if(imageA && imageB)
|
if(!imageA.empty() && !imageB.empty())
|
||||||
{
|
{
|
||||||
CvSize sizeA = cvGetSize(imageA);
|
cv::Size sizeA = imageA.size();
|
||||||
CvSize sizeB = cvGetSize(imageB);
|
cv::Size sizeB = imageB.size();
|
||||||
CvSize targetSize = cvSize(0,0);
|
cv::Size targetSize(0,0);
|
||||||
targetSize.width = sizeA.width + sizeB.width;
|
targetSize.width = sizeA.width + sizeB.width;
|
||||||
targetSize.height = sizeA.height > sizeB.height ? sizeA.height : sizeB.height;
|
targetSize.height = sizeA.height > sizeB.height ? sizeA.height : sizeB.height;
|
||||||
IplImage* targetImage = cvCreateImage(targetSize, imageA->depth, imageA->nChannels);
|
cv::Mat targetImage(targetSize, imageA.type());
|
||||||
if(targetImage)
|
|
||||||
|
cv::Mat roiA(targetImage, cv::Rect( 0, 0, sizeA.width, sizeA.height ));
|
||||||
|
imageA.copyTo(roiA);
|
||||||
|
cv::Mat roiB( targetImage, cvRect( sizeA.width, 0, sizeB.width, sizeB.height ) );
|
||||||
|
imageB.copyTo(roiB);
|
||||||
|
|
||||||
|
if(!cv::imwrite(targetFilePath.c_str(), targetImage))
|
||||||
{
|
{
|
||||||
cvSetImageROI( targetImage, cvRect( 0, 0, sizeA.width, sizeA.height ) );
|
printf("Error : saving to \"%s\" goes wrong...\n", targetFilePath.c_str());
|
||||||
cvCopy( imageA, targetImage );
|
|
||||||
cvSetImageROI( targetImage, cvRect( sizeA.width, 0, sizeB.width, sizeB.height ) );
|
|
||||||
cvCopy( imageB, targetImage );
|
|
||||||
cvResetImageROI( targetImage );
|
|
||||||
|
|
||||||
if(!cvSaveImage(targetFilePath.c_str(), targetImage))
|
|
||||||
{
|
|
||||||
printf("Error : saving to \"%s\" goes wrong...\n", targetFilePath.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Saved \"%s\" \n", targetFilePath.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
cvReleaseImage(&targetImage);
|
|
||||||
|
|
||||||
fileNameA = dir.getNextFilePath();
|
|
||||||
fileNameB = dir.getNextFilePath();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Error : can't allocated the target image with size (%d,%d)\n", targetSize.width, targetSize.height);
|
printf("Saved \"%s\" \n", targetFilePath.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileNameA = dir.getNextFilePath();
|
||||||
|
fileNameB = dir.getNextFilePath();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Error: loading images failed!\n");
|
printf("Error: loading images failed!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(imageA)
|
|
||||||
{
|
|
||||||
cvReleaseImage(&imageA);
|
|
||||||
}
|
|
||||||
if(imageB)
|
|
||||||
{
|
|
||||||
cvReleaseImage(&imageB);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
printf("%d files processed\n", i-1);
|
printf("%d files processed\n", i-1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user