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

Commit 78941e2

Browse files
authored
Fix visualization issue on ASI183MM/MC (and possibly other high resolution 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)
1 parent a1736a7 commit 78941e2

6 files changed

Lines changed: 57 additions & 59 deletions

File tree

src/commons/configuration.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ define_setting(max_display_fps, int, 30)
9797
define_setting(max_display_fps_recording, int, 15)
9898
define_setting(limit_fps, bool, true)
9999
define_setting(debayer, bool, true)
100-
define_setting(opengl, bool, true)
101100
define_setting(limit_fps_recording, bool, true)
102101

103102
define_setting_enum(recording_limit_type, Configuration::RecordingLimit, Configuration::FramesNumber)

src/commons/configuration.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class Configuration : public QObject
4141
declare_setting(limit_fps_recording, bool)
4242
declare_setting(debayer, bool)
4343
declare_setting(limit_fps, bool)
44-
declare_setting(opengl, bool)
4544

4645
declare_setting(buffered_output, bool )
4746
declare_setting(max_memory_usage, long long )

src/drivers/zwo_asi/asiimagingworker.cpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#include "zwoexception.h"
2121
#include <atomic>
2222
#include "commons/frame.h"
23+
#include <array>
2324

25+
#define FRAMES_BUFFER 5
2426
using namespace std;
2527

2628
DPTR_IMPL(ASIImagingWorker) {
@@ -35,6 +37,12 @@ DPTR_IMPL(ASIImagingWorker) {
3537
int getCVImageType();
3638
Frame::ColorFormat color_format;
3739
Frame::ColorFormat colorFormat() const;
40+
#ifdef FRAMES_BUFFER
41+
array<FramePtr, FRAMES_BUFFER> frames;
42+
#endif
43+
uint8_t current_frame = 0;
44+
FramePtr new_frame() const;
45+
uint8_t next_index();
3846
};
3947

4048
ASIImagingWorker::ASIImagingWorker(const QRect& roi, int bin, const ASI_CAMERA_INFO& info, ASI_IMG_TYPE format)
@@ -59,6 +67,22 @@ ASIImagingWorker::ASIImagingWorker(const QRect& roi, int bin, const ASI_CAMERA_I
5967
d->color_format = Frame::Mono;
6068
}
6169
calc_exposure_timeout();
70+
#ifdef FRAMES_BUFFER
71+
generate(begin(d->frames), end(d->frames), bind(&Private::new_frame, d.get()));
72+
#endif
73+
}
74+
75+
FramePtr ASIImagingWorker::Private::new_frame() const {
76+
// ASI CAMs are little endian
77+
return make_shared<Frame>( format == ASI_IMG_RAW16 ? 16 : 8, colorFormat(), QSize{roi.width(), roi.height()}, Frame::LittleEndian);
78+
}
79+
80+
uint8_t ASIImagingWorker::Private::next_index() {
81+
#ifdef FRAMES_BUFFER
82+
return (current_frame++) % frames.size();
83+
#else
84+
return 0;
85+
#endif
6286
}
6387

6488
ASIImagingWorker::~ASIImagingWorker()
@@ -83,8 +107,11 @@ void ASIImagingWorker::calc_exposure_timeout()
83107

84108
FramePtr ASIImagingWorker::shoot()
85109
{
86-
// ASI CAMs are little endian
87-
auto frame = make_shared<Frame>( d->format == ASI_IMG_RAW16 ? 16 : 8, d->colorFormat(), QSize{d->roi.width(), d->roi.height()}, Frame::LittleEndian);
110+
#ifdef FRAMES_BUFFER
111+
FramePtr frame = d->frames[d->next_index()];
112+
#else
113+
FramePtr frame = d->new_frame();
114+
#endif
88115
ASI_CHECK << ASIGetVideoData(d->info.CameraID, frame->data(), frame->size(), d->exposure_timeout) << "Capture frame";
89116
return frame;
90117
}

src/planetaryimager_mainwindow.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,6 @@ PlanetaryImagerMainWindow::PlanetaryImagerMainWindow(
163163
d->ui->image->layout()->setMargin(0);
164164
d->ui->image->layout()->setSpacing(0);
165165
d->ui->image->layout()->addWidget(d->image_widget = new ZoomableImage(false));
166-
#ifdef HAVE_QT5_OPENGL // TODO: make configuration item
167-
if(d->planetaryImager->configuration().opengl())
168-
{
169-
if (!QGLFormat::hasOpenGL())
170-
qWarning() << "Window system does not support OpenGL.";
171-
else
172-
d->image_widget->setOpenGL();
173-
}
174-
#endif
175166
d->image_widget->scene()->setBackgroundBrush(QBrush{Qt::black, Qt::Dense4Pattern});
176167
connect(d->image_widget, &ZoomableImage::zoomLevelChanged, d->statusbar_info_widget, &StatusBarInfoWidget::zoom);
177168
d->statusbar_info_widget->zoom(d->image_widget->zoomLevel());

src/widgets/configurationdialog.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,10 @@ ConfigurationDialog::~ConfigurationDialog()
4343

4444
ConfigurationDialog::ConfigurationDialog(Configuration &configuration, QWidget* parent) : QDialog(parent), dptr(configuration, this)
4545
{
46-
static bool original_opengl_setting = d->configuration.opengl();
4746
d->ui.reset(new Ui::ConfigurationDialog);
4847
d->ui->setupUi(this);
49-
#ifndef HAVE_QT5_OPENGL
50-
d->ui->opengl->hide();
51-
#endif
5248
connect(d->ui->debayer, &QCheckBox::toggled, bind(&Configuration::set_debayer, &d->configuration, _1));
53-
connect(d->ui->opengl, &QCheckBox::toggled, bind(&Configuration::set_opengl, &d->configuration, _1));
5449
d->ui->debayer->setChecked(d->configuration.debayer());
55-
d->ui->opengl->setChecked(d->configuration.opengl());
5650
d->ui->pauseShouldStopRecordingTimeout->setChecked(d->configuration.recording_pause_stops_timer());
5751
connect(d->ui->pauseShouldStopRecordingTimeout, &QCheckBox::toggled, bind(&Configuration::set_recording_pause_stops_timer, &d->configuration, _1));
5852

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

183172
d->ui->pixelDataEndianess->addItem("camera default", static_cast<int>(Configuration::CaptureEndianess::CameraDefault));
184173
d->ui->pixelDataEndianess->addItem("little-endian", static_cast<int>(Configuration::CaptureEndianess::Little));

src/widgets/configurationdialog.ui

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<item row="1" column="0">
2828
<widget class="QTabWidget" name="configurationTab">
2929
<property name="currentIndex">
30-
<number>2</number>
30+
<number>0</number>
3131
</property>
3232
<widget class="QWidget" name="tab">
3333
<attribute name="title">
@@ -40,16 +40,17 @@
4040
<string>Image Display</string>
4141
</property>
4242
<layout class="QGridLayout" name="gridLayout">
43-
<item row="2" column="0">
44-
<widget class="QCheckBox" name="enable_fps_limit_recording">
45-
<property name="sizePolicy">
46-
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
47-
<horstretch>1</horstretch>
48-
<verstretch>0</verstretch>
49-
</sizepolicy>
43+
<item row="2" column="2">
44+
<widget class="QLabel" name="label_16">
45+
<property name="text">
46+
<string>FPS</string>
5047
</property>
48+
</widget>
49+
</item>
50+
<item row="0" column="0" colspan="3">
51+
<widget class="QCheckBox" name="debayer">
5152
<property name="text">
52-
<string>Set FPS limit while recording</string>
53+
<string>Debayer images (colour camera only in raw mode)</string>
5354
</property>
5455
</widget>
5556
</item>
@@ -60,16 +61,16 @@
6061
</property>
6162
</widget>
6263
</item>
63-
<item row="1" column="0">
64-
<widget class="QCheckBox" name="enable_fps_limit">
64+
<item row="2" column="1">
65+
<widget class="QSpinBox" name="fps_limit_recording">
6566
<property name="sizePolicy">
6667
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
6768
<horstretch>1</horstretch>
6869
<verstretch>0</verstretch>
6970
</sizepolicy>
7071
</property>
71-
<property name="text">
72-
<string>Set FPS limit while not recording</string>
72+
<property name="minimum">
73+
<number>1</number>
7374
</property>
7475
</widget>
7576
</item>
@@ -86,27 +87,33 @@
8687
</property>
8788
</widget>
8889
</item>
89-
<item row="2" column="1">
90-
<widget class="QSpinBox" name="fps_limit_recording">
90+
<item row="1" column="0">
91+
<widget class="QCheckBox" name="enable_fps_limit">
9192
<property name="sizePolicy">
9293
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
9394
<horstretch>1</horstretch>
9495
<verstretch>0</verstretch>
9596
</sizepolicy>
9697
</property>
97-
<property name="minimum">
98-
<number>1</number>
98+
<property name="text">
99+
<string>Set FPS limit while not recording</string>
99100
</property>
100101
</widget>
101102
</item>
102-
<item row="2" column="2">
103-
<widget class="QLabel" name="label_16">
103+
<item row="2" column="0">
104+
<widget class="QCheckBox" name="enable_fps_limit_recording">
105+
<property name="sizePolicy">
106+
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
107+
<horstretch>1</horstretch>
108+
<verstretch>0</verstretch>
109+
</sizepolicy>
110+
</property>
104111
<property name="text">
105-
<string>FPS</string>
112+
<string>Set FPS limit while recording</string>
106113
</property>
107114
</widget>
108115
</item>
109-
<item row="4" column="1">
116+
<item row="3" column="1">
110117
<spacer name="verticalSpacer_3">
111118
<property name="orientation">
112119
<enum>Qt::Vertical</enum>
@@ -119,20 +126,6 @@
119126
</property>
120127
</spacer>
121128
</item>
122-
<item row="0" column="0" colspan="3">
123-
<widget class="QCheckBox" name="debayer">
124-
<property name="text">
125-
<string>Debayer images (colour camera only in raw mode)</string>
126-
</property>
127-
</widget>
128-
</item>
129-
<item row="3" column="0" colspan="3">
130-
<widget class="QCheckBox" name="opengl">
131-
<property name="text">
132-
<string>Use OpenGL rendering (requires restart)</string>
133-
</property>
134-
</widget>
135-
</item>
136129
</layout>
137130
</widget>
138131
</item>

0 commit comments

Comments
 (0)