Ask Your Question

Revision history [back]

I want to point out that what you are trying is not that straightforward as you might think. But hey, this are the steps to follow.

  1. Train a cascade classifier using train_cascade, or create an object classifier using the SVM functionality openCV provides. This way you retrieve an object model able to detect your object in given input ranges.
  2. Use model to detect objects, which returns you the bounding box, but not the exact boundaries.

http://docs.opencv.org/doc/user_guide/ug_traincascade.html?highlight=train%20cascade

This is problem 1, how will you segment the boundaries. You could try it with stuff like gradient detection (Sobel operators, Scharr operators) or the canny edge detector. Again this is all provided in OpenCV.

http://docs.opencv.org/doc/tutorials/imgproc/table_of_content_imgproc/table_of_content_imgproc.html#table-of-content-imgproc

Next you would need to define a binary image based on the edge with what is background and what is the object itself.

Extracting the object won't be to difficult, thats just cutting out the returning bounding box.

About the perspective transform, nothing I have done so far, so can't help you there. But this is probably enough to get you started.