finished with the gui. writing SER files next.

master
Steffen Pohle 1 year ago
parent 9670beb903
commit 173d4bc01d

@ -91,10 +91,12 @@ void cb_menu_set_rgbenc (GtkCheckMenuItem *checkmenuitem, gpointer user_data) {
} }
//data
//
// callback from filter thread. Data will point to the output VideoFrame. // callback from filter thread. Data will point to the output VideoFrame.
// Access to this data must be Locked before use. // Access to this data must be Locked before use.
gboolean cb_thread_filter (gpointer data) { //
/* gboolean cb_thread_filter (gpointer data) {
VideoFrame *vf = (VideoFrame *) data; VideoFrame *vf = (VideoFrame *) data;
int pix_h, pix_w; int pix_h, pix_w;
@ -127,6 +129,7 @@ gboolean cb_thread_filter (gpointer data) {
output.UnLockImageMutex(); output.UnLockImageMutex();
return false; return false;
}; };
*/
// //

12
gui.h

@ -154,15 +154,13 @@ G_MODULE_EXPORT gboolean cb_thread_video (gpointer data);
G_MODULE_EXPORT void cb_input_show_window (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_input_show_window (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_input_btncapture (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_input_btncapture (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_input_btnsnapshot (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_input_btnsnapshot (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_input_btnstop (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_input_btnscale (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_input_btnscale (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_input_btnsetdestpath (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_input_btnsetdestpath (GtkWidget *widget, gpointer data);
// //
// filter detect or image data // filter detect or image data
G_MODULE_EXPORT void cb_imagetempda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data); G_MODULE_EXPORT void cb_imagetempda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data);
G_MODULE_EXPORT gboolean cb_thread_filter (gpointer data);
G_MODULE_EXPORT gboolean cb_thread_detect (gpointer data);
G_MODULE_EXPORT gboolean cb_thread_posctl (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);
@ -212,10 +210,16 @@ G_MODULE_EXPORT void cb_menu_set_histlog (GtkCheckMenuItem *checkmenuitem, gpoi
G_MODULE_EXPORT void cb_menu_set_displaycalibdata(GtkCheckMenuItem *checkmenuitem, gpointer user_data); G_MODULE_EXPORT void cb_menu_set_displaycalibdata(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
// //
// error handling // error handling and thread handling
G_MODULE_EXPORT gboolean errormessage_thread (gpointer data); G_MODULE_EXPORT gboolean errormessage_thread (gpointer data);
G_MODULE_EXPORT void errormessage_cb_btnok (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void errormessage_cb_btnok (GtkWidget *widget, gpointer data);
// G_MODULE_EXPORT gboolean cb_thread_filter (gpointer data);
G_MODULE_EXPORT gboolean cb_thread_detect (gpointer data);
G_MODULE_EXPORT gboolean cb_thread_posctl (gpointer data);
G_MODULE_EXPORT gboolean cb_thread_output (gpointer data);
#ifdef __cplusplus #ifdef __cplusplus

@ -6,9 +6,60 @@
#include "config.h" #include "config.h"
#include "gui.h" #include "gui.h"
#include "output.h" #include "output.h"
#include "configuration.h"
#include "error.h"
extern GtkBuilder *_builder_; // work around for threads
extern Output output; extern Output output;
/*
* callback from output thread
*/
gboolean cb_thread_output (gpointer data) {
int mode = output.GetStatus();
GtkWidget *btncapture = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "btn_inputcapture"));
GtkWidget *btnstop = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "btn_inputstop"));
GtkWidget *btnsnapshot = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "btn_inputsnapshot"));
GtkWidget *btninputdest = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "input_btn_destpath"));
GtkWidget *inputdest = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "input_entry_destpath"));
if (mode & OUTPUT_MODE_SER_STARTED) {
gtk_widget_set_sensitive(btnstop, true);
gtk_widget_set_sensitive(btncapture, false);
gtk_widget_set_sensitive(btnsnapshot, false);
gtk_widget_set_sensitive(btninputdest, false);
gtk_widget_set_sensitive(inputdest, false);
}
else {
gtk_widget_set_sensitive(btnstop, false);
gtk_widget_set_sensitive(btncapture, true);
gtk_widget_set_sensitive(btnsnapshot, true);
gtk_widget_set_sensitive(btninputdest, true);
gtk_widget_set_sensitive(inputdest, true);
}
return false;
}
void cb_input_btncapture (GtkWidget *widget, gpointer data) {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
GtkWidget *inputdest = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "input_entry_destpath"));
std::string s = gtk_entry_get_text(GTK_ENTRY(inputdest));
output.SERStart(s);
};
void cb_input_btnsnapshot (GtkWidget *widget, gpointer data) {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
};
void cb_input_btnstop (GtkWidget *widget, gpointer data) {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
output.SERStop();
};
// //
// C / C++ Wrapper for the thread function // C / C++ Wrapper for the thread function
// //
@ -19,6 +70,9 @@ gpointer _OutputThread (gpointer data) {
/*
*
*/
Output::Output() { // @suppress("Class members should be properly initialized") Output::Output() { // @suppress("Class members should be properly initialized")
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__); printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
@ -30,9 +84,36 @@ Output::Output() { // @suppress("Class members should be properly initialized")
inFrame.Delete(); inFrame.Delete();
thread = NULL; thread = NULL;
thread = g_thread_new("Output", _OutputThread, NULL); thread = g_thread_new("Output", _OutputThread, NULL);
mode = 0;
};
void Output::NotifyGTK () {
gdk_threads_add_idle(cb_thread_output, NULL);
}
/*
* open output file and set mode flag
*/
void Output::SERStart (std::string destpath) {
printf ("%s:%d SERStart Destination Folder: %s\n", __FILE__, __LINE__, destpath.c_str());
mode |= OUTPUT_MODE_SER_STARTED;
// start SER output
NotifyGTK();
}; };
/*
* clode output file
*/
void Output::SERStop () {
mode &= ~(OUTPUT_MODE_SER_STARTED);
// stop SER output
NotifyGTK();
};
Output::~Output() { Output::~Output() {
running = 0; running = 0;
@ -47,7 +128,10 @@ Output::~Output() {
int Output::NewFrame(VideoFrameRaw *rawframe) { int Output::NewFrame(VideoFrameRaw *rawframe) {
if (rawframe == NULL) return -1; if (rawframe == NULL) return -1;
printf ("%s:%d Output::NewFrame Frame Raw: %d x %d Type: %s\n", __FILE__, __LINE__, rawframe->w, rawframe->h, convert_from_pixelformat(rawframe->pixfmt).c_str()); // printf ("%s:%d Output::NewFrame Frame Raw: %d x %d Type: %s\n", __FILE__, __LINE__, rawframe->w, rawframe->h, convert_from_pixelformat(rawframe->pixfmt).c_str());
if (inFrameNew) {
printf ("%s:%d Output::NewFrame truncating one frame.\n", __FILE__, __LINE__);
}
LockInMutex(); LockInMutex();
inFrame.CopyFrom(rawframe); inFrame.CopyFrom(rawframe);
@ -57,11 +141,6 @@ int Output::NewFrame(VideoFrameRaw *rawframe) {
}; };
void Output::NewImage() {
// newimage = 1;
}
// //
// NewFrame: will set new frame // NewFrame: will set new frame
// Thread: newFrame |------> Find Object --- not found ---> send gui information // Thread: newFrame |------> Find Object --- not found ---> send gui information
@ -69,17 +148,16 @@ void Output::Thread() {
while (running) { while (running) {
// check for new frame // check for new frame
LockInMutex(); LockInMutex();
if (inFrameNew == 1) { if (inFrameNew == 1) {
if (mode & OUTPUT_MODE_SER_STARTED) {
// for now display error message
errormessage_display((char*)"windows-main", (char*)"Error", (char*)"Writing SER files is not finished yet.");
SERStop();
}
inFrameNew = 0; inFrameNew = 0;
//
// do some other stuff use if possible only the oldFrame data
ComposeOutput();
UnLockInMutex();
// copy output image for gtk
} }
else
UnLockInMutex(); UnLockInMutex();
usleep (10000); // sleep 10ms usleep (10000); // sleep 10ms
@ -87,8 +165,3 @@ void Output::Thread() {
} }
void Output::ComposeOutput() {
// printf ("%s:%d inFrame (w:%d h:%d)\n", __FILE__, __LINE__, inFrame.w, inFrame.h);
}

@ -14,6 +14,8 @@
#include "videoframe.h" #include "videoframe.h"
#define OUTPUT_MODE_SER_STARTED 0x0001
class Output { class Output {
private: private:
int running; int running;
@ -24,18 +26,16 @@ private:
GMutex mutextmp; // for access the temp image GMutex mutextmp; // for access the temp image
GMutex mutex; // general mutex for changing settings GMutex mutex; // general mutex for changing settings
GThread *thread; GThread *thread;
unsigned int mode; // see OUTPUT_MODE_ flags
// int newimage;
void ComposeOutput(); void ComposeOutput();
void NotifyGTK ();
public: public:
Output(); Output();
~Output(); ~Output();
int NewFrame (VideoFrameRaw *rawframe); int NewFrame (VideoFrameRaw *rawframe);
void NewImage ();
//
// Thread Releated Functions (maybe soon private?) // Thread Releated Functions (maybe soon private?)
int TryLockInMutex() { return g_mutex_trylock(&mutexin); }; int TryLockInMutex() { return g_mutex_trylock(&mutexin); };
void LockInMutex() { g_mutex_lock(&mutexin);}; void LockInMutex() { g_mutex_lock(&mutexin);};
@ -54,6 +54,11 @@ public:
void SetObject (VideoFrame objFrame, int newx, int newy); void SetObject (VideoFrame objFrame, int newx, int newy);
void GetObjectPos (int *x, int *y); void GetObjectPos (int *x, int *y);
void SERStart(std::string destpath);
void SERStop();
int GetStatus() { return mode; };
void Thread(); void Thread();
}; };

@ -2458,6 +2458,21 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkButton" id="btn_inputstop">
<property name="label" translatable="yes">Stop</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="activate" handler="cb_input_btnstop" swapped="no"/>
<signal name="pressed" handler="cb_input_btnstop" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkComboBoxText"> <object class="GtkComboBoxText">
<property name="visible">True</property> <property name="visible">True</property>
@ -2472,19 +2487,11 @@
<item translatable="yes">Flat</item> <item translatable="yes">Flat</item>
<item translatable="yes">DarkFlat</item> <item translatable="yes">DarkFlat</item>
</items> </items>
<child internal-child="entry">
<object class="GtkEntry">
<property name="can-focus">False</property>
<property name="editable">False</property>
<property name="width-chars">6</property>
<property name="text" translatable="yes">Light</property>
</object>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>

@ -860,16 +860,6 @@ void cb_video_cbox_videodev (GtkWidget *widget, gpointer data) {
}; };
void cb_input_btncapture (GtkWidget *widget, gpointer data) {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
};
void cb_input_btnsnapshot (GtkWidget *widget, gpointer data) {
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
};
/* /*
* resize windows depending on the button which was pressed * resize windows depending on the button which was pressed
*/ */
@ -905,3 +895,6 @@ void cb_input_btnscale (GtkWidget *widget, gpointer data) {
gtk_window_resize(GTK_WINDOW(win), ww, wh); gtk_window_resize(GTK_WINDOW(win), ww, wh);
}; };

Loading…
Cancel
Save