c# 版本 使用比较方便
[DllImport("D:/code/removal/x64/Release/removal.dll")]
public static extern void removal_far_point(string filein, string fileout, float leaf , int k_point, float r);
public Form1()
{
string filein = "C:/Users/12875/Desktop/数据/点云/1.pcd";
string fileout= "C:/Users/12875/Desktop/数据/点云/1_new.pcd";
removal_far_point(filein, fileout,1.0f,50,1.2f);
}
import 里面放动态库的地址,函数名要与动态库中函数名一致就可以使用
C++版本 调用麻烦一点,有两种版本,这里只有其一(定义和调用比较麻烦)
定义 myDLL.cpp
#include"myDLL.h"
#include <Windows.h>
HINSTANCE g_hCtrlInstance = NULL;
removal_point remval_point_fun = NULL;
bool LoadCtrl(char* strPath)
{
g_hCtrlInstance = LoadLibrary(strPath);
if (!g_hCtrlInstance)
{
return false;
}
remval_point_fun = (removal_point)GetProcAddress(g_hCtrlInstance, "removal_far_point");
return true;
}
myDLL.h
#pragma once
#include <iostream>
using namespace std;
typedef void(*removal_point)(char*,char*,float,int,float);
extern removal_point remval_point_fun ;
bool LoadCtrl(char* strPath);
使用 Main.cpp
#include "myDLL.h"
int main()
{
clock_t start = clock();
char filepcd[50] = "1.pcd";
char filepcd2[50] ="1_22.pcd";
char str[50] = "removal.dll";
if (LoadCtrl(str)) {
cout << "are you ok?" << endl;
}
remval_point_fun(filepcd, filepcd2,0.3,50,0.6);
}