b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

imreadC#调用C++、Opencv的代码可以通过托管和(2)

电脑杂谈  发布时间:2018-01-28 02:04:38  来源:网络整理

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

imread函数的用法_imread_python imread

using System.Windows.Forms;

using System.Runtime.InteropServices;

namespace ImageCS2

{

public partial class Form1 : Form

{

[DllImport("ImageCPP.dll")]

public static extern IntPtr run1(string a, out int width, out int height, out int step);

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

string filename;

OpenFileDialog op = new OpenFileDialog();

if (op.ShowDialog() == DialogResult.OK)

{

filename = op.FileName;

int width, height, step;

IntPtr dst = run1(filename, out width, out height, out step);

Bitmap img = new Bitmap(width, height, step, System.Drawing.Imaging.PixelFormat. Format24bppRgb, dst);

pictureBox1.Image = img;

}

}

}

}

(6) C++传递灰度图,在C#中的代码略有差别,代码如下:

[DllImport("raildetection.dll")]

public static extern IntPtr run1(string a , out int width, out int height, out int step);

private void button1_Click(object sender, EventArgs e)

{

string filename;

OpenFileDialog op = new OpenFileDialog();

if (op.ShowDialog() == DialogResult.OK)

{

filename = op.FileName;

int width, height, step;

IntPtr dst = run1(filename,out width,out height, out step);

Bitmap img = new Bitmap(width, height, step, <strong>System.Drawing.Imaging.PixelFormat.Format8bppIndexed</strong>,dst);

<strong>img.Palette = CvToolbox.GrayscalePalette;</strong>

pictureBox1.Image = img;

}

}

public static class CvToolbox


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-63301-2.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...