I am getting the four corner of the image using this code
:
cv::Mat CVSquares::detectedSquaresInImage (cv::Mat image, float tol, int threshold, int levels, int acc)
{
vector<vector<Point> > squares;
if( image.empty() )
{
cout << "CVSquares.m: Couldn't load " << endl;
}
tolerance = tol;
thresh = threshold;
N = levels;
accuracy = acc;
findSquares(image, squares);
//drawSquares(image, squares);
// The largest of them probably represents the paper
vector<Point> largest_square;
find_largest_square(squares, largest_square);
drawSquares(image, largest_square);
// Print the x,y coordinates of the square
cout << "Point 1: " << largest_square[0] << endl;
cout << "Point 2: " << largest_square[1] << endl;
cout << "Point 3: " << largest_square[2] << endl;
cout << "Point 4: " << largest_square[3] << endl;
return image;
}
Its giving me four points but now I want to crop the image to that point. Can anyone please help me with this?
I have tried to use code from this answer
But its display error below.
duplicate symbol __Z9getCenterNSt3__16vectorIN2cv6Point_IiEENS_9allocatorIS3_EEEE in:
/Users/user/Library/Developer/Xcode/DerivedData/OpenCVSquares-gbnzjrefuxhjlchibreeqqdoaiqq/Build/Intermediates/OpenCVSquares.build/Debug-iphonesimulator/OpenCVSquares.build/Objects-normal/i386/UIImage+OpenCV.o
/Users/user/Library/Developer/Xcode/DerivedData/OpenCVSquares-gbnzjrefuxhjlchibreeqqdoaiqq/Build/Intermediates/OpenCVSquares.build/Debug-iphonesimulator/OpenCVSquares.build/Objects-normal/i386/CVSquares.o
duplicate symbol __Z25sortSquarePointsClockwiseNSt3__16vectorIN2cv6Point_IiEENS_9allocatorIS3_EEEE in:
/Users/user/Library/Developer/Xcode/DerivedData/OpenCVSquares-gbnzjrefuxhjlchibreeqqdoaiqq/Build/Intermediates/OpenCVSquares.build/Debug-iphonesimulator/OpenCVSquares.build/Objects-normal/i386/UIImage+OpenCV.o
/Users/user/Library/Developer/Xcode/DerivedData/OpenCVSquares-gbnzjrefuxhjlchibreeqqdoaiqq/Build/Intermediates/OpenCVSquares.build/Debug-iphonesimulator/OpenCVSquares.build/Objects-normal/i386/CVSquares.o
ld: 2 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)