emgu cv 在WPF上显示图像
来源:互联网 发布:欧洲 旅游 大学生 知乎 编辑:程序博客网 时间:2024/05/17 04:19
xmal页代码
<Window x:Class="显示图片.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <Image Height="287" HorizontalAlignment="Left" Margin="34,12,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="380" /> <Button Content="Button" Height="20" HorizontalAlignment="Left" Margin="432,40,0,0" Name="button1" VerticalAlignment="Top" Width="46" Click="button1_Click" /> </Grid></Window>
xmal.cs代码
需要在dll里面添加System.Drawing
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using System.Runtime.InteropServices;using Emgu.CV;using Emgu.CV.Structure;namespace 显示图片{ /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void display() { Image<Bgr, Byte> image = new Image<Bgr, byte>("d:/0.bmp"); MCvFont f = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_PLAIN, 3.0, 3.0); image.Draw("Hello, world", ref f, new System.Drawing.Point(10, 50), new Bgr(255.0, 0.0, 0.0)); image1.Source = ToBitmapSource(image); } /// <summary> /// emgu cv 显示 /// </summary> /// <param name="o"></param> /// <returns></returns> [DllImport("gdi32")] private static extern int DeleteObject(IntPtr o); public static BitmapSource ToBitmapSource(IImage image) { using (System.Drawing.Bitmap source = image.Bitmap) { IntPtr ptr = source.GetHbitmap(); //obtain the Hbitmap BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( ptr, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); DeleteObject(ptr); //release the HBitmap return bs; } } private void button1_Click(object sender, RoutedEventArgs e) { display(); } }}
结果如图
- emgu cv 在WPF上显示图像
- emgu cv 读取摄像头图像
- emgu cv 图像三色的直方图
- emgu.cv的图像金字塔操作
- Emgu CV添加UI控件不显示
- Emgu在WPF中的使用
- WPF 将Bitmapsource转换到Emgu.cv.image
- 在WPF中使用Emgu加载Image<,>图像的两种方法
- C#-Emgu.CV-------视频截取和图像处理基础
- [RTSP]WPF用Emgu显示RTSP视频
- Emgu CV的安装
- Emgu CV--基础知识
- Emgu CV Lesson 1
- emgu cv 轮廓提取
- emgu cv 透视变换
- Emgu Cv示例
- Emgu.Cv基础知识
- EMGU CV环境配置
- mac os xcode app 自动注册开启自动启动
- CSU 1317 Find the max Link
- 《UNIX环境高级编程》笔记--open函数,create函数,close函数
- Android中设置控件可见与不可见详解
- android fragment android.support.v4.app.Fragment与android.app.Fragment区别
- emgu cv 在WPF上显示图像
- Silverlight 之 image source 绑定
- 感谢他们,但除了感谢我实在不可能对他们有其他的感觉了,就像我
- Asp.Net MVC 路由
- ios开发适配3.5寸和4寸屏幕
- ZOJ1109-map与string
- POJ 2019 Cornfields (二维RMQ,3级)
- Linux 下编译、安装、配置 QT
- 定时器的比较