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
  1. Home
  2. General Programming
  3. C#
  4. Showing webcam preview in picturebox Problem....

Showing webcam preview in picturebox Problem....

Scheduled Pinned Locked Moved C#
graphicshelpquestion
8 Posts 2 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

    i need to show a preview of my webcam in a picture box when i connected to the webcam. im using WIA. how can i show preview of my webcam in a picturebox. here is my code to connect to webcam...

    private void btnDecode_Click_1(object sender, EventArgs e)
    {
    try
    {
    Cursor.Current = Cursors.WaitCursor;
    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)
    {
    i++;
    WIA.ImageFile imagefile = item.Transfer(format) as WIA.ImageFile;

                    imagefile.SaveFile("d:\\\\" + i + ".jpg");
                    Bitmap image = new Bitmap("d:\\\\" + i + ".jpg");
                    Bitmap bm = new Bitmap(image, 200, 150);
                    Gray(bm);
    
    C 1 Reply Last reply
    0
    • S S K Y

      i need to show a preview of my webcam in a picture box when i connected to the webcam. im using WIA. how can i show preview of my webcam in a picturebox. here is my code to connect to webcam...

      private void btnDecode_Click_1(object sender, EventArgs e)
      {
      try
      {
      Cursor.Current = Cursors.WaitCursor;
      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)
      {
      i++;
      WIA.ImageFile imagefile = item.Transfer(format) as WIA.ImageFile;

                      imagefile.SaveFile("d:\\\\" + i + ".jpg");
                      Bitmap image = new Bitmap("d:\\\\" + i + ".jpg");
                      Bitmap bm = new Bitmap(image, 200, 150);
                      Gray(bm);
      
      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Well, what does it do, and not do ? I know how to do this, but not with WIA, so you'll need to tell us what's going wrong.

      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

        Well, what does it do, and not do ? I know how to do this, but not with WIA, so you'll need to tell us what's going wrong.

        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

        as my code show previous i take a picture of a QR barcode using my webcam. so i need to show a preview of my webcam befor take the picture of barcode. bcz that will be easy to user to show the barcode properly to the webcam. so i can get perfect image to process. that is the purpose.

        A S E L A

        C 1 Reply Last reply
        0
        • S S K Y

          as my code show previous i take a picture of a QR barcode using my webcam. so i need to show a preview of my webcam befor take the picture of barcode. bcz that will be easy to user to show the barcode properly to the webcam. so i can get perfect image to process. that is the purpose.

          A S E L A

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

          So, wait, all this code works, but you can't work out how to set the properties of a picturebox to show the image ? I thought this was a web app ?

          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

            So, wait, all this code works, but you can't work out how to set the properties of a picturebox to show the image ? I thought this was a web app ?

            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

            yaa untill now every thing work fine. can take image and as you told me earlierday doing image processing and filtering and convert to gray scale and adjust brightness and contrast. after process can deocde barcode to. some times got few errors. but now only problem is i have to take few images untill i get the fine image. bcz its very dificult to show QR properly without a preview of webcam. my plane to user a another picturebox to show the preview of webcam. sorry i forgot to tell you. this is not web app...just a windows app...

            A S E L A

            C 1 Reply Last reply
            0
            • S S K Y

              yaa untill now every thing work fine. can take image and as you told me earlierday doing image processing and filtering and convert to gray scale and adjust brightness and contrast. after process can deocde barcode to. some times got few errors. but now only problem is i have to take few images untill i get the fine image. bcz its very dificult to show QR properly without a preview of webcam. my plane to user a another picturebox to show the preview of webcam. sorry i forgot to tell you. this is not web app...just a windows app...

              A S E L A

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

              So, you have a picturebox, it has a property, called source or image. I forget which. Set it to point to your bitmap.

              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

                So, you have a picturebox, it has a property, called source or image. I forget which. Set it to point to your bitmap.

                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
                #7

                video Preview?

                A S E L A

                C 1 Reply Last reply
                0
                • S S K Y

                  video Preview?

                  A S E L A

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

                  what ? A picturebox shows pictures, and it does it in a pretty standard way. If you want to show video, then you need a timer to update the picture. A picturebox plainly is not a video control.

                  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

                  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