QT显示调用C++编译的dll
//定义函数指针:
typedef cv::Mat(*Fun)(std::string); //定义函数指针,以备调用
.
.
.
.
void ImageMaster_Pro::Img_stich()
{
QString imgpath = QFileDialog::getExistingDirectory(this, "待拼接影像文件夹", "./", QFileDialog::ShowDirsOnly);
QLibrary mylib("ImgStiching_dll.dll"); //声明所用到的dll文件
if (imgpath.isEmpty())
{
return;
}
else
{
cv::Mat result;
if (mylib.load()) //判断是否正确加载
{
Fun open = (Fun)mylib.resolve("ImgStich"); //援引 add() 函数
if (open) //是否成功连接上 add() 函数
{
result = open(imgpath.toStdString());
QImage outimg;
QString savepath = "1.jpg";
cv::imwrite(savepath.toStdString(), result);
outimg.load(savepath);
ShowImage(outimg, true);
}
else
QMessageBox::information(NULL, "NO", "Linke to Function is not OK!!!!");
}
}
}