Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Find ROI functionalty very slow in VB.net

Hi, i have the vb 6.0 application which finds the ROI of the image which is very fast in vb 6.0 approximately takes 2 secs but after the converting the this vb application into VB.net (2008). that finding ROI functionality taking so much time (10 secs). given below the code.

 

VB 6.0

 

Do Until file.AtEndOfStream
        For i = 0 To CInt(sPoints) - 1
            sLine = file.ReadLine
            If Len(sLine) > 0 And InStr(sLine, vbTab) > 0 Then
                ' Split x,y and store it as IMAQ poly points
                asPoints() = Split(sLine, vbTab, 2)
                ' Add and intiallize the IMAQpoly points.
                imaqPoly.Points.Add.Initialize CInt(asPoints(0)), CInt(asPoints(1))
            Else
                Exit For
            End If
        Next i
        If imaqPoly.Points.Count > 2 Then
            ' Add polygon region to the IMAQwindow (ROI of the cell)
            imaqRegions.AddPolygon imaqPoly
            sPoints = file.ReadLine
        End If
        imaqPoly.Points.RemoveAll
    Loop

-----------------------------------------

 

VB.net code

 

Do Until file.AtEndOfStream
                For i = 0 To CShort(sPoints) - 1
                    sLine = file.ReadLine
                    If Len(sLine) > 0 And InStr(sLine, vbTab) > 0 Then
                        ' Split x,y and store it as IMAQ poly points
                        asPoints = Split(sLine, vbTab, 2)
                        'EventLog.WriteEntry("VSOM", "Final Start " & DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss.fff"))
                        p1 = CSng(asPoints(0))
                        p2 = CSng(asPoints(1))
                        'EventLog.WriteEntry("VSOM", "Final End " & DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss.fff"))

                        ' Add and intiallize the IMAQpoly points.
                        'EventLog.WriteEntry("VSOM", "sdsdsFinal start " & DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss.fff"))
                        imaqPoly.Points.Add.Initialize(p1, p2)
                        'Type Visual Basic 6 code here...

                        'EventLog.WriteEntry("VSOM", "sdsdsFinal end " & DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss.fff"))
                    Else
                        Exit For
                    End If
                Next i
                If imaqPoly.Points.Count > 2 Then
                    ' Add polygon region to the IMAQwindow (ROI of the cell)
                    imaqRegions.AddPolygon(imaqPoly)
                    sPoints = file.ReadLine
                End If
                imaqPoly.Points.RemoveAll()
            Loop

 

 ---------------------------------------------------------

i guess when i converting the point p1 & p2 from string to single.. it takes much time..

please help .. i am totally stuck there... 😞

0 Kudos
Message 1 of 1
(3,248 Views)