diff --git a/Makefile.rules.linux b/Makefile.rules.linux index 5be2262..784621a 100644 --- a/Makefile.rules.linux +++ b/Makefile.rules.linux @@ -5,7 +5,7 @@ CPP = c++ CPPFLAGS = -std=c++11 -ggdb -Wall -Werror -O0 `pkg-config --cflags gtk+-3.0 gmodule-export-2.0` -Wl,--export-dynamic -I/usr/include -DBUILD_LINUX=1 INCLUDES = LDFLAGS = -LIBS = `pkg-config --libs gtk+-3.0 gmodule-export-2.0` -L/usr/lib -ljpeg +LIBS = `pkg-config --libs gtk+-3.0 gmodule-export-2.0` -L/usr/lib -ljpeg -ltiff OBJECTS = diff --git a/video.cc b/video.cc index ba39db0..28d204f 100644 --- a/video.cc +++ b/video.cc @@ -471,13 +471,16 @@ void cb_video_btnstop (GtkWidget *widget, gpointer data) { * Access to this data must be Locked before use. */ gboolean cb_thread_video (gpointer data) { - GtkWidget *btnstart; - GtkWidget *btnstop; + GtkWidget *btnstart = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "btn-video-rec")); + GtkWidget *btnstop = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "btn-video-stop")); VideoDevThreadData *cbdata = (VideoDevThreadData*) data; VideoFrame *vf = NULL; -// printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__); + if (videodev == NULL) return false; + // + // after video starts, on the first frame + // read out all controls if (cbdata != NULL) { vf = &cbdata->vf; if (cbdata->running == 1) { @@ -486,11 +489,9 @@ gboolean cb_thread_video (gpointer data) { } if (vf->w <= 0 || vf->h <= 0 || vf->data == NULL) vf = NULL; } - if (videodev == NULL) return false; - - btnstop = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "btn-video-stop")); - btnstart = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "btn-video-rec")); + // + // create video drawarea if needed if (video_da == NULL) video_da = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "video-da")); @@ -499,6 +500,9 @@ gboolean cb_thread_video (gpointer data) { memset (gdk_pixbuf_get_pixels(video_pixbuf), 0, 3 * gdk_pixbuf_get_height(video_pixbuf) * gdk_pixbuf_get_width(video_pixbuf)); } + // + // if cbdata not set, we have a error on the video stream + // stop recording. Else push framedata into the detect thread. if (cbdata == NULL) { printf ("%s:%d %s something went wrong CBData == NULL\n", __FILE__, __LINE__, __FUNCTION__); videodev->Stop(); @@ -512,6 +516,9 @@ gboolean cb_thread_video (gpointer data) { int pix_h, pix_w; videodev->LockMutex(); + + // + // check and resize video_drawarea if needed if (video_pixbuf) { pix_h = gdk_pixbuf_get_height(video_pixbuf); pix_w = gdk_pixbuf_get_width(video_pixbuf); @@ -526,9 +533,13 @@ gboolean cb_thread_video (gpointer data) { pix_w = vf->w; pix_h = vf->h; } - vf->ToPixbuf(video_pixbuf); - detect.NewFrame(vf); + + vf->ToPixbuf(video_pixbuf); // convert Frame to pixeldata + detect.NewFrame(vf); // push new data to detect object + videodev->UnLockMutex(); + + // redraw drawarea on screen. gdk_window_invalidate_rect(gtk_widget_get_window(video_da), NULL, true); }