在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,很奇怪真是。