Results 1 to 8 of 8

Thread: [RESOLVED] [2005] how to capture image and compare two images to find differences

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    18

    Resolved [RESOLVED] [2005] how to capture image and compare two images to find differences

    hi to all the expert
    can anybody care to provide me a full detail source code to capture image from webcam and store at picturebox1 as reference and compare the image from webcam which display on picturebox2.

    objective is to compare 2 picturebox is same or difference.

    i am using visual basic express 2005 and WIA.dll for webcam.



    Your generous help really save my live..
    Thanks in advance and had a wonderful day ahead
    Last edited by hobbyman; Jul 16th, 2006 at 09:34 AM.

  2. #2
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: [2005] how to capture image and compare two images to find differences

    Thats a pretty tall order

  3. #3
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Re: [2005] how to capture image and compare two images to find differences

    A fast way to see if the images are the same, is to save them uncompressed and then compare them bit-wise:
    VB Code:
    1. PictureBox1.Image.Save("Image1.bmp", Imaging.ImageFormat.Bmp)
    2. PictureBox2.Image.Save("Image2.bmp", Imaging.ImageFormat.Bmp)
    3.  
    4. If IO.File.ReadAllText("Image1.bmp").Equals(IO.File.ReadAllText("Image2.bmp")) Then
    5.     'They are the same
    6. End If
    To check which pixels are different, you can use this:
    (Sadly, this may be too slow for moving webcam pictures.)
    VB Code:
    1. Dim Image1 As Bitmap = PictureBox1.Image
    2. Dim Image2 As Bitmap = PictureBox2.Image
    3.  
    4. For iX As Int32 = 0 To Image1.Size.Height - 1
    5.     For iY As Int32 = 0 To Image2.Size.Width - 1
    6.         If Not Image1.GetPixel(iX, iY).ToArgb = Image2.GetPixel(iX, iY).ToArgb Then
    7.             'This pixel is a different colour.
    8.         End If
    9.     Next iY
    10. Next iX
    I don't know how to retrieve images from a webcam.
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    18

    Re: [2005] how to capture image and compare two images to find differences

    Hi to all the expert

    Do anyone know how to capture image and stored into the memory.
    I urgently need to capture 1 image as reference at picturebox1 and then compare the image with picturebox2 with the aid of webcam.
    to determine whether they are the same or diferent.
    Can anyone provide me the full detail of the source code using visual baisc express 2005.

    Your kindful help really save lives.
    Thanks in advance

  5. #5
    New Member
    Join Date
    May 2006
    Posts
    9

    Re: [2005] how to capture image and compare two images to find differences

    hmm well i know how to do this in vb6 but i'm not sure of how to capture the image from memory using managed code in vb.net I'll write up a sample application that will compair two images to see if they are the same.
    Also i've never captured an image from a webcam so that could provide the most difficulties I think.

    After you get that past its a rather simple process of compairing pixels.

  6. #6
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Re: [2005] how to capture image and compare two images to find differences

    There is a tutorial on capturing images from a webcam on MSDN's Coding4Fun available here.

    And I just gave you the source code for comparing images in the post above.

    Combine these two and you should be able to get your program working.
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    18

    Re: [2005] how to capture image and compare two images to find differences

    hi arsmakman

    i had try you source to compare 2 picturebox but they are not working
    Please Advice

    by the way thank for the link on the info of how to capture picture.

    thank you
    Last edited by hobbyman; Jul 19th, 2006 at 07:48 PM.

  8. #8
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Re: [2005] how to capture image and compare two images to find differences

    I made a stupid error in the code above, (which shows me once again: always test my own code) I switched width and height.

    To see why it did not work, I made a sample form. You can download it below. This work fine now.

    If you want to show WHICH pixels are different, you could load the differences into an Array of Drawing.Point's and then paint those pixels a different color in one of the pictureboxes.
    Attached Files Attached Files
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width