Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Particle Filter Error

The following code is given in the IMAQ Vision documentation for conducting a particle filter

Dim i As New CWIMAQImage
Dim data As New CWIMAQParticleFilterData
' Select particles that contain less than 100 pixels or
' more than 300 pixels and remove them.
data.Add
data(1).Parameter = cwimaqParticleArea
data(1).MinValue = 100
data(1).MaxValue = 300
data(1).Exclude = True
' Perform the particle filter operation and
' store the result in i
CWIMAQVision1.ParticleFilter CWIMAQViewer1.Image, i, data, True


However it generates the following error for me when doing this on a binary image.
Run time error ‘438’ - Object does not support this property or method which is generate
d by the line in the code
data(1).MinValue = 100
same is also true for the line
data(1).MaxValue = 300
but not
data(1).Exclude = True
Has the syntax been changed from that in the documentation? I want to be able to filter aprticles based upon size criteria
0 Kudos
Message 1 of 5
(3,537 Views)
Dear enthusiast,

I really don't believe the problem is with the binary image, and I know that the documentation is old.Please try the following code and let us know if it works for you:

Dim i As New CWIMAQImage
Dim data As New CWIMAQParticleFilterData
Dim myRange As CWIMAQRange
' Select particles that contain less than 100 pixels or
' more than 300 pixels and remove them.
data.Add
data(1).Parameter = cwimaqParticleArea myRange.Initialize 100, 300
data(1).Exclude = True
data(1).Range = myRange
' Perform the particle filter operation and
' store the result in i
CWIMAQVision1.ParticleFilter CWIMAQViewer1.Image, i, data, True


Regards,

Nestor Sanchez
Applications Engineer
National Instruments
Nestor
0 Kudos
Message 2 of 5
(3,537 Views)
Nestor,
Is there anywhere you can download new updated documentation for the Vision software?
0 Kudos
Message 3 of 5
(3,537 Views)
I Tried this code which also does not work! The line data(1).Parameter = cwimaqParticleArea myRange.Initialize, 100, 300 generates an error in VB "Expected End of Statement" after cwimaqParticleArea. So VB does not expect cwimaqParticleArea to have any parameters passed with it!
0 Kudos
Message 4 of 5
(3,537 Views)
Bashbam,

data(1).Parameter = cwimaqParticleArea
myRange.Initialize, 100, 300

This is the way it should be.

Nestor.
Nestor
0 Kudos
Message 5 of 5
(3,537 Views)