mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-13 11:51:47 -05:00
ATV modulator: added camera devices scan and selector in the GUI
This commit is contained in:
parent
293ac223e4
commit
02328b82ff
@ -49,6 +49,7 @@ ATVMod::ATVMod() :
|
||||
m_videoOK(false)
|
||||
{
|
||||
setObjectName("ATVMod");
|
||||
scanCameras();
|
||||
|
||||
m_config.m_outputSampleRate = 1000000;
|
||||
m_config.m_inputFrequencyOffset = 0;
|
||||
@ -69,6 +70,7 @@ ATVMod::ATVMod() :
|
||||
ATVMod::~ATVMod()
|
||||
{
|
||||
if (m_video.isOpened()) m_video.release();
|
||||
releaseCameras();
|
||||
}
|
||||
|
||||
void ATVMod::configure(MessageQueue* messageQueue,
|
||||
@ -567,4 +569,27 @@ void ATVMod::seekVideoFileStream(int seekPercentage)
|
||||
}
|
||||
}
|
||||
|
||||
void ATVMod::scanCameras()
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ATVCamera newCamera;
|
||||
m_cameras.push_back(newCamera);
|
||||
m_cameras.back().m_cameraNumber = i;
|
||||
m_cameras.back().m_camera.open(i);
|
||||
|
||||
if (!m_cameras.back().m_camera.isOpened())
|
||||
{
|
||||
m_cameras.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ATVMod::releaseCameras()
|
||||
{
|
||||
for (std::vector<ATVCamera>::iterator it = m_cameras.begin(); it != m_cameras.end(); ++it)
|
||||
{
|
||||
if (it->m_camera.isOpened()) it->m_camera.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
|
||||
@ -59,6 +61,12 @@ public:
|
||||
ATVModulationFM
|
||||
} ATVModulation;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
cv::VideoCapture m_camera;
|
||||
int m_cameraNumber;
|
||||
} ATVCamera;
|
||||
|
||||
class MsgConfigureImageFileName : public Message
|
||||
{
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
@ -206,6 +214,12 @@ public:
|
||||
|
||||
Real getMagSq() const { return m_movingAverage.average(); }
|
||||
|
||||
void getCameraNumbers(std::vector<int>& numbers) {
|
||||
for (std::vector<ATVCamera>::iterator it = m_cameras.begin(); it != m_cameras.end(); ++it) {
|
||||
numbers.push_back(it->m_cameraNumber);
|
||||
}
|
||||
}
|
||||
|
||||
static int getSampleRateUnits(ATVStd std);
|
||||
|
||||
signals:
|
||||
@ -361,6 +375,8 @@ private:
|
||||
bool m_videoEOF; //!< current video has reached end of file
|
||||
bool m_videoOK;
|
||||
|
||||
std::vector<ATVCamera> m_cameras; //!< vector of available cameras
|
||||
|
||||
static const float m_blackLevel;
|
||||
static const float m_spanLevel;
|
||||
static const int m_levelNbSamples;
|
||||
@ -378,6 +394,8 @@ private:
|
||||
void calculateVideoSizes();
|
||||
void resizeVideo();
|
||||
void seekVideoFileStream(int seekPercentage);
|
||||
void scanCameras();
|
||||
void releaseCameras();
|
||||
|
||||
inline void pullImageLine(Real& sample)
|
||||
{
|
||||
|
@ -356,6 +356,13 @@ ATVModGUI::ATVModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
|
||||
|
||||
connect(m_atvMod->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
|
||||
connect(m_atvMod, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int)));
|
||||
|
||||
std::vector<int> cameraNumbers;
|
||||
m_atvMod->getCameraNumbers(cameraNumbers);
|
||||
|
||||
for (std::vector<int>::iterator it = cameraNumbers.begin(); it != cameraNumbers.end(); ++it) {
|
||||
ui->camSelect->addItem(tr("%1").arg(*it));
|
||||
}
|
||||
}
|
||||
|
||||
ATVModGUI::~ATVModGUI()
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>342</width>
|
||||
<height>366</height>
|
||||
<height>364</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -284,6 +284,12 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>video signal level in % of 0:1 range</string>
|
||||
</property>
|
||||
@ -639,6 +645,40 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="camLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="camLabel">
|
||||
<property name="text">
|
||||
<string>Cam</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="camSelect"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user