以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  摄像头不同,程序出错  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=172327)

--  作者:mxl810823
--  发布时间: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 & "]"


--  作者:有点蓝
--  发布时间:2021/10/8 17:26:00
--  
应该是获取不到图片【pic.Image = _Cap.GetBitmap()】,pic.Image是空的。

可能摄像头组件不支持外接的摄像头,或者是摄像头的驱动没有安装正确

--  作者:mxl810823
--  发布时间:2021/10/8 17:36:00
--  
外接的摄像头分辨率要大于电脑自带的
--  作者:二月龙
--  发布时间:2022/1/9 20:36:00
--  
问题是如何解决的呢 我也遇到这样的问题
--  作者:有点蓝
--  发布时间:2022/1/9 20:46:00
--  
检查驱动是否安装正确。

如果不支持,咨询厂家是否有开发接口