closing and reopening windows will works. As well as the menus for some settings

master
Steffen Pohle 3 years ago
parent 3485300d28
commit e5c5b90cad

@ -1,3 +1,7 @@
2022-11-29:
- closing and reopening of windows is working now.
- RGB16 debayer mode simple/bilinear can now be choosen in the settings menu
2022-11-26: 2022-11-26:
- adding histogram - adding histogram

@ -78,8 +78,9 @@ void Configuration::SaveConfig(std::string filename) {
// //
// histogram settings // histogram settings and debayer mode
jp.AddObject("histogram_log", histogram_log); jp.AddObject("histogram_log", histogram_log);
jp.AddObject("debayer_mode", debayer_mode);
// //
@ -143,7 +144,11 @@ void Configuration::LoadConfig(std::string filename) {
gtk_entry_set_text(GTK_ENTRY(cbdevice), vstr.c_str()); gtk_entry_set_text(GTK_ENTRY(cbdevice), vstr.c_str());
} }
jp.GetValueInt("histogram_log", &histogram_log); jp.GetValueInt("histogram_log", &i);
SetHistogramLog(i);
jp.GetValueInt("debayer_mode", &i);
SetDebayerMode(i);
// //
// start streaming if a device was selected. // start streaming if a device was selected.
@ -200,3 +205,18 @@ list<VideoDevCtrl> Configuration::GetPresetButton (int btn) {
}; };
void Configuration::SetHistogramLog(int trueorfalse) {
GtkWidget *cfg_logh = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "menu-settings-loghistogram"));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(cfg_logh), (trueorfalse == 1));
histogram_log = trueorfalse;
};
void Configuration::SetDebayerMode(int trueorfalse) {
GtkWidget *cfg_debayer = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "menu-settings-bilinearrgb"));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(cfg_debayer), (trueorfalse == 1));
debayer_mode = trueorfalse;
};

@ -17,14 +17,15 @@
class Configuration { class Configuration {
private: private:
int histogram_log = 1; // logarithmic or linear scale
JSONParse config; JSONParse config;
std::string GetDefaultFileName(); std::string GetDefaultFileName();
list<VideoDevCtrl> presetbtn[BTN_PRESET_MAX]; list<VideoDevCtrl> presetbtn[BTN_PRESET_MAX];
public: public:
char *debugpath; char *debugpath;
char *readdumppath; char *readdumppath;
int histogram_log = 1; // logarithmic or linear scale int debayer_mode = 0; // 0..simple mode, 1..bilinear
Configuration(); Configuration();
~Configuration(); ~Configuration();
@ -35,6 +36,11 @@ public:
void LoadConfig(std::string filename); void LoadConfig(std::string filename);
void SaveConfig(std::string filename); void SaveConfig(std::string filename);
void SetDebayerMode(int trueorfalse);
void SetHistogramLog(int trueorfalse);
int GetHistogramLog() { return histogram_log; };
void SetPresetButton (int btn, list<VideoDevCtrl> *parameters); void SetPresetButton (int btn, list<VideoDevCtrl> *parameters);
list<VideoDevCtrl> GetPresetButton (int btn); list<VideoDevCtrl> GetPresetButton (int btn);
}; };

@ -347,8 +347,8 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr
break; break;
case (V4L2_PIX_FMT_SGRBG16): case (V4L2_PIX_FMT_SGRBG16):
//debayer_grbg16_simple ((uint16_t *)ptrsrc, srcw, srch, ptrdst, dest->w, dest->h); if (config.debayer_mode == 0) debayer_grbg16_simple ((uint16_t *)ptrsrc, srcw, srch, ptrdst, dest->w, dest->h);
debayer_grbg16_bilinear ((uint16_t *)ptrsrc, srcw, srch, ptrdst, dest->w, dest->h); else debayer_grbg16_bilinear ((uint16_t *)ptrsrc, srcw, srch, ptrdst, dest->w, dest->h);
break; break;
case (V4L2_PIX_FMT_UYVY): case (V4L2_PIX_FMT_UYVY):

@ -81,7 +81,12 @@ void cb_window_show (GtkWidget *widget, gpointer data) {
detect.SetObjectSize(300, 300); detect.SetObjectSize(300, 300);
cb_video_btnrefreshlist (NULL, NULL); cb_video_btnrefreshlist (NULL, NULL);
//
// load config and setup elements
config.LoadDefault(); config.LoadDefault();
GtkWidget *cfg_rgbenc = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "menu-settings-bilinearrgb"));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(cfg_rgbenc), (config.debayer_mode != 0));
// //
// update the input video controls every 2 seconds. // update the input video controls every 2 seconds.
@ -89,6 +94,12 @@ void cb_window_show (GtkWidget *widget, gpointer data) {
}; };
void cb_menu_set_rgbenc (GtkCheckMenuItem *checkmenuitem, gpointer user_data) {
if (gtk_check_menu_item_get_active(checkmenuitem) == TRUE) config.debayer_mode = 1;
else config.debayer_mode = 1;
}
void displayerror (std::string error) { void displayerror (std::string error) {
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *window = GTK_WIDGET (gtk_builder_get_object (_builder_, "main-window")); GtkWidget *window = GTK_WIDGET (gtk_builder_get_object (_builder_, "main-window"));
@ -359,3 +370,26 @@ void cb_detect_btnsetpos (GtkWidget *widget, gpointer data) {
}; };
void cb_output_show_window (GtkWidget *widget, gpointer data) {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
GtkWidget *wnd = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "window-output"));
gtk_widget_show(wnd);
};
void cb_detect_show_window (GtkWidget *widget, gpointer data) {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
GtkWidget *wnd = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "window-detect"));
gtk_widget_show(wnd);
};
void cb_input_show_window (GtkWidget *widget, gpointer data) {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
GtkWidget *wnd = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "window-input"));
gtk_widget_show(wnd);
};

10
gui.h

@ -79,6 +79,7 @@ gboolean video_pre_long(gpointer data);
// //
// thread new inframe // thread new inframe
G_MODULE_EXPORT gboolean cb_thread_video (gpointer data); G_MODULE_EXPORT gboolean cb_thread_video (gpointer data);
G_MODULE_EXPORT void cb_input_show_window (GtkWidget *widget, gpointer data);
// //
@ -88,15 +89,17 @@ G_MODULE_EXPORT gboolean cb_thread_filter (gpointer data);
G_MODULE_EXPORT gboolean cb_thread_detect (gpointer data); G_MODULE_EXPORT gboolean cb_thread_detect (gpointer data);
G_MODULE_EXPORT void cb_image_btnnew (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_image_btnnew (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_image_btnsave (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_image_btnsave (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_detect_bright (GtkRange *range, gpointer data); G_MODULE_EXPORT void cb_output_show_window (GtkWidget *widget, gpointer data);
// //
// detection elements // detection elements
G_MODULE_EXPORT void cb_detect_bright (GtkRange *range, gpointer data);
G_MODULE_EXPORT void cb_detect_btnsetpos (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_detect_btnsetpos (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_detect_btnsetsize (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_detect_btnsetsize (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_detect_followtype (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_detect_followtype (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_detect_detecttype (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_detect_detecttype (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_detect_show_window (GtkWidget *widget, gpointer data);
// //
@ -106,8 +109,13 @@ G_MODULE_EXPORT void cb_histogramda_motion (GtkWidget *widget, GdkEvent *event,
G_MODULE_EXPORT void cb_histogramda_btnpress (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_histogramda_btnpress (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_histogramda_btnrelease (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_histogramda_btnrelease (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_histogramda_keypress (GtkWidget *widget, GdkEventKey *event, gpointer data); G_MODULE_EXPORT void cb_histogramda_keypress (GtkWidget *widget, GdkEventKey *event, gpointer data);
G_MODULE_EXPORT void cb_histogram_show_window (GtkWidget *widget, gpointer data);
//
// menu elements
G_MODULE_EXPORT void cb_menu_set_rgbenc (GtkCheckMenuItem *checkmenuitem, gpointer user_data);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -72,7 +72,7 @@ void cb_histogramda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer da
int histogram_scale = histogram_width - 1 > 0 ? histogram_width - 1 : 1; int histogram_scale = histogram_width - 1 > 0 ? histogram_width - 1 : 1;
for (int i = 0; i < histogram_width; i++) { for (int i = 0; i < histogram_width; i++) {
px = HISTOGRAM_MARGIN + ((clientw-HISTOGRAM_MARGIN*2) * i) / histogram_scale; px = HISTOGRAM_MARGIN + ((clientw-HISTOGRAM_MARGIN*2) * i) / histogram_scale;
if (config.histogram_log) if (config.GetHistogramLog())
py2 = (clienth-HISTOGRAM_MARGIN) - ((clienth-HISTOGRAM_MARGIN*2) * log10(histogram[chan][histogram_zoom_start+i]+1) / log10(histogram_max)); py2 = (clienth-HISTOGRAM_MARGIN) - ((clienth-HISTOGRAM_MARGIN*2) * log10(histogram[chan][histogram_zoom_start+i]+1) / log10(histogram_max));
else else
py2 = (clienth-HISTOGRAM_MARGIN) - ((clienth-HISTOGRAM_MARGIN*2) * histogram[chan][histogram_zoom_start+i] / histogram_max); py2 = (clienth-HISTOGRAM_MARGIN) - ((clienth-HISTOGRAM_MARGIN*2) * histogram[chan][histogram_zoom_start+i] / histogram_max);
@ -98,7 +98,7 @@ void cb_histogramda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer da
} }
// draw some text // draw some text
if (config.histogram_log) snprintf (txt, 255, "%d - Log", histogram_max); if (config.GetHistogramLog()) snprintf (txt, 255, "%d - Log", histogram_max);
else snprintf (txt, 255, "%d - Lin", histogram_max); else snprintf (txt, 255, "%d - Lin", histogram_max);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
@ -227,14 +227,19 @@ void cb_histogramda_btnrelease (GtkWidget *widget, gpointer data) {
void cb_histogramda_keypress (GtkWidget *widget, GdkEventKey *event, gpointer data) { void cb_histogramda_keypress (GtkWidget *widget, GdkEventKey *event, gpointer data) {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__); printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
if (event == NULL) return; if (event == NULL) return;
else if (event->keyval == 'l') { else if (event->keyval == 'l') config.SetHistogramLog(config.GetHistogramLog() == 0);
if (config.histogram_log == 0) config.histogram_log = 1; };
else config.histogram_log = 0;
}
void cb_histogram_show_window (GtkWidget *widget, gpointer data) {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
GtkWidget *wnd = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "window-histogram"));
gtk_widget_show(wnd);
}; };

@ -14,6 +14,7 @@
<property name="title" translatable="yes">Detect</property> <property name="title" translatable="yes">Detect</property>
<property name="default-width">440</property> <property name="default-width">440</property>
<property name="default-height">250</property> <property name="default-height">250</property>
<signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
@ -469,6 +470,7 @@
<object class="GtkWindow" id="window-histogram"> <object class="GtkWindow" id="window-histogram">
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="title" translatable="yes">Histogram</property> <property name="title" translatable="yes">Histogram</property>
<signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
<child> <child>
<object class="GtkDrawingArea" id="histogram-da"> <object class="GtkDrawingArea" id="histogram-da">
<property name="visible">True</property> <property name="visible">True</property>
@ -487,6 +489,7 @@
<property name="title" translatable="yes">Input</property> <property name="title" translatable="yes">Input</property>
<property name="default-width">400</property> <property name="default-width">400</property>
<property name="default-height">300</property> <property name="default-height">300</property>
<signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
<child> <child>
<object class="GtkDrawingArea" id="video-da"> <object class="GtkDrawingArea" id="video-da">
<property name="visible">True</property> <property name="visible">True</property>
@ -520,61 +523,46 @@
<object class="GtkMenuItem"> <object class="GtkMenuItem">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">_Datei</property> <property name="label" translatable="yes">_Window</property>
<property name="use-underline">True</property> <property name="use-underline">True</property>
<child type="submenu"> <child type="submenu">
<object class="GtkMenu"> <object class="GtkMenu">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<child> <child>
<object class="GtkImageMenuItem"> <object class="GtkMenuItem">
<property name="label">gtk-new</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">_Detect</property>
<property name="use-underline">True</property> <property name="use-underline">True</property>
<property name="use-stock">True</property> <signal name="activate" handler="cb_detect_show_window" swapped="no"/>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkImageMenuItem"> <object class="GtkMenuItem">
<property name="label">gtk-open</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">_Input</property>
<property name="use-underline">True</property> <property name="use-underline">True</property>
<property name="use-stock">True</property> <signal name="activate" handler="cb_input_show_window" swapped="no"/>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkImageMenuItem"> <object class="GtkMenuItem">
<property name="label">gtk-save</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">_Output</property>
<property name="use-underline">True</property> <property name="use-underline">True</property>
<property name="use-stock">True</property> <signal name="activate" handler="cb_output_show_window" swapped="no"/>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkImageMenuItem"> <object class="GtkMenuItem">
<property name="label">gtk-save-as</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">_Histogram</property>
<property name="use-underline">True</property> <property name="use-underline">True</property>
<property name="use-stock">True</property> <signal name="activate" handler="cb_histogram_show_window" swapped="no"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object> </object>
</child> </child>
</object> </object>
@ -585,77 +573,31 @@
<object class="GtkMenuItem"> <object class="GtkMenuItem">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">_Bearbeiten</property> <property name="label" translatable="yes">_Settings</property>
<property name="use-underline">True</property> <property name="use-underline">True</property>
<child type="submenu"> <child type="submenu">
<object class="GtkMenu"> <object class="GtkMenu">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<child> <child>
<object class="GtkImageMenuItem"> <object class="GtkCheckMenuItem" id="menu-settings-bilinearrgb">
<property name="label">gtk-cut</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="tooltip-text" translatable="yes">Encoding of
BB GG BB GG
GG RR GG RR
Image Data</property>
<property name="label" translatable="yes">_Bilinear RGB Encoding (RAW8/RAW16)</property>
<property name="use-underline">True</property> <property name="use-underline">True</property>
<property name="use-stock">True</property> <signal name="toggled" handler="cb_menu_set_rgbenc" swapped="no"/>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkImageMenuItem"> <object class="GtkCheckMenuItem" id="menu-settings-loghistogram">
<property name="label">gtk-copy</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-paste</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_Ansicht</property>
<property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_Hilfe</property>
<property name="use-underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-about</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">_Log-Histogram</property>
<property name="use-underline">True</property> <property name="use-underline">True</property>
<property name="use-stock">True</property>
</object> </object>
</child> </child>
</object> </object>
@ -1013,6 +955,7 @@
<property name="title" translatable="yes">Output</property> <property name="title" translatable="yes">Output</property>
<property name="default-width">400</property> <property name="default-width">400</property>
<property name="default-height">300</property> <property name="default-height">300</property>
<signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>

Loading…
Cancel
Save