5

I am basically processing bar codes with an open source software. But the tool sometimes fails detecting no bar code at all.

So I want to myself check wether the image was really blank or it contains some sort of bar code.

My images are produced through scanning and they only contain a bar code (if they are not blank) and some noise images produced by the scanning. So my problem could be even down to checking if the image contains a significant amount of concentrated black pixels to differentiate it from white space images with noise.

I have checked this SO question, but the suggestion was to use "probabilistic Hough line transform" which I found a little bit an overkill for my situation.

I have also checked out this but it has unsafe code. I am looking for a managed C# solution.

Community
  • 1
  • 1
antew
  • 949
  • 8
  • 17

3 Answers3

0

What you are looking for is computer vision, sounds fancy but it is very simple now (5 years back it was not that popular ans somehow difficult) take a look at these articles:

http://www.codeproject.com/Articles/28465/Easy-to-use-Wrapper-DLL-for-Intel-s-OpenCV-Library

http://www.chinhdo.com/20080910/detect-blank-images/

Luiscencio
  • 3,855
  • 13
  • 43
  • 74
0

The second sample that you linked to uses unsafe code only to speed up access to pixel values in your bitmap. You can easily replace all that by using the Bitmap's GetPixel() method instead (the downside is that this will then be extremely slow, but it will probably still be fast enough for your purposes).

As far as the unsafe code goes, however, there is no reason to worry about using it. The only issue with the unsafe tag is that some users (depending on their permissions levels) may not be able to run the code, although I have never actually encountered this potential problem myself.

MusiGenesis
  • 74,184
  • 40
  • 190
  • 334
  • 1
    There is a midway between `GetPixel()` and `unsafe` pointer arithmetic code, and that is the `Marshal` class. See for example this answer: http://stackoverflow.com/a/1563170/860585 – Rotem Sep 11 '12 at 14:48
0

You could use this C# library OpenSURF and look at the value for the SURF feature descriptor vector. I am not sure if it is "safe"

d4v3y0rk
  • 345
  • 1
  • 9