pull/39/head
JackyMa 3 years ago
parent b7ba593ee9
commit 333f28d634

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

@ -0,0 +1,29 @@
#ifndef ATR_H
#define ATR_H
#include <iostream>
#include <stdlib.h>
#include <QImage>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <cv_bridge/cv_bridge.h>
#include <QObject>
#include <QThread>
#include <QStringListModel>
#include <QSettings>
class ATR : public QThread{
Q_OBJECT
public:
ATR();
void runCommand();
void getSolvedPic();
cv::Mat SolvedImg;
Q_SIGNALS:
void show_solvedImage(QImage solvedImage);
};
#endif // ATR_H

@ -11,6 +11,7 @@
#include "qnode.hpp" #include "qnode.hpp"
#include "dashboard.h" #include "dashboard.h"
#include <sensor_msgs/BatteryState.h> #include <sensor_msgs/BatteryState.h>
#include "atr.h"
using namespace cv; using namespace cv;
namespace Ui { namespace Ui {
@ -49,7 +50,8 @@ public slots:
void Slider_linear_valueChanged(int v); void Slider_linear_valueChanged(int v);
void importFrame();//read video void importFrame();//read video
void slot_show_image(const QImage& image);//added void slot_show_image(const QImage& image);//added
void slot_show_solvedImage(const QImage& solvedImage);
void slot_get_slovedImage();
private slots: private slots:
void on_Stop_receive_clicked(); void on_Stop_receive_clicked();
@ -60,6 +62,7 @@ private slots:
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
QNode qnode; QNode qnode;
ATR atr;
JoyStick *rock_widget; JoyStick *rock_widget;
DashBoard *m_DashBoard_x; DashBoard *m_DashBoard_x;
DashBoard *m_DashBoard_th; DashBoard *m_DashBoard_th;

@ -0,0 +1,29 @@
#include "../include/Air_Ground_CEC/atr.h"
using namespace std;
#include "stdlib.h"
char filename[100];
ATR::ATR()
{
}
void ATR::runCommand(){
string ws = "cd /home/cyber/Study/Codes/catkin_ws/src/Air_Ground_CEC/src/YOLOv6";
string CMD = "python3 ../YOLOv6/tools/infer.py --weights ../YOLOv6/yolov6n.pt --source ../YOLOv6/imgdir/";
string Pic = "x.jpg";
string Command = ws + "&&" + CMD + Pic;
std::cout<<Command<<endl;
system(Command.c_str());
}
void ATR::getSolvedPic(){
string Path = "/home/cyber/Study/Codes/catkin_ws/src/Air_Ground_CEC/src/YOLOv6/runs/inference/exp/";
string SolvedPicPath = Path + "x.jpg";
sprintf(filename, SolvedPicPath.c_str());
SolvedImg = cv::imread(filename);
QImage image = QImage(SolvedImg.data,SolvedImg.cols,SolvedImg.rows,SolvedImg.step[0],QImage::Format_RGB888);
std::cout<<"image"<<endl;
emit show_solvedImage(image);
}

@ -186,6 +186,8 @@ void MainWindow::connections(){
connect(rock_widget, SIGNAL(keyNumchanged(int)), this, connect(rock_widget, SIGNAL(keyNumchanged(int)), this,
SLOT(slot_rockKeyChange(int))); SLOT(slot_rockKeyChange(int)));
connect(ui->getimage, SIGNAL(clicked()), this, SLOT(slot_get_slovedImage()));
//绑定slider的函数 //绑定slider的函数
connect(ui->horizontalSlider_raw, SIGNAL(valueChanged(int)), this, connect(ui->horizontalSlider_raw, SIGNAL(valueChanged(int)), this,
SLOT(Slider_raw_valueChanged(int))); SLOT(Slider_raw_valueChanged(int)));
@ -198,10 +200,17 @@ void MainWindow::connections(){
//电源的信号 //电源的信号
connect(&qnode, SIGNAL(batteryState(sensor_msgs::BatteryState)), this, connect(&qnode, SIGNAL(batteryState(sensor_msgs::BatteryState)), this,
SLOT(slot_batteryState(sensor_msgs::BatteryState))); SLOT(slot_batteryState(sensor_msgs::BatteryState)));
// image
connect(&qnode, SIGNAL(show_image(QImage)), this, SLOT(slot_show_image(QImage))); connect(&qnode, SIGNAL(show_image(QImage)), this, SLOT(slot_show_image(QImage)));
// solvedimage
connect(&atr, SIGNAL(show_solvedImage(QImage)), this, SLOT(slot_show_solvedImage(QImage)));
} }
void MainWindow::slot_get_slovedImage(){
atr.runCommand();
atr.getSolvedPic();
}
void MainWindow::slot_speed_x(double x) { void MainWindow::slot_speed_x(double x) {
m_DashBoard_x->set_speed(abs(x * 100)); m_DashBoard_x->set_speed(abs(x * 100));
@ -254,6 +263,10 @@ void MainWindow::slot_show_image(const QImage& image)
//qimage_mutex_.unlock(); //qimage_mutex_.unlock();
} }
void MainWindow::slot_show_solvedImage(const QImage& solvedImage){
ui->label_2->setPixmap(QPixmap::fromImage(solvedImage));
ui->label_2->resize(ui->label_2->pixmap()->size());
}
void MainWindow::setBtnStyles(){ void MainWindow::setBtnStyles(){
/* /*

@ -31,7 +31,6 @@ bool QNode::init() {
SubAndPubTopic(); SubAndPubTopic();
}); });
return true; return true;
} }

@ -203,16 +203,16 @@ margin:0px 0px 0px 0px;
<item row="0" column="0"> <item row="0" column="0">
<widget class="QStackedWidget" name="stackedWidget_main"> <widget class="QStackedWidget" name="stackedWidget_main">
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="mainWidget"> <widget class="QWidget" name="mainWidget">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>780</x> <x>240</x>
<y>200</y> <y>10</y>
<width>311</width> <width>851</width>
<height>151</height> <height>491</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
@ -564,7 +564,7 @@ QProgressBar::chunk
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_8"> <layout class="QVBoxLayout" name="verticalLayout_8">
<item> <item>
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="solvedimage">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>270</width> <width>270</width>
@ -572,7 +572,7 @@ QProgressBar::chunk
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>map</string> <string>target</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -590,15 +590,15 @@ QProgressBar::chunk
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_12"> <widget class="QPushButton" name="getimage">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>270</width> <width>180</width>
<height>200</height> <height>40</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>target</string> <string>PushButton</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -648,7 +648,7 @@ QProgressBar::chunk
<item> <item>
<widget class="QStackedWidget" name="stackedWidget_ros_control"> <widget class="QStackedWidget" name="stackedWidget_ros_control">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="keyboard_control"> <widget class="QWidget" name="keyboard_control">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">

Loading…
Cancel
Save