I'm trying to identify objects in an image and I encounter an error "Object reference not set to an instance of an object" I am using Alturos.Yolo version 2.2.2
And I also use Alturos.YoloV2TinyVocData version 1.0.0
This is the code:
using Alturos.Yolo;
using Alturos.Yolo.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OBD
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnDetect_Click(object sender, EventArgs e)
{
var configurationDetector = new ConfigurationDetector();
var config = configurationDetector.Detect();
using (YoloWrapper yoloWrapper = new YoloWrapper(config))
{
using(MemoryStream ms = new MemoryStream())
{
pictureBox1.Image.Save(ms, ImageFormat.Png);
var Items = yoloWrapper.Detect(ms.ToArray());
yoloItemBindingSource.DataSource = Items;
//dataGridView1.DataSource = Items;
//var Itemi = yoloWrapper.Detect(ms.ToArray()).ToList();
//Draw(Itemi);
}
//var items = yoloWrapper.Detect(@"image.jpg");
//items[0].Type -> "Person, Car, ..."
//items[0].Confidence -> 0.0 (low) -> 1.0 (high)
//items[0].X -> bounding box
//items[0].Y -> bounding box
//items[0].Width -> bounding box
//items[0].Height -> bounding box
}
}
public void Draw(List<YoloItem> sItems)
{
foreach (var item in sItems)
{
}
}
private void btnOpen_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog() { Filter = "PNG|*.Png|JEPG|*.Jepg"};
if(ofd.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = new Bitmap(ofd.FileName);
}
}
}
}