title: How to crop image using four corner point using openCV?
body: <p>I am getting the four corner of the image using this <code>code</code>:</p>
  
  <pre><code>cv::Mat CVSquares::detectedSquaresInImage (cv::Mat image, float tol, int threshold, int levels, int acc)
  {
      vector&lt;vector&lt;Point&gt; &gt; squares;
  
      if( image.empty() )
          {
          cout &lt;&lt; "CVSquares.m: Couldn't load " &lt;&lt; endl;
          }
  
      tolerance = tol;
      thresh = threshold;
      N = levels;
      accuracy = acc;
      findSquares(image, squares);
      //drawSquares(image, squares);
  
      // The largest of them probably represents the paper
      vector&lt;Point&gt; largest_square;
      find_largest_square(squares, largest_square);
      drawSquares(image, largest_square);
  
      // Print the x,y coordinates of the square
      cout &lt;&lt; "Point 1: " &lt;&lt; largest_square[0] &lt;&lt; endl;
      cout &lt;&lt; "Point 2: " &lt;&lt; largest_square[1] &lt;&lt; endl;
      cout &lt;&lt; "Point 3: " &lt;&lt; largest_square[2] &lt;&lt; endl;
      cout &lt;&lt; "Point 4: " &lt;&lt; largest_square[3] &lt;&lt; endl;
  
      return image;
  }
  </code></pre>
  
  <p>Its giving me four points but now I want to crop the image to that point. Can anyone please help me with this?</p>
  
  <p>I have tried to use code from <a href="https://stackoverflow.com/questions/13098073/adjust-corners-and-crop-the-image-opencv">this answer</a></p>
  
  <p>But its display error below.</p>
  
  <pre><code>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)
  </code></pre>