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.
The second sample that you linked to uses
unsafecode only to speed up access to pixel values in your bitmap. You can easily replace all that by using theBitmap‘sGetPixel()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
unsafecode goes, however, there is no reason to worry about using it. The only issue with theunsafetag 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.