VERSION 5.00 Object = "{DF6D6558-5B0C-11D3-9396-008029E9B3A6}#1.0#0"; "ezVidC60.ocx" Begin VB.Form frmMain Caption = "Dual Image" ClientHeight = 12450 ClientLeft = 60 ClientTop = 345 ClientWidth = 10800 LinkTopic = "Form1" ScaleHeight = 830 ScaleMode = 3 'Pixel ScaleWidth = 720 StartUpPosition = 3 'Windows Default Begin VB.Frame Frame2 Caption = "Calculations" Height = 3915 Left = 0 TabIndex = 8 Top = 8340 Width = 9915 Begin VB.TextBox txtDistAB Height = 285 Left = 4080 TabIndex = 42 TabStop = 0 'False Text = "24.5" Top = 2220 Width = 555 End Begin VB.TextBox txtMaxDistance Height = 315 Left = 4080 TabIndex = 39 Text = "20" Top = 2520 Width = 555 End Begin VB.TextBox txtLScanD Height = 255 Left = 900 TabIndex = 37 Text = "-1" Top = 900 Width = 795 End Begin VB.TextBox txtRScanD Height = 255 Left = 1740 TabIndex = 36 Text = "-1" Top = 900 Width = 795 End Begin VB.Timer tmrUpdateScan Interval = 1 Left = 3420 Top = 240 End Begin VB.CommandButton cmdCenterL Caption = "Reset" Height = 255 Left = 900 TabIndex = 35 Top = 2340 Width = 795 End Begin VB.CommandButton cmdStepL Caption = "Step" Height = 255 Left = 900 TabIndex = 34 Top = 2040 Width = 795 End Begin VB.TextBox txtDScanPitch Height = 255 Left = 2580 TabIndex = 31 Text = "-1" Top = 1440 Width = 795 End Begin VB.TextBox txtDScanYaw Height = 255 Left = 2580 TabIndex = 30 Text = "-1" Top = 1200 Width = 795 End Begin VB.TextBox txtDScanY Height = 255 Left = 2580 TabIndex = 29 Text = "-1" Top = 660 Width = 795 End Begin VB.TextBox txtDScanX Height = 255 Left = 2580 TabIndex = 28 Text = "-1" Top = 420 Width = 795 End Begin VB.TextBox txtRColor Height = 255 Left = 1740 TabIndex = 26 Text = "-1" Top = 1740 Width = 795 End Begin VB.TextBox txtRScanPitch Height = 255 Left = 1740 TabIndex = 25 Text = "-1" Top = 1440 Width = 795 End Begin VB.TextBox txtRScanYaw Height = 255 Left = 1740 TabIndex = 24 Text = "-1" Top = 1200 Width = 795 End Begin VB.TextBox txtRScanY Height = 255 Left = 1740 TabIndex = 23 Text = "-1" Top = 660 Width = 795 End Begin VB.TextBox txtRScanX Height = 255 Left = 1740 TabIndex = 22 Text = "-1" Top = 420 Width = 795 End Begin VB.TextBox txtLColor Height = 255 Left = 900 TabIndex = 20 Text = "-1" Top = 1740 Width = 795 End Begin VB.TextBox txtLScanPitch Height = 255 Left = 900 TabIndex = 18 Text = "-1" Top = 1440 Width = 795 End Begin VB.TextBox txtLScanYaw Height = 255 Left = 900 TabIndex = 17 Text = "-1" Top = 1200 Width = 795 End Begin VB.TextBox txtLScanY Height = 255 Left = 900 TabIndex = 16 Text = "-1" Top = 660 Width = 795 End Begin VB.TextBox txtLScanX Height = 255 Left = 900 TabIndex = 15 Text = "-1" Top = 420 Width = 795 End Begin VB.PictureBox pctFinal Height = 3615 Left = 4980 ScaleHeight = 237 ScaleMode = 3 'Pixel ScaleWidth = 317 TabIndex = 9 Top = 180 Width = 4815 End Begin VB.Label Label21 BackStyle = 0 'Transparent Caption = """" Height = 195 Left = 4680 TabIndex = 44 Top = 2220 Width = 255 End Begin VB.Label Label20 BackStyle = 0 'Transparent Caption = "Dist AB" Height = 195 Left = 3360 TabIndex = 43 Top = 2280 Width = 675 End Begin VB.Label Label17 Caption = "Max Dist" Height = 195 Left = 3360 TabIndex = 41 Top = 2580 Width = 735 End Begin VB.Label Label16 Caption = "px" Height = 195 Left = 4680 TabIndex = 40 Top = 2580 Width = 255 End Begin VB.Label Label15 Caption = "Scan D" Height = 195 Left = 60 TabIndex = 38 Top = 900 Width = 675 End Begin VB.Label Label14 Alignment = 2 'Center Caption = "Difference" Height = 195 Left = 2580 TabIndex = 27 Top = 180 Width = 795 End Begin VB.Label Label8 Alignment = 2 'Center Caption = "Right" Height = 195 Left = 1740 TabIndex = 21 Top = 180 Width = 795 End Begin VB.Label Label13 Caption = "Color" Height = 195 Left = 60 TabIndex = 19 Top = 1740 Width = 915 End Begin VB.Label Label12 Caption = "Scan Yaw" Height = 255 Left = 60 TabIndex = 14 Top = 1200 Width = 855 End Begin VB.Label Label11 Caption = "Scan Pitch" Height = 195 Left = 60 TabIndex = 13 Top = 1440 Width = 915 End Begin VB.Label Label10 Caption = "Scan Y" Height = 195 Left = 60 TabIndex = 12 Top = 660 Width = 675 End Begin VB.Label Label9 Caption = "Scan X" Height = 255 Left = 60 TabIndex = 11 Top = 420 Width = 615 End Begin VB.Label Label7 Alignment = 2 'Center Caption = "Left" Height = 195 Left = 900 TabIndex = 10 Top = 180 Width = 795 End End Begin VB.Frame Frame1 Caption = "Captured Images" Height = 3975 Left = 0 TabIndex = 5 Top = 4320 Width = 9915 Begin VB.PictureBox pctRight Height = 3615 Left = 4980 Picture = "frmDualImages.frx":0000 ScaleHeight = 237 ScaleMode = 3 'Pixel ScaleWidth = 317 TabIndex = 7 Top = 240 Width = 4815 End Begin VB.PictureBox pctLeft Height = 3615 Left = 120 Picture = "frmDualImages.frx":38442 ScaleHeight = 237 ScaleMode = 3 'Pixel ScaleWidth = 317 TabIndex = 6 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.TextBox txtLCamYawOffset Height = 285 Left = 3600 TabIndex = 48 TabStop = 0 'False Text = "68.0" Top = 3900 Width = 495 End Begin VB.TextBox txtLCamYaw Height = 285 Left = 3600 TabIndex = 47 TabStop = 0 'False Text = "22.0" Top = 3600 Width = 495 End Begin VB.TextBox txtLCamPitch Height = 285 Left = 4140 TabIndex = 46 TabStop = 0 'False Text = "16.5" Top = 3600 Width = 495 End Begin VB.TextBox txtLCamPitchOffset Height = 285 Left = 4140 TabIndex = 45 TabStop = 0 'False Text = "0" Top = 3900 Width = 495 End Begin VB.ComboBox cmbDeviceR Height = 315 Left = 5040 Style = 2 'Dropdown List TabIndex = 33 Top = 540 Width = 4635 End Begin VB.ComboBox cmbDeviceL Height = 315 Left = 180 Style = 2 'Dropdown List TabIndex = 32 Top = 540 Width = 4755 End Begin vbVidC60.ezVidCap ezVidCapR Height = 3600 Left = 4980 TabIndex = 2 Top = 540 Width = 4800 _ExtentX = 8467 _ExtentY = 6350 Preview = 0 'False End Begin vbVidC60.ezVidCap ezVidCapL Height = 1800 Left = 120 TabIndex = 1 Top = 540 Width = 2400 _ExtentX = 4233 _ExtentY = 3175 Preview = 0 'False End Begin VB.Label Label6 BackStyle = 0 'Transparent Caption = "Cam Offset" Height = 195 Left = 2760 TabIndex = 54 Top = 3960 Width = 1035 End Begin VB.Label Label4 BackStyle = 0 'Transparent Caption = "Cam Angle" Height = 195 Left = 2760 TabIndex = 53 Top = 3660 Width = 975 End Begin VB.Label Label25 Alignment = 2 'Center BackStyle = 0 'Transparent Caption = "Yaw" Height = 195 Left = 3600 TabIndex = 52 Top = 3360 Width = 495 End Begin VB.Label Label26 BackStyle = 0 'Transparent Caption = "o" Height = 195 Left = 4620 TabIndex = 51 Top = 3540 Width = 255 End Begin VB.Label Label27 BackStyle = 0 'Transparent Caption = "o" Height = 195 Left = 4620 TabIndex = 50 Top = 3840 Width = 255 End Begin VB.Label Label28 Alignment = 2 'Center BackStyle = 0 'Transparent Caption = "Pitch" Height = 195 Left = 4140 TabIndex = 49 Top = 3360 Width = 495 End Begin VB.Label Label5 Caption = "Right Camera" Height = 255 Left = 4980 TabIndex = 4 Top = 240 Width = 1335 End Begin VB.Label Label2 Caption = "Left Camera" Height = 255 Left = 180 TabIndex = 3 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 Dim LScan As position 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) 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 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 End Sub Private Sub tmrUpdateScan_Timer() txtLScanX.Text = LScan.x txtLScanY.Text = LScan.y txtLScanD.Text = LScan.dist txtLScanYaw.Text = (LScan.x / pctLeft.ScaleWidth) * (txtLCamYaw.Text * 2) - (txtLCamYaw.Text) txtLScanPitch.Text = -((LScan.y / pctLeft.ScaleHeight) * (txtLCamPitch.Text * 2) - (txtLCamPitch.Text)) shpScanL.Left = LScan.x - Round(shpScanL.Width / 2) shpScanL.Top = LScan.y - Round(shpScanL.Height / 2) End Sub 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 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 End Sub