diff --git a/src/pointbase.cpp b/src/pointbase.cpp index c488e79..b9e90f9 100644 --- a/src/pointbase.cpp +++ b/src/pointbase.cpp @@ -3,6 +3,8 @@ #include "opencv2/imgproc.hpp" #include "opencv2/imgcodecs.hpp" #include "opencv2/stitching.hpp" +#include +#include #include #include #include @@ -380,7 +382,7 @@ class PointBase { void cumdump(int imgWidth,int imgHeight) { - + std::vector edges; @@ -390,7 +392,10 @@ class PointBase { double minY=edges[2]; double maxY=edges[3]; - Mat img = Mat::zeros((int)(maxY*(imgHeight/imgHeightDeg))+imgHeight,(int)((360/imgWidthDeg)*imgWidth) + imgWidth,CV_8UC3); + int windowHeight = (int)(maxY*(imgHeight/imgHeightDeg))+imgHeight; + int windowWidth = (int)((360/imgWidthDeg)*imgWidth) + imgWidth; + + Mat img = Mat::zeros(windowHeight,windowWidth,CV_8UC3); rectangle(img,Point(3,3),Point(15,15),Scalar(128,128, 0),2,2,0); int imgIdx = 0; @@ -465,11 +470,12 @@ class PointBase { 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); + int qIdx = 0; for (Point2d coords: stitchQueue) { //log which images are in which result file @@ -492,13 +498,76 @@ class PointBase { cout < windowWidth) xWitdth = windowWidth - xLoc; + if (yLoc + yHeight > windowHeight) yHeight = windowHeight - yLoc; + + Mat roi; + roi = img(Rect(xLoc, yLoc, xWitdth, yHeight)); + /*imshow("roi",roi); + imwrite("temp.jpg", roi); + waitKey(0);*/ + + + cv::Ptr siftPtr = SIFT::create(); + std::vector keypointsROI, keypointsImg; + cv::Ptr siftExtrPtr; + cv::Mat descriptorsROI, descriptorsImg; + siftPtr->detect(roi, keypointsROI); + siftPtr->detect(imgSmall, keypointsImg); + + + + // Add results to image and save. + /* + cv::Mat output; + cv::drawKeypoints(imgSmall, keypointsImg, output); + imshow("sift_result.jpg", output); + waitKey(0);*/ + + cout<<" SIZE \n"<compute(roi, + keypointsROI, + descriptorsROI); + /*siftExtrPtr->compute(imgSmall, + keypointsImg, + descriptorsImg);*/ + + + cv::BFMatcher matcher(cv::NORM_L2,true); + std::vector matches; + + matcher.match(descriptorsROI,descriptorsImg,matches); + cv::Mat imageMatches; + + drawMatches(roi,keypointsROI,imgSmall,keypointsImg,matches,imageMatches); + cv::namedWindow("matches"); + cv::imshow("matches",imageMatches); + cv::waitKey(0); + + + //cout<