www.pudn.com > sdk3000demo.rar > main.frm, change:2009-07-04,size:12962b


VERSION 5.00 
Object = "{285817C3-2870-4884-9F7A-982DA436AC21}#1.0#0"; "SDK3000.ocx" 
Begin VB.Form formMain  
   AutoRedraw      =   -1  'True 
   Caption         =   "SDK3000-Demo" 
   ClientHeight    =   11115 
   ClientLeft      =   60 
   ClientTop       =   345 
   ClientWidth     =   15240 
   KeyPreview      =   -1  'True 
   LinkTopic       =   "Form1" 
   ScaleHeight     =   11115 
   ScaleWidth      =   15240 
   StartUpPosition =   3  'Windows Default 
   WindowState     =   2  'Maximized 
   Begin VB.CommandButton btnUpdate  
      Caption         =   "Update" 
      Height          =   495 
      Left            =   6960 
      TabIndex        =   24 
      Top             =   10440 
      Width           =   1335 
   End 
   Begin VB.ComboBox comboVideoSource  
      Height          =   315 
      ItemData        =   "main.frx":0000 
      Left            =   12960 
      List            =   "main.frx":0013 
      Style           =   2  'Dropdown List 
      TabIndex        =   12 
      Top             =   9720 
      Width           =   1935 
   End 
   Begin VB.CommandButton btnExit  
      Caption         =   "退出" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   13 
      Top             =   10200 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnCustomSnap  
      Caption         =   "自定义抓拍" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   11 
      Top             =   4800 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnCircularSnap  
      Caption         =   "循环抓拍" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   10 
      Top             =   4320 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnOsdSet  
      Caption         =   "设置字幕叠加" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   0 
      Top             =   240 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnCaptureSet  
      Caption         =   "设置捕获参数" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   1 
      Top             =   720 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnColorProperty  
      Caption         =   "颜色属性设置" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   2 
      Top             =   1200 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnOutHigh  
      Caption         =   "输出高电平" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   3 
      Top             =   5400 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnOutLow  
      Caption         =   "输出低电平" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   4 
      Top             =   5880 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnStartCapture  
      Caption         =   "开始捕获" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   5 
      Top             =   1680 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnStopCapture  
      Caption         =   "停止捕获" 
      Enabled         =   0   'False 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   6 
      Top             =   2160 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnRun  
      Caption         =   "运行视频" 
      Enabled         =   0   'False 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   7 
      Top             =   2760 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnPause  
      Caption         =   "暂停视频" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   8 
      Top             =   3240 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnSnap  
      Caption         =   "拍照" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   9 
      Top             =   3840 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnStopMD  
      Caption         =   "停止动态检测" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   19 
      Top             =   8880 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnStartMD  
      Caption         =   "开始动态检测" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   18 
      Top             =   8400 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnStartInLow  
      Caption         =   "开始低输入" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   16 
      Top             =   7320 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnStartInHigh  
      Caption         =   "开始高输入" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   15 
      Top             =   6840 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnStopIn  
      Caption         =   "停止输入" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   17 
      Top             =   7800 
      Width           =   2055 
   End 
   Begin SDK3000Lib.SDK3000 SDK30001  
      Height          =   10080 
      Left            =   120 
      TabIndex        =   22 
      Top             =   120 
      Width           =   12600 
      _Version        =   65536 
      _ExtentX        =   22225 
      _ExtentY        =   17780 
      _StockProps     =   0 
   End 
   Begin VB.CommandButton btnInitIn  
      Caption         =   "输入初始化" 
      Height          =   375 
      Left            =   12840 
      TabIndex        =   14 
      Top             =   6360 
      Width           =   2055 
   End 
   Begin VB.CommandButton btnDisConnect  
      Caption         =   "断开" 
      Height          =   375 
      Left            =   6120 
      TabIndex        =   21 
      Top             =   8520 
      Visible         =   0   'False 
      Width           =   1095 
   End 
   Begin VB.CommandButton btnConnect  
      Caption         =   "连接" 
      Height          =   375 
      Left            =   6120 
      TabIndex        =   20 
      Top             =   8160 
      Visible         =   0   'False 
      Width           =   1095 
   End 
   Begin VB.Label Label12  
      Caption         =   "视频源通道:" 
      Height          =   255 
      Left            =   12960 
      TabIndex        =   23 
      Top             =   9480 
      Width           =   1095 
   End 
End 
Attribute VB_Name = "formMain" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
 
'设置捕获参数 
Private Sub btnCaptureSet_Click() 
 
    Call formCaptureSet.Show(vbModal, Me) 
     
End Sub 
 
Private Sub btnCircularSnap_Click() 
 
    Call formCapPic.Show(vbModal, Me) 
     
End Sub 
 
Private Sub btnColorProperty_Click() 
 
    Call formColorProperty.Show(vbModal, Me) 
     
End Sub 
'Download by http://www.codefans.net 
Private Sub btnConnect_Click() 
 
    Call SDK30001.Connect(0, True, g_nCapWidth, g_nCapHeight) 
     
    '全局变量更新 
    g_bConnected = True 
    g_nPlayState = 1 
         
End Sub 
 
 
Private Sub btnCustomSnap_Click() 
     
    Dim cur As Date 
    cur = Now 
     
    Dim strFile As String 
    strFile = g_strPicturePath + Format(cur, "yyyymmdd-HHmmss") 
     
    If g_nPlayState = 1 And g_bBmp Then 
        If Not SDK30001.SaveRangeToBmp(strFile + ".bmp", 0, 0, 0, 0) Then 
            Call MsgBox("请选择区域") 
        End If 
     
    ElseIf g_nPlayState = 1 And Not g_bBmp Then 
        If Not SDK30001.SaveRangeToJpg(strFile + ".jpg", 100, 0, 0, 0, 0) Then 
            Call MsgBox("请选择区域") 
        End If 
     
    End If 
 
End Sub 
 
Private Sub btnDisConnect_Click() 
 
    Call SDK30001.Disconnect 
    g_bConnected = False 
     
End Sub 
 
Private Sub btnExit_Click() 
 
    Call Unload(Me) 
     
End Sub 
 
Private Sub btnInitIn_Click() 
 
    g_bInput = False 
    Call SDK30001.InitIOAlertIn(AddressOf MyPrcIoAlertCallBack) 
     
End Sub 
 
 
'设置字幕叠加 
Private Sub btnOsdSet_Click() 
 
    Call formOsdSet.Show(vbModal, Me) 
     
End Sub 
 
Private Sub btnOutHigh_Click() 
 
    Call SDK30001.IOAlertOut(True) 
     
End Sub 
 
Private Sub btnOutLow_Click() 
 
    Call SDK30001.IOAlertOut(False) 
     
End Sub 
 
Private Sub btnPause_Click() 
 
    Call SDK30001.SaveImageToBmp("C:\ocx.bmp", 1, False) 
    Sleep (150) 
     
    Call SDK30001.SaveImageToJpg("C:\ocx.jpg", 100, 1, False) 
    Sleep (150) 
     
    If Not SDK30001.Pause() Then 
        Call MsgBox("error") 
        Exit Sub 
    End If 
     
    g_nPlayState = 2 
    btnRun.Enabled = True 
    btnPause.Enabled = False 
     
End Sub 
 
Private Sub btnRun_Click() 
 
    If Not SDK30001.Run() Then 
        Call MsgBox("error") 
    End If 
 
    g_nPlayState = 1 
    btnRun.Enabled = False 
    btnPause.Enabled = True 
     
End Sub 
 
 
Private Sub btnSnap_Click() 
 
    Dim cur As Date 
    cur = Now 
     
    Dim strFile As String 
    strFile = g_strPicturePath + Format(cur, "yyyymmdd-HHmmss") 
 
    If g_nPlayState = 1 And g_bBmp Then 
        Call SDK30001.SaveImageToBmp(strFile + ".bmp", 1, False) 
     
    ElseIf g_nPlayState = 2 And g_bBmp Then 
        Call CopyFile("C:\ocx.bmp", strFile + ".bmp", 0) 
     
    ElseIf g_nPlayState = 1 And Not g_bBmp Then 
        Call SDK30001.SaveImageToJpg(strFile + ".jpg", 100, 1, False) 
     
    ElseIf g_nPlayState = 2 And Not g_bBmp Then 
        Call CopyFile("C:\ocx.jpg", strFile + ".jpg", 0) 
     
    End If 
 
End Sub 
 
Private Sub btnStartCapture_Click() 
     
    Dim cur As Date 
    cur = Now 
     
    Dim strFile As String 
    strFile = g_strVideoPath + Format(cur, "yyyymmdd-HHmmss") + ".avi" 
     
    Call SDK30001.SetCurVideoCompressor(g_nCurComp) 
     
    Call SDK30001.StartCapture(strFile, -1) 
    btnStartCapture.Enabled = False 
    btnStopCapture.Enabled = True 
     
End Sub 
 
Private Sub btnStartInHigh_Click() 
 
    Call SDK30001.StartIOAlertIn(True) 
     
End Sub 
 
Private Sub btnStartInLow_Click() 
 
    Call SDK30001.StartIOAlertIn(False) 
     
End Sub 
 
Private Sub btnStartMD_Click() 
 
    Dim nDetectWidth As Long 
    Dim nDetectHeight As Long 
    Dim nDetectBlocks As Long 
     
    nDetectWidth = g_nCapWidth / 16 
    nDetectHeight = g_nCapHeight / 16 
    nDetectBlocks = nDetectWidth * nDetectHeight 
     
    Dim pAreaMap As String 
    pAreaMap = String(nDetectBlocks, 48) 
    nDetectWidth = SDK30001.EnableMotionDetect(pAreaMap, nDetectBlocks, 10, AddressOf moduleGlobal.MyPrcCbMotionDetect) 
     
End Sub 
 
Private Sub btnStopCapture_Click() 
 
    If Not SDK30001.StopCapture() Then 
        Call MsgBox("error") 
    End If 
         
    btnStartCapture.Enabled = True 
    btnStopCapture.Enabled = False 
     
End Sub 
 
Private Sub btnStopIn_Click() 
 
    Call SDK30001.StopIOAlertIn 
     
g_bInput = False 
End Sub 
 
Private Sub btnStopMD_Click() 
 
    Call SDK30001.DisableMotionDetect 
     
End Sub 
 
Private Sub comboCard_Click() 
 
    '多卡切换,本Demo未处理 
    'Call MsgBox("多卡切换,本Demo未处理") 
     
End Sub 
 
Private Sub btnUpdate_Click() 
 
    SDK30001.Width = 576 * 10 
    SDK30001.Height = 488 * 10 
    Call SDK30001.UpdateVideoRect 
     
End Sub 
 
Private Sub comboVideoSource_Click() 
 
    If g_bConnected Then 
        SDK30001.VideoSource = comboVideoSource.ListIndex 
    End If 
     
End Sub 
 
Private Sub Form_Load() 
     
    '全局变量初始化. 
    '连接用到的全局变量 
    g_bConnected = False 
    g_nCapWidth = 720 
    g_nCapHeight = 576 
    g_nPlayState = 0 
    g_bRecAudio = False 
     
    '动态检测用到的全局变量 
    g_bInput = False 
    g_bMove = False 
     
    '循环抓拍用到的全局变量 
    g_nCycNum = 5 
    g_nPic = 0 
    g_strCircularSnapDir = "e:\" 
    g_nSource = 0 
    g_nCircularPicCount = 1 
    g_bCircularSnapBmp = False 
    g_nPersist = 2 
     
    g_bCircularSource(0) = True 
    Dim i As Long 
    For i = 1 To 4 
        g_bCircularSource(i) = False 
    Next i 
     
    '捕获参数设置用到的全局变量 
    g_strVideoPath = "e:\" 
    g_strPicturePath = "e:\" 
    g_nCurComp = -1 
    g_bBmp = False 
         
    '本窗体变量初始化 
    comboVideoSource.ListIndex = 0 
     
    '连接 
    Call btnConnect_Click 
 
End Sub 
 
Private Sub Form_Unload(Cancel As Integer) 
 
    If g_bConnected Then 
        Call btnDisConnect_Click 
    End If 
     
End Sub