BitmapConverterを使ってimageに指定するのが味噌
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
// 以下を追加
using OpenCvSharp;
using OpenCvSharp.CPlusPlus;
using OpenCvSharp.Extensions; // Bitmap変換に必要
using System.Diagnostics;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button_imageLoad_Click(object sender, EventArgs e)
{
Mat matOrgImage = new Mat(@"C:\Users\hoge\Pictures\hogehoge.jpg");
Mat matDispImage = new Mat();
CvSize size = new CvSize(pictureBox1.Width, pictureBox1.Height); // formのpicture boxのサイズにあわせた
Cv2.Resize(matOrgImage, matDispImage, size);
Image image = BitmapConverter.ToBitmap(matDispImage);
pictureBox1.Image = image;
}
}
}
0 件のコメント:
コメントを投稿