資源簡介
代碼+文檔說明,詳細介紹如何生成c++的dll,以及c#調用如何調用,包括各種數據的轉換,特別是openCV圖片數據格式的傳入輸出轉換。
代碼片段和文件信息
using?System;
using?System.Drawing;
using?System.Windows.Forms;
using?System.Drawing.Imaging;
using?System.Runtime.InteropServices;
using?System.IO;
using?Dll_Interface;
namespace?cSharp
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?loadImg_Click(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????/*注意:若讀入的圖片行位數byte(即行像素點*通道數)不是4的倍數(工業相機一般是),
??????????????????Bitmap會自動補齊此時容易造成后面Bitmap與byte[]之間互轉后圖片出錯(該問題目前未解決)*/
????????????????Bitmap?srcImg?=?new?Bitmap(@“5.jpg“);?
????????????????#region
????????????????//byte[]?img?=?new?byte[srcImg.Width?*?srcImg.Height];
????????????????//for?(int?yy?=?0;?yy?????????????????//{
????????????????//????for?(int?xx?=?0;?xx?????????????????//????{
????????????????//????????img[yy?*?srcImg.Width?+?xx]?=?srcImg.GetPixel(xx?yy).R;
????????????????//????}
????????????????//}
????????????????#endregion
????????????????byte[]?img?=?null;
????????????????bitmapToByte(srcImg?ref?img);
????????????????#region
????????????????dllInterface?IFclass?=?new?dllInterface();
????????????????/********************結構體示例*********************/
????????????????Ipoint?p1??p2?p3;
????????????????p1?=?new?Ipoint();
????????????????p2?=?new?Ipoint();
????????????????p3?=?new?Ipoint();
????????????????p1.X?=?1;?p1.Y?=?2;
????????????????p2.X?=?3;?p2.Y?=?4;
????????????????IFclass.IAddPoints(p1?p2?ref?p3);
????????????????label1.Text?=?“add?x:?“?+?(p3.X).ToString()?+?“\n“?+?“add?y:?“?+?(p3.Y).ToString();
????????????????/***************vector示例*************************/
????????????????int?numEle?=?3;
????????????????Ipoint[]?retVce?=?new?Ipoint[numEle];
????????????????Ipoint[]?vec1?=?new?Ipoint[numEle];
????????????????Ipoint[]?vec2?=?new?Ipoint[numEle];
????????????????Ipoint[]?VceResult?=?new?Ipoint[numEle];
????????????????vec1[0]?=?p1;?vec1[1]?=?p2;?vec1[2]?=?p3;
????????????????vec2[0]?=?p1;?vec2[1]?=?p2;?vec2[2]?=?p3;
????????????????retVce?=?IFclass.vecTest(vec1??vec2?numEle?ref?VceResult);
????????????????#endregion
????????????????/***************圖像示例*************************/
????????????????int?Depth?=?System.Drawing.Bitmap.GetPixelFormatSize(srcImg.PixelFormat);//目前僅支持24位或8位
????????????????int?channel?=?Depth?/?8;
????????????????bool?isColor?=?false;
????????????????if?(channel?==?3)
????????????????{
????????????????????isColor?=?true;
????????????????}
????????????????byte[]?imgFilter?=?new?byte[srcImg.Width?*?srcImg.Height?*?channel];?
????????????????IFclass.IMeamImage(img?srcImg.Height?srcImg.Width?ref?imgFilter?isColor);
????????????????Bitmap?Image1?=?CovertToBitmap(imgFilter?srcImg.Width?srcImg.Height?isColor);
????????????????pictureBox1.Image?=?Image1;
???????????????
????????????}
????????????catch?(Exception?ex)
????????????{
???????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-11-09?10:04??csCallCplus\
?????目錄???????????0??2018-11-09?09:58??csCallCplus\.vs\
?????目錄???????????0??2018-11-09?09:58??csCallCplus\.vs\csCallCplus\
?????目錄???????????0??2018-11-09?09:58??csCallCplus\.vs\csCallCplus\v14\
?????文件???????73728??2018-11-09?10:04??csCallCplus\.vs\csCallCplus\v14\.suo
?????目錄???????????0??2018-11-09?09:58??csCallCplus\DllTest\
?????文件?????????702??2018-10-18?16:45??csCallCplus\DllTest\DllTest.cpp
?????文件????????5887??2018-09-13?15:35??csCallCplus\DllTest\DllTest.vcxproj
?????文件?????????948??2018-09-12?11:07??csCallCplus\DllTest\DllTest.vcxproj.filters
?????目錄???????????0??2018-11-09?09:58??csCallCplus\DllTest\x64\
?????目錄???????????0??2018-11-09?09:58??csCallCplus\DllTest\x64\Debug\
?????文件????????1496??2018-10-18?16:45??csCallCplus\DllTest\x64\Debug\DllTest.Build.CppClean.log
?????文件????????1095??2018-10-18?16:45??csCallCplus\DllTest\x64\Debug\DllTest.log
?????文件??????136073??2018-10-18?16:45??csCallCplus\DllTest\x64\Debug\DllTest.obj
?????目錄???????????0??2018-11-09?09:58??csCallCplus\DllTest\x64\Debug\DllTest.tlog\
?????文件?????????526??2018-10-18?16:45??csCallCplus\DllTest\x64\Debug\DllTest.tlog\CL.command.1.tlog
?????文件???????39038??2018-10-18?16:45??csCallCplus\DllTest\x64\Debug\DllTest.tlog\CL.read.1.tlog
?????文件?????????488??2018-10-18?16:45??csCallCplus\DllTest\x64\Debug\DllTest.tlog\CL.write.1.tlog
?????文件?????????209??2018-10-18?16:45??csCallCplus\DllTest\x64\Debug\DllTest.tlog\DllTest.lastbuildstate
?????文件????????1458??2018-10-18?16:45??csCallCplus\DllTest\x64\Debug\DllTest.tlog\li
?????文件????????3476??2018-10-18?16:45??csCallCplus\DllTest\x64\Debug\DllTest.tlog\li
?????文件?????????578??2018-10-18?16:45??csCallCplus\DllTest\x64\Debug\DllTest.tlog\li
?????文件?????????672??2018-11-09?09:57??csCallCplus\DllTest\x64\Debug\DllTest.vcxprojResolveAssemblyReference.cache
?????文件?????1100800??2018-10-18?16:45??csCallCplus\DllTest\x64\Debug\vc140.idb
?????文件?????1183744??2018-10-18?16:45??csCallCplus\DllTest\x64\Debug\vc140.pdb
?????目錄???????????0??2018-11-09?09:58??csCallCplus\DllTest\x64\Release\
?????文件????????1048??2018-09-13?14:05??csCallCplus\DllTest\x64\Release\DllTest.Build.CppClean.log
?????文件????????1233??2018-09-13?14:05??csCallCplus\DllTest\x64\Release\DllTest.log
?????文件?????1840239??2018-09-13?14:05??csCallCplus\DllTest\x64\Release\DllTest.obj
?????目錄???????????0??2018-11-09?09:58??csCallCplus\DllTest\x64\Release\DllTest.tlog\
?????文件?????????546??2018-09-13?14:05??csCallCplus\DllTest\x64\Release\DllTest.tlog\CL.command.1.tlog
............此處省略219個文件信息
- 上一篇:明解C語言入門與中級篇.rar
- 下一篇:利用二叉樹結構實現赫夫曼編/解碼器。
評論
共有 條評論