reading a barcode with a webcam

前端 未结 1 1101
广开言路
广开言路 2021-02-06 15:27

Hey,
I\'m trying to read a EAN-13 barcode from my webcam.
I already wrote a class to do that work.
I\'m taking a picture from my webcam, trimming it to show ONLY the

相关标签:
1条回答
  • 2021-02-06 15:41

    I see two problems:

    1) You only scan the top most pixel row of your image (see the second parameter of GetPixel). Your barcode is probably in the middle of the image and not at the top.

    Color c = bb.GetPixel((int)Math.Round(i,0), 0);
    

    2) Instead of the green component, you take the alpha component to convert the colored pixel into a binary value. Since the alpha component is probably always 255, you always get 0 unless you have a very dark pixel.

    if (c.A + c.B + c.R > 128 * 3)
    
    0 讨论(0)
提交回复
热议问题