Results 1 to 30 of 30

Thread: Comparing Images using Icam

Hybrid View

  1. #1
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: Comparing Images using Icam

    How about

    If not BitmapA.GetPixel(x, y) = BitmapB.GetPixel(x, y) then

    instead? equals is in the list of operators for type color in the help files..

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    24

    Re: Comparing Images using Icam

    Quote Originally Posted by conipto
    How about

    If not BitmapA.GetPixel(x, y) = BitmapB.GetPixel(x, y) then

    instead? equals is in the list of operators for type color in the help files..

    Bill
    it doesn't work too..it gives out the same error...

    here is the code from the class

    Private Sub cmdViewStill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdViewStill.Click
    If myCam.iRunning Then
    Dim a As FrmImage
    a = New FrmImage

    a.picImage.Image = myCam.copyFrame(Me.picOutput, New RectangleF(0, 0, _
    Me.picOutput.Width, Me.picOutput.Height))

    SomethingMoved()
    Else
    MessageBox.Show("Camera Is Not Running!")
    End If
    End Sub
    Public Function SomethingMoved(ByVal BitmapA As Bitmap, ByVal BitmapB As Bitmap) As Boolean

    Dim x As Integer = 0
    Dim y As Integer = 0
    Dim ChangedPixelCount As Integer = 0

    'assume both images are the same size
    For y = 2 To BitmapA.Height Step 5
    For x = 2 To BitmapA.Width Step 5
    If BitmapA.GetPixel(x, y) = BitmapB.GetPixel(x, y) Then
    ChangedPixelCount += 1
    End If
    Next x
    Next y

    If ChangedPixelCount >= 5 Then
    'yes, motion detected
    Return True
    Else
    'nope.
    Return False
    End If

    End Function


    now how do i save 2 image and compare pixels? the operators "=" and "<>" doesn't work at all...or is there a way to convert bitmap to integer so that i can use the operators?
    Last edited by nightkids31; Jul 3rd, 2005 at 02:18 AM.

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