标签:stc mtk wp7 ax1 vsx dct xca fda vdc
emguCV是OpenCV关于C#的封装库。可以说是OpenCV在C#中使用的版本,可以弥补OpenCV关于GUI界面的缺陷。对于emguCV网上资料较少,但不能说它没用。
一.emguCV配置(win10系统下)
1.环境变量的配置(我的电脑->属性->高级系统配置->环境变量)
在path路径下添加emguCV安装路径
有些电脑需要重启才能生效。
2.在VS2013中新建WindowsForm工程
3.在解决方案的reference中添加五个动态库
4.在TOOLS->choose Toolbox items...中选中一下几个.dll
此时emguCV基本上配置完了,接下来就可以下代码了,下面的代码,嵌入水印功能还未完善。
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms; 10 using System.IO; 11 using Emgu.CV; 12 using Emgu.Util; 13 using Emgu.CV.Structure; 14 15 16 namespace WindowsFormsApplication1 17 { 18 public partial class Form1 : Form 19 { 20 public Form1() 21 { 22 InitializeComponent(); 23 } 24 25 private void button1_Click(object sender, EventArgs e) 26 { 27 var dialog = new OpenFileDialog(); 28 dialog.Filter = "图片(*.jpg/*.png/*.gif/*.bmp)|*.jpg;*.png;*.gif;*.bmp"; 29 if (dialog.ShowDialog() == DialogResult.OK) 30 { 31 var filename = dialog.FileName; 32 33 IntPtr image = CvInvoke.cvLoadImage(filename, Emgu.CV.CvEnum.LOAD_IMAGE_TYPE.CV_LOAD_IMAGE_ANYCOLOR); 34 Image<Bgr, byte> dest = new Image<Bgr, byte>(CvInvoke.cvGetSize(image)); 35 CvInvoke.cvCopy(image, dest, IntPtr.Zero); 36 pictureBox1.Image = dest.ToBitmap(); 37 } 38 39 //OpenFileDialog ofd = new OpenFileDialog(); 40 //ofd.ShowDialog(); 41 //string path = ofd.FileName; 42 //textBox1.Text = File.ReadAllText(path,Encoding.Default); 43 } 44 45 private void textBox1_TextChanged(object sender, EventArgs e) 46 { 47 48 } 49 50 private void pictureBox1_Click(object sender, EventArgs e) 51 { 52 53 } 54 55 private void button2_Click(object sender, EventArgs e) //打开水印 56 { 57 var dialog = new OpenFileDialog(); 58 dialog.Filter = "图片(*.jpg/*.png/*.gif/*.bmp)|*.jpg;*.png;*.gif;*.bmp"; 59 if (dialog.ShowDialog() == DialogResult.OK) 60 { 61 var filename = dialog.FileName; 62 63 IntPtr mark = CvInvoke.cvLoadImage(filename, Emgu.CV.CvEnum.LOAD_IMAGE_TYPE.CV_LOAD_IMAGE_ANYCOLOR); 64 Image<Bgr, byte> rawMark = new Image<Bgr, byte>(CvInvoke.cvGetSize(mark)); 65 CvInvoke.cvCopy(mark, rawMark, IntPtr.Zero); 66 pictureBox2.Image = rawMark.ToBitmap(); 67 68 } 69 } 70 71 private void embed_Click(object sender, EventArgs e) //嵌入水印 72 { 73 74 } 75 } 76 }
运行结果:
标签:stc mtk wp7 ax1 vsx dct xca fda vdc
原文地址:http://www.cnblogs.com/t-code/p/6231917.html