Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Commit

Permalink
Fix visualization issue on ASI183MM/MC (and possibly other high resol…
Browse files Browse the repository at this point in the history
…ution ASI cameras) where image is always black in preview window by disabling opengl rendering (which didn't seem to improve performances as much as expected, AND to cause rendering issues). (#92)
  • Loading branch information
GuLinux committed Jun 13, 2019
1 parent a1736a7 commit 78941e2
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 59 deletions.
1 change: 0 additions & 1 deletion src/commons/configuration.cpp
Expand Up @@ -97,7 +97,6 @@ define_setting(max_display_fps, int, 30)
define_setting(max_display_fps_recording, int, 15)
define_setting(limit_fps, bool, true)
define_setting(debayer, bool, true)
define_setting(opengl, bool, true)
define_setting(limit_fps_recording, bool, true)

define_setting_enum(recording_limit_type, Configuration::RecordingLimit, Configuration::FramesNumber)
Expand Down
1 change: 0 additions & 1 deletion src/commons/configuration.h
Expand Up @@ -41,7 +41,6 @@ class Configuration : public QObject
declare_setting(limit_fps_recording, bool)
declare_setting(debayer, bool)
declare_setting(limit_fps, bool)
declare_setting(opengl, bool)

declare_setting(buffered_output, bool )
declare_setting(max_memory_usage, long long )
Expand Down
31 changes: 29 additions & 2 deletions src/drivers/zwo_asi/asiimagingworker.cpp
Expand Up @@ -20,7 +20,9 @@
#include "zwoexception.h"
#include <atomic>
#include "commons/frame.h"
#include <array>

#define FRAMES_BUFFER 5
using namespace std;

DPTR_IMPL(ASIImagingWorker) {
Expand All @@ -35,6 +37,12 @@ DPTR_IMPL(ASIImagingWorker) {
int getCVImageType();
Frame::ColorFormat color_format;
Frame::ColorFormat colorFormat() const;
#ifdef FRAMES_BUFFER
array<FramePtr, FRAMES_BUFFER> frames;
#endif
uint8_t current_frame = 0;
FramePtr new_frame() const;
uint8_t next_index();
};

ASIImagingWorker::ASIImagingWorker(const QRect& roi, int bin, const ASI_CAMERA_INFO& info, ASI_IMG_TYPE format)
Expand All @@ -59,6 +67,22 @@ ASIImagingWorker::ASIImagingWorker(const QRect& roi, int bin, const ASI_CAMERA_I
d->color_format = Frame::Mono;
}
calc_exposure_timeout();
#ifdef FRAMES_BUFFER
generate(begin(d->frames), end(d->frames), bind(&Private::new_frame, d.get()));
#endif
}

FramePtr ASIImagingWorker::Private::new_frame() const {
// ASI CAMs are little endian
return make_shared<Frame>( format == ASI_IMG_RAW16 ? 16 : 8, colorFormat(), QSize{roi.width(), roi.height()}, Frame::LittleEndian);
}

uint8_t ASIImagingWorker::Private::next_index() {
#ifdef FRAMES_BUFFER
return (current_frame++) % frames.size();
#else
return 0;
#endif
}

ASIImagingWorker::~ASIImagingWorker()
Expand All @@ -83,8 +107,11 @@ void ASIImagingWorker::calc_exposure_timeout()

FramePtr ASIImagingWorker::shoot()
{
// ASI CAMs are little endian
auto frame = make_shared<Frame>( d->format == ASI_IMG_RAW16 ? 16 : 8, d->colorFormat(), QSize{d->roi.width(), d->roi.height()}, Frame::LittleEndian);
#ifdef FRAMES_BUFFER
FramePtr frame = d->frames[d->next_index()];
#else
FramePtr frame = d->new_frame();
#endif
ASI_CHECK << ASIGetVideoData(d->info.CameraID, frame->data(), frame->size(), d->exposure_timeout) << "Capture frame";
return frame;
}
Expand Down
9 changes: 0 additions & 9 deletions src/planetaryimager_mainwindow.cpp
Expand Up @@ -163,15 +163,6 @@ PlanetaryImagerMainWindow::PlanetaryImagerMainWindow(
d->ui->image->layout()->setMargin(0);
d->ui->image->layout()->setSpacing(0);
d->ui->image->layout()->addWidget(d->image_widget = new ZoomableImage(false));
#ifdef HAVE_QT5_OPENGL // TODO: make configuration item
if(d->planetaryImager->configuration().opengl())
{
if (!QGLFormat::hasOpenGL())
qWarning() << "Window system does not support OpenGL.";
else
d->image_widget->setOpenGL();
}
#endif
d->image_widget->scene()->setBackgroundBrush(QBrush{Qt::black, Qt::Dense4Pattern});
connect(d->image_widget, &ZoomableImage::zoomLevelChanged, d->statusbar_info_widget, &StatusBarInfoWidget::zoom);
d->statusbar_info_widget->zoom(d->image_widget->zoomLevel());
Expand Down
11 changes: 0 additions & 11 deletions src/widgets/configurationdialog.cpp
Expand Up @@ -43,16 +43,10 @@ ConfigurationDialog::~ConfigurationDialog()

ConfigurationDialog::ConfigurationDialog(Configuration &configuration, QWidget* parent) : QDialog(parent), dptr(configuration, this)
{
static bool original_opengl_setting = d->configuration.opengl();
d->ui.reset(new Ui::ConfigurationDialog);
d->ui->setupUi(this);
#ifndef HAVE_QT5_OPENGL
d->ui->opengl->hide();
#endif
connect(d->ui->debayer, &QCheckBox::toggled, bind(&Configuration::set_debayer, &d->configuration, _1));
connect(d->ui->opengl, &QCheckBox::toggled, bind(&Configuration::set_opengl, &d->configuration, _1));
d->ui->debayer->setChecked(d->configuration.debayer());
d->ui->opengl->setChecked(d->configuration.opengl());
d->ui->pauseShouldStopRecordingTimeout->setChecked(d->configuration.recording_pause_stops_timer());
connect(d->ui->pauseShouldStopRecordingTimeout, &QCheckBox::toggled, bind(&Configuration::set_recording_pause_stops_timer, &d->configuration, _1));

Expand Down Expand Up @@ -174,11 +168,6 @@ ConfigurationDialog::ConfigurationDialog(Configuration &configuration, QWidget*
}
d->ui->video_codec->setCurrentIndex(d->ui->video_codec->findData(d->configuration.video_codec()));
connect(d->ui->video_codec, F_PTR(QComboBox, activated, int), [=](int index){ d->configuration.set_video_codec(d->ui->video_codec->itemData(index).toString()); });
connect(this, &QDialog::accepted, [this] {
if(original_opengl_setting != d->configuration.opengl()) {
QMessageBox::information(this, tr("Restart required"), tr("You changed the OpenGL setting. Please restart PlanetaryImage for this change to take effect"));
}
});

d->ui->pixelDataEndianess->addItem("camera default", static_cast<int>(Configuration::CaptureEndianess::CameraDefault));
d->ui->pixelDataEndianess->addItem("little-endian", static_cast<int>(Configuration::CaptureEndianess::Little));
Expand Down
63 changes: 28 additions & 35 deletions src/widgets/configurationdialog.ui
Expand Up @@ -27,7 +27,7 @@
<item row="1" column="0">
<widget class="QTabWidget" name="configurationTab">
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
Expand All @@ -40,16 +40,17 @@
<string>Image Display</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QCheckBox" name="enable_fps_limit_recording">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="2" column="2">
<widget class="QLabel" name="label_16">
<property name="text">
<string>FPS</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="debayer">
<property name="text">
<string>Set FPS limit while recording</string>
<string>Debayer images (colour camera only in raw mode)</string>
</property>
</widget>
</item>
Expand All @@ -60,16 +61,16 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="enable_fps_limit">
<item row="2" column="1">
<widget class="QSpinBox" name="fps_limit_recording">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Set FPS limit while not recording</string>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
Expand All @@ -86,27 +87,33 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="fps_limit_recording">
<item row="1" column="0">
<widget class="QCheckBox" name="enable_fps_limit">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
<property name="text">
<string>Set FPS limit while not recording</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_16">
<item row="2" column="0">
<widget class="QCheckBox" name="enable_fps_limit_recording">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FPS</string>
<string>Set FPS limit while recording</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="3" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -119,20 +126,6 @@
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="debayer">
<property name="text">
<string>Debayer images (colour camera only in raw mode)</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="opengl">
<property name="text">
<string>Use OpenGL rendering (requires restart)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 78941e2

Please sign in to comment.