Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports OpenTK
- Imports OpenTK.Graphics
- Imports OpenTK.Graphics.OpenGL
- Imports System.Threading
- Imports Emgu.CV
- Imports Emgu.CV.Util
- Imports Emgu.CV.Structure
- Public Class Form1
- Dim filelocation() As String
- Dim framecount As Integer = 0
- Dim MaxNum As Integer = 100
- Dim objectcount As Integer
- Dim points(MaxNum) As List(Of Vector3)
- Dim border(MaxNum) As minmax
- 'Dim normals(MaxNum) As List(Of Vector3)
- Dim colors(MaxNum) As Drawing.Color
- Dim Gridpic As Bitmap = New Bitmap(640, 480)
- Dim Gridgfx As Drawing.Graphics = Drawing.Graphics.FromImage(Gridpic)
- Dim pointsset As Boolean = False
- 'GL
- Dim rotateX As Integer = 0
- Dim rotatey As Integer = 1
- Dim rotatez As Integer = 0
- Dim positionx As Integer = 0 '250
- Dim positiony As Integer = 0 '-250
- Dim Scalez As Decimal = 1
- Dim zpos As Integer = 0 '-100
- Dim mousecontrol As Boolean = False
- Dim mousestartrotate As Point
- Dim mousestartposition As Point
- Dim mousestartZpos As Integer
- Dim mousecontroltype As Integer = 0
- Dim tbar1 As Integer = 0
- Dim tbar2 As Integer = 1
- 'Grid
- Dim zdiff As Single
- Dim Zupper As Single
- Dim ZLower As Single
- Dim gridheight As Integer
- Dim gridwidth As Integer
- Dim DisplayPoints As Boolean = True
- Dim DisplayLines As Boolean = False
- 'File Import
- Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
- If pointsset = True Then 'Remove this stuff for multiple files
- Dim result As MsgBoxResult = MsgBox("Close Current Project?", MsgBoxStyle.OkCancel)
- If result = MsgBoxResult.Cancel Then
- Return
- End If
- End If
- OpenFileDialog1.ShowDialog()
- End Sub
- Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
- If pointsset = True Then 'Remove this stuff for multiple files
- points(0).Clear()
- objectcount = 0
- End If
- filelocation = OpenFileDialog1.FileNames
- For i2 = 0 To filelocation.Length - 1
- If System.IO.File.Exists(filelocation(i2)) = True Then
- Dim subz As String = filelocation(i2).Substring(filelocation(i2).Length - 3, 3)
- subz = subz.ToLower
- If subz = "stl" Then
- fileimportSTL(i2)
- End If
- If subz = "obj" Then
- fileimportOBJ(i2)
- End If
- End If
- Dim maxX, minX, maxY, minY, maxZ, minZ As Single
- maxX = -100000000
- maxY = -100000000
- maxZ = -100000000
- minX = 100000000
- minY = 100000000
- minZ = 100000000
- For i = 0 To points(objectcount - 1).Count - 1
- If points(objectcount - 1)(i).X < minX Then
- minX = points(objectcount - 1)(i).X
- End If
- If points(objectcount - 1)(i).X > maxX Then
- maxX = points(objectcount - 1)(i).X
- End If
- If points(objectcount - 1)(i).Y < minY Then
- minY = points(objectcount - 1)(i).Y
- End If
- If points(objectcount - 1)(i).Y > maxY Then
- maxY = points(objectcount - 1)(i).Y
- End If
- If points(objectcount - 1)(i).Z < minZ Then
- minZ = points(objectcount - 1)(i).Z
- End If
- If points(objectcount - 1)(i).Z > maxZ Then
- maxZ = points(objectcount - 1)(i).Z
- End If
- Next
- Dim tempminmax As minmax
- tempminmax.Xmax = maxX
- tempminmax.Xmin = minX
- tempminmax.Ymax = maxY
- tempminmax.Ymin = minY
- tempminmax.Zmax = maxZ
- tempminmax.Zmin = minZ
- border(objectcount - 1) = tempminmax
- Next
- GlControl1.Invalidate()
- End Sub
- Public Sub fileimportSTL(ByRef objectnum As Integer)
- Dim pointsstring() As Byte
- GC.Collect()
- pointsstring = System.IO.File.ReadAllBytes(filelocation(objectnum))
- GC.Collect()
- 'normals(objectcount) = New List(Of Vector3)
- points(objectcount) = New List(Of Vector3)
- colors(objectcount) = Color.Cyan
- Dim pointcount As UInt32 = BitConverter.ToUInt32(pointsstring, 80)
- Dim NX, NY, NZ, X1, X2, X3, Y1, Y2, Y3, Z1, Z2, Z3 As Single
- For i = 84 To pointsstring.Length - 51 Step 50
- 'NX = BitConverter.ToSingle(pointsstring, i + 0)
- 'NY = BitConverter.ToSingle(pointsstring, i + 4)
- 'NZ = BitConverter.ToSingle(pointsstring, i + 8)
- 'normals(objectcount).Add(New Vector3(NX, NY, NZ))
- X1 = BitConverter.ToSingle(pointsstring, i + 12)
- Y1 = BitConverter.ToSingle(pointsstring, i + 16)
- Z1 = BitConverter.ToSingle(pointsstring, i + 20)
- X2 = BitConverter.ToSingle(pointsstring, i + 24)
- Y2 = BitConverter.ToSingle(pointsstring, i + 28)
- Z2 = BitConverter.ToSingle(pointsstring, i + 32)
- X3 = BitConverter.ToSingle(pointsstring, i + 36)
- Y3 = BitConverter.ToSingle(pointsstring, i + 40)
- Z3 = BitConverter.ToSingle(pointsstring, i + 44)
- points(objectcount).Add(New Vector3(X1, Y1, Z1))
- points(objectcount).Add(New Vector3(X2, Y2, Z2))
- points(objectcount).Add(New Vector3(X3, Y3, Z3))
- Next
- objectcount = objectcount + 1
- pointsset = True
- End Sub
- Public Sub fileimportOBJ(ByRef objectnum As Integer)
- Dim pointsstring() As String
- GC.Collect()
- pointsstring = System.IO.File.ReadAllLines(filelocation(objectnum))
- GC.Collect()
- points(objectcount) = New List(Of Vector3)
- colors(objectcount) = Color.Cyan
- Dim X1, Y1, Z1 As Single
- Dim C As Color
- For i = 0 To pointsstring.Length - 1
- If pointsstring(i).Length > 2 Then
- If pointsstring(i)(0) = "v" And pointsstring(i)(1) = " " Then
- Dim tempstring = pointsstring(i)
- pointsstring(i) = pointsstring(i).Substring(pointsstring(i).IndexOf(" ") + 1)
- Dim XST As String = pointsstring(i).Substring(0, pointsstring(i).IndexOf(" "))
- pointsstring(i) = pointsstring(i).Substring(pointsstring(i).IndexOf(" ") + 1)
- Dim YST As String = pointsstring(i).Substring(0, pointsstring(i).IndexOf(" "))
- pointsstring(i) = pointsstring(i).Substring(pointsstring(i).IndexOf(" ") + 1)
- Dim tempint As Integer = pointsstring(i).IndexOf(" ")
- Dim ZST As String
- If tempint <> -1 Then
- ZST = pointsstring(i).Substring(0, pointsstring(i).IndexOf(" "))
- Else
- ZST = pointsstring(i)
- End If
- X1 = XST
- Y1 = YST
- Z1 = ZST
- End If
- End If
- points(objectcount).Add(New Vector3(X1, Y1, Z1))
- Next
- objectcount = objectcount + 1
- pointsset = True
- End Sub
- 'Grid Draw
- Public Sub GridDraw()
- If points(0) IsNot Nothing Then
- Dim drawpoints As List(Of Vector3) = New List(Of Vector3)
- For i = 0 To points(0).Count - 1
- If points(0)(i).Z < Zupper And points(0)(i).Z > ZLower Then
- drawpoints.Add(points(0)(i))
- End If
- Next
- Dim drawdots As List(Of Point) = New List(Of Point)
- Gridgfx.FillRectangle(Brushes.White, 0, 0, gridwidth, gridheight)
- For i = 0 To drawpoints.Count - 1
- Dim x As Single = ((drawpoints(i).X - border(0).Xmin) / (border(0).Xmax - border(0).Xmin)) * gridwidth
- Dim y As Single = ((drawpoints(i).Y - border(0).Ymin) / (border(0).Ymax - border(0).Ymin)) * gridheight
- y = 480 - y
- drawdots.Add(New Point(x, y))
- Next
- drawdots = drawdots.Distinct().ToList()
- For i = 0 To drawdots.Count - 1
- Gridgfx.FillRectangle(Brushes.Black, drawdots(i).X - 0, drawdots(i).Y - 0, 2, 2)
- Next
- If DisplayPoints = True Then
- PictureBox1.Image = Gridpic
- End If
- If DisplayLines = True Then
- Dim imagez = New Image(Of Gray, Byte)(Gridpic)
- Dim imagez2 As Image(Of Gray, Byte) = imagez.Canny(150, 60)
- Dim imagez3 As Image(Of Gray, Byte) = New Image(Of Gray, Byte)(gridwidth, gridheight)
- Dim RhoRes As Double = RhoResNMUD.Value
- Dim Threshold As Double = ThresholdNMUD.Value
- Dim MinLineWidth As Double = MinLineNMUD.Value
- Dim linegap As Integer = LineWidthNMUD.Value
- Dim ThetaRes As Double = Math.PI / 180
- Dim Linez()() As LineSegment2D = imagez2.HoughLinesBinary(RhoRes, ThetaRes, Threshold, MinLineWidth, linegap)
- If Linez(0).Length >= 0 Then
- For i = 0 To Linez(0).Length - 1
- imagez3.Draw(Linez(0)(i), New Gray(255), 2)
- Next
- End If
- PictureBox1.Image = imagez3.ToBitmap
- End If
- End If
- End Sub
- 'GL Load
- Private Sub GlControl1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles GlControl1.Load
- GL.ClearColor(Color.Black)
- GlControl1.Invalidate()
- End Sub
- 'GL mouse control
- Private Sub GlControl1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GlControl1.MouseDown
- mousecontrol = True
- If e.Button = MouseButtons.Right Then
- mousecontroltype = 2
- mousestartposition = New Point(MousePosition.X - positionx, MousePosition.Y - positiony)
- ElseIf e.Button = MouseButtons.Left Then
- mousestartrotate = New Point(MousePosition.X - rotatey, MousePosition.Y - rotateX)
- mousecontroltype = 1
- ElseIf e.Button = MouseButtons.Middle Then
- mousestartZpos = MousePosition.Y - zpos
- mousecontroltype = 3
- End If
- Timer1.Enabled = True
- End Sub
- Private Sub GlControl1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GlControl1.MouseMove
- If mousecontrol = True Then
- If mousecontroltype = 1 Then
- rotatey = MousePosition.X - mousestartrotate.X
- rotateX = MousePosition.Y - mousestartrotate.Y
- ElseIf mousecontroltype = 2 Then
- positionx = MousePosition.X - mousestartposition.X
- positiony = MousePosition.Y - mousestartposition.Y
- ElseIf mousecontroltype = 3 Then
- zpos = MousePosition.Y - mousestartZpos
- End If
- End If
- End Sub
- Private Sub GlControl1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GlControl1.MouseUp
- mousecontrol = False
- mousecontroltype = 0
- Timer1.Enabled = False
- GlControl1.Invalidate()
- End Sub
- Private Sub GlControl1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GlControl1.MouseWheel
- Scalez = Scalez + e.Delta / 240
- If Scalez <= 0 Then
- Scalez = 0.1
- End If
- GlControl1.Invalidate()
- End Sub
- 'Object Drawing
- Private Sub GlControl1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles GlControl1.Paint
- GL.Clear(ClearBufferMask.ColorBufferBit)
- GL.Clear(ClearBufferMask.DepthBufferBit)
- Dim perspective As Matrix4 = Matrix4.CreatePerspectiveFieldOfView(1.04, 4 / 3, 1, 10000)
- Dim lookat As Matrix4 = Matrix4.LookAt(200, 20, 0, 0, 0, 0, 0, 1, 0)
- GL.MatrixMode(MatrixMode.Projection)
- GL.LoadIdentity()
- GL.LoadMatrix(perspective)
- GL.MatrixMode(MatrixMode.Modelview)
- GL.LoadIdentity()
- GL.LoadMatrix(lookat)
- GL.Viewport(0, 0, GlControl1.Width, GlControl1.Height) 'Size of window
- GL.Rotate(-rotateX, 0, 0, 1)
- GL.Rotate(rotatey, 0, 1, 0)
- GL.Begin(BeginMode.LineLoop)
- GL.Color3(Color.Green)
- GL.Vertex3(50, 0, 0)
- GL.Color3(Color.White)
- GL.Vertex3(50, 0, -50)
- GL.Color3(Color.Red)
- GL.Vertex3(0, 0, -50)
- GL.Color3(Color.White)
- GL.Vertex3(-50, 0, -50)
- GL.Color3(Color.Blue)
- GL.Vertex3(-50, 0, 0)
- GL.Color3(Color.White)
- GL.Vertex3(-50, 0, 50)
- GL.Color3(Color.Yellow)
- GL.Vertex3(0, 0, 50)
- GL.Color3(Color.White)
- GL.Vertex3(50, 0, 50)
- GL.Color3(Color.Green)
- GL.Vertex3(50, 0, 0)
- GL.End()
- GL.Translate((zpos * Scalez), (-positiony * Scalez), (-positionx * Scalez))
- GL.Scale(Scalez, Scalez, Scalez)
- GL.Enable(EnableCap.DepthTest) 'Enable correct Z Drawings
- GL.DepthFunc(DepthFunction.Less) 'Enable correct Z Drawings
- GL.DepthMask(True)
- If pointsset = True Then
- GL.Color3(Color.LimeGreen)
- GL.Begin(BeginMode.LineLoop)
- GL.Vertex3(New Vector3(border(0).Xmax, border(0).Ymax, zdiff))
- GL.Vertex3(New Vector3(border(0).Xmin, border(0).Ymax, zdiff))
- GL.Vertex3(New Vector3(border(0).Xmin, border(0).Ymin, zdiff))
- GL.Vertex3(New Vector3(border(0).Xmax, border(0).Ymin, zdiff))
- GL.End()
- GL.Color3(Color.Blue)
- GL.Begin(BeginMode.LineLoop)
- GL.Vertex3(New Vector3(border(0).Xmax, border(0).Ymax, Zupper))
- GL.Vertex3(New Vector3(border(0).Xmin, border(0).Ymax, Zupper))
- GL.Vertex3(New Vector3(border(0).Xmin, border(0).Ymin, Zupper))
- GL.Vertex3(New Vector3(border(0).Xmax, border(0).Ymin, Zupper))
- GL.End()
- GL.Begin(BeginMode.LineLoop)
- GL.Vertex3(New Vector3(border(0).Xmax, border(0).Ymax, ZLower))
- GL.Vertex3(New Vector3(border(0).Xmin, border(0).Ymax, ZLower))
- GL.Vertex3(New Vector3(border(0).Xmin, border(0).Ymin, ZLower))
- GL.Vertex3(New Vector3(border(0).Xmax, border(0).Ymin, ZLower))
- GL.End()
- GL.Begin(BeginMode.Lines)
- GL.Vertex3(New Vector3(border(0).Xmax, border(0).Ymax, ZLower))
- GL.Vertex3(New Vector3(border(0).Xmax, border(0).Ymax, Zupper))
- GL.Vertex3(New Vector3(border(0).Xmin, border(0).Ymax, ZLower))
- GL.Vertex3(New Vector3(border(0).Xmin, border(0).Ymax, Zupper))
- GL.Vertex3(New Vector3(border(0).Xmin, border(0).Ymin, ZLower))
- GL.Vertex3(New Vector3(border(0).Xmin, border(0).Ymin, Zupper))
- GL.Vertex3(New Vector3(border(0).Xmax, border(0).Ymin, ZLower))
- GL.Vertex3(New Vector3(border(0).Xmax, border(0).Ymin, Zupper))
- GL.End()
- GL.Color3(Color.White)
- If DisplayPoints = True Then
- Dim vertz((points(0).Count) * 3) As Single
- For i = 0 To points(0).Count - 1
- vertz((i * 3) + 0) = points(0)(i).X
- vertz((i * 3) + 1) = points(0)(i).Y
- vertz((i * 3) + 2) = points(0)(i).Z
- Next
- GL.EnableClientState(ArrayCap.VertexArray)
- GL.VertexPointer(3, VertexPointerType.Float, 0, vertz)
- GL.DrawArrays(BeginMode.Points, 0, points(0).Count)
- GL.DisableClientState(ArrayCap.VertexArray)
- End If
- If DisplayLines = True Then
- Dim vertz((points(1).Count) * 3) As Single
- For i = 0 To points(1).Count - 1
- vertz((i * 3) + 0) = points(1)(i).X
- vertz((i * 3) + 1) = points(1)(i).Y
- vertz((i * 3) + 2) = points(1)(i).Z
- Next
- GL.EnableClientState(ArrayCap.VertexArray)
- GL.VertexPointer(3, VertexPointerType.Float, 0, vertz)
- GL.DrawArrays(BeginMode.Lines, 0, points(1).Count)
- GL.DisableClientState(ArrayCap.VertexArray)
- End If
- End If
- GraphicsContext.CurrentContext.VSync = True
- GlControl1.SwapBuffers()
- End Sub
- 'GL Invalidate Tick
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- GlControl1.Invalidate()
- End Sub
- Structure minmax
- Public Xmin As Single
- Public Xmax As Single
- Public Ymin As Single
- Public Ymax As Single
- Public Zmin As Single
- Public Zmax As Single
- End Structure
- 'TrackBar
- Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
- tbar1 = TrackBar1.Value
- zdiff = (((tbar1 / 100) * (border(0).Zmax - border(0).Zmin) / (border(0).Zmax - border(0).Zmin)) * (border(0).Zmax - border(0).Zmin)) + border(0).Zmin
- Zupper = (((tbar2 / 200) * (border(0).Zmax - border(0).Zmin) / (border(0).Zmax - border(0).Zmin)) * (border(0).Zmax - border(0).Zmin)) + zdiff
- ZLower = (((-tbar2 / 200) * (border(0).Zmax - border(0).Zmin) / (border(0).Zmax - border(0).Zmin)) * (border(0).Zmax - border(0).Zmin)) + zdiff
- GlControl1.Invalidate()
- GridDraw()
- End Sub
- Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
- tbar2 = TrackBar2.Value
- zdiff = (((tbar1 / 100) * (border(0).Zmax - border(0).Zmin) / (border(0).Zmax - border(0).Zmin)) * (border(0).Zmax - border(0).Zmin)) + border(0).Zmin
- Zupper = (((tbar2 / 200) * (border(0).Zmax - border(0).Zmin) / (border(0).Zmax - border(0).Zmin)) * (border(0).Zmax - border(0).Zmin)) + zdiff
- ZLower = (((-tbar2 / 200) * (border(0).Zmax - border(0).Zmin) / (border(0).Zmax - border(0).Zmin)) * (border(0).Zmax - border(0).Zmin)) + zdiff
- GlControl1.Invalidate()
- GridDraw()
- End Sub
- 'Form Load
- Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- gridheight = PictureBox1.Height
- gridwidth = PictureBox1.Width
- Gridgfx.FillRectangle(Brushes.White, 0, 0, gridwidth, gridheight)
- PictureBox1.Image = Gridpic
- End Sub
- 'Grid Buttons
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- DisplayPoints = True
- DisplayLines = False
- GridDraw()
- GlControl1.Invalidate()
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- DisplayLines = True
- DisplayPoints = False
- GridDraw()
- GlControl1.Invalidate()
- End Sub
- 'Numeric Up Down changes
- Private Sub RhoResNMUD_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RhoResNMUD.ValueChanged
- GridDraw()
- End Sub
- Private Sub ThresholdNMUD_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThresholdNMUD.ValueChanged
- GridDraw()
- End Sub
- Private Sub MinLineNMUD_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MinLineNMUD.ValueChanged
- GridDraw()
- End Sub
- Private Sub LineWidthNMUD_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LineWidthNMUD.ValueChanged
- GridDraw()
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- LineSearchTMR.Enabled = True
- tbar1 = 0
- tbar2 = 1
- points(1) = New List(Of Vector3)
- points(1).Clear()
- objectcount = objectcount + 1
- End Sub
- 'Line Search, almost same code as grid draw
- Private Sub LineSearchTMR_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LineSearchTMR.Tick
- zdiff = (((tbar1 / 100) * (border(0).Zmax - border(0).Zmin) / (border(0).Zmax - border(0).Zmin)) * (border(0).Zmax - border(0).Zmin)) + border(0).Zmin
- Zupper = (((tbar2 / 200) * (border(0).Zmax - border(0).Zmin) / (border(0).Zmax - border(0).Zmin)) * (border(0).Zmax - border(0).Zmin)) + zdiff
- ZLower = (((-tbar2 / 200) * (border(0).Zmax - border(0).Zmin) / (border(0).Zmax - border(0).Zmin)) * (border(0).Zmax - border(0).Zmin)) + zdiff
- Dim drawpoints As List(Of Vector3) = New List(Of Vector3)
- For i = 0 To points(0).Count - 1
- If points(0)(i).Z < Zupper And points(0)(i).Z > ZLower Then
- drawpoints.Add(points(0)(i))
- End If
- Next
- Dim drawdots As List(Of Point) = New List(Of Point)
- Gridgfx.FillRectangle(Brushes.White, 0, 0, gridwidth, gridheight)
- For i = 0 To drawpoints.Count - 1
- Dim x As Single = ((drawpoints(i).X - border(0).Xmin) / (border(0).Xmax - border(0).Xmin)) * gridwidth
- Dim y As Single = ((drawpoints(i).Y - border(0).Ymin) / (border(0).Ymax - border(0).Ymin)) * gridheight
- y = gridheight - y
- drawdots.Add(New Point(x, y))
- Next
- drawdots = drawdots.Distinct().ToList()
- For i = 0 To drawdots.Count - 1
- Gridgfx.FillRectangle(Brushes.Black, drawdots(i).X - 0, drawdots(i).Y - 0, 2, 2)
- Next
- Dim imagez = New Image(Of Gray, Byte)(Gridpic)
- Dim imagez2 As Image(Of Gray, Byte) = imagez.Canny(150, 60)
- Dim imagez3 As Image(Of Gray, Byte) = New Image(Of Gray, Byte)(gridwidth, gridheight)
- Dim RhoRes As Double = RhoResNMUD.Value
- Dim Threshold As Double = ThresholdNMUD.Value
- Dim MinLineWidth As Double = MinLineNMUD.Value
- Dim linegap As Integer = LineWidthNMUD.Value
- Dim ThetaRes As Double = Math.PI / 180
- Dim Linez()() As LineSegment2D = imagez2.HoughLinesBinary(RhoRes, ThetaRes, Threshold, MinLineWidth, linegap)
- If Linez(0).Length >= 0 Then
- For i = 0 To Linez(0).Length - 1
- imagez3.Draw(Linez(0)(i), New Gray(255), 2)
- Dim p1x As Single = ((Linez(0)(i).P1.X / gridwidth) * (border(0).Xmax - border(0).Xmin)) + border(0).Xmin
- Dim p1y As Single = (((gridheight - Linez(0)(i).P1.Y) / gridheight) * (border(0).Ymax - border(0).Ymin)) + border(0).Ymin
- Dim p2x As Single = ((Linez(0)(i).P2.X / gridwidth) * (border(0).Xmax - border(0).Xmin)) + border(0).Xmin
- Dim p2y As Single = (((gridheight - Linez(0)(i).P2.Y) / gridheight) * (border(0).Ymax - border(0).Ymin)) + border(0).Ymin
- points(1).Add(New Vector3(p1x, p1y, zdiff))
- points(1).Add(New Vector3(p2x, p2y, zdiff))
- Next
- End If
- PictureBox1.Image = imagez3.ToBitmap
- GlControl1.Invalidate()
- tbar1 = tbar1 + 1
- If tbar1 = 101 Then
- LineSearchTMR.Enabled = False
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement