0

i would like to know how can i cut a jpg file using a coordinates i want to retrieve using artoolkit and opencv, see:

Blob Detection

i want to retrieve coordinates of the white sheet and then use those coordinates to cut a jpg file I'm took before. Find this but how can this help? How to slice/cut an image into pieces

Community
  • 1
  • 1
Ruben Veiga
  • 343
  • 3
  • 15

1 Answers1

1

If you already have the coordinates, you might want to deskew the image first:

http://nuigroup.com/?ACT=28&fid=27&aid=1892_H6eNAaign4Mrnn30Au8d

This post uses cv::warpPerspective() to achieve that effect.

The references above use the C++ interface of OpenCV, but I'm sure you are capable of converting between the two.

Second, cutting a particular area of an image is known as extracting a Region Of Interest (ROI). The general procedure is: create a CvRect to define your ROI and then call cvSetImageROI() followed by cvSaveImage() to save it on the disk.

This post shares C code to achieve this task.

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • uhm ok i will try to look at the post and see want i can do thanks again Karl – Ruben Veiga May 24 '12 at 15:00
  • Karl i was seeing the deskew image but its not what i want i just want to cut the image using the coordinates so i can use it as an opengl texture i think if i deskew the image i will not have the perfect match for my texture (its is just what i thing not sure of that) – Ruben Veiga May 24 '12 at 15:54
  • The last reference I shared provides the code, which among other things, sets a ROI and save it to the disk. – karlphillip May 24 '12 at 17:25