Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. QR barcode decoder problem.

QR barcode decoder problem.

Scheduled Pinned Locked Moved C#
graphicshelp
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    S K Y
    wrote on last edited by
    #1

    my decoder cannot detect picture of webcam. i change the brightness and contrast. some time can detect but some times cannot. i know thats picture problem. now i edit the image but its useless. can i change webcam setting or do any changes to my code..here is my code....

    private void btnDecode_Click_1(object sender, EventArgs e)
    {
    try
    {

                DeviceManager manager = new DeviceManagerClass();
                Device d = null;
                foreach (DeviceInfo info in manager.DeviceInfos)
                {
                    d = info.Connect();
                    
                }
    
                Item item = d.ExecuteCommand(CommandID.wiaCommandTakePicture);
    
                foreach (string format in item.Formats)
                {
    
                    WIA.ImageFile imagefile = item.Transfer(format) as WIA.ImageFile;
                   // if (File.Exists("d:\\\\test.jpg"))
                    {
                       // picDecode.Image = null;
                       // File.Delete("d:\\\\test.jpg");
                    }
                   imagefile.SaveFile("d:\\\\4.jpg");
                    Bitmap image = new Bitmap("d:\\\\4.jpg");
                    Bitmap bm = new Bitmap(image, 200, 150);
    
                    System.Drawing.Bitmap TempBitmap = bm;
                    float brightness = 0.6f;
                    float constrast = 6f;
                    System.Drawing.Bitmap NewBitmap = new System.Drawing.Bitmap(TempBitmap.Width, TempBitmap.Height);
                    System.Drawing.Graphics NewGraphics = System.Drawing.Graphics.FromImage(NewBitmap);
                    float\[\]\[\] FloatColorMatrix ={
                    new float\[\] {constrast, 0, 0, 0, 0},
                    new float\[\] {0, constrast, 0, 0, 0},
                    new float\[\] {0, 0, constrast, 0, 0},
                    new float\[\] {0, 0, 0, constrast, 0},
                    new float\[\] {brightness, brightness, brightness, 1, 1}
                };
    
                    System.Drawing.Imaging.ColorMatrix NewColorMatrix = new System.Drawing.Imaging.ColorMatrix(FloatColorMatrix);
                    System.Drawing.Imaging.ImageAttributes Attributes = new System.Drawing.Imaging.ImageAttributes();
                    Attributes.SetColorMatrix(NewColorMatrix);
                    NewGraphics.DrawImage(TempBitmap, new System.Drawing.Rectangle(0, 0, TempBitmap.Width, TempBitmap.Height), 0, 0, TempBitmap.Width, TempBitmap.Height, System.Drawing.
    
    C 1 Reply Last reply
    0
    • S S K Y

      my decoder cannot detect picture of webcam. i change the brightness and contrast. some time can detect but some times cannot. i know thats picture problem. now i edit the image but its useless. can i change webcam setting or do any changes to my code..here is my code....

      private void btnDecode_Click_1(object sender, EventArgs e)
      {
      try
      {

                  DeviceManager manager = new DeviceManagerClass();
                  Device d = null;
                  foreach (DeviceInfo info in manager.DeviceInfos)
                  {
                      d = info.Connect();
                      
                  }
      
                  Item item = d.ExecuteCommand(CommandID.wiaCommandTakePicture);
      
                  foreach (string format in item.Formats)
                  {
      
                      WIA.ImageFile imagefile = item.Transfer(format) as WIA.ImageFile;
                     // if (File.Exists("d:\\\\test.jpg"))
                      {
                         // picDecode.Image = null;
                         // File.Delete("d:\\\\test.jpg");
                      }
                     imagefile.SaveFile("d:\\\\4.jpg");
                      Bitmap image = new Bitmap("d:\\\\4.jpg");
                      Bitmap bm = new Bitmap(image, 200, 150);
      
                      System.Drawing.Bitmap TempBitmap = bm;
                      float brightness = 0.6f;
                      float constrast = 6f;
                      System.Drawing.Bitmap NewBitmap = new System.Drawing.Bitmap(TempBitmap.Width, TempBitmap.Height);
                      System.Drawing.Graphics NewGraphics = System.Drawing.Graphics.FromImage(NewBitmap);
                      float\[\]\[\] FloatColorMatrix ={
                      new float\[\] {constrast, 0, 0, 0, 0},
                      new float\[\] {0, constrast, 0, 0, 0},
                      new float\[\] {0, 0, constrast, 0, 0},
                      new float\[\] {0, 0, 0, constrast, 0},
                      new float\[\] {brightness, brightness, brightness, 1, 1}
                  };
      
                      System.Drawing.Imaging.ColorMatrix NewColorMatrix = new System.Drawing.Imaging.ColorMatrix(FloatColorMatrix);
                      System.Drawing.Imaging.ImageAttributes Attributes = new System.Drawing.Imaging.ImageAttributes();
                      Attributes.SetColorMatrix(NewColorMatrix);
                      NewGraphics.DrawImage(TempBitmap, new System.Drawing.Rectangle(0, 0, TempBitmap.Width, TempBitmap.Height), 0, 0, TempBitmap.Width, TempBitmap.Height, System.Drawing.
      
      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Your problem is not going to change. A webcam photo of a barcode is never going to be a scanned image of a barcode, and you need a much more complex algorithm to read it. I would imagine you could do some sort of auto cleanup to make sure the lines are straight ( a deskew ) and that the brightness/contrast levels are good, but I don't think you will ever get 100% success.

      Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

      S 1 Reply Last reply
      0
      • C Christian Graus

        Your problem is not going to change. A webcam photo of a barcode is never going to be a scanned image of a barcode, and you need a much more complex algorithm to read it. I would imagine you could do some sort of auto cleanup to make sure the lines are straight ( a deskew ) and that the brightness/contrast levels are good, but I don't think you will ever get 100% success.

        Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

        S Offline
        S Offline
        S K Y
        wrote on last edited by
        #3

        ya but how they do the mobile barcode decoder...? i mean mobile phone application...how it works...?

        A S E L A

        C 1 Reply Last reply
        0
        • S S K Y

          ya but how they do the mobile barcode decoder...? i mean mobile phone application...how it works...?

          A S E L A

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          With a ton of image processing to find the barcode amongst the noise. That's what I keep telling you.

          Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

          S 1 Reply Last reply
          0
          • C Christian Graus

            With a ton of image processing to find the barcode amongst the noise. That's what I keep telling you.

            Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

            S Offline
            S Offline
            S K Y
            wrote on last edited by
            #5

            hi can just please tell me what kind of filters i should do for the omage.... noise filer and etc?

            A S E L A

            C 1 Reply Last reply
            0
            • S S K Y

              hi can just please tell me what kind of filters i should do for the omage.... noise filer and etc?

              A S E L A

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              I told you already. You need to deskew, you need to remove noise and you need to get your balance right

              Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

              M 1 Reply Last reply
              0
              • C Christian Graus

                I told you already. You need to deskew, you need to remove noise and you need to get your balance right

                Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

                M Offline
                M Offline
                Mycroft Holmes
                wrote on last edited by
                #7

                Christian Graus wrote:

                I told you already

                What's this he asked for the codz - why won't you snd the codz, advice will not get the job done he needs the codz......

                Never underestimate the power of human stupidity RAH

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups