rockinfresh
rockinfresh

Reputation: 2106

Recognition and counting of books from side using OpenCV

Just wish to receive some ideas on I can solve this problem.

For a clearer picture, here are examples of some of the image that we are looking at:

enter image description here enter image description here enter image description here

I have tried looking into thresholding it, like otsu, blobbing it, etc. However, I am still unable to segment out the books and count them properly. Hardcover is easy of course, as the cover clearly separates the books, but when it comes to softcover, I have not been able to successfully count the number of books.

Does anybody have any suggestions on what I can do? Any help will be greatly appreciated. Thanks.

Upvotes: 4

Views: 2556

Answers (5)

user3791372
user3791372

Reputation: 4665

I would try a completely different approach; with paperbacks, the covers are medium-dark lines whilst the rest of the (assuming white pages) are fairly white and "bloomed", so I'd try to thicken up the dark edges to make them easy to detect, then that would give the edges akin to working with hardbacks which you say you've done.

I'd try something like an erosion to thicken up the edges. This would be a nice, fast operation.

Upvotes: 0

Bharat
Bharat

Reputation: 2179

There exist more sophisticated methods which are much better in contour detection and segmentation, you can have a look at them here, however it is quite slow, http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/resources.html

Once you get the ultrametric contour map, you can perform some computation on them to count the number of books

Upvotes: 1

avihayas
avihayas

Reputation: 281

I think that @audiohead's recommendation is good but you should be careful when applying the Hough transform for images that will have the library's stamp as it might confuse it with another book (You can see that the letters form some break-lines that will be detected by sobel).

Consider to apply first an edge preserving smoothing algorithm such as a Bilateral Filter. When tuned correctly (setting of the Kernels) it can avoid these such of problems.

A Different Solution That Might Work (But can be slow)

Here is a different approach that is based on pixel marking strategy.

a) Based on some very dark threshold, mark all black pixels as visited.

b) While there are unvisited pixels: Pick the next unvisited pixel and apply a region-growing algorithm http://en.wikipedia.org/wiki/Region_growing while marking its pixels with a unique number. At this stage you will need to analyse the geometric shape that this region is forming. A good criteria to detecting a book is that the region is creating some form of a rectangle where width >> height. This will detect a book and mark all its pixels to the unique number.

Once there are no more unvisited pixels, the number of unique numbers is the number of books you will have + For each pixel on your image you will now to which book does it belongs.

Upvotes: 2

Soumyajit
Soumyajit

Reputation: 445

Do you have to keep the books this way? If you can change the books to face back side to the camera then I think you can get more information about the different colors used by different books.The lines by Hough transform or edge detection will be more prominent this way.

Upvotes: 1

deeptigp
deeptigp

Reputation: 393

I ran a sobel edge detector and used Hough transform to detect lines on the last image and it seemed to be working okay for me. You can then link the edges on the output of the sobel edge detector and then count the number of horizontal lines. Or, you can do the same on the output of the lines detected using Hough.

You can further narrow down the area of interest by converting the image into a binary image. The outputs of all of these operators can be seen in following figure ( I couldn't upload an image so had to host it here) http://www.pictureshoster.com/files/v34h8hvvv1no4x13ng6c.jpg

Refer to http://www.mathworks.com/help/images/analyzing-images.html#f11-12512 for some more useful examples on how to do edge, line and corner detection.

Hope this helps.

Upvotes: 2

Related Questions