opencv matchShapes()

First you will need to get contours of shapes from image. For example use Canny() to find edges in images. Than use findContours() on image of edges to get contours.
Than you can use matchShapes() to find contour that is most similar to your model contour (among all contours extracted by findContours()).
【opencv matchShapes()】 Note that this approach is very fast comparing to other methods of object detection, but if you can't get single contour around your book you will not able to find it. matchShapes() compares single contour to single contour.

    推荐阅读