[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
Re: [2005] how to capture image and compare two images to find differences
Thats a pretty tall order
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:
PictureBox1.Image.Save("Image1.bmp", Imaging.ImageFormat.Bmp)
PictureBox2.Image.Save("Image2.bmp", Imaging.ImageFormat.Bmp)
If IO.File.ReadAllText("Image1.bmp").Equals(IO.File.ReadAllText("Image2.bmp")) Then
'They are the same
End If
To check which pixels are different, you can use this:
(Sadly, this may be too slow for moving webcam pictures.)
VB Code:
Dim Image1 As Bitmap = PictureBox1.Image
Dim Image2 As Bitmap = PictureBox2.Image
For iX As Int32 = 0 To Image1.Size.Height - 1
For iY As Int32 = 0 To Image2.Size.Width - 1
If Not Image1.GetPixel(iX, iY).ToArgb = Image2.GetPixel(iX, iY).ToArgb Then
'This pixel is a different colour.
End If
Next iY
Next iX
I don't know how to retrieve images from a webcam.
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 :thumb:
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.
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.
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
1 Attachment(s)
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.