如何检查连接到PC的相机(计算机)

如何检查连接到PC的相机(计算机)

问题描述:

//我想从摄像机捕获图像.我要检查相机是否已连接

// I want to captute image from camera. I want to check camera has connected

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenCVDotNet;

namespace WindowsApplication6
{
    public partial class Form1 : Form
    {
        private CVCapture capture;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            capture = new CVCapture(0); // when  debug i see signal light camera
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
                using (CVImage nextFrame = capture.QueryFrame())

                {
      
                    selectPictureBox1.Image = nextFrame.ToBitmap();// this line error. Because of  nextFrame set null . may be camera not connected?
	            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = !(timer1.Enabled);
        }
    }
}


如何解决这个问题?


How to fix this problem? Thanks!

关注该链接. :)


http://support.microsoft.com/kb/283658 [
follow thw link. :)


http://support.microsoft.com/kb/283658[^]


mark as answer if solves your problem.