应用程序无法启动网络摄像头 [英] Application fails to start webcam

查看:142
本文介绍了应用程序无法启动网络摄像头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在与应该使用网络摄像头拍照的应用程序发生噩梦.表单上有一个开始网络摄像头"按钮,可以打开照相机进行拍照.它的事件是下面的OpenCamera():

Hi guys,
i''m having a nightmare with an application that is supposed to take a picture with a webcam. There is a ''Start Webcam'' button on the form to open the camera to take a picture. Its event is OpenCamera() below:

<pre lang="vb">Private Sub OpenCamera()<br />
        Dim iHeight As Integer = picCapture.Height<br />
        Dim iWidth As Integer = picCapture.Width<br />
        '' Open Preview window in picturebox .<br />
        '' Create a child window with capCreateCaptureWindowA so you can display it in a picturebox.<br />
        hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, _<br />
            480, picCapture.Handle.ToInt32, 0)<br />
        '' Connect to device<br />
        If SendMessage(hHwnd, CAP_DRIVER_CONNECT, iDevice, 0) Then<br />
            '' Set the preview scale<br />
            SendMessage(hHwnd, CAP_SET_SCALE, True, 0)<br />
            '' Set the preview rate in milliseconds<br />
            SendMessage(hHwnd, CAP_SET_PREVIEWRATE, 66, 0)<br />
            '' Start previewing the image from the camera<br />
            SendMessage(hHwnd, CAP_SET_PREVIEW, True, 0)<br />
            '' Resize window to fit in picturebox<br />
            SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, picCapture.Width, picCapture.Height, _<br />
                                   SWP_NOMOVE Or SWP_NOZORDER)<br />
        Else<br />
            '' Error connecting to device close window<br />
            DestroyWindow(hHwnd)<br />
        End If<br />
    End Sub</pre>



然后,form_closing事件具有以下内容:



Then, the form_closing event has the following:

<pre lang="vb">'' Disconnect from device<br />
       SendMessage(hHwnd, CAP_DRIVER_DISCONNECT, iDevice, 0)<br />
       Clipboard.Clear()<br />
       '' ''close window<br />
       DestroyWindow(hHwnd)</pre><br />



仅在第一次加载表单时,此方法才能正常工作.随后的任何时间都需要拔出USB摄像头并重新安装.
我已经解决了两个星期,没有解决方案.请问有人可以帮我吗?

Thanx.



This works fine only the first time the form is loaded. Any subsequent time requires pulling out the USB camera and reattaching it.
I''ve been on this for two weeks now with no solution. Please can anyone help me out here?

Thanx.

推荐答案

具有.Net的WebCam [< ^ ]

此链接必须对您有帮助


网络摄像头DirectShow CP文章 [
WebCam With .Net[^]

This link must help you


Webcam DirectShow CP Article[^]


这篇关于应用程序无法启动网络摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆