2014年3月21日 星期五

EMGUCV 開影像檔

//  Modified by Jerry
//  Copyright (c) 2013年 vince. All rights reserved.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
//using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using Emgu.CV;           //for emguCV
using Emgu.CV.Structure; //for Bgr

//namespace c_sharp_emgucv_setup

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog filename = new OpenFileDialog();
            if (filename.ShowDialog() == DialogResult.OK)
            {
                string name = filename.FileName;
                Image<Gray, Byte> img = new Image<Gray, Byte>(name);
                pictureBox1.Image = img.ToBitmap();
                pictureBox1.Width = 512;
                pictureBox1.Height = 512;
                button1.Left = 100;
                button1.Top = 100;
                pictureBox1.Left = 0;
                pictureBox1.Top = 0;
            }
         
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Width = 640;
            this.Height = 480;
        }
    }
}

參考

沒有留言:

張貼留言