同意
pull/43/head
pvqf6mep3 2 years ago
commit 182b92fb7d

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 KiB

@ -41,6 +41,10 @@ public:
//void subImage(); //void subImage();
QImage image; QImage image;
bool issaveImage = false;
void setissaveImageTrue();
void setissaveImageFalse();
Q_SIGNALS: Q_SIGNALS:
void speed_x(double x); void speed_x(double x);
@ -80,6 +84,8 @@ private:
QImage Mat2QImage(cv::Mat const &src); QImage Mat2QImage(cv::Mat const &src);
cv::Mat QImage2Mat(QImage &image); cv::Mat QImage2Mat(QImage &image);
}; };
#endif #endif

@ -1,7 +1,7 @@
#include "../include/Air_Ground_CEC/atr.h" #include "../include/Air_Ground_CEC/atr.h"
using namespace std; using namespace std;
#include "stdlib.h" #include "stdlib.h"
char filename[100];
ATR::ATR() ATR::ATR()
{ {
@ -10,7 +10,7 @@ ATR::ATR()
void ATR::runCommand(){ void ATR::runCommand(){
string ws = "cd /home/cyber/Study/Codes/catkin_ws/src/Air_Ground_CEC/src/YOLOv6"; 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 CMD = "python3 ../YOLOv6/tools/infer.py --weights ../YOLOv6/yolov6n.pt --source ../YOLOv6/imgdir/";
string Pic = "x.jpg"; string Pic = "test.jpg";
string Command = ws + "&&" + CMD + Pic; string Command = ws + "&&" + CMD + Pic;
std::cout<<Command<<endl; std::cout<<Command<<endl;
system(Command.c_str()); system(Command.c_str());
@ -18,10 +18,8 @@ void ATR::runCommand(){
void ATR::getSolvedPic(){ void ATR::getSolvedPic(){
string Path = "/home/cyber/Study/Codes/catkin_ws/src/Air_Ground_CEC/src/YOLOv6/runs/inference/exp/"; string Path = "/home/cyber/Study/Codes/catkin_ws/src/Air_Ground_CEC/src/YOLOv6/runs/inference/exp/";
string SolvedPicPath = Path + "x.jpg"; string SolvedPicPath = Path + "test.jpg";
sprintf(filename, SolvedPicPath.c_str()); QImage image = QImage(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; std::cout<<"image"<<endl;
emit show_solvedImage(image); emit show_solvedImage(image);
} }

@ -210,8 +210,14 @@ void MainWindow::connections(){
} }
void MainWindow::slot_get_slovedImage(){ void MainWindow::slot_get_slovedImage(){
qnode.setissaveImageTrue();
while(true){
if(qnode.issaveImage == false){
atr.runCommand(); atr.runCommand();
atr.getSolvedPic(); atr.getSolvedPic();
break;
}
}
} }
void MainWindow::slot_speed_x(double x) { void MainWindow::slot_speed_x(double x) {
@ -260,14 +266,20 @@ void MainWindow::slot_show_image(const QImage& image)
{ {
//qimage_mutex_.lock(); //qimage_mutex_.lock();
//qimage_ = image.copy(); //qimage_ = image.copy();
ui->label_camera->setScaledContents(true);
ui->label_camera->setPixmap(QPixmap::fromImage(image)); ui->label_camera->setPixmap(QPixmap::fromImage(image));
ui->label_camera->resize(ui->label_camera->pixmap()->size()); ui->label_camera->resize(ui->label_camera->pixmap()->size());
//qimage_mutex_.unlock(); //qimage_mutex_.unlock();
} }
void MainWindow::slot_show_solvedImage(const QImage& solvedImage){ void MainWindow::slot_show_solvedImage(const QImage& solvedImage){
ui->label_2->setScaledContents(true);
ui->label_2->setPixmap(QPixmap::fromImage(solvedImage)); ui->label_2->setPixmap(QPixmap::fromImage(solvedImage));
ui->label_2->resize(ui->label_2->pixmap()->size()); ui->label_2->resize(ui->label_2->pixmap()->size());
ui->solvedimage->setScaledContents(true);
ui->solvedimage->setPixmap(QPixmap::fromImage(solvedImage));
ui->solvedimage->resize(ui->solvedimage->pixmap()->size());
} }
void MainWindow::setBtnStyles(){ void MainWindow::setBtnStyles(){

@ -6,7 +6,7 @@
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
QNode::QNode(int argc, char **argv) : init_argc(argc), init_argv(argv){ QNode::QNode(int argc, char **argv) : init_argc(argc), init_argv(argv){
issaveImage = false;
} }
@ -34,6 +34,14 @@ bool QNode::init() {
return true; return true;
} }
void QNode::setissaveImageTrue(){
issaveImage = true;
}
void QNode::setissaveImageFalse(){
issaveImage = false;
}
void QNode::SubAndPubTopic(){ void QNode::SubAndPubTopic(){
ros::NodeHandle n; ros::NodeHandle n;
@ -48,7 +56,7 @@ void QNode::SubAndPubTopic(){
&QNode::batteryCallback, this); &QNode::batteryCallback, this);
image_transport::ImageTransport it(n); image_transport::ImageTransport it(n);
//camera/rgb/image_raw //camera/rgb/image_raw raspicam_node/image
image_sub = it.subscribe("raspicam_node/image", 10, &QNode::imageCallback, this); image_sub = it.subscribe("raspicam_node/image", 10, &QNode::imageCallback, this);
//image_sub0 = n.subscribe("camera/rgb/image_raw",100,&QNode::imageCallback,this) //image_sub0 = n.subscribe("camera/rgb/image_raw",100,&QNode::imageCallback,this)
@ -179,7 +187,7 @@ void QNode::speedCallback(const nav_msgs::Odometry::ConstPtr& msg)
void QNode::imageCallback(const sensor_msgs::ImageConstPtr &msg) void QNode::imageCallback(const sensor_msgs::ImageConstPtr &msg)
{ {
ROS_INFO("i am ok"); //ROS_INFO("i am ok");
try try
{ {
cv_bridge::CvImageConstPtr cv_ptr = cv_bridge::CvImageConstPtr cv_ptr =
@ -187,7 +195,12 @@ void QNode::imageCallback(const sensor_msgs::ImageConstPtr &msg)
cv::Mat img = cv_ptr->image; cv::Mat img = cv_ptr->image;
QImage image = QImage(img.data,img.cols,img.rows,img.step[0],QImage::Format_RGB888);//change to QImage format QImage image = QImage(img.data,img.cols,img.rows,img.step[0],QImage::Format_RGB888);//change to QImage format
//ROS_INFO("I'm setting picture in mul_t callback function!"); //ROS_INFO("I'm setting picture in mul_t callback function!");
//image.save("/home/jackyma/test.jpg"); if(issaveImage){
string path = "/home/cyber/Study/Codes/catkin_ws/src/Air_Ground_CEC/src/YOLOv6/imgdir/";
image.save((path + "test.jpg").c_str());
issaveImage = false;
}
emit show_image(image); emit show_image(image);
} }
catch (cv_bridge::Exception& e) catch (cv_bridge::Exception& e)

@ -203,7 +203,7 @@ 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>0</number> <number>2</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">
@ -211,10 +211,22 @@ margin:0px 0px 0px 0px;
<rect> <rect>
<x>240</x> <x>240</x>
<y>10</y> <y>10</y>
<width>851</width> <width>741</width>
<height>491</height> <height>511</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>741</width>
<height>511</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>741</width>
<height>511</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Main Widget</string> <string>Main Widget</string>
</property> </property>
@ -369,8 +381,8 @@ margin:0px 0px 0px 0px;
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>680</x> <x>690</x>
<y>10</y> <y>0</y>
<width>735</width> <width>735</width>
<height>750</height> <height>750</height>
</rect> </rect>
@ -574,8 +586,49 @@ QProgressBar::chunk
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_8"> <layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_8"> <layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QLabel" name="label_target_text">
<property name="font">
<font>
<pointsize>18</pointsize>
</font>
</property>
<property name="text">
<string>Target</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QLabel" name="solvedimage"> <widget class="QLabel" name="solvedimage">
<property name="minimumSize"> <property name="minimumSize">
@ -584,8 +637,14 @@ QProgressBar::chunk
<height>200</height> <height>200</height>
</size> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>270</width>
<height>200</height>
</size>
</property>
<property name="text"> <property name="text">
<string>target</string> <string>SolvedImage</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -594,6 +653,9 @@ QProgressBar::chunk
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
@ -641,27 +703,27 @@ QProgressBar::chunk
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item> <item>
<spacer name="horizontalSpacer_13"> <spacer name="verticalSpacer_8">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>20</width>
<height>20</height> <height>40</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout>
</item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QStackedWidget" name="stackedWidget_ros_control"> <widget class="QStackedWidget" name="stackedWidget_ros_control">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</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">
@ -1268,10 +1330,10 @@ background-color: rgb(255,255,255);
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>21</x> <x>31</x>
<y>1</y> <y>1</y>
<width>660</width> <width>651</width>
<height>756</height> <height>751</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
@ -1283,40 +1345,39 @@ background-color: rgb(255,255,255);
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="title">
<string>Logging</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_camera">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>600</width> <width>0</width>
<height>270</height> <height>400</height>
</size> </size>
</property> </property>
<property name="text"> <property name="maximumSize">
<string>CameraLabel</string> <size>
<width>16777215</width>
<height>400</height>
</size>
</property> </property>
</widget> <property name="title">
</item> <string>Logging</string>
<item>
<widget class="QListView" name="view_logging_2">
<property name="enabled">
<bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_camera">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>600</width> <width>620</width>
<height>81</height> <height>360</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>620</width>
<height>81</height> <height>360</height>
</size> </size>
</property> </property>
<property name="text">
<string>CameraLabel</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -1334,6 +1395,12 @@ background-color: rgb(255,255,255);
<height>300</height> <height>300</height>
</size> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
</property> </property>
@ -1346,7 +1413,13 @@ background-color: rgb(255,255,255);
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>160</width> <width>160</width>
<height>30</height> <height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>160</width>
<height>29</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
@ -1372,7 +1445,13 @@ background-color: rgb(255,255,255);
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>60</width> <width>60</width>
<height>35</height> <height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>30</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
@ -1407,6 +1486,12 @@ background-color: rgb(255,255,255);
<height>300</height> <height>300</height>
</size> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
</property> </property>
@ -1422,6 +1507,12 @@ background-color: rgb(255,255,255);
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>160</width>
<height>30</height>
</size>
</property>
<property name="text"> <property name="text">
<string>x 轴线速度</string> <string>x 轴线速度</string>
</property> </property>
@ -1434,8 +1525,8 @@ background-color: rgb(255,255,255);
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>0</width>
<height>20</height> <height>30</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -1445,7 +1536,13 @@ background-color: rgb(255,255,255);
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>60</width> <width>60</width>
<height>35</height> <height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>30</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">

Loading…
Cancel
Save