From 248899c4b84949a51f0df8193748cd2cbf775f46 Mon Sep 17 00:00:00 2001 From: Pavol Debnar Date: Wed, 15 Feb 2023 14:47:01 +0100 Subject: [PATCH] creation of cumulative dump function; edited test cumdump() - puts all images into a single one with no stiching yet test.cpp - use of cumdump(), added img locations for quicker use --- src/pointbase.cpp | 162 +++++++++++++++++++++++++++++++++++++++++++++- src/test.cpp | 22 ++++++- 2 files changed, 182 insertions(+), 2 deletions(-) diff --git a/src/pointbase.cpp b/src/pointbase.cpp index 4a7c3ca..fd7413b 100644 --- a/src/pointbase.cpp +++ b/src/pointbase.cpp @@ -41,6 +41,9 @@ class PointBase { vector toDoVector; //points yet to be searched for adjacent points std::map 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 @@ -63,6 +66,9 @@ class PointBase { Point2d newPoint = Point2d(coords["depthPos"]["x"].asDouble() , coords["depthPos"]["y"].asDouble()); pathMap[newPoint] = filePath; 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 stitchQueue; + stitchQueue.push_back(p); + points.erase(points.begin()); + + vector 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 <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); + } + */ + + } + + + } + + }; \ No newline at end of file diff --git a/src/test.cpp b/src/test.cpp index 17b9665..9ff4aca 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -39,10 +39,16 @@ int main(int argc, char** argv) //test pointbase load PointBase pb; + //pb.load("../data/"); + //120/2022-11-15_09-35-09 + //155/2022-11-15_07-18-56 + //2/2022-10-13_13-33-22 + //1/2022-10-13_11-50-12 + //pb.load("../1/2022-10-13_11-50-12/snapshots/"); pb.load("../data/"); //test print all point info - pb.printPoints(1); + pb.printPoints(0); /* test get path path: ../data/0000044.json; @@ -53,4 +59,18 @@ int main(int argc, char** argv) pb.showPointImg(); + /* + vector res = pb.getAdjacents(Point2d(75.1,3220.80)); + for (Point2d p :res) + { + cout << "x: " << p.x << std::endl; + cout << "y: " << p.y << std::endl; + } + */ + + //pb.stitchImgs(); + cout <<"IMG HEIGHT:" << pb.imgHeightDeg <<"\n"; + cout <<"IMG WIDTH DEG:" << pb.imgWidthDeg <<"\n"; + pb.cumdump(650,525); + } \ No newline at end of file