void Align::align(void) { std::cout << "Registering input images..." << std::endl; // Vector containing the shift values in x and y between images i and i+1 std::vector<std::vector<int>> consecutiveShifts(images->size()-1, std::vector<int>(2,0)); // Compute the offsets between one image and the next one in the list for (unsigned int i=0; i<images->size()-1; i++) { // Calculate the consecutive shifts in x and y between the current image and the next one std::cout << "Calculating shift between image " << i << " and image " << i+1 << "..." << std::endl; getExpShift((*images)[i], (*images)[i+1], shift_bits, consecutiveShifts[i]); #ifdef DEBUG std::cout << "Shift between image " << i << " and image " << i+1 << ":\n" << "\tx: " << consecutiveShifts[i][0] << "\n" << "\ty: " << consecutiveShifts[i][1] << std::endl; #endif } // end for all image pairs // Build a matrix of offsets from any image to any other one. updateRelativeShifts(consecutiveShifts); // Use this matrix to crop the images so that they // have the same size and are correctly registered cropImages(); };
pieces_t findPieces(const cv::Mat &inputImage) { std::cout << "Finding pieces of the document in the input image..." << std::endl; rectangles_t rectangles = findSquares(inputImage); rectangles = filterOutOverlappingRectangles(rectangles); pieces_t result = cropImages(inputImage, rectangles); return result; }