我有一个使用aforge.net的项目,我有点面临问题。 我总是得到无效的图像大小指定的异常,我不知道为什么。 如果有人能帮助我,那就太好了......
这是我的代码:
private void videoSourcePlayer_NewFrame(object sender, ref Bitmap image)
{
string filepath = @"C:\Users\RLNGSTRDRGNTR\Documents\Visual Studio 2010\Projects\PengenalanPlatAccordNet\PengenalanPlatAccordNet\plat.JPG";
Bitmap imageContoh = new Bitmap(System.Drawing.Image.FromFile(filepath, true));
UnmanagedImage unImage = UnmanagedImage.FromManagedImage(imageContoh);
UnmanagedImage clone = unImage.Clone();
ResizeBilinear resize = new ResizeBilinear(512, 512);
imageUntukDiproses = resize.Apply(clone);
if (imageUntukDiproses != null)
{
//Preprosessing gambar
PreProcessing pre = new PreProcessing(imageUntukDiproses);
UnmanagedImage hasilPre = pre.HasilPreProcessing;
UnmanagedImage grayscale = pre.GambarGrayscale;
//penentuan lokasi plat
PenentuLokasiPlat plat = new PenentuLokasiPlat(hasilPre, grayscale);
//ekstraksi plat
UnmanagedImage platfix = plat.PlatKendaraan;
plat.Drawing(image);
//tampilan histogram untuk hasil preprosessing
histogram1.Values = plat.Hishorlogic;
histogram3.Values = plat.Hisverlogic;
if (platfix != null)
{
SegmentasiHuruf segmen = new SegmentasiHuruf(platfix);
byte[,] ciripertama = segmen.Karakter[1];
this.Invoke(new MethodInvoker(delegate() { dataGridView1.DataSource = new ArrayDataView(ciripertama); }));
//Menampilkan image hasil
}
}
Bitmap gambar = imageUntukDiproses.ToManagedImage();
image = gambar;
}
关于异常,我看到图像为空..