13#include "kstars_debug.h"
14#include "collimationoverlayoptions.h"
15#include "qobjectdefs.h"
17#include <basedevice.h>
19#include <KLocalizedString>
27#include <QSocketNotifier>
34#include <QImageWriter>
35#include <QImageReader>
57void RecordOptions::selectRecordDirectory()
73 streamWidth = streamHeight = -1;
74 processStream = colorFrame = isRecording =
false;
76 options =
new RecordOptions(
this);
82 CollimationOverlayOptions::Instance(
this)->openEditor();
90 ccd->getSERNameDirectory(filename, directory);
92 double duration = 0.1;
102 options->recordFilenameEdit->setText(filename);
103 options->recordDirectoryEdit->setText(directory);
105 setWindowTitle(
i18nc(
"@title:window",
"%1 Live Video", ccd->getDeviceName()));
123 connect(ccd,
SIGNAL(videoRecordToggled(
bool)),
this,
SLOT(updateRecordStatus(
bool)));
128 resize(Options::streamWindowWidth(), Options::streamWindowHeight());
130 eoszoom = m_Camera->getProperty(
"eoszoom");
131 if (eoszoom ==
nullptr)
139 auto tvp = eoszoom->getText();
146 m_Camera->sendNewProperty(
tvp);
149 m_Camera->sendNewProperty(
tvp);
155 eoszoomposition = m_Camera->getProperty(
"eoszoomposition");
156 if (eoszoomposition ==
nullptr)
168 auto tvp = eoszoomposition->getText();
171 m_Camera->sendNewProperty(
tvp);
176 auto tvp = eoszoomposition->getText();
179 m_Camera->sendNewProperty(
tvp);
185 connect(m_Camera, &ISD::Camera::newFPS,
this, &StreamWG::updateFPS);
186 connect(m_Camera, &ISD::Camera::propertyUpdated,
this, [
this](INDI::Property
prop)
188 if (
prop.isNameMatch(
"CCD_INFO") ||
prop.isNameMatch(
"CCD_CFA"))
189 syncDebayerParameters();
196 m_Camera->setVideoStreamEnabled(
false);
199 m_Camera->setVideoStreamEnabled(
true);
207 m_DebayerActive = !m_DebayerActive;
209 syncDebayerParameters();
212void StreamWG::syncDebayerParameters()
214 m_DebayerSupported = queryDebayerParameters();
215 debayerB->setEnabled(m_DebayerSupported);
216 m_DebayerActive = m_DebayerSupported;
219bool StreamWG::queryDebayerParameters()
224 ISD::CameraChip *targetChip = m_Camera->getChip(ISD::CameraChip::PRIMARY_CCD);
230 if (targetChip->getISOList().
isEmpty() ==
false)
236 if (targetChip->getImageInfo(w, h, pixelX, pixelY, m_BBP) ==
false)
245 if (targetChip->getBayerInfo(offsetX, offsetY, pattern) ==
false)
248 m_DebayerParams.method = DC1394_BAYER_METHOD_NEAREST;
249 m_DebayerParams.filter = DC1394_COLOR_FILTER_RGGB;
251 if (pattern ==
"GBRG")
252 m_DebayerParams.filter = DC1394_COLOR_FILTER_GBRG;
253 else if (pattern ==
"GRBG")
254 m_DebayerParams.filter = DC1394_COLOR_FILTER_GRBG;
255 else if (pattern ==
"BGGR")
256 m_DebayerParams.filter = DC1394_COLOR_FILTER_BGGR;
261QSize StreamWG::sizeHint()
const
263 QSize size(Options::streamWindowWidth(), Options::streamWindowHeight());
281 processStream =
false;
283 Options::setStreamWindowWidth(
width());
284 Options::setStreamWindowHeight(
height());
291void StreamWG::setColorFrame(
bool color)
296void StreamWG::enableStream(
bool enable)
300 processStream =
true;
305 processStream =
false;
312void StreamWG::setSize(
int wd,
int ht)
314 if (
wd != streamWidth ||
ht != streamHeight)
334void StreamWG::updateRecordStatus(
bool enabled)
353void StreamWG::toggleRecord()
361 m_Camera->stopRecording();
366 m_Camera->getSERNameDirectory(filename, directory);
367 if (filename != options->recordFilenameEdit->text() ||
368 directory != options->recordDirectoryEdit->text())
370 m_Camera->setSERNameDirectory(options->recordFilenameEdit->text(), options->recordDirectoryEdit->text());
372 m_Camera->setConfig(SAVE_CONFIG);
375 if (options->recordUntilStoppedR->isChecked())
377 isRecording = m_Camera->startRecording();
379 else if (options->recordDurationR->isChecked())
381 isRecording = m_Camera->startDurationRecording(options->durationSpin->value());
385 isRecording = m_Camera->startFramesRecording(options->framesSpin->value());
396void StreamWG::newFrame(INDI::Property
prop)
398 auto bp =
prop.getBLOB()->at(0);
400 bool rc = (m_DebayerActive
404 qCWarning(
KSTARS) <<
"Failed to load video frame.";
407void StreamWG::resetFrame()
409 m_Camera->resetStreamingFrame();
412void StreamWG::setStreamingFrame(
QRect newFrame)
423 int w = newFrame.
width();
430 m_Camera->setStreamingFrame(newFrame.
x(), newFrame.
y(), w, newFrame.
height());
442 CollimationOverlayOptions::Instance(
this)->release();
CameraChip class controls a particular chip in camera.
Camera class controls an INDI Camera device.
This is the main window for KStars.
static KStars * Instance()
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
KIOCORE_EXPORT QString dir(const QString &fileClass)
const char * constData() const const
void activated(int index)
QString getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, Options options)
QIcon fromTheme(const QString &name)
bool isEmpty() const const
bool isNull() const const
QString arg(Args &&... args) const const
QString number(double n, char format, int precision)
QByteArray toLatin1() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QUrl fromLocalFile(const QString &localFile)
QString toLocalFile() const const