|
|
@ -41,6 +41,9 @@ class PointBase {
|
|
|
|
vector <Point2d> toDoVector; //points yet to be searched for adjacent points
|
|
|
|
vector <Point2d> toDoVector; //points yet to be searched for adjacent points
|
|
|
|
std::map<Point2d, string, ComparePoints> pathMap; //map for file paths - get the path of a file via pathMap[Point2d(x,y)]
|
|
|
|
std::map<Point2d, string, ComparePoints> pathMap; //map for file paths - get the path of a file via pathMap[Point2d(x,y)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double imgWidthDeg;
|
|
|
|
|
|
|
|
double imgHeightDeg;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//loaded points in pointbase are sorted according to X value
|
|
|
|
//loaded points in pointbase are sorted according to X value
|
|
|
@ -63,6 +66,9 @@ class PointBase {
|
|
|
|
Point2d newPoint = Point2d(coords["depthPos"]["x"].asDouble() , coords["depthPos"]["y"].asDouble());
|
|
|
|
Point2d newPoint = Point2d(coords["depthPos"]["x"].asDouble() , coords["depthPos"]["y"].asDouble());
|
|
|
|
pathMap[newPoint] = filePath;
|
|
|
|
pathMap[newPoint] = filePath;
|
|
|
|
points.push_back(newPoint);
|
|
|
|
points.push_back(newPoint);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
imgWidthDeg = coords["rectangle"]["w"].asDouble();
|
|
|
|
|
|
|
|
imgHeightDeg = coords["rectangle"]["h"].asDouble();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -200,7 +206,7 @@ class PointBase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -342,4 +348,158 @@ class PointBase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cumdump(int imgWidth,int imgHeight)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int imgIdx = 0;
|
|
|
|
|
|
|
|
//main loop
|
|
|
|
|
|
|
|
while (!points.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//take the first point from the left and find adjts. to it
|
|
|
|
|
|
|
|
Point2d p = points[0];
|
|
|
|
|
|
|
|
vector<Point2d> stitchQueue;
|
|
|
|
|
|
|
|
stitchQueue.push_back(p);
|
|
|
|
|
|
|
|
points.erase(points.begin());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vector<Point2d> temp = getAdjacents(p); //find adj. of first point - inits toDo vector
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (toDoVector.empty()) //if first point has no adjts. - log him as singleton
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ofstream singletonsFile("singletons.log", ios_base::app);
|
|
|
|
|
|
|
|
if(!singletonsFile)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
singletonsFile << "x: " << p.x << std::endl;
|
|
|
|
|
|
|
|
singletonsFile << "y: " << p.y << std::endl;
|
|
|
|
|
|
|
|
singletonsFile << pathMap[Point2d(p.x,p.y) ] << std::endl;
|
|
|
|
|
|
|
|
singletonsFile.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ofstream sing;
|
|
|
|
|
|
|
|
sing.open("singletons.log",ios_base::app);
|
|
|
|
|
|
|
|
sing << "x: " << p.x << std::endl;
|
|
|
|
|
|
|
|
sing << "y: " << p.y << std::endl;
|
|
|
|
|
|
|
|
sing << pathMap[Point2d(p.x,p.y) ] << std::endl;
|
|
|
|
|
|
|
|
sing.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stitchQueue.pop_back();
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//finds adjacencies to every point
|
|
|
|
|
|
|
|
while(!toDoVector.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Point2d p2 = toDoVector[0];
|
|
|
|
|
|
|
|
stitchQueue.push_back(p2);
|
|
|
|
|
|
|
|
temp = getAdjacents(p2);
|
|
|
|
|
|
|
|
toDoVector.erase(toDoVector.begin());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//stitching
|
|
|
|
|
|
|
|
// Define object to store the stitched image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double minX=999;
|
|
|
|
|
|
|
|
double maxX=0;
|
|
|
|
|
|
|
|
double minY=900000;
|
|
|
|
|
|
|
|
double maxY=0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Point2d coords: stitchQueue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (coords.x < minX) minX=coords.x;
|
|
|
|
|
|
|
|
if (coords.x > maxX) maxX=coords.x;
|
|
|
|
|
|
|
|
if (coords.y < minY) minY=coords.y;
|
|
|
|
|
|
|
|
if (coords.y > maxY) maxY=coords.y;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int xDiff = (int)round(maxX)-(int)round(minX);
|
|
|
|
|
|
|
|
int yDiff = (int)round(maxY)-(int)round(minY);
|
|
|
|
|
|
|
|
cout <<xDiff <<"\n";
|
|
|
|
|
|
|
|
cout <<yDiff <<"\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mat img = Mat::zeros((int)(maxY*(imgHeight/imgHeightDeg))+imgHeight,(int)((360/imgWidthDeg)*imgWidth) + imgWidth,CV_8UC3);
|
|
|
|
|
|
|
|
rectangle(img,Point(3,3),Point(15,15),Scalar(128,128, 0),2,2,0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//open stream for logging
|
|
|
|
|
|
|
|
string logFileName = to_string(imgIdx) + ".log";
|
|
|
|
|
|
|
|
ofstream logFile(logFileName);
|
|
|
|
|
|
|
|
for (Point2d coords: stitchQueue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//log which images are in which result file
|
|
|
|
|
|
|
|
logFile << "x: " << coords.x << std::endl;
|
|
|
|
|
|
|
|
logFile << "y: " << coords.y << std::endl;
|
|
|
|
|
|
|
|
logFile << pathMap[Point2d(coords.x,coords.y) ] << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//log to stdout
|
|
|
|
|
|
|
|
cout << "x: " << coords.x << std::endl;
|
|
|
|
|
|
|
|
cout << "y: " << coords.y << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string jsonPath = pathMap[coords];
|
|
|
|
|
|
|
|
string pngPath = jsonPath.erase(jsonPath.length()-4);
|
|
|
|
|
|
|
|
pngPath = pngPath + "png";
|
|
|
|
|
|
|
|
cout << "file: " << pngPath << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mat imgSmall = imread(pngPath,IMREAD_COLOR);
|
|
|
|
|
|
|
|
cout<< cv::typeToString( imgSmall.type() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cout <<minX <<"\n";
|
|
|
|
|
|
|
|
cout <<minY <<"\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//cout << (int)round(coords.x)-(int)round(minX)<< "\n";
|
|
|
|
|
|
|
|
//cout << (int)round(coords.y)-(int)round(minY)<< "\n";
|
|
|
|
|
|
|
|
cout << (int)round(coords.y)*(int)(imgHeight/imgHeightDeg)<< "\n";
|
|
|
|
|
|
|
|
imgSmall.copyTo(img(cv::Rect((int)round(coords.x)*(int)(imgWidth/imgWidthDeg),(int)round(coords.y)*(int)(imgHeight/imgHeightDeg),imgSmall.cols, imgSmall.rows)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
logFile.close();
|
|
|
|
|
|
|
|
string resultName = "result" + to_string(imgIdx) +".png";
|
|
|
|
|
|
|
|
imwrite(resultName, img);
|
|
|
|
|
|
|
|
imgIdx++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//stitching
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
cout << "Stitching" << std::endl;
|
|
|
|
|
|
|
|
Stitcher::Status status = stitcher->stitch(imgs, pano);
|
|
|
|
|
|
|
|
if (status != Stitcher::OK)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Check if images could not be stitched
|
|
|
|
|
|
|
|
// status is OK if images are stitched successfully
|
|
|
|
|
|
|
|
cout << "Can't stitch images\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string resultName = "result" + to_string(imgIdx) +".jpg";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Store a new image stitched from the given
|
|
|
|
|
|
|
|
//set of images as "result.jpg"
|
|
|
|
|
|
|
|
imwrite(resultName, pano);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Show the result
|
|
|
|
|
|
|
|
imshow(resultName, pano);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
waitKey(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|