Foxtable(狐表)用户栏目专家坐堂 → 摄像头不同,程序出错


  共有4296人关注过本帖树形打印复制链接

主题:摄像头不同,程序出错

帅哥哟,离线,有人找我吗?
mxl810823
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小狐 帖子:355 积分:3033 威望:0 精华:0 注册:2018/2/27 17:32:00
摄像头不同,程序出错  发帖心情 Post By:2021/10/8 17:04:00 [显示全部帖子]

在运行拍照程序时,电脑自带的摄像头是可以执行的,但是外接一个摄像头就会在msgbox(11111) 和 msgbox(2222)之间出错,提示找不到对象。为什么,要怎么搞
Dim pic As WinForm.PictureBox = e.Form.Controls("PicView")
Dim pic2 As WinForm.PictureBox = e.Form.Controls("PicView2")
Dim cam As WinForm.Control = e.Form.Controls("CamView")
Dim box As WinForm.Control = e.Form.Controls("LineBox")
'预览框尺寸
Dim x As Integer = cam.Left
Dim y As Integer = cam.Top
Dim w As Integer = cam.Width
Dim h As Integer = cam.Height
'截图框尺寸
Dim x1 As Integer = box.Left
Dim y1 As Integer = box.Top
Dim w1 As Integer = box.Width
Dim h1 As Integer = box.Height

'摄像头拍照
_Cap.GrapImg()
pic.Image = _Cap.GetBitmap()
'摄像头分辨率
msgbox(11111)
Dim camw As Integer = pic.Image.Width
Dim camh As Integer = pic.Image.Height
'截取框和预览框比例
msgbox(222)
Dim cw As Double = camw / w
Dim ch As Double = camh / h
'计算截图坐标

msgbox(3333332)
Dim picx As Integer = CInt(CDbl(x1-x) * cw)
Dim picy As Integer = CInt(CDbl(y1-y) * ch)
Dim picw As Integer = CInt(CDbl(w1) * cw)
Dim pich As Integer = CInt(CDbl(h1) * ch)
'截取图片

pic2.Image = Functions.Execute("GetBitmapPart",_Cap.GetBitmap(),picx,picy,picw,pich)
'输入信息
e.Form.Controls("ViewSize").Text = "预览框尺寸:[" & w & "*" & h & "]"
e.Form.Controls("BoxSize").Text = "截图框尺寸:[" & w1 & "*" & h1 & "]"
e.Form.Controls("PicSize").Text = "照片尺寸:[" & picw & "*" & pich & "]"
e.Form.Controls("CamSize").Text = "摄像头分辨率:[" & camw & "*" & camh & "]"
e.Form.Controls("ZoomRate").Text = "缩放比:[" & cw & ":" & ch & "]"


 回到顶部
帅哥哟,离线,有人找我吗?
mxl810823
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小狐 帖子:355 积分:3033 威望:0 精华:0 注册:2018/2/27 17:32:00
  发帖心情 Post By:2021/10/8 17:36:00 [显示全部帖子]

外接的摄像头分辨率要大于电脑自带的

 回到顶部