添加单反相机控制看板
This commit is contained in:
@ -773,6 +773,10 @@ void HPPA::initControlTabwidget()
|
||||
m_depthCameraWindow = new DepthCameraWindow();
|
||||
ui.controlTabWidget->addTab(m_depthCameraWindow, QString::fromLocal8Bit("深度相机"));
|
||||
|
||||
//单反相机
|
||||
m_singleLensReflexCameraWindow = new SingleLensReflexCameraWindow();
|
||||
ui.controlTabWidget->addTab(m_singleLensReflexCameraWindow, QString::fromLocal8Bit("单反相机"));
|
||||
|
||||
//rgb相机
|
||||
m_rgbCameraControlWindow = new rgbCameraWindow();
|
||||
connect(m_rgbCameraControlWindow, &rgbCameraWindow::PlotRgbImageSignal, this, &HPPA::onPlotRgbImage);
|
||||
@ -1233,6 +1237,7 @@ void HPPA::createOneMotorScenario()
|
||||
ui.mAction_1AxisMotor->setChecked(true);
|
||||
|
||||
//右下角控制tab
|
||||
m_tabManager->hideTab(m_singleLensReflexCameraWindow);
|
||||
m_tabManager->hideTab(m_depthCameraWindow);
|
||||
m_tabManager->hideTab(m_rgbCameraControlWindow);
|
||||
m_tabManager->hideTab(m_adt);
|
||||
@ -1266,6 +1271,7 @@ void HPPA::createPlantPhenotypeScenario()
|
||||
m_tabManager->hideTab(m_omc);
|
||||
|
||||
m_tabManager->showTab(m_depthCameraWindow);
|
||||
m_tabManager->showTab(m_singleLensReflexCameraWindow);
|
||||
m_tabManager->showTab(m_rgbCameraControlWindow);
|
||||
m_tabManager->showTab(m_adt);
|
||||
m_tabManager->showTab(m_pc);
|
||||
|
||||
@ -79,6 +79,7 @@
|
||||
|
||||
#include "rgbCameraWindow.h"
|
||||
#include "DepthCameraWindow.h"
|
||||
#include "SingleLensReflexCameraWindow.h"
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
@ -281,6 +282,7 @@ private:
|
||||
rgbCameraWindow* m_rgbCameraControlWindow;
|
||||
ImageControl* m_ic;
|
||||
DepthCameraWindow* m_depthCameraWindow;
|
||||
SingleLensReflexCameraWindow* m_singleLensReflexCameraWindow;
|
||||
adjustTable* m_adt;
|
||||
PowerControl* m_pc;
|
||||
RobotArmControl* m_rac;
|
||||
|
||||
@ -151,6 +151,7 @@
|
||||
<ClCompile Include="rgbCameraWindow.cpp" />
|
||||
<ClCompile Include="RobotArmControl.cpp" />
|
||||
<ClCompile Include="setWindow.cpp" />
|
||||
<ClCompile Include="SingleLensReflexCameraWindow.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
@ -187,6 +188,7 @@
|
||||
<QtUic Include="rgbCamera.ui" />
|
||||
<QtUic Include="RobotArmControl.ui" />
|
||||
<QtUic Include="set.ui" />
|
||||
<QtUic Include="SingleLensReflexCamera.ui" />
|
||||
<QtUic Include="twoMotorControl.ui" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -239,6 +241,7 @@
|
||||
<QtMoc Include="recordFrameCounter.h" />
|
||||
<QtMoc Include="setWindow.h" />
|
||||
<QtMoc Include="rgbCameraWindow.h" />
|
||||
<QtMoc Include="SingleLensReflexCameraWindow.h" />
|
||||
<ClInclude Include="utility_tc.h" />
|
||||
<QtMoc Include="aboutWindow.h" />
|
||||
<ClInclude Include="hppaConfigFile.h" />
|
||||
|
||||
@ -217,6 +217,9 @@
|
||||
<ClCompile Include="DepthCameraWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SingleLensReflexCameraWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="fileOperation.h">
|
||||
@ -354,6 +357,9 @@
|
||||
<QtMoc Include="DepthCameraWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="SingleLensReflexCameraWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="imageProcessor.h">
|
||||
@ -448,6 +454,9 @@
|
||||
<QtUic Include="DepthCamera.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="SingleLensReflexCamera.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
|
||||
160
HPPA/SingleLensReflexCamera.ui
Normal file
160
HPPA/SingleLensReflexCamera.ui
Normal file
@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SingleLensReflexCameraClass</class>
|
||||
<widget class="QDialog" name="SingleLensReflexCameraClass">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>855</width>
|
||||
<height>481</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>SingleLensReflexCamera</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QGroupBox
|
||||
{
|
||||
border: 12px solid transparent;
|
||||
/*border-top: 12px solid transparent;
|
||||
border-right: 0px solid transparent;
|
||||
border-bottom: 0px solid transparent;
|
||||
border-left: 0px solid transparent;*/
|
||||
color: #ACCDFF;
|
||||
}
|
||||
|
||||
QPushButton
|
||||
{
|
||||
/*width: 172px;
|
||||
height: 56px;*/
|
||||
font: 19pt "新宋体";
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0.5, y1:0, x2:0.5, y2:1,
|
||||
stop:0 #283D86,
|
||||
stop:1 #0F1A40
|
||||
);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
QPushButton:hover
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #3A4875,
|
||||
stop:1 #5F6B91
|
||||
);
|
||||
}
|
||||
/* 按下时的效果 */
|
||||
QPushButton:pressed
|
||||
{
|
||||
background-color: qlineargradient(
|
||||
spread:pad,
|
||||
x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 #1A254F,
|
||||
stop:1 #3A466B
|
||||
);
|
||||
/* 可选:添加下压效果 */
|
||||
padding-top: 9px;
|
||||
padding-bottom: 7px;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>18</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>135</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="closeSLRCamera_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>关 闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="openSLRCamera_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打 开</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>135</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>18</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
95
HPPA/SingleLensReflexCameraWindow.cpp
Normal file
95
HPPA/SingleLensReflexCameraWindow.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
#include "SingleLensReflexCameraWindow.h"
|
||||
|
||||
SingleLensReflexCameraWindow::SingleLensReflexCameraWindow(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
m_SLRCameraThread = new QThread();
|
||||
m_SingleLensReflexCameraOperation = new SingleLensReflexCameraOperation();
|
||||
m_SingleLensReflexCameraOperation->moveToThread(m_SLRCameraThread);
|
||||
m_SLRCameraThread->start();
|
||||
|
||||
connect(ui.openSLRCamera_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::openSLRCamera);
|
||||
connect(ui.closeSLRCamera_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::closeSLRCamera);
|
||||
|
||||
connect(this, &SingleLensReflexCameraWindow::openSLRCameraSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::OpenSLRCamera);
|
||||
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamOpenedSignal, this, &SingleLensReflexCameraWindow::onCamOpened);
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamClosedSignal, this, &SingleLensReflexCameraWindow::onCamClosed);
|
||||
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::PlotSignal, this, &SingleLensReflexCameraWindow::PlotSLRImageSignal);
|
||||
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamClosedSignal, this, &SingleLensReflexCameraWindow::SLRCamClosedSignal);
|
||||
}
|
||||
|
||||
SingleLensReflexCameraWindow::~SingleLensReflexCameraWindow()
|
||||
{
|
||||
m_SLRCameraThread->quit();
|
||||
m_SLRCameraThread->wait();
|
||||
delete m_SingleLensReflexCameraOperation;
|
||||
m_SingleLensReflexCameraOperation = nullptr;
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::openSLRCamera()
|
||||
{
|
||||
if (!m_SingleLensReflexCameraOperation->getRecordStatus())
|
||||
{
|
||||
emit openSLRCameraSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onCamOpened()
|
||||
{
|
||||
ui.openSLRCamera_btn->setEnabled(false);
|
||||
ui.closeSLRCamera_btn->setEnabled(true);
|
||||
|
||||
ui.openSLRCamera_btn->setText(QString::fromLocal8Bit("已打开"));
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::closeSLRCamera()
|
||||
{
|
||||
m_SingleLensReflexCameraOperation->CloseSLRCamera();
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onCamClosed()
|
||||
{
|
||||
ui.openSLRCamera_btn->setEnabled(true);
|
||||
ui.closeSLRCamera_btn->setEnabled(false);
|
||||
|
||||
ui.openSLRCamera_btn->setText(QString::fromLocal8Bit("打 开"));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------
|
||||
SingleLensReflexCameraOperation::SingleLensReflexCameraOperation()
|
||||
{
|
||||
m_func = nullptr;
|
||||
record = false;
|
||||
}
|
||||
|
||||
SingleLensReflexCameraOperation::~SingleLensReflexCameraOperation()
|
||||
{
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::OpenSLRCamera()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::OpenSLRCamera_callback()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::setCallback(void(*func)())
|
||||
{
|
||||
m_func = func;
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraOperation::CloseSLRCamera()
|
||||
{
|
||||
std::cout << "SingleLensReflexCameraOperation::CloseSLRCamera,关闭单反相机" << std::endl;
|
||||
|
||||
record = false;
|
||||
|
||||
emit CamClosedSignal();
|
||||
}
|
||||
76
HPPA/SingleLensReflexCameraWindow.h
Normal file
76
HPPA/SingleLensReflexCameraWindow.h
Normal file
@ -0,0 +1,76 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QImage>
|
||||
#include <Qthread>
|
||||
#include <QDir>
|
||||
|
||||
#include <iostream>
|
||||
#include "ui_SingleLensReflexCamera.h"
|
||||
#include "AppSettings.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <opencv2/opencv.hpp>
|
||||
typedef void(*func)();
|
||||
|
||||
class SingleLensReflexCameraOperation :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SingleLensReflexCameraOperation();
|
||||
~SingleLensReflexCameraOperation();
|
||||
|
||||
QImage m_colorImage;
|
||||
QImage m_depthImage;
|
||||
void setCallback(void(*func)());
|
||||
bool getRecordStatus() const { return record; }
|
||||
|
||||
private:
|
||||
cv::Mat frame;
|
||||
|
||||
func m_func;
|
||||
|
||||
bool record;
|
||||
|
||||
public slots:
|
||||
void OpenSLRCamera();
|
||||
void OpenSLRCamera_callback();//不使用信号而使用回调函数来通知界面刷新视频
|
||||
void CloseSLRCamera();
|
||||
|
||||
signals:
|
||||
void PlotSignal();
|
||||
|
||||
void CamOpenedSignal();
|
||||
void CamClosedSignal();
|
||||
};
|
||||
|
||||
class SingleLensReflexCameraWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SingleLensReflexCameraWindow(QWidget* parent = nullptr);
|
||||
~SingleLensReflexCameraWindow();
|
||||
|
||||
SingleLensReflexCameraOperation* m_SingleLensReflexCameraOperation;
|
||||
|
||||
public Q_SLOTS:
|
||||
void openSLRCamera();
|
||||
void onCamOpened();
|
||||
void closeSLRCamera();
|
||||
void onCamClosed();
|
||||
|
||||
signals:
|
||||
void openSLRCameraSignal();
|
||||
void PlotSLRImageSignal();
|
||||
void SLRCamClosedSignal();
|
||||
|
||||
private:
|
||||
Ui::SingleLensReflexCameraClass ui;
|
||||
QThread* m_SLRCameraThread;
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user