用于Windows窗体的覆盆子皮c#中的摄像头串行接口

时间:2018-03-15 06:19:49

标签: c# .net camera mono raspberry-pi3

我一直在尝试在c#中创建一个程序,通过相机串行接口定期拍摄照片并自动将其保存在文件夹中。问题是如何从单声道c#启用摄像头并开始定期拍摄静止图像?基本上,Windows窗体有一个按钮和一个具有摄像头和按钮实时流媒体的图片框,其中有一个点击事件可以捕获相机上的静止图像。很感谢任何形式的帮助..!感谢。

这里我有c#

中单声道窗体的代码
namespace MyNamespace
{
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
public class MyForm : System.Windows.Forms.Form
{
    Button btnLoad;
    Button btnSave;
    PictureBox pboxPhoto;
    Label lbl;
    TextBox tbx;

    public MyForm()
    {
        this.Text = "Hello AMD";            // Create and configure the Button

        btnLoad = new Button();
        btnLoad.Text = "&Load";
        btnLoad.Left = 10;
        btnLoad.Top = 10;
        btnLoad.Click += new System.EventHandler(this.OnLoadClick);            // Create and configure the PictureBox

        btnSave = new Button();
        btnSave.Text = "&Save";
        btnSave.Left = 100;
        btnSave.Top = 10;
        btnSave.Click += new System.EventHandler(this.OnSaveClick);            // Create and configure the PictureBox

        pboxPhoto = new PictureBox();
        pboxPhoto.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
        pboxPhoto.Width = this.Width / 3;
        pboxPhoto.Height = this.Height / 3;
        pboxPhoto.Left = (this.Width - pboxPhoto.Width) / 2;
        pboxPhoto.Top = (this.Height - pboxPhoto.Height) / 2;
        pboxPhoto.SizeMode = PictureBoxSizeMode.StretchImage;            // Add our new controls to the Form

        lbl = new Label();
        lbl.Text = "name";
        lbl.Left = 10;
        lbl.Top = 220;

        tbx = new TextBox();
        tbx.Left = 150;
        tbx.Top = 220;
                // Create and configure the PictureBox


        this.Controls.Add(btnLoad);
        this.Controls.Add(pboxPhoto);
        this.Controls.Add(btnSave);
        this.Controls.Add(lbl);
        this.Controls.Add(tbx);

    }
    private void OnLoadClick(object sender, System.EventArgs e)
    {
        OpenFileDialog dlg = new OpenFileDialog();
        dlg.Title = "Open Photo";
        dlg.Filter = "jpg files (*.jpg)|*.jpg|All files (*.*)|*.*" ;
        if (dlg.ShowDialog() == DialogResult.OK)
        {
            pboxPhoto.Image = new Bitmap(dlg.OpenFile());
        }
        dlg.Dispose();

    }

    private void OnSaveClick(object sender , System.EventArgs e)

    {
        Process proc = new System.Diagnostics.Process();
        proc.StartInfo.FileName = "/bin/bash ";
        proc.StartInfo.Arguments = "-c raspistill -o gg.jpg";
        proc.StartInfo.UseShellExecute = false; 
        proc.StartInfo.RedirectStandardError = true;
        proc.StartInfo.RedirectStandardInput = true;
        proc.StartInfo.RedirectStandardOutput = true;
        proc.Start();
    }



    public static void Main()
    {
        Application.Run(new MyForm());
    }
}
} 

我认为是一种形式,在OnLoadClick上,图片框有来自相机模块的实时视频(不是录制),OnSaveClick在该特定时间捕获它。

0 个答案:

没有答案