C++ e“mysecondqtproject.h” #包括“showerrordialog.h” #包括 #包括“objectdetect.h” MySecondQtProject::MySecondQtProject(QWidget*parent) :QDialog(父级) { ui.setupUi(这个); } MySecondQtProject::~MySecondQtProject() { } void MySecondQtProject::在\u pushImage\u clicked()上 { 形象= QFileDialog::getOpenFileName(this,tr(“打开文件”),“C:/Users/mankum93/Documents/Visual Studio 2013/Projects/BananaClassifiedRopencv/BananaClassifiedRopencv”, “图像(*.png*.xpm*.jpg)”; } void MySecondQtProject::在单击时 { 分级机= QFileDialog::getOpenFileName(this,tr(“打开文件”),“C:/Users/mankum93/Documents/Visual Studio 2013/Projects/BananaClassifiedRopencv/BananaClassifiedRopencv”, “XML文件(*.XML)”); } void MySecondQtProject::在点击确定时() { 接受(); //现在让我们比较任何字符串的无效性: if(image.isNull()| | classifier.isNull()) { 打开对话框(此); dialog.exec(); } 其他的 { //将Qstring转换为std::string 字符串imageFileName=image.toLocal8Bit().constData(); 字符串cascadeFileName=分类器.toLocal8Bit().constData(); //现在,我们可以转到主检测逻辑 detectObject(图像文件名、级联文件名); } }
编辑3:以下是您可能想要查看的其他有用文件C++ e“mysecondqtproject.h” #包括“showerrordialog.h” #包括 #包括“objectdetect.h” MySecondQtProject::MySecondQtProject(QWidget*parent) :QDialog(父级) { ui.setupUi(这个); } MySecondQtProject::~MySecondQtProject() { } void MySecondQtProject::在\u pushImage\u clicked()上 { 形象= QFileDialog::getOpenFileName(this,tr(“打开文件”),“C:/Users/mankum93/Documents/Visual Studio 2013/Projects/BananaClassifiedRopencv/BananaClassifiedRopencv”, “图像(*.png*.xpm*.jpg)”; } void MySecondQtProject::在单击时 { 分级机= QFileDialog::getOpenFileName(this,tr(“打开文件”),“C:/Users/mankum93/Documents/Visual Studio 2013/Projects/BananaClassifiedRopencv/BananaClassifiedRopencv”, “XML文件(*.XML)”); } void MySecondQtProject::在点击确定时() { 接受(); //现在让我们比较任何字符串的无效性: if(image.isNull()| | classifier.isNull()) { 打开对话框(此); dialog.exec(); } 其他的 { //将Qstring转换为std::string 字符串imageFileName=image.toLocal8Bit().constData(); 字符串cascadeFileName=分类器.toLocal8Bit().constData(); //现在,我们可以转到主检测逻辑 detectObject(图像文件名、级联文件名); } },c++,qt,dialog,C++,Qt,Dialog,编辑3:以下是您可能想要查看的其他有用文件 /******************************************************************************** ** Form generated from reading UI file 'mysecondqtproject.ui' ** ** Created by: Qt User Interface Compiler version 5.4.1 ** ** WARNING! All change
/********************************************************************************
** Form generated from reading UI file 'mysecondqtproject.ui'
**
** Created by: Qt User Interface Compiler version 5.4.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MYSECONDQTPROJECT_H
#define UI_MYSECONDQTPROJECT_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QDialog>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MySecondQtProjectClass
{
public:
QPushButton *pushOK;
QWidget *layoutWidget;
QVBoxLayout *verticalLayout;
QPushButton *pushImage;
QPushButton *pushClassifier;
void setupUi(QDialog *MySecondQtProjectClass)
{
if (MySecondQtProjectClass->objectName().isEmpty())
MySecondQtProjectClass->setObjectName(QStringLiteral("MySecondQtProjectClass"));
MySecondQtProjectClass->resize(600, 272);
pushOK = new QPushButton(MySecondQtProjectClass);
pushOK->setObjectName(QStringLiteral("pushOK"));
pushOK->setGeometry(QRect(290, 220, 91, 31));
layoutWidget = new QWidget(MySecondQtProjectClass);
layoutWidget->setObjectName(QStringLiteral("layoutWidget"));
layoutWidget->setGeometry(QRect(200, 100, 181, 91));
verticalLayout = new QVBoxLayout(layoutWidget);
verticalLayout->setSpacing(6);
verticalLayout->setContentsMargins(11, 11, 11, 11);
verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
verticalLayout->setContentsMargins(0, 0, 0, 0);
pushImage = new QPushButton(layoutWidget);
pushImage->setObjectName(QStringLiteral("pushImage"));
verticalLayout->addWidget(pushImage);
pushClassifier = new QPushButton(layoutWidget);
pushClassifier->setObjectName(QStringLiteral("pushClassifier"));
verticalLayout->addWidget(pushClassifier);
retranslateUi(MySecondQtProjectClass);
QObject::connect(pushImage, SIGNAL(clicked()), MySecondQtProjectClass, SLOT(on_pushImage_clicked()));
QObject::connect(pushClassifier, SIGNAL(clicked()), MySecondQtProjectClass, SLOT(on_pushClassifier_clicked()));
QObject::connect(pushOK, SIGNAL(clicked()), MySecondQtProjectClass, SLOT(on_pushOK_clicked()));
QMetaObject::connectSlotsByName(MySecondQtProjectClass);
} // setupUi
void retranslateUi(QDialog *MySecondQtProjectClass)
{
MySecondQtProjectClass->setWindowTitle(QApplication::translate("MySecondQtProjectClass", "MySecondQtProject", 0));
pushOK->setText(QApplication::translate("MySecondQtProjectClass", "OK", 0));
pushImage->setText(QApplication::translate("MySecondQtProjectClass", "Browse for the Image", 0));
pushClassifier->setText(QApplication::translate("MySecondQtProjectClass", "Browse for the classifier", 0));
} // retranslateUi
};
namespace Ui {
class MySecondQtProjectClass: public Ui_MySecondQtProjectClass {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MYSECONDQTPROJECT_H
/********************************************************************************
**从读取UI文件“mysecondqtproject.UI”生成的表单
**
**创建人:Qt用户界面编译器版本5.4.1
**
**警告!重新编译UI文件时,此文件中所做的所有更改都将丢失!
********************************************************************************/
#ifndef UI_MYSECONDQTPROJECT_H
#定义UI_MYSECONDQTPROJECT_H
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
QT_开始名称空间
类Ui_MySecondQtProjectClass
{
公众:
QPushButton*pushOK;
QWidget*layoutWidget;
QVBoxLayout*垂直布局;
QPushButton*按钮图像;
QPushButton*按钮分类器;
无效设置UI(QDialog*MySecondQtProjectClass)
{
如果(MySecondQtProjectClass->objectName().isEmpty())
MySecondQtProjectClass->setObjectName(QStringLiteral(“MySecondQtProjectClass”);
MySecondQtProjectClass->调整大小(600272);
pushOK=新的QPushButton(MySecondQtProjectClass);
pushOK->setObjectName(QStringLiteral(“pushOK”);
pushOK->setGeometry(QRect(290、220、91、31));
layoutWidget=新的QWidget(MySecondQtProjectClass);
layoutWidget->setObjectName(QStringLiteral(“layoutWidget”);
layoutWidget->setGeometry(QRect(20010018191));
verticalLayout=新的QVBoxLayout(layoutWidget);
垂直布局->设置间距(6);
垂直布局->设置内容边缘(11,11,11,11);
verticalLayout->setObjectName(QStringLiteral(“verticalLayout”);
垂直布局->设置内容边缘(0,0,0,0);
pushImage=新的QPushButton(layoutWidget);
pushImage->setObjectName(QStringLiteral(“pushImage”);
垂直布局->添加小部件(pushImage);
pushClassifier=新的QPushButton(layoutWidget);
pushClassifier->setObjectName(QStringLiteral(“pushClassifier”);
垂直布局->添加小部件(pushClassifier);
重新翻译(MySecondQtProjectClass);
QObject::connect(pushImage,信号(单击()),MySecondQtProjectClass,插槽(在pushImage上单击());
连接(pushClassifier,SIGNAL(clicked()),MySecondQtProjectClass,SLOT(在pushClassifier上单击());
QObject::connect(点击OK,信号(点击()),MySecondQtProjectClass,插槽(点击OK,点击());
QMetaObject::connectSlotsByName(MySecondQtProjectClass);
}//setupUi
无效重新传输(QDialog*MySecondQtProjectClass)
{
MySecondQtProjectClass->setWindowTitle(QApplication::translate(“MySecondQtProjectClass”,“MySecondQtProject”,0));
pushOK->setText(QApplication::translate(“MySecondQtProjectClass”,“OK”,0));
pushImage->setText(QApplication::translate(“MySecondQtProjectClass”,“浏览图像”,0));
pushClassifier->setText(QApplication::translate(“MySecondQtProjectClass”,“浏览分类器”,0));
}//重新翻译
};
名称空间用户界面{
类MySecondQtProjectClass:public Ui_MySecondQtProjectClass{};
}//名称空间用户界面
QT_END_名称空间
#endif//UI\u mysecondqt项目
第二个:/********************************************************************************
** Form generated from reading UI file 'showerrordialog.ui'
**
** Created by: Qt User Interface Compiler version 5.4.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_SHOWERRORDIALOG_H
#define UI_SHOWERRORDIALOG_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QDialog>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
QT_BEGIN_NAMESPACE
class Ui_ShowErrorDialog
{
public:
QLabel *label;
void setupUi(QDialog *ShowErrorDialog)
{
if (ShowErrorDialog->objectName().isEmpty())
ShowErrorDialog->setObjectName(QStringLiteral("ShowErrorDialog"));
ShowErrorDialog->resize(400, 65);
label = new QLabel(ShowErrorDialog);
label->setObjectName(QStringLiteral("label"));
label->setGeometry(QRect(70, 20, 241, 21));
retranslateUi(ShowErrorDialog);
QMetaObject::connectSlotsByName(ShowErrorDialog);
} // setupUi
void retranslateUi(QDialog *ShowErrorDialog)
{
ShowErrorDialog->setWindowTitle(QApplication::translate("ShowErrorDialog", "ShowErrorDialog", 0));
label->setText(QApplication::translate("ShowErrorDialog", "Please properly select the Image or the classifier", 0));
} // retranslateUi
};
namespace Ui {
class ShowErrorDialog: public Ui_ShowErrorDialog {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_SHOWERRORDIALOG_H
/********************************************************************************
**从读取UI文件'showerrordialog.UI'生成的表单
**
**创建人:Qt用户界面编译器版本5.4.1
**
**警告!重新编译UI文件时,此文件中所做的所有更改都将丢失!
********************************************************************************/
#ifndef用户界面
#定义用户界面对话框
#包括
#包括
#包括
#包括
#包括
#包括
#包括
QT_开始名称空间
类Ui\u对话框
{
公众:
QLabel*标签;
无效设置UI(QDialog*对话框)
{
如果(对话框->对象名().isEmpty())
淋浴对话框->设置对象名称(QStringLiteral(“淋浴对话框”);
对话框->调整大小(400,65);
标签=新的QLabel(对话框);
标签->设置对象名(QStringLiteral(“标签”);
标签->设置几何(QRect(70,20,241,21));
重译(对话);
QMetaObject::connectSlotsByName(对话框);
}//setupUi
无效重新传输(QDialog*对话框)
{
淋浴对话框->设置窗口标题(QApplication::translate(“淋浴对话框”,“淋浴对话框”,0));
label->setText(QApplication::translate(“对话框”,“请正确选择图像或分类器”,0));
}//重新翻译
};
名称空间用户界面{
类淋浴器对话框:公共Ui\u淋浴器对话框
/********************************************************************************
** Form generated from reading UI file 'mysecondqtprojectHp7256.ui'
**
** Created by: Qt User Interface Compiler version 5.4.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef MYSECONDQTPROJECTHP7256_H
#define MYSECONDQTPROJECTHP7256_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QDialog>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MySecondQtProjectClass
{
public:
QPushButton *pushOK;
QWidget *layoutWidget;
QVBoxLayout *verticalLayout;
QPushButton *pushImage;
QPushButton *pushClassifier;
void setupUi(QDialog *MySecondQtProjectClass)
{
if (MySecondQtProjectClass->objectName().isEmpty())
MySecondQtProjectClass->setObjectName(QStringLiteral("MySecondQtProjectClass"));
MySecondQtProjectClass->resize(600, 272);
pushOK = new QPushButton(MySecondQtProjectClass);
pushOK->setObjectName(QStringLiteral("pushOK"));
pushOK->setGeometry(QRect(290, 220, 91, 31));
layoutWidget = new QWidget(MySecondQtProjectClass);
layoutWidget->setObjectName(QStringLiteral("layoutWidget"));
layoutWidget->setGeometry(QRect(200, 100, 181, 91));
verticalLayout = new QVBoxLayout(layoutWidget);
verticalLayout->setSpacing(6);
verticalLayout->setContentsMargins(11, 11, 11, 11);
verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
verticalLayout->setContentsMargins(0, 0, 0, 0);
pushImage = new QPushButton(layoutWidget);
pushImage->setObjectName(QStringLiteral("pushImage"));
verticalLayout->addWidget(pushImage);
pushClassifier = new QPushButton(layoutWidget);
pushClassifier->setObjectName(QStringLiteral("pushClassifier"));
verticalLayout->addWidget(pushClassifier);
retranslateUi(MySecondQtProjectClass);
QObject::connect(pushImage, SIGNAL(clicked()), MySecondQtProjectClass, SLOT(on_pushImage_clicked()));
QObject::connect(pushClassifier, SIGNAL(clicked()), MySecondQtProjectClass, SLOT(on_pushClassifier_clicked()));
QObject::connect(pushOK, SIGNAL(clicked()), MySecondQtProjectClass, SLOT(on_pushOK_clicked()));
QMetaObject::connectSlotsByName(MySecondQtProjectClass);
} // setupUi
void retranslateUi(QDialog *MySecondQtProjectClass)
{
MySecondQtProjectClass->setWindowTitle(QApplication::translate("MySecondQtProjectClass", "MySecondQtProject", 0));
pushOK->setText(QApplication::translate("MySecondQtProjectClass", "OK", 0));
pushImage->setText(QApplication::translate("MySecondQtProjectClass", "Browse for the Image", 0));
pushClassifier->setText(QApplication::translate("MySecondQtProjectClass", "Browse for the classifier", 0));
} // retranslateUi
};
namespace Ui {
class MySecondQtProjectClass: public Ui_MySecondQtProjectClass {};
} // namespace Ui
QT_END_NAMESPACE
#endif // MYSECONDQTPROJECTHP7256_H
/********************************************************************************
** Form generated from reading UI file 'showerrordialogmU7256.ui'
**
** Created by: Qt User Interface Compiler version 5.4.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef SHOWERRORDIALOGMU7256_H
#define SHOWERRORDIALOGMU7256_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QDialog>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
QT_BEGIN_NAMESPACE
class Ui_ShowErrorDialog
{
public:
QLabel *label;
void setupUi(QDialog *ShowErrorDialog)
{
if (ShowErrorDialog->objectName().isEmpty())
ShowErrorDialog->setObjectName(QStringLiteral("ShowErrorDialog"));
ShowErrorDialog->resize(400, 65);
label = new QLabel(ShowErrorDialog);
label->setObjectName(QStringLiteral("label"));
label->setGeometry(QRect(70, 20, 241, 21));
retranslateUi(ShowErrorDialog);
QMetaObject::connectSlotsByName(ShowErrorDialog);
} // setupUi
void retranslateUi(QDialog *ShowErrorDialog)
{
ShowErrorDialog->setWindowTitle(QApplication::translate("ShowErrorDialog", "ShowErrorDialog", 0));
label->setText(QApplication::translate("ShowErrorDialog", "Please properly select the Image or the classifier", 0));
} // retranslateUi
};
namespace Ui {
class ShowErrorDialog: public Ui_ShowErrorDialog {};
} // namespace Ui
QT_END_NAMESPACE
#endif // SHOWERRORDIALOGMU7256_H
#include "mysecondqtproject.h"
#include "showerrordialog.h"
#include <QFileDialog>
#include "objectdetect.h"
MySecondQtProject::MySecondQtProject(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
}
MySecondQtProject::~MySecondQtProject()
{
}
void MySecondQtProject::on_pushImage_clicked()
{
image =
QFileDialog::getOpenFileName(this, tr("open file"), "C:/Users/mankum93/Documents/Visual Studio 2013/Projects/BananaClassifierOpenCV/BananaClassifierOpenCV",
"Images (*.png *.xpm *.jpg)");
}
void MySecondQtProject::on_pushClassifier_clicked()
{
classifier =
QFileDialog::getOpenFileName(this, tr("open file"), "C:/Users/mankum93/Documents/Visual Studio 2013/Projects/BananaClassifierOpenCV/BananaClassifierOpenCV",
"XML files (*.xml)");
}
void MySecondQtProject::on_pushOK_clicked()
{
accept();
//Now lets compare for invalidity of any string:
if (image.isNull() || classifier.isNull())
{
ShowErrorDialog dialog(this);
dialog.exec();
}
else
{
//Convert Qstring to std::string
String imageFileName = image.toLocal8Bit().constData();
String cascadeFileName = classifier.toLocal8Bit().constData();
// Now, we can go to main detection logic
detectObject(imageFileName, cascadeFileName);
}
}
/********************************************************************************
** Form generated from reading UI file 'mysecondqtproject.ui'
**
** Created by: Qt User Interface Compiler version 5.4.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MYSECONDQTPROJECT_H
#define UI_MYSECONDQTPROJECT_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QDialog>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MySecondQtProjectClass
{
public:
QPushButton *pushOK;
QWidget *layoutWidget;
QVBoxLayout *verticalLayout;
QPushButton *pushImage;
QPushButton *pushClassifier;
void setupUi(QDialog *MySecondQtProjectClass)
{
if (MySecondQtProjectClass->objectName().isEmpty())
MySecondQtProjectClass->setObjectName(QStringLiteral("MySecondQtProjectClass"));
MySecondQtProjectClass->resize(600, 272);
pushOK = new QPushButton(MySecondQtProjectClass);
pushOK->setObjectName(QStringLiteral("pushOK"));
pushOK->setGeometry(QRect(290, 220, 91, 31));
layoutWidget = new QWidget(MySecondQtProjectClass);
layoutWidget->setObjectName(QStringLiteral("layoutWidget"));
layoutWidget->setGeometry(QRect(200, 100, 181, 91));
verticalLayout = new QVBoxLayout(layoutWidget);
verticalLayout->setSpacing(6);
verticalLayout->setContentsMargins(11, 11, 11, 11);
verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
verticalLayout->setContentsMargins(0, 0, 0, 0);
pushImage = new QPushButton(layoutWidget);
pushImage->setObjectName(QStringLiteral("pushImage"));
verticalLayout->addWidget(pushImage);
pushClassifier = new QPushButton(layoutWidget);
pushClassifier->setObjectName(QStringLiteral("pushClassifier"));
verticalLayout->addWidget(pushClassifier);
retranslateUi(MySecondQtProjectClass);
QObject::connect(pushImage, SIGNAL(clicked()), MySecondQtProjectClass, SLOT(on_pushImage_clicked()));
QObject::connect(pushClassifier, SIGNAL(clicked()), MySecondQtProjectClass, SLOT(on_pushClassifier_clicked()));
QObject::connect(pushOK, SIGNAL(clicked()), MySecondQtProjectClass, SLOT(on_pushOK_clicked()));
QMetaObject::connectSlotsByName(MySecondQtProjectClass);
} // setupUi
void retranslateUi(QDialog *MySecondQtProjectClass)
{
MySecondQtProjectClass->setWindowTitle(QApplication::translate("MySecondQtProjectClass", "MySecondQtProject", 0));
pushOK->setText(QApplication::translate("MySecondQtProjectClass", "OK", 0));
pushImage->setText(QApplication::translate("MySecondQtProjectClass", "Browse for the Image", 0));
pushClassifier->setText(QApplication::translate("MySecondQtProjectClass", "Browse for the classifier", 0));
} // retranslateUi
};
namespace Ui {
class MySecondQtProjectClass: public Ui_MySecondQtProjectClass {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MYSECONDQTPROJECT_H
/********************************************************************************
** Form generated from reading UI file 'showerrordialog.ui'
**
** Created by: Qt User Interface Compiler version 5.4.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_SHOWERRORDIALOG_H
#define UI_SHOWERRORDIALOG_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QDialog>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
QT_BEGIN_NAMESPACE
class Ui_ShowErrorDialog
{
public:
QLabel *label;
void setupUi(QDialog *ShowErrorDialog)
{
if (ShowErrorDialog->objectName().isEmpty())
ShowErrorDialog->setObjectName(QStringLiteral("ShowErrorDialog"));
ShowErrorDialog->resize(400, 65);
label = new QLabel(ShowErrorDialog);
label->setObjectName(QStringLiteral("label"));
label->setGeometry(QRect(70, 20, 241, 21));
retranslateUi(ShowErrorDialog);
QMetaObject::connectSlotsByName(ShowErrorDialog);
} // setupUi
void retranslateUi(QDialog *ShowErrorDialog)
{
ShowErrorDialog->setWindowTitle(QApplication::translate("ShowErrorDialog", "ShowErrorDialog", 0));
label->setText(QApplication::translate("ShowErrorDialog", "Please properly select the Image or the classifier", 0));
} // retranslateUi
};
namespace Ui {
class ShowErrorDialog: public Ui_ShowErrorDialog {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_SHOWERRORDIALOG_H