标题: CCD采集控件 vb源代码 [打印本页]

作者: 周星星2017    时间: 2017-7-18 14:00
标题: CCD采集控件 vb源代码
CCD采集控件的界面显示:


vb源程序如下:
  1. VERSION 5.00
  2. Object = "{DF6D6558-5B0C-11D3-9396-008029E9B3A6}#1.0#0"; "ezvidc60.ocx"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Begin VB.Form Form1
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "Form1"
  7.    ClientHeight    =   9030
  8.    ClientLeft      =   45
  9.    ClientTop       =   375
  10.    ClientWidth     =   9585
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   9030
  15.    ScaleWidth      =   9585
  16.    StartUpPosition =   2  '屏幕中心
  17.    Begin VB.CommandButton Command4
  18.       Caption         =   "Command4"
  19.       Height          =   615
  20.       Left            =   2235
  21.       TabIndex        =   8
  22.       Top             =   7440
  23.       Width           =   1335
  24.    End
  25.    Begin VB.Timer Timer3
  26.       Enabled         =   0   'False
  27.       Interval        =   500
  28.       Left            =   360
  29.       Top             =   7537
  30.    End
  31.    Begin VB.TextBox Text1
  32.       Height          =   390
  33.       Left            =   1320
  34.       Locked          =   -1  'True
  35.       TabIndex        =   6
  36.       Top             =   8280
  37.       Width           =   8295
  38.    End
  39.    Begin VB.Timer Timer2
  40.       Enabled         =   0   'False
  41.       Left            =   7080
  42.       Top             =   8280
  43.    End
  44.    Begin VB.Timer Timer1
  45.       Interval        =   1000
  46.       Left            =   8400
  47.       Top             =   8280
  48.    End
  49.    Begin MSComctlLib.StatusBar StatusBar1
  50.       Align           =   2  'Align Bottom
  51.       Height          =   375
  52.       Left            =   0
  53.       TabIndex        =   5
  54.       Top             =   8655
  55.       Width           =   9585
  56.       _ExtentX        =   16907
  57.       _ExtentY        =   661
  58.       _Version        =   393216
  59.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
  60.          NumPanels       =   3
  61.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
  62.             AutoSize        =   1
  63.             Object.Width           =   7117
  64.          EndProperty
  65.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
  66.             Alignment       =   1
  67.             AutoSize        =   1
  68.             Object.Width           =   7117
  69.          EndProperty
  70.          BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628}
  71.             Style           =   5
  72.             Alignment       =   1
  73.             AutoSize        =   2
  74.             TextSave        =   "15:18"
  75.          EndProperty
  76.       EndProperty
  77.    End
  78.    Begin VB.CommandButton Command5
  79.       Caption         =   "Command5"
  80.       Height          =   615
  81.       Left            =   4125
  82.       TabIndex        =   4
  83.       Top             =   7440
  84.       Width           =   1335
  85.    End
  86.    Begin VB.CommandButton Command3
  87.       Caption         =   "Command3"
  88.       Height          =   615
  89.       Left            =   6015
  90.       TabIndex        =   3
  91.       Top             =   7440
  92.       Width           =   1335
  93.    End
  94.    Begin VB.CommandButton Command2
  95.       Caption         =   "Command2"
  96.       Height          =   615
  97.       Left            =   7905
  98.       TabIndex        =   2
  99.       Top             =   7440
  100.       Width           =   1335
  101.    End
  102.    Begin VB.CommandButton Command1
  103.       Caption         =   "Command1"
  104.       Height          =   615
  105.       Left            =   345
  106.       TabIndex        =   1
  107.       Top             =   7440
  108.       Width           =   1335
  109.    End
  110.    Begin vbVidC60.ezVidCap ezVidCap1
  111.       Height          =   7200
  112.       Left            =   0
  113.       TabIndex        =   0
  114.       Top             =   0
  115.       Width           =   9600
  116.       _ExtentX        =   16933
  117.       _ExtentY        =   12700
  118.       CenterVideo     =   0   'False
  119.       MakeUserConfirmCapture=   0
  120.       AbortLeftMouse  =   0
  121.       AbortRightMouse =   0
  122.       YieldEventEnabled=   -1  'True
  123.       UsePreciseCaptureControls=   -1  'True
  124.    End
  125.    Begin VB.Label Label1
  126.       Caption         =   "文件路径:"
  127.       BeginProperty Font
  128.          Name            =   "宋体"
  129.          Size            =   12
  130.          Charset         =   134
  131.          Weight          =   400
  132.          Underline       =   0   'False
  133.          Italic          =   0   'False
  134.          Strikethrough   =   0   'False
  135.       EndProperty
  136.       Height          =   255
  137.       Left            =   120
  138.       TabIndex        =   7
  139.       Top             =   8348
  140.       Width           =   1335
  141.    End
  142. End
  143. Attribute VB_Name = "Form1"
  144. Attribute VB_GlobalNameSpace = False
  145. Attribute VB_Creatable = False
  146. Attribute VB_PredeclaredId = True
  147. Attribute VB_Exposed = False
  148. Public strFileAVI As String     '保存视频的文件名
  149. Public strFileBMP As String
  150. Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
  151. Private Declare Function sndPlaySound Lib "Winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
  152. Private Const SND_ASYNC = &H1 '允许异步
  153. Private Sub Command1_Click()
  154. Dim Filename
  155. ezVidCap1.CaptureAudio = True
  156. If Command1.Caption = "开始录像" Then
  157. Command1.Caption = "停止录像"
  158. Filename = Format(Now, "yyyymmddhhmmss") '生成日期时间序列
  159. CreateFolder App.Path & "\Temp"    '调过函数创建临时文件夹
  160. strFileAVI = App.Path & "\Temp\" & Filename & ".AVI" '保存的视频文件名,下面一句也可以
  161. 'strFileAVI = App.Path & "\TEMP\" & Minute(Now) & Second(Now) & ".AVI" '保存的视频文件名
  162. With ezVidCap1
  163. .CaptureFile = strFileAVI   '捕获视频文件名
  164. .Preview = True '打开预览
  165. .PreviewRate = 15   '预览速率
  166. .CaptureVideo  '开始录制视频
  167. End With
  168.   Else
  169. ezVidCap1.CaptureEnd
  170.   Command1.Caption = "开始录像"
  171.   End If
  172. End Sub
  173. Private Sub Command2_Click()
  174. Dim exit_ As Integer
  175. exit_ = exit1
  176. If exit_ = 11 Or exit_ = 10 Then
  177. Timer3.Enabled = True
  178. End If
  179. End Sub
  180. Private Sub Command3_Click()
  181. ezVidCap1.About
  182. End Sub

  183. Private Sub Command4_Click()
  184. Dim Filename
  185. Dim SaveimageOK As Boolean
  186. Filename = Format(Now, "yyyymmddhhmmss") '生成日期时间序列
  187. CreateFolder App.Path & "\Image"    '调过函数创建临时文件夹
  188.   strFileBMP = App.Path & "\Image\" & Filename & ".bmp" '生新保存图片文件的名称
  189.     On Error Resume Next    '错误处理
  190.    SaveimageOK = ezVidCap1.SaveDIB(strFileBMP)   '保存图片
  191.    If SaveimageOK = True Then
  192.    sndPlaySound App.Path & "\shutter.wav", 0
  193.    Text1.Text = strFileBMP
  194.    
  195.    End If
  196.      If Err Then '若有错误
  197.     Beep 1000, 100
  198.       MsgBox "请先停止录像,再拍照," & Chr(13) & "错误代码:" & Err.Description, vbInformation, App.Title  '显示错误信息
  199.     End If
  200. End Sub

  201. Private Sub Command5_Click()
  202. ezVidCap1.ShowDlgVideoSource
  203. End Sub



  204. Private Sub ezVidCap1_CaptureYield()    '捕获事件
  205. DoEvents
  206. End Sub


  207. Private Sub Form_Load()
  208. If App.PrevInstance Then
  209. Beep 1000, 100
  210. fanhuizhi = MsgBox("程序正在运行,请关闭本程序", vbOKOnly, "警告")
  211. If fanhuizhi = 1 Then
  212.   End
  213. End If
  214. End If
  215. Text1.Text = "显示最后一次拍照、录制或者正在录制文件的路径"
  216. Form1.Caption = "ccd采集控件可录像和截图(自行研究)"
  217. Command1.Caption = "开始录像"
  218. Command2.Caption = "退出"
  219. Command3.Caption = "关于控件"
  220. Command4.Caption = "拍照"
  221. Command5.Caption = "选择视频源"
  222. End Sub

  223. Private Sub ezVidCap1_StatusMessage(ByVal StatCode As Long, ByVal StatString As String)
  224.     '捕获状态事件
  225.   If StatCode <> 0 Then   '状态码不为0
  226.      StatusBar1.Panels(1).Text = Left(StatString, InStr(StatString, ")"))   '显示状态信息
  227.     '  If StatCode = 301 Then  '若是结束状态
  228.       '  mnuRecStart.Caption = "开始录制"    '修改菜单标题
  229.     '      frmCamera.Hide  '隐藏摄像头窗体
  230.           ' frmVideo.Show   '显示预览窗体
  231.       ' End If
  232.     End If
  233.     DoEvents
  234. End Sub
  235. Private Sub ezVidCap1_PreRollComplete() '准备开始录制
  236.    Dim lRet As Long
  237.     lRet = MsgBox("单击“确定”按钮开始录制!" & Chr(13) & "单击“取消”按钮取消录制!", vbOKCancel, App.Title) '显示确认信息
  238.     If lRet = vbOK Then '单击“确定”按钮
  239.         ezVidCap1.PreciseCaptureStart   '开始录制
  240.        Text1.Text = strFileAVI
  241.    Else    '单击“取消”按钮
  242.      ezVidCap1.PreciseCaptureCancel  '放弃录制
  243.      Timer2.Enabled = True '错开文件是否被占用时间
  244.      Timer2.Interval = 500
  245.    End If
  246. End Sub

  247. Private Sub DeleteFile(FilePath As String)
  248. ……………………

  249. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
CCD采集控件代码.rar (71 KB, 下载次数: 14)









欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1