-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrackswitch.cpp
More file actions
76 lines (70 loc) · 2.1 KB
/
trackswitch.cpp
File metadata and controls
76 lines (70 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*界面部分*/
#include "trackswitch.h"
#include "ui_trackswitch.h"
#include "QMainWindow"
#include "QMessageBox"
#include "QDir"
#include "QFileDialog"
#include "switch_detect.h"
using namespace cv;
using namespace std;
QString path;
TrackSwitch::TrackSwitch(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::TrackSwitch)
{
ui->setupUi(this);
}
TrackSwitch::~TrackSwitch()
{
delete ui;
}
void TrackSwitch::on_toolButton_clicked()
{
path = QFileDialog::getOpenFileName(this, tr("选择图片"), "/Users/hhzjj/Code/C:C++/Clion/TrackSwitch/image", tr("JPEG Files(*.jpg)"));
QString StrWidth,StrHeigth;
QImage* img = new QImage;
QImage* scaledimg = new QImage;
img->load(path);
if (!path.isEmpty())
{
ui->comboBox->addItem(path);
int Owidth=img->width();
int Oheight=img->height();
int Fwidth,Fheight; //缩放后的图片大小
int Mul; //记录图片与label大小的比例,用于缩放图片
if(Owidth/241>=Oheight/300)
Mul=Owidth/241;
else
Mul=Oheight/300;
Fwidth=Owidth/Mul;
Fheight=Oheight/Mul;
*scaledimg=img->scaled(Fwidth,Fheight,Qt::KeepAspectRatio);
ui->label_3->setPixmap(QPixmap::fromImage(*scaledimg));
}
else {
QMessageBox::warning(this, tr("选择图片"), tr("您没有选择图片!"));
}
}
void TrackSwitch::on_pushButton_clicked()
{
string spath;
spath = string((const char *)path.toLocal8Bit());
LSD(spath);
int is_ballas = 0, is_switch = 0;
is_ballas = have_ballas();
is_switch = select();
if(is_switch == 1 && is_ballas == 1)
ui->label_4->setText(tr("该场景为有砟道岔场景!"));
else if (is_switch == 1 && is_ballas == 0) {
ui->label_4->setText(tr("该场景为无砟道岔场景!"));
}
else if (is_switch == 0 && is_ballas == 1) {
ui->label_4->setText(tr("该场景为有砟单轨场景!"));
}
else if(is_switch == 0 && is_ballas == 0)
{
ui->label_4->setText(tr("该场景为无砟单轨场景!"));
}
clear_arrays();
}