VERSION 5.00 Begin VB.Form frmMain Caption = "Dual Image" ClientHeight = 11160 ClientLeft = 60 ClientTop = 345 ClientWidth = 10800 LinkTopic = "Form1" ScaleHeight = 744 ScaleMode = 3 'Pixel ScaleWidth = 720 StartUpPosition = 3 'Windows Default Begin VB.Frame Frame2 Caption = "Calculations" Height = 2775 Left = 0 TabIndex = 6 Top = 8340 Width = 9915 Begin VB.TextBox txtDistDE Height = 255 Left = 6540 TabIndex = 74 Text = "-1" Top = 1800 Width = 795 End Begin VB.TextBox txtDistCE Height = 255 Left = 6540 TabIndex = 73 Text = "-1" Top = 2040 Width = 795 End Begin VB.TextBox txtAngleD Height = 255 Left = 6540 TabIndex = 71 Text = "-1" Top = 780 Width = 795 End Begin VB.TextBox txtAngleB Height = 255 Left = 6540 TabIndex = 69 Text = "-1" Top = 540 Width = 795 End Begin VB.TextBox txtAngleA Height = 255 Left = 6540 TabIndex = 67 Text = "-1" Top = 300 Width = 795 End Begin VB.TextBox txtDistCD Height = 255 Left = 6540 TabIndex = 65 Text = "-1" Top = 1560 Width = 795 End Begin VB.TextBox txtDistAD Height = 255 Left = 6540 TabIndex = 63 Text = "-1" Top = 1320 Width = 795 End Begin VB.TextBox txtDistAC Height = 255 Left = 6540 TabIndex = 61 Text = "-1" Top = 1080 Width = 795 End Begin VB.CommandButton cmdStepR Caption = "Step" Height = 255 Left = 1740 TabIndex = 38 Top = 1740 Width = 795 End Begin VB.CommandButton cmdDoFrameR Caption = "Frame" Height = 255 Left = 1740 TabIndex = 37 Top = 2040 Width = 795 End Begin VB.CommandButton cmdDoFrameL Caption = "Frame" Height = 255 Left = 900 TabIndex = 36 Top = 2040 Width = 795 End Begin VB.TextBox txtMaxDistance Height = 315 Left = 2460 TabIndex = 33 Text = "20" Top = 2340 Width = 555 End Begin VB.TextBox txtLScanD Height = 255 Left = 900 TabIndex = 31 Text = "-1" Top = 900 Width = 795 End Begin VB.TextBox txtRScanD Height = 255 Left = 1740 TabIndex = 30 Text = "-1" Top = 900 Width = 795 End Begin VB.CommandButton cmdCenterL Caption = "Reset" Height = 255 Left = 900 TabIndex = 29 Top = 2340 Width = 795 End Begin VB.CommandButton cmdStepL Caption = "Step" Height = 255 Left = 900 TabIndex = 28 Top = 1740 Width = 795 End Begin VB.TextBox txtDScanPitch Height = 255 Left = 2580 TabIndex = 25 Text = "-1" Top = 1440 Width = 795 End Begin VB.TextBox txtDScanYaw Height = 255 Left = 2580 TabIndex = 24 Text = "-1" Top = 1200 Width = 795 End Begin VB.TextBox txtDScanY Height = 255 Left = 2580 TabIndex = 23 Text = "-1" Top = 660 Width = 795 End Begin VB.TextBox txtDScanX Height = 255 Left = 2580 TabIndex = 22 Text = "-1" Top = 420 Width = 795 End Begin VB.TextBox txtRScanPitch Height = 255 Left = 1740 TabIndex = 20 Text = "-1" Top = 1440 Width = 795 End Begin VB.TextBox txtRScanYaw Height = 255 Left = 1740 TabIndex = 19 Text = "-1" Top = 1200 Width = 795 End Begin VB.TextBox txtRScanY Height = 255 Left = 1740 TabIndex = 18 Text = "-1" Top = 660 Width = 795 End Begin VB.TextBox txtRScanX Height = 255 Left = 1740 TabIndex = 17 Text = "-1" Top = 420 Width = 795 End Begin VB.TextBox txtLScanPitch Height = 255 Left = 900 TabIndex = 15 Text = "-1" Top = 1440 Width = 795 End Begin VB.TextBox txtLScanYaw Height = 255 Left = 900 TabIndex = 14 Text = "-1" Top = 1200 Width = 795 End Begin VB.TextBox txtLScanY Height = 255 Left = 900 TabIndex = 13 Text = "-1" Top = 660 Width = 795 End Begin VB.TextBox txtLScanX Height = 255 Left = 900 TabIndex = 12 Text = "-1" Top = 420 Width = 795 End Begin VB.Label Label37 Caption = "Dist DE" Height = 195 Left = 5940 TabIndex = 76 Top = 1800 Width = 615 End Begin VB.Label Label36 Caption = "Dist CE" Height = 195 Left = 5940 TabIndex = 75 Top = 2040 Width = 615 End Begin VB.Label Label35 Caption = "Angle D" Height = 195 Left = 5940 TabIndex = 72 Top = 780 Width = 615 End Begin VB.Label Label34 Caption = "Angle B" Height = 195 Left = 5940 TabIndex = 70 Top = 540 Width = 615 End Begin VB.Label Label33 Caption = "Angle A" Height = 195 Left = 5940 TabIndex = 68 Top = 300 Width = 615 End Begin VB.Line Line15 BorderStyle = 3 'Dot X1 = 5160 X2 = 5160 Y1 = 2220 Y2 = 300 End Begin VB.Label Label32 Caption = "Dist CD" Height = 195 Left = 5940 TabIndex = 66 Top = 1560 Width = 615 End Begin VB.Label Label31 Caption = "Dist AD" Height = 195 Left = 5940 TabIndex = 64 Top = 1320 Width = 615 End Begin VB.Label Label30 Caption = "Dist AC" Height = 195 Left = 5940 TabIndex = 62 Top = 1080 Width = 615 End Begin VB.Shape Shape4 FillColor = &H000000FF& FillStyle = 0 'Solid Height = 135 Left = 9450 Shape = 3 'Circle Top = 660 Width = 135 End Begin VB.Line Line14 BorderStyle = 3 'Dot X1 = 9540 X2 = 9540 Y1 = 720 Y2 = 1020 End Begin VB.Label Label27 Alignment = 2 'Center BackStyle = 0 'Transparent Caption = "E" ForeColor = &H00000000& Height = 195 Left = 9420 TabIndex = 45 Top = 1080 Width = 255 End Begin VB.Line Line10 BorderColor = &H000000FF& X1 = 8220 X2 = 9840 Y1 = 1020 Y2 = 660 End Begin VB.Shape Shape1 FillColor = &H000000FF& FillStyle = 0 'Solid Height = 135 Left = 4560 Shape = 3 'Circle Top = 540 Width = 135 End Begin VB.Label Label24 Alignment = 2 'Center BackStyle = 0 'Transparent Caption = "D" ForeColor = &H00FF0000& Height = 195 Left = 4500 TabIndex = 44 Top = 2220 Width = 255 End Begin VB.Line Line13 BorderColor = &H00FF0000& X1 = 4620 X2 = 4620 Y1 = 600 Y2 = 2220 End Begin VB.Line Line12 BorderStyle = 3 'Dot X1 = 8220 X2 = 9780 Y1 = 1020 Y2 = 1020 End Begin VB.Label Label23 Alignment = 2 'Center BackStyle = 0 'Transparent Caption = "D" ForeColor = &H00FF0000& Height = 195 Left = 7980 TabIndex = 43 Top = 900 Width = 255 End Begin VB.Line Line11 BorderStyle = 3 'Dot X1 = 4320 X2 = 4320 Y1 = 2220 Y2 = 300 End Begin VB.Label Label22 Alignment = 2 'Center BackStyle = 0 'Transparent Caption = "C" ForeColor = &H000000FF& Height = 195 Left = 9360 TabIndex = 42 Top = 480 Width = 255 End Begin VB.Shape Shape6 FillColor = &H00FFFFFF& FillStyle = 0 'Solid Height = 1635 Left = 9750 Top = 180 Width = 75 End Begin VB.Line Line9 BorderColor = &H0000FFFF& X1 = 9780 X2 = 8190 Y1 = 1800 Y2 = 1020 End Begin VB.Line Line8 BorderColor = &H0000FFFF& X1 = 8220 X2 = 9780 Y1 = 1020 Y2 = 180 End Begin VB.Label Label18 BackStyle = 0 'Transparent Caption = "C" ForeColor = &H000000FF& Height = 195 Left = 4740 TabIndex = 41 Top = 480 Width = 255 End Begin VB.Line Line6 BorderColor = &H000000FF& X1 = 4320 X2 = 4680 Y1 = 2220 Y2 = 240 End Begin VB.Shape Shape2 FillColor = &H00FFFFFF& FillStyle = 0 'Solid Height = 75 Left = 3510 Top = 240 Width = 1635 End Begin VB.Line Line7 BorderColor = &H000000C0& X1 = 5160 X2 = 4500 Y1 = 2220 Y2 = 180 End Begin VB.Shape Shape3 FillColor = &H00FFFFFF& FillStyle = 0 'Solid Height = 75 Left = 4320 Top = 180 Width = 1635 End Begin VB.Line Line5 BorderStyle = 3 'Dot X1 = 4320 X2 = 5160 Y1 = 2220 Y2 = 2220 End Begin VB.Label Label3 BackStyle = 0 'Transparent Caption = "B" ForeColor = &H00004040& Height = 195 Left = 5220 TabIndex = 40 Top = 2100 Width = 255 End Begin VB.Label Label1 Alignment = 2 'Center BackStyle = 0 'Transparent Caption = "A" ForeColor = &H00004040& Height = 195 Left = 4080 TabIndex = 39 Top = 2100 Width = 255 End Begin VB.Line Line4 BorderColor = &H0000C0C0& X1 = 5940 X2 = 5160 Y1 = 255 Y2 = 2220 End Begin VB.Line Line3 BorderColor = &H0000C0C0& X1 = 4320 X2 = 5160 Y1 = 240 Y2 = 2220 End Begin VB.Line Line2 BorderColor = &H0000FFFF& X1 = 5160 X2 = 4320 Y1 = 300 Y2 = 2220 End Begin VB.Line Line1 BorderColor = &H0000FFFF& X1 = 3510 X2 = 4335 Y1 = 300 Y2 = 2235 End Begin VB.Label Label17 Caption = "Max Dist" Height = 195 Left = 1740 TabIndex = 35 Top = 2400 Width = 735 End Begin VB.Label Label16 Caption = "px" Height = 195 Left = 3060 TabIndex = 34 Top = 2400 Width = 255 End Begin VB.Label Label15 Caption = "Scan D" Height = 195 Left = 60 TabIndex = 32 Top = 900 Width = 675 End Begin VB.Label Label14 Alignment = 2 'Center Caption = "Difference" Height = 195 Left = 2580 TabIndex = 21 Top = 180 Width = 795 End Begin VB.Label Label8 Alignment = 2 'Center Caption = "Right" Height = 195 Left = 1740 TabIndex = 16 Top = 180 Width = 795 End Begin VB.Label Label12 Caption = "Scan Yaw" Height = 195 Left = 60 TabIndex = 11 Top = 1200 Width = 855 End Begin VB.Label Label11 Caption = "Scan Pitch" Height = 195 Left = 60 TabIndex = 10 Top = 1440 Width = 915 End Begin VB.Label Label10 Caption = "Scan Y" Height = 195 Left = 60 TabIndex = 9 Top = 660 Width = 675 End Begin VB.Label Label9 Caption = "Scan X" Height = 195 Left = 60 TabIndex = 8 Top = 420 Width = 615 End Begin VB.Label Label7 Alignment = 2 'Center Caption = "Left" Height = 195 Left = 900 TabIndex = 7 Top = 180 Width = 795 End End Begin VB.Frame Frame1 Caption = "Captured Images" Height = 3975 Left = 0 TabIndex = 3 Top = 4320 Width = 9915 Begin VB.PictureBox pctRight Height = 3615 Left = 4980 Picture = "frmDualImages.frx":0000 ScaleHeight = 237 ScaleMode = 3 'Pixel ScaleWidth = 317 TabIndex = 5 Top = 240 Width = 4815 Begin VB.Line lineRCross1 BorderColor = &H00800000& X1 = 84 X2 = 244 Y1 = 68 Y2 = 184 End Begin VB.Line lineRCross2 BorderColor = &H00800000& X1 = 64 X2 = 244 Y1 = 164 Y2 = 52 End Begin VB.Shape shpScanR BorderColor = &H00FF0000& Height = 150 Left = 300 Top = 420 Width = 150 End End Begin VB.PictureBox pctLeft Height = 3615 Left = 120 Picture = "frmDualImages.frx":38444 ScaleHeight = 237 ScaleMode = 3 'Pixel ScaleWidth = 317 TabIndex = 4 Top = 240 Width = 4815 Begin VB.Line lineLCross2 BorderColor = &H00800000& X1 = 84 X2 = 264 Y1 = 168 Y2 = 56 End Begin VB.Line lineLCross1 BorderColor = &H00800000& X1 = 104 X2 = 264 Y1 = 72 Y2 = 188 End Begin VB.Shape shpScanL BorderColor = &H00FF0000& Height = 150 Left = 1020 Top = 540 Width = 150 End End End Begin VB.Frame frmMain3 Caption = "Cameras" Height = 4275 Left = 0 TabIndex = 0 Top = 0 Width = 9915 Begin VB.Frame Frame3 Caption = "Camera Settings" Height = 1695 Left = 3840 TabIndex = 46 Top = 2520 Width = 2175 Begin VB.TextBox txtDistAB Height = 285 Left = 1260 TabIndex = 58 TabStop = 0 'False Text = "24.5" Top = 1320 Width = 615 End Begin VB.TextBox txtRCamPitch Height = 285 Left = 1440 TabIndex = 54 TabStop = 0 'False Text = "16.5" Top = 780 Width = 495 End Begin VB.TextBox txtRCamYaw Height = 285 Left = 900 TabIndex = 53 TabStop = 0 'False Text = "22.0" Top = 780 Width = 495 End Begin VB.TextBox txtLCamPitch Height = 285 Left = 1440 TabIndex = 48 TabStop = 0 'False Text = "16.5" Top = 480 Width = 495 End Begin VB.TextBox txtLCamYaw Height = 285 Left = 900 TabIndex = 47 TabStop = 0 'False Text = "22.0" Top = 480 Width = 495 End Begin VB.Label Label20 BackStyle = 0 'Transparent Caption = "Dist Between" Height = 195 Left = 180 TabIndex = 60 Top = 1380 Width = 1095 End Begin VB.Label Label21 BackStyle = 0 'Transparent Caption = """" Height = 195 Left = 1920 TabIndex = 59 Top = 1320 Width = 255 End Begin VB.Label Label29 BackStyle = 0 'Transparent Caption = "* 0 = center of cam" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = -1 'True Strikethrough = 0 'False EndProperty Height = 195 Left = 480 TabIndex = 57 Top = 1080 Width = 1575 End Begin VB.Label Label19 BackStyle = 0 'Transparent Caption = "o" Height = 195 Left = 1920 TabIndex = 56 Top = 720 Width = 255 End Begin VB.Label Label6 BackStyle = 0 'Transparent Caption = "Right FOV" Height = 195 Left = 60 TabIndex = 55 Top = 840 Width = 795 End Begin VB.Label Label28 Alignment = 2 'Center BackStyle = 0 'Transparent Caption = "Pitch" Height = 195 Left = 1440 TabIndex = 52 Top = 240 Width = 495 End Begin VB.Label Label26 BackStyle = 0 'Transparent Caption = "o" Height = 195 Left = 1920 TabIndex = 51 Top = 420 Width = 255 End Begin VB.Label Label25 Alignment = 2 'Center BackStyle = 0 'Transparent Caption = "Yaw" Height = 195 Left = 900 TabIndex = 50 Top = 240 Width = 495 End Begin VB.Label Label4 BackStyle = 0 'Transparent Caption = "Left FOV" Height = 195 Left = 60 TabIndex = 49 Top = 540 Width = 795 End End Begin VB.ComboBox cmbDeviceR Height = 315 Left = 5040 Style = 2 'Dropdown List TabIndex = 27 Top = 540 Width = 4635 End Begin VB.ComboBox cmbDeviceL Height = 315 Left = 180 Style = 2 'Dropdown List TabIndex = 26 Top = 540 Width = 4755 End Begin VB.Label Label5 Caption = "Right Camera" Height = 255 Left = 4980 TabIndex = 2 Top = 240 Width = 1335 End Begin VB.Label Label2 Caption = "Left Camera" Height = 255 Left = 180 TabIndex = 1 Top = 240 Width = 1335 End End End Attribute VB_Name = "frmMain" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Type position X As Integer Y As Integer dist As Integer ' distance from center End Type Private Type pixel r As Integer g As Integer b As Integer End Type Const red_pct = 0.5 ' 0.7=30% more red than B and G Dim LScan As position, RScan As position Dim paL As BCHPicArray.clsPicArray ' array to store the bitmap in for processing, loads it from the imgInput picture Dim paR As BCHPicArray.clsPicArray ' array to store the bitmap in for processing, loads it from the imgInput picture Private Sub cmdCenterL_Click() LScan.X = Round(pctLeft.ScaleWidth / 2) + 1 LScan.Y = Round(pctLeft.ScaleHeight / 2) + 1 LScan.dist = 0 End Sub Private Function NextPosition(cur_x As Integer, cur_y As Integer, cur_dist As Integer) As position Dim center_x, center_y ' move clockwise in a square center_x = Round(pctLeft.ScaleWidth / 2) center_y = Round(pctLeft.ScaleHeight / 2) ' for scanning for the second point, this should be changed to scan left/right mostly, then up/down since pitch should be the same on both cameras If cur_dist = 0 Then ' special case for the starting condition cur_x = center_x + 1 cur_y = center_y cur_dist = 1 Else If (cur_x = center_x + cur_dist And cur_y = center_y + cur_dist) Then ' bottom right corner, start/end cur_x = cur_x + 1 cur_dist = cur_dist + 1 ElseIf (cur_x = center_x + cur_dist And cur_y = center_y - cur_dist) Then ' upper right cur_x = cur_x - 1 ElseIf (cur_x = center_x - cur_dist And cur_y = center_y - cur_dist) Then ' upper left cur_y = cur_y + 1 ElseIf (cur_x = center_x - cur_dist And cur_y = center_y + cur_dist) Then ' bottom left cur_x = cur_x + 1 ElseIf (cur_y = center_y - cur_dist) Then ' top cur_x = cur_x - 1 ' move left ElseIf (cur_x = center_x - cur_dist) Then ' left cur_y = cur_y + 1 ' move down ElseIf (cur_y = center_y + cur_dist) Then ' bottom cur_x = cur_x + 1 ' move right ElseIf (cur_x = center_x + cur_dist) Then ' right cur_y = cur_y - 1 ' move up Else MsgBox "error in nextposition, cur_x=" & cur_x & "; cur_y = " & cur_y End If End If If cur_x > pctLeft.ScaleWidth Then cur_x = pctLeft.ScaleWidth End If If cur_y > pctLeft.ScaleHeight Then cur_y = pctLeft.ScaleHeight End If NextPosition.X = cur_x NextPosition.Y = cur_y NextPosition.dist = cur_dist End Function Private Sub cmdStepL_Click() ' scan from the center out Dim next_pos As position next_pos = NextPosition(LScan.X, LScan.Y, LScan.dist) LScan.X = next_pos.X LScan.Y = next_pos.Y LScan.dist = next_pos.dist If IsLaser(LScan.X, LScan.Y, paL) Then ' hit a laser on the left tmrUpdateScan_Timer ' MsgBox "Hit Left: " & LScan.X & "x" & LScan.Y & " @ " & LScan.dist RScan.X = LScan.X RScan.Y = LScan.Y RScan.dist = 0 cmdDoFrameR_Click End If End Sub Private Sub cmdDoFrameL_Click() Dim next_pos As position next_pos = NextPosition(LScan.X, LScan.Y, LScan.dist) Do While (next_pos.Y < pctLeft.ScaleHeight) next_pos = NextPosition(LScan.X, LScan.Y, LScan.dist) cmdStepL_Click Loop End Sub Private Sub cmdStepR_Click() ' scan from the center out Dim next_pos As position next_pos = NextPosition(RScan.X, RScan.Y, RScan.dist) RScan.X = next_pos.X RScan.Y = next_pos.Y RScan.dist = next_pos.dist If IsLaser(RScan.X, RScan.Y, paR) Then ' hit a laser on the right tmrUpdateScan_Timer CalculateIntersect MsgBox "Hit right: " & RScan.X & "x" & RScan.Y & " @ " & RScan.dist End If End Sub Private Sub cmdDoFrameR_Click() Dim next_pos As position next_pos = NextPosition(RScan.X, RScan.Y, RScan.dist) Do While (next_pos.Y < pctRight.ScaleHeight) next_pos = NextPosition(RScan.X, RScan.Y, RScan.dist) cmdStepR_Click Loop End Sub Private Function IsLaser(X As Integer, Y As Integer, pa As BCHPicArray.clsPicArray) As Boolean ' compare current position to known image. Dim color As Long color = pa.ReadPixel(X, pctLeft.ScaleHeight - Y) ' read in reverse x order If (((color And &HFF) * red_pct) > ((color \ 256) And &HFF) And ((color And &HFF) * red_pct) > ((color \ 65536) And &HFF)) Then IsLaser = True End If End Function Private Function CalculateIntersect() Dim angle_A As Double, angle_A2 As Double, angle_B As Double, angle_B2 As Double, angle_C As Double, angle_C2 As Double, angle_D As Double Dim dist_AC As Double, dist_AB As Double, dist_BD As Double, dist_CA As Double, dist_BC As Double Dim dist_CD As Double, dist_AD As Double, dist_CE As Double, dist_DE As Double tmrUpdateScan_Timer ' update the values angle_A2 = txtLScanYaw.Text angle_A = 90 - angle_A2 angle_B2 = txtRScanYaw.Text ' Val(txtCameraYawOffset.Text) + Val(txtScanYaw.Text) angle_B = 90 + angle_B2 angle_D = txtLScanPitch.Text ' average with r? something? txtAngleA.Text = angle_A txtAngleB.Text = angle_B txtAngleD.Text = angle_D ' find: distance, yaw, pitch ' 1) find dist_CD and dist_BD If (angle_A <= 90 And angle_B <= 90) Then dist_AC = (txtDistAB.Text * Sin(Radians(angle_B))) / Sin(Radians(180 - angle_A - angle_B)) dist_CD = dist_AC * Sin(Radians(angle_A)) dist_AD = dist_AC * Cos(Radians(angle_A)) ' dist_BD = dist_AB - dist_AD ElseIf (angle_A > 90) Then angle_A2 = 90 - angle_A angle_C = 180 - angle_A - angle_B angle_C2 = 90 - angle_C dist_AC = -1 ' ? dist_CD = dist_CA * Sin(Radians(angle_A2)) dist_AD = -dist_CA * Sin(Radians(angle_C2)) ' dist_BD = dist_AB - dist_AD ElseIf (angle_B > 90) Then angle_B2 = 90 - angle_B angle_C = 180 - angle_A - angle_B angle_C2 = 90 - angle_C dist_BC = -1 ' ? dist_CD = dist_BC * Sin(Radians(angle_B2)) dist_BD = dist_BC * Sin(Radians(angle_C2)) dist_AD = dist_AB - dist_BD Else dist_CD = Val("-1") dist_AD = Val("-1") End If txtDistAC.Text = dist_AC txtDistAD.Text = dist_AD txtDistCD.Text = dist_CD ' 2) find CE and DE If (dist_CD > -1 And dist_BD > -1) Then ' if first calcs were valid dist_DE = dist_CD * Cos(Radians(angle_D)) dist_CE = dist_CD * Sin(Radians(angle_D)) Else dist_CE = "-1" dist_DE = "-1" End If txtDistCE.Text = dist_CE txtDistDE.Text = dist_DE End Function Private Sub cmbDeviceL_Change() ' Dim oldDriver As Long ' oldDriver = ezVidCapL.DriverIndex ' ' On Error Resume Next ' ezVidCapL.DriverIndex = cmbDeviceL.ListIndex - 1 ' If Err Then 'restore old settings ' ezVidCapL.DriverIndex = oldDriver ' cmbDeviceL.ListIndex = oldDriver ' Else ' SaveSetting "DualImage", "Settings", "DeviceIndexL", cmbDeviceL.ListIndex ' End If End Sub Private Sub cmdDeviceR_Change() ' Dim oldDriver As Long ' oldDriver = ezVidCapR.DriverIndex ' ' On Error Resume Next ' ezVidCapR.DriverIndex = cmbDeviceL.ListIndex - 1 ' If Err Then 'restore old settings ' ezVidCapL.DriverIndex = oldDriver ' cmbDeviceL.ListIndex = oldDriver ' Else ' SaveSetting "DualImage", "Settings", "DeviceIndexL", cmbDeviceL.ListIndex ' End If End Sub Private Sub Form_Load() Dim i Set paL = New clsPicArray ' initialize picture array Set paR = New clsPicArray ' initialize picture array cmbDeviceL.AddItem ("") ' If ezVidCapL.NumCapDevs > 0 Then ' For i = 0 To ezVidCapL.NumCapDevs - 1 ' cmbDeviceL.AddItem (ezVidCapL.GetDriverName(i)) ' Next ' End If cmbDeviceL.ListIndex = 0 cmbDeviceL.ListIndex = GetSetting("LaserDistance", "Settings", "DeviceIndexL", cmbDeviceL.ListIndex) cmbDeviceR.ListIndex = GetSetting("LaserDistance", "Settings", "DeviceIndexR", cmbDeviceR.ListIndex) lineLCross1.X1 = 0 lineLCross1.Y1 = 0 lineLCross1.X2 = pctLeft.ScaleWidth lineLCross1.Y2 = pctLeft.ScaleHeight lineLCross2.X1 = 0 lineLCross2.Y1 = pctLeft.ScaleHeight lineLCross2.X2 = pctLeft.ScaleWidth lineLCross2.Y2 = 0 lineRCross1.X1 = 0 lineRCross1.Y1 = 0 lineRCross1.X2 = pctRight.ScaleWidth lineRCross1.Y2 = pctRight.ScaleHeight lineRCross2.X1 = 0 lineRCross2.Y1 = pctRight.ScaleHeight lineRCross2.X2 = pctRight.ScaleWidth lineRCross2.Y2 = 0 paL.LoadPicArray pctLeft.Picture ' load the bitmap from the picture into the buffer paR.LoadPicArray pctRight.Picture ' load the bitmap from the picture into the buffer End Sub Private Sub tmrUpdateScan_Timer() txtLScanX.Text = LScan.X txtLScanY.Text = LScan.Y txtLScanD.Text = LScan.dist txtRScanX.Text = RScan.X txtRScanY.Text = RScan.Y txtRScanD.Text = RScan.dist txtLScanYaw.Text = (LScan.X / pctLeft.ScaleWidth) * (txtLCamYaw.Text * 2) - (txtLCamYaw.Text) txtLScanPitch.Text = -((LScan.Y / pctLeft.ScaleHeight) * (txtLCamPitch.Text * 2) - (txtLCamPitch.Text)) txtRScanYaw.Text = (RScan.X / pctRight.ScaleWidth) * (txtLCamYaw.Text * 2) - (txtLCamYaw.Text) txtRScanPitch.Text = -((RScan.Y / pctRight.ScaleHeight) * (txtLCamPitch.Text * 2) - (txtLCamPitch.Text)) shpScanL.Left = LScan.X - Round(shpScanL.Width / 2) shpScanL.Top = LScan.Y - Round(shpScanL.Height / 2) shpScanR.Left = RScan.X - Round(shpScanR.Width / 2) shpScanR.Top = RScan.Y - Round(shpScanR.Height / 2) End Sub ' generic functions Function Radians(Degrees As Double) Radians = Degrees * (3.141592654 / 180) End Function Function Degrees(Radians As Double) Degrees = Radians * (180 / 3.141592654) End Function