头文件:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include
#include “Halcon.h”
#include “HalconCpp.h”
#include
#include
using namespace HalconCpp;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
HObject ho_Image, ho_Region;
HTuple hv_windowID,hv_AcqHandle;
Hlong widid;
~MainWindow();
private slots:
void on_readImage_clicked();
void on_ImageProcess_clicked();
void on_Imagecapture_clicked();
void on_Imagecapture1_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
.cpp文件
#include “mainwindow.h”
#include “ui_mainwindow.h”
#include
#include
#include “Halcon.h”
#include “HalconCpp.h”
#include
#include
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->pushButton1,SIGNAL(pressed()),this,SLOT(on_readImage_clicked()));
connect(ui->pushButton2,SIGNAL(pressed()),this,SLOT(on_ImageProcess_clicked()));
connect(ui->pushButton3,SIGNAL(pressed()),this,SLOT(on_Imagecapture_clicked()));
connect(ui->pushButton4,SIGNAL(pressed()),this,SLOT(on_Imagecapture1_clicked()));
}
MainWindow::~MainWindow()
{
delete ui;
}
//这里打开的图像路径不能够有中文
void MainWindow::on_readImage_clicked()
{
}
//图像处理
void MainWindow::on_ImageProcess_clicked()
{
}
//相机实时拍摄图像
void MainWindow::on_Imagecapture_clicked()
{
OpenFramegrabber(“USB3Vision”, 0, 0, 0, 0, 0, 0, “progressive”, -1, “default”,
-1, “false”, “default”, “2BDF07914029_U3V_LBASU313170M”, 0, -1, &hv_AcqHandle);
widid = (Hlong) this->winId();
//在openwindow前先抓取一帧图片
GrabImage(&ho_Image, hv_AcqHandle);
OpenWindow(ui->widget1->y(),ui->widget1->x(),ui->widget1->width(),ui->widget1->height(),widid,"","",&hv_windowID);
HDevWindowStack::Push(hv_windowID);
while(0 != 1)
{
GrabImage(&ho_Image, hv_AcqHandle);
if (HDevWindowStack::IsOpen())
DispObj(ho_Image, HDevWindowStack::GetActive());
WaitSeconds(0.1);
// WriteImage(ho_Image, “tiff”, 0, “D:/Picture/cameraCapture_real/1.png”);
}
CloseFramegrabber(hv_AcqHandle);
}
//相机实时拍摄图像1
void MainWindow::on_Imagecapture1_clicked()
{
}