Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 494
rockinfresh Avatar asked Oct 14 '25 08:10

rockinfresh


2 Answers

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.

like image 57
deeptigp Avatar answered Oct 17 '25 18:10

deeptigp


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.

like image 41
avihayas Avatar answered Oct 17 '25 17:10

avihayas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!