资源简介
c++里通过opencv读取图片后考入内存传出指针给c#,并在picturebox里显示
代码片段和文件信息
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 System.Runtime.InteropServices;
using System.Threading;
using System.IO;
using System.Drawing.Imaging;
namespace _1108_2
{
public partial class Form1 : Form
{
class CPPDLL
{
[DllImport(“dll.dll“ CharSet = CharSet.Ansi)]
public static extern unsafe byte* initZed( out int widthout int heightout int channels);
// public static extern unsafe Byte* initZed();
//[DllImport(“111.dll“ CharSet = CharSet.Ansi)]
//public static extern unsafe int initZed();
////[DllImport(“1107.dll“ CharSet = CharSet.Ansi)]
////public static extern unsafe int test();
//[DllImport(“1107.dll“ CharSet = CharSet.Ansi)]
//public static extern unsafe float* getImage();
////[DllImport(“111.dll“ CharSet = CharSet.Ansi)]
////public static extern unsafe int test();
}
public Form1()
{
InitializeComponent();
}
private float[] cross(float[] A float[] B float[] C)
{
float[] AB = new float[3];
float[] BC = new float[3];
AB[0] = B[0] - A[0];
AB[1] = B[1] - A[1];
AB[2] = B[2] - A[2];
BC[0] = C[0] - B[0];
BC[1] = C[1] - B[1];
BC[2] = C[2] - B[2];
float[] arr = new float[3];
float crs1 = AB[1] * BC[2] - AB[2] * BC[1];
float crs2 = BC[0] * AB[2] - BC[2] * AB[0];
float crs3 = AB[0] * BC[1] - AB[1] * BC[0];
arr[0] = crs1;
arr[1] = crs2;
arr[2] = crs3;
return arr;
}
private void Form1_Load(object sender EventArgs e)
{
// int key = CPPDLL.initZed();
}
public static Bitmap BytesToBmp(byte[] bmpBytes Size imageSize)
{
Bitmap bmp = new Bitmap(imageSize.Width imageSize.Height);
BitmapData bData = bmp.LockBits(new Rectangle(0 0 imageSize.Width imageSize.Height)
ImageLockMode.ReadWrite
PixelFormat.Format24bppRgb); //24bit rgb Format24bppRgb
// Copy the bytes to the bitmap object
System.Runtime.InteropServices.Marshal.Copy(bmpBytes 0 bData.Scan0 bmpBytes.Length);
bmp.UnlockBits(bData);
return bmp;
}
private void button1_Click(object sender EventArgs e)
{
unsafe
{
int width heightchannels;
byte * ptr_image_data ;
//byte image_data = new byte();
ptr_image_data = CPPDLL.in
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5921 2018-12-11 10:23 dll读取图片到c#\Form1.cs
文件 980 2018-12-11 10:26 dll读取图片到c#\MyDll.cpp
目录 0 2018-12-11 10:27 dll读取图片到c#\
相关资源
- 基于C#平台开发的surf算法,可直接运
- linux opencv车牌识别
- VS2012-C++编写、调用DLL库教程
- DLL转VC++格式的lib、转C++builder格式的
- 6步学会VS2010环境下C语言DLL封装.pdf
- MFC规则DLL(MFC Regular DLL)添加DLLMain(
- FTD2XX.DLL
- opencv多视频同一窗口显示C++程序
- 基于opencv的手势识别
- SQlite3库及头文件在VS2010中MFC使用成功
- 利用opencv做的垃圾检测代码
- 字形轮廓提取显示C#源码
- Opencv3.0 鱼眼相机标定fisheye
- 如何用VC++创建及调用DLL
- C# IOCP完成端口模型简单实用高效
- LSD直线提取算法Opencv
- C#callC++dll.pptx
- 使用vc++6.0调用opencv库函数生成5*5单位
- VC6.0做的仿按键精灵找图找色功能 f
- opencv绘制点与坐标系
- MFCN42D.DLL
- C++ 垃圾代码生成器
- 基于socket和opencv在linux中实现摄像头实
- 图片浏览器实现和图像编辑器实现源
- c++与c#命名管道
- danmu 基于opencv平台编写的单目相机标
- OpenCV边缘检测程序 by浅墨
- mfc110.dll
- mfc42.dll
- MFC42.DLL MFC42D.DLL MFC042D.DLL
评论
共有 条评论