在c#中用emgu处理图片,结果一副图片总是读不进来,一星期了还没解决问题,急死了。CSDN新人,所以积分只有1分,请各位大佬们帮帮忙,谢谢。
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;
using Emgu.Util;
using Emgu.CV.UI;
namespace xinshouxuexi
{
public partial class Form4 : Form
{
public Form4()
{
InitializeComponent();
}
private void Form4_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog opdia = new OpenFileDialog();
opdia.Title = "获取图片";
opdia.Filter = "图片文件(*.bmp;*.jpg;*.gif;*.jpeg;*.png)|*.bmp;*.jpg;*.gif;*.jpeg;*.png|所有文件(*.*)|*.*";
if (opdia.ShowDialog() == DialogResult.OK)
{
//创建一个img
Mat img = new Mat(200, 400, DepthType.Cv8U, 3);
//将imread读入的图像存入
img = CvInvoke.Imread("edcf85bc2864a86.jpg", LoadImageType.AnyColor);
if (img == null)
{
Image<Bgr, byte> image = new Image<Bgr, byte>(opdia.FileName);
imageBox1.Image = image;
image.Dispose();
}
}
}
如图为调试结果:

可以看到img的data值为null,但是并没有进入if,很奇怪真是。