05-31-2007 08:13 PM
06-01-2007 02:05 PM
Hello rebecs,
Would it be possible for you to post your project to the forum, so we can take a look at it? I would like to run the code you are using to see if I can duplicate the problem. Thank you.
Regards,
Jasper S
06-04-2007 08:09 PM
Dim ViewRect As New NationalInstruments.CWIMAQControls.CWIMAQRegions
Dim ColInfo As New NationalInstruments.CWIMAQControls.CWIMAQColorInformation
Dim Scores As Object
Dim sid As System.UInt32 Dim errorCode As Integer Public IMAQVision As NationalInstruments.CWIMAQControls.AxCWIMAQVision Dim myImage As NationalInstruments.CWIMAQControls.CWIMAQImage Dim BufferNumber As Integer Private WithEvents t1 As System.Timers.Timer ' A creatable COM class must have a Public Sub New() ' with no parameters, otherwise, the class will not be ' registered in the COM registry and cannot be created ' via CreateObject. Public Sub New() MyBase.New()IMAQVision =
New NationalInstruments.CWIMAQControls.AxCWIMAQVisionIMAQVision.CreateControl()
'image initializationmyImage =
New NationalInstruments.CWIMAQControls.CWIMAQImagemyImage.Type = NationalInstruments.CWIMAQControls.CWIMAQImageTypes.cwimaqImageTypeRGB32
'timer initializationt1 =
New System.Timers.Timer(250)errorCode = CWIMAQ1394.CameraOpen2("cam0", CWIMAQ1394.CameraMode.IMG1394_CAMERA_MODE_CONTROLLER, sid)
If (errorCode <> CWIMAQ1394.ErrorCodes.IMG1394_ERR_GOOD) ThenConsole.WriteLine(" camera error!!")
GoTo ErrorHandler End Ift1.Enabled =
TrueerrorCode = CWIMAQ1394.SetupGrabCW(sid)
If (errorCode <> CWIMAQ1394.ErrorCodes.IMG1394_ERR_GOOD) ThenConsole.WriteLine(" grab error!!")
GoTo ErrorHandler End IfErrorHandler:
If (errorCode <> CWIMAQ1394.ErrorCodes.IMG1394_ERR_GOOD) Then End If End SubPublic Function GetLedColor() As Integer Dim roi As New CWIMAQRegions Dim roiRect As New CWIMAQRectangle
System.Threading.Thread.Sleep(250)
roiRect.Initialize(111, 54, 7, 15)
ViewRect.AddRectangle(roiRect)
IMAQVision.LearnColor(myImage, ColInfo, ViewRect)
System.Threading.Thread.Sleep(250)
IMAQVision.MatchColor(myImage, ColInfo, Scores, ViewRect)
IMAQVision.Dispose()
Return Scores(0) End FunctionPublic Sub TimerFired(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles t1.Elapsed
errorCode = CWIMAQ1394.Grab2CW(sid, 1, BufferNumber, myImage)
If (errorCode <> CWIMAQ1394.ErrorCodes.IMG1394_ERR_GOOD) ThenConsole.WriteLine("timer error")
t1.Enabled =
False End If End Sub
End
Classi am calling this library from a tcl script,using DOS(i mean i run the tcl script from DOS command prompt)..and it is supposed to return the score of the color matching function to the calling program.
for now,it is returning the score..but it is taking some time..as for the first time it is called,it takes forever.. when i posted this question in one of the forums earlier, someone suggested that maybe there is some delay needed for marshaling between .NET and COM...that is from the .NET/COM perspective..wat about the NI perspective?does any of the NI function have an inherent delay?or is this purely dependent on the machine im using?
thanks so much...
06-06-2007 06:17 PM
06-07-2007 03:20 AM
hello jasper,
thank u so much for ur reply..well,since the delay is expected,i guess i have to make do with it...at least my application works.
06-21-2010 11:22 AM
To speed Up your process, you can change your architecture:
- create a Windows Service which connects permanently the camera and IMAQ. Some kind of "out of process" COM executable
- create a small EXE that will exchange small information with the COM server.
That architecture will be VERY fast : you won't have to load all the DLLs each time because they will be already loaded and running !