vs下opencv的人脸检测以及qt下dll的封装调用(四、qt下测试dll)

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QLibrary>
#include "detectdll.h"
#include <QImage>
#include <mat2qimage.h>
#include <opencv.hpp>
#include <QLibrary>
#include <QDebug>
#include <QMessageBox>
#include <QPixmap>
#include <opencv2/opencv.hpp>
#include <QTimer>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}
MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::on_pushButton_clicked()
{
    typedef IplImage* (*Fun)(Mat, char*,String );
    char* path = "D:\\VStest\\face\\face1.jpg";
    Mat srcImage = imread("D:\\VStest\\face\\0a.jpg");
    String cascadeName = "D:\\qtTest\\build-test6-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug\\debug\\haarcascade_frontalface_alt.xml";

    QLibrary mylib("detectdll.dll");   //声明所用到的dll文件

    IplImage* imgdetect;
    if (mylib.load())              //判断是否正确加载
    {
        //      QMessageBox::information(NULL,"OK","DLL load is OK!");
        Fun open=(Fun)mylib.resolve("det");    //援引 add() 函数

        if (open)                  //是否成功连接上 add() 函数
        {
            //         QMessageBox::information(NULL,"OK","Link to Function is OK!");
            //         result=open(5,6);      //这里函数指针调用dll中的 add() 函数
            // result=open();
            imgdetect=open(srcImage, path, cascadeName);
            Mat detect = cvarrToMat(imgdetect);
            QImage detect1= Mat2QImage(detect);
            ui->label_1->setPixmap(QPixmap::fromImage(detect1));//将结果在label上显示
            ui->label_1->setScaledContents(true);//使图像尺寸与label大小匹配
        }
        else
            //        QMessageBox::information(NULL,"NO","Linke to Function is not OK!!!!");
            cout<<"dll fail"<<endl;
    }
    else
        //    QMessageBox::information(NULL,"NO","DLL is not loaded!");
        cout<<"dll fail"<<endl;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值