mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 09:48:45 -05:00
ATV Modulator: open video file
This commit is contained in:
parent
a392ccb50f
commit
f52f382a24
@ -23,6 +23,7 @@
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(ATVMod::MsgConfigureATVMod, Message)
|
||||
MESSAGE_CLASS_DEFINITION(ATVMod::MsgConfigureImageFileName, Message)
|
||||
MESSAGE_CLASS_DEFINITION(ATVMod::MsgConfigureVideoFileName, Message)
|
||||
|
||||
const float ATVMod::m_blackLevel = 0.3f;
|
||||
const float ATVMod::m_spanLevel = 0.7f;
|
||||
@ -251,8 +252,12 @@ bool ATVMod::handleMessage(const Message& cmd)
|
||||
{
|
||||
MsgConfigureImageFileName& conf = (MsgConfigureImageFileName&) cmd;
|
||||
openImage(conf.getFileName());
|
||||
// m_fileName = conf.getFileName(); // TODO
|
||||
// openFileStream();
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureVideoFileName::match(cmd))
|
||||
{
|
||||
MsgConfigureVideoFileName& conf = (MsgConfigureVideoFileName&) cmd;
|
||||
openVideo(conf.getFileName());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -343,6 +348,7 @@ void ATVMod::applyStandard()
|
||||
m_linesPerVBar = m_nbImageLines2 / m_nbBars;
|
||||
m_hBarIncrement = m_spanLevel / (float) m_nbBars;
|
||||
m_vBarIncrement = m_spanLevel / (float) m_nbBars;
|
||||
m_fps = 30.0f;
|
||||
break;
|
||||
case ATVStdPAL625: // Follows PAL-B/G/H standard
|
||||
default:
|
||||
@ -364,6 +370,7 @@ void ATVMod::applyStandard()
|
||||
m_linesPerVBar = m_nbImageLines2 / m_nbBars;
|
||||
m_hBarIncrement = m_spanLevel / (float) m_nbBars;
|
||||
m_vBarIncrement = m_spanLevel / (float) m_nbBars;
|
||||
m_fps = 25.0f;
|
||||
}
|
||||
|
||||
if (m_imageOK)
|
||||
@ -383,6 +390,19 @@ void ATVMod::openImage(const QString& fileName)
|
||||
}
|
||||
}
|
||||
|
||||
void ATVMod::openVideo(const QString& fileName)
|
||||
{
|
||||
m_videoOK = m_video.open(qPrintable(fileName));
|
||||
|
||||
if (m_videoOK)
|
||||
{
|
||||
m_videoFPS = m_video.get(CV_CAP_PROP_FPS);
|
||||
m_videoWidth = (int) m_video.get(CV_CAP_PROP_FRAME_WIDTH);
|
||||
m_videoHeight = (int) m_video.get(CV_CAP_PROP_FRAME_HEIGHT);
|
||||
qDebug("ATVMod::openVideo(: FPS: %f size: %d x %d", m_videoFPS, m_videoWidth, m_videoHeight);
|
||||
}
|
||||
}
|
||||
|
||||
void ATVMod::resizeImage()
|
||||
{
|
||||
float fy = (m_nbImageLines - 2*m_nbBlankLines) / (float) m_imageOriginal.rows;
|
||||
|
@ -80,6 +80,27 @@ public:
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgConfigureVideoFileName : public Message
|
||||
{
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
const QString& getFileName() const { return m_fileName; }
|
||||
|
||||
static MsgConfigureVideoFileName* create(const QString& fileName)
|
||||
{
|
||||
return new MsgConfigureVideoFileName(fileName);
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
|
||||
MsgConfigureVideoFileName(const QString& fileName) :
|
||||
Message(),
|
||||
m_fileName(fileName)
|
||||
{ }
|
||||
};
|
||||
|
||||
ATVMod();
|
||||
~ATVMod();
|
||||
|
||||
@ -207,6 +228,7 @@ private:
|
||||
QMutex m_settingsMutex;
|
||||
int m_horizontalCount; //!< current point index on line
|
||||
int m_lineCount; //!< current line index in frame
|
||||
float m_fps; //!< resulting frames per second
|
||||
|
||||
MovingAverage<Real> m_movingAverage;
|
||||
quint32 m_levelCalcCount;
|
||||
@ -217,6 +239,13 @@ private:
|
||||
cv::Mat m_image; //!< resized image for transmission at given rate
|
||||
bool m_imageOK;
|
||||
|
||||
cv::VideoCapture m_video; //!< current video capture
|
||||
cv::Mat m_frame; //!< current frame
|
||||
float m_videoFPS;
|
||||
int m_videoWidth;
|
||||
int m_videoHeight;
|
||||
bool m_videoOK;
|
||||
|
||||
static const float m_blackLevel;
|
||||
static const float m_spanLevel;
|
||||
static const int m_levelNbSamples;
|
||||
@ -229,6 +258,7 @@ private:
|
||||
void modulateSample();
|
||||
void applyStandard();
|
||||
void openImage(const QString& fileName);
|
||||
void openVideo(const QString& fileName);
|
||||
void resizeImage();
|
||||
|
||||
inline void pullImageLine(Real& sample)
|
||||
|
@ -235,11 +235,24 @@ void ATVModGUI::on_imageFileDialog_clicked(bool checked)
|
||||
if (fileName != "")
|
||||
{
|
||||
m_imageFileName = fileName;
|
||||
ui->recordFileText->setText(m_imageFileName);
|
||||
ui->imageFileText->setText(m_imageFileName);
|
||||
configureImageFileName();
|
||||
}
|
||||
}
|
||||
|
||||
void ATVModGUI::on_videoFileDialog_clicked(bool checked)
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Open video file"), ".", tr("Video Files (*.avi *.mpg *.mp4 *.mov *.m4v)"));
|
||||
|
||||
if (fileName != "")
|
||||
{
|
||||
m_videoFileName = fileName;
|
||||
ui->videoFileText->setText(m_videoFileName);
|
||||
configureVideoFileName();
|
||||
}
|
||||
}
|
||||
|
||||
void ATVModGUI::configureImageFileName()
|
||||
{
|
||||
qDebug() << "ATVModGUI::configureImageFileName: " << m_imageFileName.toStdString().c_str();
|
||||
@ -247,6 +260,13 @@ void ATVModGUI::configureImageFileName()
|
||||
m_atvMod->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
void ATVModGUI::configureVideoFileName()
|
||||
{
|
||||
qDebug() << "ATVModGUI::configureVideoFileName: " << m_videoFileName.toStdString().c_str();
|
||||
ATVMod::MsgConfigureVideoFileName* message = ATVMod::MsgConfigureVideoFileName::create(m_videoFileName);
|
||||
m_atvMod->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
void ATVModGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
||||
{
|
||||
}
|
||||
|
@ -67,11 +67,13 @@ private slots:
|
||||
void on_volume_valueChanged(int value);
|
||||
void on_channelMute_toggled(bool checked);
|
||||
void on_imageFileDialog_clicked(bool checked);
|
||||
void on_videoFileDialog_clicked(bool checked);
|
||||
|
||||
void onWidgetRolled(QWidget* widget, bool rollDown);
|
||||
void onMenuDoubleClicked();
|
||||
|
||||
void configureImageFileName();
|
||||
void configureVideoFileName();
|
||||
void tick();
|
||||
|
||||
private:
|
||||
@ -88,6 +90,7 @@ private:
|
||||
MovingAverage<Real> m_channelPowerDbAvg;
|
||||
|
||||
QString m_imageFileName;
|
||||
QString m_videoFileName;
|
||||
quint32 m_recordLength;
|
||||
int m_recordSampleRate;
|
||||
int m_samplesCount;
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>342</width>
|
||||
<height>363</height>
|
||||
<height>366</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -466,18 +466,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="fileNameLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="recordFileText">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="playControllLayout">
|
||||
<layout class="QHBoxLayout" name="imagFileLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="imageFileDialog">
|
||||
<property name="minimumSize">
|
||||
@ -505,12 +494,23 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<widget class="QLabel" name="imageFileText">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="videoFileLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="videoFileDialog">
|
||||
<property name="minimumSize">
|
||||
@ -537,6 +537,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="videoFileText">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="playControllLayout">
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="playLoop">
|
||||
<property name="toolTip">
|
||||
|
Loading…
Reference in New Issue
Block a user