I Have Upload Images for C# but I want It Activate WebCam and Capture Instead of Upload

时间:2015-08-07 01:47:03

标签: c#

I'm novice in C#. I want to have capture image using webcam instead of upload image function. Here's my codes for Upload Image.

Note:

"MyQuery" is my class name. Then conn is my connection declared inside my "MyQuery" class name. 

Here's my Upload Image when the button is trigger

private void button1_Click(object sender, EventArgs e){
    MyQuery capture = new MyQuery();
        capture.Connection();
        OpenFileDialog fp = new OpenFileDialog();
        fp.InitialDirectory = @"";
        fp.Filter = "[JPG,JPEG]|*.jpg";
        if (fp.ShowDialog() == DialogResult.OK)
        {
            this.pictureBox1.Image = Image.FromFile(fp.FileName);
            this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            this.pictureBox1.Refresh();
        }
        MySqlCommand cmd = new MySqlCommand("Insert into MyImage (ImgFiled) values('" + this.pictureBox1.Image + "')",capture.conn);
        cmd.ExecuteNonQuery();
        MessageBox.Show("Successfully Uploaded");
}

1 个答案:

答案 0 :(得分:-1)

只需进行路径保存即可解决问题。我也没有使用这个代码。