久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

emgucv之Matrix操作

 ontheroad96j47 2021-11-08

  主要是解答群友的兩個小問題

  1. 獲取datagridview的行號和列號

    private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { MessageBox.Show("當前行號" + e.RowIndex.ToString() + "當前列號:"+ e.ColumnIndex.ToString()); }

2. 將數(shù)組賦值給Matrix并轉(zhuǎn)換為Mat

using Emgu.CV;using System;using System.Windows.Forms;
namespace WindowsFormsApp7{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { // MessageBox.Show("當前行號" + e.RowIndex.ToString() + "當前列號:"+ e.ColumnIndex.ToString());
} public Mat CreateMatFromArr(double[,] arr) { int height = arr.GetLength(0); int width = arr.GetLength(1); Matrix<double> mask = new Matrix<double>(height,width); mask.Data = arr; return mask.Mat; }
private void Form1_Load(object sender, EventArgs e) { double[,] dataArr = { { 100,100,100,100,100,100,100,100,100,100},{100,100,100,100,100,100,100,100,100,100} }; Mat m = CreateMatFromArr(dataArr); pictureBox1.Image = m.Bitmap; } }}

運行結(jié)果:

函數(shù)的參數(shù)需要泛型,。。,。,。,,修改如下:

using Emgu.CV;using System;using System.Windows.Forms;
namespace WindowsFormsApp7{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { // MessageBox.Show("當前行號" + e.RowIndex.ToString() + "當前列號:"+ e.ColumnIndex.ToString());
} public Mat CreateMatFromArr<T>(T[,] arr) { int height = arr.GetLength(0); int width = arr.GetLength(1); Matrix<double> mask = new Matrix<Double>(height, width); for (int row = 0;row < height;row ++) { for (int col = 0; col < width; col++) mask.Data[row, col] = Convert.ToDouble(arr[row, col]); } return mask.Mat; }
private void Form1_Load(object sender, EventArgs e) { int[,] dataArr = { { 100,100,100,100,100,100,100,100,100,100},{100,100,100,100,100,100,100,100,100,100} };// int,double,byte均可 Mat m = CreateMatFromArr(dataArr); pictureBox1.Image = m.Bitmap; } }}

    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多