adding new gui elements

test16bit
Steffen Pohle 4 years ago
parent e8f891e8b2
commit f1e1bd83f7

@ -33,13 +33,16 @@ Detect::Detect() { // @suppress("Class members should be properly initialized")
thread = g_thread_new("Detect", _DetectThread, NULL); thread = g_thread_new("Detect", _DetectThread, NULL);
objectW = 300; objectW = 300;
objectH = 300; objectH = 300;
objectX = -1;
objectY = -1;
posmaxx = 0; posmaxx = 0;
posmaxy = 0; posmaxy = 0;
maxx = NULL; maxx = NULL;
maxy = NULL; maxy = NULL;
detmatrix = NULL; detmatrix = NULL;
detmatrixv2 = NULL; detmatrixv2 = NULL;
autodetecttype = 2; autodetecttype = 0;
autofollowtype = 0;
}; };
@ -69,8 +72,10 @@ int Detect::NewFrame(VideoFrame *newframe) {
// Thread: newFrame |------> Find Object --- not found ---> send gui information // Thread: newFrame |------> Find Object --- not found ---> send gui information
void Detect::Thread() { void Detect::Thread() {
DetectOutput output; DetectOutput output;
int errorinputtype = -1; int errorinputtype = -1, x, y;
int posx = -1, posy = -1;
objectX = -1;
objectY = -1;
while (running) { while (running) {
// check for new frame // check for new frame
@ -83,36 +88,31 @@ void Detect::Thread() {
// //
// 1. if no position of the object is known, search brightest // 1. if no position of the object is known, search brightest
// object on the inFrame image. // object on the inFrame image.
if (objectX < objectW/2 || objectX > (inFrame.w-objectW/2) ||
objectY < objectH/2 || objectY > (inFrame.h-objectH/2))
{
switch (autodetecttype) {
case AUTODETECT_BRIGHT:
InputDetect(&objectX, &objectY);
break;
default:
break;
}
}
//
// 2. check near the last known position. // 2. check near the last known position.
//
switch (autodetecttype) { else {
case -1: switch (autofollowtype) {
// no detection case AUTOFOLLOW_BRIGHT:
break; InputDetect(&objectX, &objectY);
break;
case 0: case AUTOFOLLOW_CROSSC:
InputDetect(&posx, &posy); InputDetectCrossC(&objectX, &objectY);
break; break;
default:
case 1: break;
if (posx < objectW/2 || posy < objectH/2 || }
posx > (inFrame.w-objectW/2) || posy > (inFrame.h-objectH/2))
InputDetect(&posx, &posy);
else InputDetectCrossC(&posx, &posy);
break;
case 2:
if (posx < objectW/2 || posy < objectH/2 ||
posx > (inFrame.w-objectW/2) || posy > (inFrame.h-objectH/2))
InputDetect(&posx, &posy);
else InputDetectCrossCv2(&posx, &posy);
break;
default:
if (errorinputtype != autodetecttype)
printf ("%s:%d %s error: autodetecttype (%d) not found\n", __FILE__, __LINE__, __FUNCTION__, autodetecttype);
errorinputtype = autodetecttype;
break;
} }
oldFrame.CopyFrom(&inFrame); oldFrame.CopyFrom(&inFrame);
@ -123,11 +123,12 @@ void Detect::Thread() {
imagegtk.CopyFrom(&image); imagegtk.CopyFrom(&image);
UnLockImageMutex(); UnLockImageMutex();
output.posx = objectX;
output.posy = objectY;
output.image = &imagegtk;
UnLockMutex(); // unlock Config UnLockMutex(); // unlock Config
output.posx = posx;
output.posy = posy;
output.image = &imagegtk;
gdk_threads_add_idle(cb_thread_detect , &output); gdk_threads_add_idle(cb_thread_detect , &output);
} }
else else
@ -148,15 +149,22 @@ void Detect::SetInputSize (int nw, int nh) {
maxy = (float*) malloc (nh * sizeof (float)); maxy = (float*) malloc (nh * sizeof (float));
} }
if ((posmaxx * posmaxy) < (nw * nh) || detmatrix != NULL) { if ((posmaxx * posmaxy) < (nw * nh)) {
free (detmatrix); printf ("%s:%d %s reset Object Position (%d,%d) < (%d,%d) detmatrix:%p\n", __FILE__, __LINE__, __FUNCTION__,
free (detmatrixv2); posmaxx, posmaxy, nw, nh, detmatrix);
if (detmatrix != NULL) {
free (detmatrix);
free (detmatrixv2);
}
detmatrix = (float*) malloc (sizeof(float) * nw * nh); detmatrix = (float*) malloc (sizeof(float) * nw * nh);
detmatrixv2 = (uint16_t*) malloc (sizeof(uint16_t) * nw * nh); detmatrixv2 = (uint16_t*) malloc (sizeof(uint16_t) * nw * nh);
}
posmaxx = nw; objectX = nw/2;
posmaxy = nh; objectY = nw/2;
posmaxx = nw;
posmaxy = nh;
}
} }
@ -234,7 +242,7 @@ void Detect::InputDetect(int *posx, int *posy) {
#define OBJSIZE 50 #define OBJSIZE 50
#define MAXSHIFT 40 #define MAXSHIFT 20
// #define DEBUGTIMES 1 // #define DEBUGTIMES 1
void Detect::InputDetectCrossC(int *posx, int *posy) { void Detect::InputDetectCrossC(int *posx, int *posy) {
unsigned char *pxi; // input image unsigned char *pxi; // input image
@ -284,16 +292,16 @@ void Detect::InputDetectCrossC(int *posx, int *posy) {
// fixme: help help // fixme: help help
f = 0.0; f = 0.0;
for (y = 0; y < objectH; y++) { for (y = 0; y < OBJSIZE; y++) {
oldx = (*posx)- objectW/2; oldx = (*posx)- OBJSIZE/2;
oldy = (*posy)- objectH/2 + y; oldy = (*posy)- OBJSIZE/2 + y;
oldi = 3 * (oldx + oldFrame.w * oldy); oldi = 3 * (oldx + oldFrame.w * oldy);
inx = oldx + shiftx - MAXSHIFT/2; inx = oldx + shiftx - MAXSHIFT/2;
iny = oldy + shifty - MAXSHIFT/2; iny = oldy + shifty - MAXSHIFT/2;
ini = 3* (inx + inFrame.w * iny); ini = 3* (inx + inFrame.w * iny);
for (x = 0; x < objectW; x++, oldi += 3, ini += 3, oldx++, inx++) { for (x = 0; x < OBJSIZE; x++, oldi += 3, ini += 3, oldx++, inx++) {
if (oldx >= 0 && oldy >= 0 && oldx < oldFrame.w && oldy <= oldFrame.h && if (oldx >= 0 && oldy >= 0 && oldx < oldFrame.w && oldy <= oldFrame.h &&
inx >= 0 && inx < inFrame.w && iny >= 0 && iny < inFrame.h) { inx >= 0 && inx < inFrame.w && iny >= 0 && iny < inFrame.h) {
f += (float)(pxo[oldi+0])*(float)(pxi[ini+0]); f += (float)(pxo[oldi+0])*(float)(pxi[ini+0]);
@ -313,18 +321,7 @@ void Detect::InputDetectCrossC(int *posx, int *posy) {
*posx += (mxx-MAXSHIFT/2); *posx += (mxx-MAXSHIFT/2);
*posy += (mxy-MAXSHIFT/2); *posy += (mxy-MAXSHIFT/2);
CopyObjectImage (*posx, *posy);
//
// copy image data to destination
for (x = 0; x < objectW; x++) for (y = 0; y < objectH; y++) {
desti = 3*(x + y * objectW);
ini = 3*((x + *posx - objectW/2) + (y + *posy - objectH/2) * inFrame.w);
if (desti < 0 || desti > objectW*objectH*3) continue;
if (ini < 0 || ini > inFrame.w*inFrame.h*3) continue;
pxd[desti+0] = pxi[ini+0];
pxd[desti+1] = pxi[ini+1];
pxd[desti+2] = pxi[ini+2];
}
#ifdef DEBUGTIMES #ifdef DEBUGTIMES
f = get_cycletime(&t1); f = get_cycletime(&t1);
@ -335,118 +332,57 @@ void Detect::InputDetectCrossC(int *posx, int *posy) {
} }
#define OBJSIZE 50 void Detect::CopyObjectImage(int objx, int objy) {
#define MAXSHIFT 20 int x, y, desti, ini;
// #define DEBUGTIMES 1
void Detect::InputDetectCrossCv2(int *posx, int *posy) {
unsigned char *pxi; // input image unsigned char *pxi; // input image
unsigned char *pxd; // destination image unsigned char *pxd; // destination image
unsigned char *pxo; // old image
int inx, iny, oldx, oldy;
struct timeval t1, t2;
int shiftx, shifty, x, y, ini, oldi, desti, mxi, mxx, mxy;
float f;
if (oldFrame.h != inFrame.h || oldFrame.w != inFrame.w || *posx == -1 || *posy == -1) {
*posx = -1;
*posy = -1;
return;
}
#ifdef DEBUGTIMES
f = get_cycletime(&t1);
t2 = t1;
#endif
if (objectW > inFrame.w || objectH > inFrame.h) {
printf ("%s:%d %s objectW,H (%d,%d) > inFrame.W,H (%d, %d)\n", __FILE__, __LINE__, __FUNCTION__,
objectW, objectH, inFrame.w, inFrame.h);
*posx = -1;
*posy = -1;
return;
}
image.SetSize (objectW, objectH);
SetInputSize(inFrame.w, inFrame.h);
pxi = inFrame.data; pxi = inFrame.data;
pxo = oldFrame.data;
pxd = image.data; pxd = image.data;
#ifdef DEBUGTIMES
f = get_cycletime(&t1);
printf ("%s:%d setup memory time needed:%f\n", __FILE__, __LINE__, f);
#endif
mxx = mxy = 0;
for (shifty = 0; shifty < MAXSHIFT; shifty++) {
// printf ("%s:%d %s shift (%d)\n", __FILE__, __LINE__, __FUNCTION__, shifty);
mxi = shifty * objectW;
for (shiftx = 0; shiftx < MAXSHIFT; shiftx++, mxi++) {
// fixme: help help
f = 0.0;
for (y = 0; y < OBJSIZE; y++) {
oldx = (*posx)- OBJSIZE/2;
oldy = (*posy)- OBJSIZE/2 + y;
oldi = 3 * (oldx + oldFrame.w * oldy);
inx = oldx + shiftx - MAXSHIFT/2;
iny = oldy + shifty - MAXSHIFT/2;
ini = 3* (inx + inFrame.w * iny);
for (x = 0; x < OBJSIZE; x++, oldi += 3, ini += 3, oldx++, inx++) {
if (oldx >= 0 && oldy >= 0 && oldx < oldFrame.w && oldy <= oldFrame.h &&
inx >= 0 && inx < inFrame.w && iny >= 0 && iny < inFrame.h) {
f += (float)(pxo[oldi+0])*(float)(pxi[ini+0]);
}
}
}
detmatrix[mxi] = f;
if (detmatrix[mxx + (mxy * objectW)] < f) {
mxx = shiftx;
mxy = shifty;
}
}
}
// printf ("%s:%d %s pos (%d,%d) dpos (%d,%d) newpos (%d,%d)\n", __FILE__, __LINE__, __FUNCTION__,
// *posx, *posy, (mxx-MAXSHIFT/2), (mxy-MAXSHIFT/2), *posx - (mxx-MAXSHIFT/2), *posy - (mxy-MAXSHIFT/2));
*posx += (mxx-MAXSHIFT/2);
*posy += (mxy-MAXSHIFT/2);
// //
// copy image data to destination // copy image data to destination
for (x = 0; x < objectW; x++) for (y = 0; y < objectH; y++) { for (x = 0; x < objectW; x++) for (y = 0; y < objectH; y++) {
desti = 3*(x + y * objectW); desti = 3*(x + y * objectW);
ini = 3*((x + *posx - objectW/2) + (y + *posy - objectH/2) * inFrame.w); ini = 3*((x + objx - objectW/2) + (y + objy - objectH/2) * inFrame.w);
if (desti < 0 || desti > objectW*objectH*3) continue; if (desti < 0 || desti > objectW*objectH*3) continue;
if (ini < 0 || ini > inFrame.w*inFrame.h*3) continue; if (ini < 0 || ini > inFrame.w*inFrame.h*3) continue;
pxd[desti+0] = pxi[ini+0]; pxd[desti+0] = pxi[ini+0];
pxd[desti+1] = pxi[ini+1]; pxd[desti+1] = pxi[ini+1];
pxd[desti+2] = pxi[ini+2]; pxd[desti+2] = pxi[ini+2];
} }
}
#ifdef DEBUGTIMES
f = get_cycletime(&t1); //
printf ("%s:%d copy output:%f\n", __FILE__, __LINE__, f); // set/get the automatic follow mode
f = get_cycletime(&t2); void Detect::SetFollowType(int intype) {
printf ("%s:%d time needed:%f\n", __FILE__, __LINE__, f); LockMutex();
#endif autofollowtype = intype;
UnLockMutex();
} }
int Detect::GetFollowType() {
int i;
LockMutex();
i = autofollowtype;
UnLockMutex();
return i;
}
void Detect::SetInputType(int intype) {
// set/get the automatic detection mode
void Detect::SetDetectType(int intype) {
LockMutex(); LockMutex();
autodetecttype = intype; autodetecttype = intype;
UnLockMutex(); UnLockMutex();
} }
int Detect::GetInputType() { int Detect::GetDetectType() {
int i; int i;
LockMutex(); LockMutex();
@ -509,4 +445,20 @@ int Detect::GetMinBrightness() {
void Detect::GetObjectPos(int *x, int *y) {
LockMutex();
*x = objectX;
*y = objectY;
UnLockMutex();
}
void Detect::SetObjectPos(int x, int y) {
LockMutex();
image.SetSize (objectW, objectH);
SetInputSize(inFrame.w, inFrame.h);
objectX = x;
objectY = y;
CopyObjectImage (objectX, objectY);
UnLockMutex();
}

@ -13,6 +13,17 @@
#include "video.h" #include "video.h"
#include "videoframe.h" #include "videoframe.h"
enum {
AUTODETECT_OFF = 0,
AUTODETECT_BRIGHT
};
enum {
AUTOFOLLOW_OFF = 0,
AUTOFOLLOW_BRIGHT,
AUTOFOLLOW_CROSSC
};
struct { struct {
VideoFrame *image; // detected image VideoFrame *image; // detected image
@ -42,16 +53,19 @@ private:
float *detmatrix; float *detmatrix;
uint16_t *detmatrixv2; uint16_t *detmatrixv2;
int objectX; // current object position
int objectY; // current object position
int objectW; // object Image Size Width int objectW; // object Image Size Width
int objectH; // object Image Size Height int objectH; // object Image Size Height
int minBright; // min brightness int minBright; // min brightness
int autodetecttype; // input detection type to use int autodetecttype; // input detection type to use
int autofollowtype; // input detection type to use
void InputDetect (int *posx, int *posy); void InputDetect (int *posx, int *posy);
void InputDetectCrossC (int *posx, int *posy); void InputDetectCrossC (int *posx, int *posy);
void InputDetectCrossCv2 (int *posx, int *posy); // MMX optimiert
void SetInputSize (int nw, int nh); void SetInputSize (int nw, int nh);
void CopyObjectImage(int objx, int objy);
public: public:
Detect(); Detect();
@ -80,9 +94,13 @@ public:
void SetMinBrightness (int value); void SetMinBrightness (int value);
int GetMinBrightness(); int GetMinBrightness();
void SetInputType(int intype); void SetFollowType(int intype);
int GetInputType(); int GetFollowType();
void SetDetectType(int intype);
int GetDetectType();
void SetObjectPos (int x, int y);
void GetObjectPos (int *x, int *y); void GetObjectPos (int *x, int *y);
void Thread(); void Thread();

@ -16,10 +16,15 @@
#include "filter.h" #include "filter.h"
#include "detect.h" #include "detect.h"
extern GtkBuilder *_builder_; // work around for threads extern GtkBuilder *_builder_; // work around for threads
extern Filter filter; extern Filter filter;
extern Detect detect; extern Detect detect;
//
// defines what should happen on clicking a point on the input videodata
int video_enterdata = VID_ENTERDATA_NONE; // see VID_ENTERDATA_xxxxx
position_2d video_enterdata_pos;
GtkWidget *detect_da = NULL; GtkWidget *detect_da = NULL;
GdkPixbuf *detect_pixbuf = NULL; GdkPixbuf *detect_pixbuf = NULL;
@ -46,14 +51,20 @@ void cb_window_show (GtkWidget *widget, gpointer data) {
GtkWidget *btnstop = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "btn-video-stop")); GtkWidget *btnstop = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "btn-video-stop"));
GtkWidget *w = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-entry-w")); GtkWidget *w = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-entry-w"));
GtkWidget *h = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-entry-h")); GtkWidget *h = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-entry-h"));
GtkWidget *rboff = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-pos-cboff"));
GtkWidget *rbcrossc = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-type-indet2"));
// changing the value, will cause the 'change' event to be triggered
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rboff), true);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rbcrossc), true);
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
gtk_widget_set_sensitive(btnstart, true); gtk_widget_set_sensitive(btnstart, true);
gtk_widget_set_sensitive(btnstop, false); gtk_widget_set_sensitive(btnstop, false);
gtk_entry_set_text(GTK_ENTRY(w),"300"); gtk_entry_set_text(GTK_ENTRY(w),"300");
gtk_entry_set_text(GTK_ENTRY(h),"300"); gtk_entry_set_text(GTK_ENTRY(h),"300");
detect.SetObjectSize(300, 300); detect.SetObjectSize(300, 300);
g_timeout_add(2000, videoctrl_update, NULL); g_timeout_add(2000, videoctrl_update, NULL);
@ -262,7 +273,7 @@ void cb_image_btnsave (GtkWidget *widget, gpointer data) {
void cb_detect_bright (GtkRange *range, gpointer data) { void cb_detect_bright (GtkRange *range, gpointer data) {
GtkWidget *scale = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-adj-bright")); // GtkWidget *scale = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-adj-bright"));
double value; double value;
value = gtk_range_get_value(range); value = gtk_range_get_value(range);
@ -270,14 +281,36 @@ void cb_detect_bright (GtkRange *range, gpointer data) {
}; };
void cb_detect_inputtype (GtkWidget *widget, gpointer data) { void cb_detect_followtype (GtkWidget *widget, gpointer data) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)) == 1) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)) == 1) {
if (widget == GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-type-indet0")))
detect.SetFollowType(AUTOFOLLOW_OFF);
if (widget == GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-type-indet1"))) if (widget == GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-type-indet1")))
detect.SetInputType(0); detect.SetFollowType(AUTOFOLLOW_BRIGHT);
if (widget == GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-type-indet2"))) if (widget == GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-type-indet2")))
detect.SetInputType(1); detect.SetFollowType(AUTOFOLLOW_CROSSC);
if (widget == GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-type-indet3"))) }
detect.SetInputType(2); };
void cb_detect_detecttype (GtkWidget *widget, gpointer data) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)) == 1) {
if (widget == GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-pos-cboff")))
detect.SetDetectType(AUTODETECT_OFF);
if (widget == GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-pos-cbbright")))
detect.SetDetectType(AUTODETECT_BRIGHT);
} }
}; };
void cb_detect_btnsetpos (GtkWidget *widget, gpointer data) {
GtkWidget *rboff = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "detect-pos-cboff"));
// changing the value, will cause the 'change' event to be triggered
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rboff), true);
video_enterdata = VID_ENTERDATA_POS;
};

17
gui.h

@ -15,8 +15,18 @@
#include <iostream> #include <iostream>
#include <list> #include <list>
enum {
VID_ENTERDATA_NONE = 0,
VID_ENTERDATA_POS
};
#define BUILDER_FILE "simpleskycam.ui" #define BUILDER_FILE "simpleskycam.ui"
struct {
int x;
int y;
} typedef position_2d;
void displayerror (std::string error); void displayerror (std::string error);
#ifdef __cplusplus #ifdef __cplusplus
@ -40,7 +50,9 @@ G_MODULE_EXPORT void cb_video_btnrec (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_video_btnstop (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_video_btnstop (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_videoda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data); G_MODULE_EXPORT void cb_videoda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data);
G_MODULE_EXPORT gboolean video_display(gpointer data); G_MODULE_EXPORT gboolean video_display(gpointer data);
G_MODULE_EXPORT void cb_videoda_motionevent (GtkWidget *widget, GdkEvent *event, gpointer data);
G_MODULE_EXPORT void cb_videoda_btnpress (GtkWidget *widget, GdkEvent *event, gpointer data);
G_MODULE_EXPORT void cb_videoda_btnrelease (GtkWidget *widget, GdkEvent *event, gpointer data);
G_MODULE_EXPORT void cb_vidctrl_entry_change (GtkWidget *widget, gpointer data); G_MODULE_EXPORT void cb_vidctrl_entry_change (GtkWidget *widget, gpointer data);
G_MODULE_EXPORT void cb_vidctrl_scale_change (GtkRange *range, gpointer data); G_MODULE_EXPORT void cb_vidctrl_scale_change (GtkRange *range, gpointer data);
gboolean videoctrl_update(gpointer data); gboolean videoctrl_update(gpointer data);
@ -65,7 +77,8 @@ G_MODULE_EXPORT void cb_detect_bright (GtkRange *range, gpointer data);
// detection elements // detection elements
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_inputtype (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);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -2,7 +2,7 @@
<!-- Generated with glade 3.38.2 --> <!-- Generated with glade 3.38.2 -->
<interface> <interface>
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<object class="GtkAdjustment" id="detect-adj-bright"> <object class="GtkAdjustment" id="detect-pos-adjbright">
<property name="upper">255.99</property> <property name="upper">255.99</property>
<property name="value">50</property> <property name="value">50</property>
<property name="step-increment">1</property> <property name="step-increment">1</property>
@ -34,7 +34,13 @@
<object class="GtkDrawingArea" id="video-da"> <object class="GtkDrawingArea" id="video-da">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="events">GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK | GDK_BUTTON3_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK | GDK_VISIBILITY_NOTIFY_MASK | GDK_PROXIMITY_IN_MASK | GDK_PROXIMITY_OUT_MASK | GDK_SUBSTRUCTURE_MASK | GDK_SCROLL_MASK | GDK_TOUCH_MASK | GDK_SMOOTH_SCROLL_MASK | GDK_TOUCHPAD_GESTURE_MASK | GDK_TABLET_PAD_MASK</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<signal name="button-press-event" handler="cb_videoda_btnpress" swapped="no"/>
<signal name="button-release-event" handler="cb_videoda_btnrelease" swapped="no"/>
<signal name="draw" handler="cb_videoda_draw" swapped="no"/> <signal name="draw" handler="cb_videoda_draw" swapped="no"/>
<signal name="motion-notify-event" handler="cb_videoda_motionevent" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="resize">False</property> <property name="resize">False</property>
@ -224,17 +230,14 @@
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="valign">start</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">2</property>
<property name="baseline-position">top</property>
<child> <child>
<!-- n-columns=7 n-rows=2 --> <object class="GtkBox">
<object class="GtkGrid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="margin-left">8</property>
<property name="margin-start">8</property>
<property name="margin-end">8</property>
<property name="margin-top">8</property>
<property name="margin-bottom">8</property>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
@ -243,57 +246,18 @@
<property name="margin-right">8</property> <property name="margin-right">8</property>
<property name="margin-start">8</property> <property name="margin-start">8</property>
<property name="margin-end">8</property> <property name="margin-end">8</property>
<property name="label" translatable="yes">Position</property> <property name="label" translatable="yes">Position:</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Size:</property>
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="expand">False</property>
<property name="top-attach">1</property> <property name="fill">True</property>
</packing> <property name="position">0</property>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">8</property>
<property name="margin-right">8</property>
<property name="margin-start">8</property>
<property name="margin-end">8</property>
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
<property name="label" translatable="yes">X:</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
<property name="label" translatable="yes">W:</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkEntry" id="detect-entry-posx"> <object class="GtkEntry" id="detect-entry-posx">
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="margin-left">4</property> <property name="margin-left">4</property>
<property name="margin-right">4</property> <property name="margin-right">4</property>
@ -307,70 +271,85 @@
<property name="input-purpose">digits</property> <property name="input-purpose">digits</property>
</object> </object>
<packing> <packing>
<property name="left-attach">2</property> <property name="expand">False</property>
<property name="top-attach">0</property> <property name="fill">True</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkEntry" id="detect-entry-w"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">False</property>
<property name="margin-left">4</property> <property name="halign">center</property>
<property name="margin-right">4</property> <property name="margin-top">3</property>
<property name="margin-start">4</property>
<property name="margin-end">4</property>
<property name="margin-top">4</property>
<property name="margin-bottom">4</property> <property name="margin-bottom">4</property>
<property name="width-chars">5</property> <property name="label" translatable="yes">,</property>
<property name="max-width-chars">5</property>
</object> </object>
<packing> <packing>
<property name="left-attach">2</property> <property name="expand">False</property>
<property name="top-attach">1</property> <property name="fill">True</property>
<property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkEntry" id="detect-entry-posy">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="margin-left">4</property>
<property name="margin-right">4</property>
<property name="margin-start">4</property>
<property name="margin-end">4</property>
<property name="margin-top">4</property> <property name="margin-top">4</property>
<property name="margin-bottom">4</property> <property name="margin-bottom">4</property>
<property name="label" translatable="yes">Y:</property> <property name="width-chars">5</property>
<property name="max-width-chars">5</property>
</object> </object>
<packing> <packing>
<property name="left-attach">3</property> <property name="expand">False</property>
<property name="top-attach">0</property> <property name="fill">True</property>
<property name="position">3</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkButton" id="detect-btnsetpos">
<property name="label" translatable="yes">Set Pos</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="margin-left">8</property>
<property name="margin-right">8</property>
<property name="margin-start">8</property>
<property name="margin-end">8</property>
<property name="margin-top">4</property> <property name="margin-top">4</property>
<property name="margin-bottom">4</property> <property name="margin-bottom">4</property>
<property name="label" translatable="yes">H:</property> <signal name="activate" handler="cb_detect_btnsetpos" swapped="no"/>
<signal name="pressed" handler="cb_detect_btnsetpos" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left-attach">3</property> <property name="expand">False</property>
<property name="top-attach">1</property> <property name="fill">False</property>
<property name="position">4</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkEntry" id="detect-entry-posy"> <object class="GtkButton" id="detect-btnsetsize">
<property name="label" translatable="yes">Set Size</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="margin-left">4</property> <property name="receives-default">True</property>
<property name="margin-right">4</property> <property name="margin-start">8</property>
<property name="margin-start">4</property> <property name="margin-end">8</property>
<property name="margin-end">4</property>
<property name="margin-top">4</property> <property name="margin-top">4</property>
<property name="margin-bottom">4</property> <property name="margin-bottom">4</property>
<property name="width-chars">5</property> <signal name="activate" handler="cb_detect_btnsetsize" swapped="no"/>
<property name="max-width-chars">5</property> <signal name="pressed" handler="cb_detect_btnsetsize" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left-attach">4</property> <property name="expand">False</property>
<property name="top-attach">0</property> <property name="fill">False</property>
<property name="pack-type">end</property>
<property name="position">5</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -387,76 +366,58 @@
<property name="max-width-chars">5</property> <property name="max-width-chars">5</property>
</object> </object>
<packing> <packing>
<property name="left-attach">4</property> <property name="expand">False</property>
<property name="top-attach">1</property> <property name="fill">True</property>
</packing> <property name="pack-type">end</property>
</child> <property name="position">6</property>
<child>
<object class="GtkCheckButton" id="detect-cb-auto">
<property name="label" translatable="yes">Auto</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="margin-left">10</property>
<property name="margin-right">8</property>
<property name="margin-start">10</property>
<property name="margin-end">8</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">5</property>
<property name="top-attach">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="detect-btnsetsize"> <object class="GtkLabel">
<property name="label" translatable="yes">Set Size</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">False</property>
<property name="receives-default">True</property>
<property name="margin-left">8</property>
<property name="margin-right">8</property>
<property name="margin-start">8</property>
<property name="margin-end">8</property>
<property name="margin-top">4</property> <property name="margin-top">4</property>
<property name="margin-bottom">4</property> <property name="margin-bottom">4</property>
<signal name="activate" handler="cb_detect_btnsetsize" swapped="no"/> <property name="label" translatable="yes">x</property>
<signal name="pressed" handler="cb_detect_btnsetsize" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left-attach">6</property> <property name="expand">False</property>
<property name="top-attach">1</property> <property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">7</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="detect-btnsetpos"> <object class="GtkEntry" id="detect-entry-w">
<property name="label" translatable="yes">Set Pos</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="receives-default">True</property> <property name="margin-left">4</property>
<property name="margin-left">8</property> <property name="margin-right">4</property>
<property name="margin-right">8</property> <property name="margin-start">4</property>
<property name="margin-start">8</property> <property name="margin-end">4</property>
<property name="margin-end">8</property>
<property name="margin-top">4</property> <property name="margin-top">4</property>
<property name="margin-bottom">4</property> <property name="margin-bottom">4</property>
<signal name="activate" handler="cb_detect_btnsetpos" swapped="no"/> <property name="width-chars">5</property>
<signal name="pressed" handler="cb_detect_btnsetpos" swapped="no"/> <property name="max-width-chars">5</property>
</object> </object>
<packing> <packing>
<property name="left-attach">6</property> <property name="expand">False</property>
<property name="top-attach">0</property> <property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">8</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
<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">_</property> <property name="label" translatable="yes">Size:</property>
</object> </object>
<packing> <packing>
<property name="left-attach">5</property> <property name="expand">False</property>
<property name="top-attach">1</property> <property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">9</property>
</packing> </packing>
</child> </child>
</object> </object>
@ -470,83 +431,32 @@
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="homogeneous">True</property> <property name="orientation">vertical</property>
<child> <property name="baseline-position">top</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">8</property>
<property name="margin-end">8</property>
<property name="label" translatable="yes">Helligkeit Grenze:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScale" id="detect-scale-bright">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="adjustment">detect-adj-bright</property>
<property name="lower-stepper-sensitivity">on</property>
<property name="upper-stepper-sensitivity">on</property>
<property name="show-fill-level">True</property>
<property name="fill-level">255</property>
<property name="round-digits">1</property>
<signal name="value-changed" handler="cb_detect_bright" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkFrame"> <object class="GtkExpander">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">True</property>
<property name="margin-start">8</property>
<property name="margin-end">8</property>
<property name="margin-top">8</property>
<property name="margin-bottom">8</property>
<property name="label-xalign">0</property>
<property name="shadow-type">etched-out</property>
<child> <child>
<object class="GtkAlignment"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="top-padding">8</property>
<property name="bottom-padding">8</property>
<property name="left-padding">12</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="orientation">vertical</property> <property name="valign">start</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child> <child>
<object class="GtkRadioButton" id="detect-type-indet1"> <object class="GtkLabel">
<property name="label" translatable="yes">InputDetect</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">False</property>
<property name="receives-default">False</property> <property name="margin-left">8</property>
<property name="active">True</property> <property name="margin-right">8</property>
<property name="draw-indicator">True</property> <property name="margin-start">8</property>
<property name="group">detect-type-indet2</property> <property name="margin-end">8</property>
<signal name="toggled" handler="cb_detect_inputtype" swapped="no"/> <property name="label" translatable="yes">Helligkeit Grenze:</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -555,40 +465,77 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkRadioButton" id="detect-type-indet2"> <object class="GtkScale" id="detect-scale-bright">
<property name="label" translatable="yes">InputDetect + InputDetectCrossC</property> <property name="visible">True</property>
<property name="can-focus">True</property>
<property name="adjustment">detect-pos-adjbright</property>
<property name="lower-stepper-sensitivity">on</property>
<property name="upper-stepper-sensitivity">on</property>
<property name="show-fill-level">True</property>
<property name="fill-level">255</property>
<property name="round-digits">1</property>
<signal name="value-changed" handler="cb_detect_bright" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkRadioButton" id="detect-pos-cboff">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="receives-default">False</property> <property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property> <property name="draw-indicator">True</property>
<property name="group">detect-type-indet1</property> <property name="group">detect-pos-cbbright</property>
<signal name="toggled" handler="cb_detect_inputtype" swapped="no"/> <signal name="toggled" handler="cb_detect_detecttype" swapped="no"/>
</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">1</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkRadioButton" id="detect-type-indet3"> <object class="GtkRadioButton" id="detect-pos-cbbright">
<property name="label" translatable="yes">neu InputDetect + InputDetectCrossCv2</property> <property name="label" translatable="yes">Brightest Point</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="receives-default">False</property> <property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property> <property name="draw-indicator">True</property>
<property name="group">detect-type-indet1</property> <property name="group">detect-pos-cboff</property>
<signal name="toggled" handler="cb_detect_inputtype" swapped="no"/> <signal name="toggled" handler="cb_detect_detecttype" swapped="no"/>
</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">1</property>
</packing> </packing>
</child> </child>
<child>
<placeholder/>
</child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">8</property>
<property name="position">1</property>
</packing>
</child> </child>
</object> </object>
</child> </child>
@ -596,37 +543,125 @@
<object class="GtkLabel"> <object class="GtkLabel">
<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">Detection Type</property> <property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">Detect Object</property>
</object> </object>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">False</property>
<property name="padding">4</property> <property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkExpander">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="halign">start</property>
<property name="valign">start</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkRadioButton" id="detect-type-indet0">
<property name="label" translatable="yes">OFF</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<property name="group">detect-type-indet1</property>
<signal name="toggled" handler="cb_detect_followtype" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="detect-type-indet1">
<property name="label" translatable="yes">Brightest Point</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<property name="group">detect-type-indet0</property>
<signal name="toggled" handler="cb_detect_followtype" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="detect-type-indet2">
<property name="label" translatable="yes">InputDetectCrossC</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="halign">start</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<property name="group">detect-type-indet0</property>
<signal name="toggled" handler="cb_detect_followtype" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Follow Object</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">False</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
<child>
<placeholder/>
</child>
</object> </object>
<packing> <packing>
<property name="position">1</property> <property name="position">1</property>
<property name="tab-fill">False</property>
</packing> </packing>
</child> </child>
<child type="tab"> <child type="tab">
<object class="GtkLabel"> <object class="GtkLabel">
<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">Detection</property> <property name="label" translatable="yes">Detection/Follow</property>
</object> </object>
<packing> <packing>
<property name="position">1</property> <property name="position">1</property>
@ -695,6 +730,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<signal name="draw" handler="cb_imagetempda_draw" swapped="no"/> <signal name="draw" handler="cb_imagetempda_draw" swapped="no"/>
<signal name="motion-notify-event" handler="cb_videoda_motionevent" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="resize">True</property> <property name="resize">True</property>

@ -18,6 +18,9 @@ GtkWidget *video_da = NULL;
GdkPixbuf *video_pixbuf = NULL; GdkPixbuf *video_pixbuf = NULL;
extern GtkBuilder *_builder_; // work around for threads extern GtkBuilder *_builder_; // work around for threads
extern Detect detect; extern Detect detect;
extern int video_enterdata;
extern position_2d video_enterdata_pos;
gboolean videoctrl_update(gpointer data) { gboolean videoctrl_update(gpointer data) {
GtkWidget *grid = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "vidctrl-grid")); GtkWidget *grid = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "vidctrl-grid"));
@ -60,7 +63,6 @@ void videoframe_to_pixbuf(GdkPixbuf* dest, VideoFrame *src) {
desth = src->h; desth = src->h;
} }
memcpy (destpixel, src->data, 3*destw*desth); memcpy (destpixel, src->data, 3*destw*desth);
} }
@ -106,46 +108,79 @@ void cb_videoda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data)
g_object_unref (pixbuf); g_object_unref (pixbuf);
//
// need to draw the select new position cross
if (video_enterdata == VID_ENTERDATA_POS) {
color.blue = 1.0;
color.red = 0.0;
color.green = 1.0;
color.alpha = 1.0;
gdk_cairo_set_source_rgba(cr, &color);
cairo_move_to(cr, S_X(video_enterdata_pos.x)-10, S_Y(video_enterdata_pos.y)-10);
cairo_line_to(cr, S_X(video_enterdata_pos.x)+10, S_Y(video_enterdata_pos.y)+10);
cairo_move_to(cr, S_X(video_enterdata_pos.x)+10, S_Y(video_enterdata_pos.y)-10);
cairo_line_to(cr, S_X(video_enterdata_pos.x)-10, S_Y(video_enterdata_pos.y)+10);
cairo_move_to(cr, S_X(video_enterdata_pos.x)-15, S_Y(video_enterdata_pos.y)-20);
cairo_line_to(cr, S_X(video_enterdata_pos.x)-20, S_Y(video_enterdata_pos.y)-20);
cairo_line_to(cr, S_X(video_enterdata_pos.x)-20, S_Y(video_enterdata_pos.y)-15);
cairo_move_to(cr, S_X(video_enterdata_pos.x)+15, S_Y(video_enterdata_pos.y)-20);
cairo_line_to(cr, S_X(video_enterdata_pos.x)+20, S_Y(video_enterdata_pos.y)-20);
cairo_line_to(cr, S_X(video_enterdata_pos.x)+20, S_Y(video_enterdata_pos.y)-15);
cairo_move_to(cr, S_X(video_enterdata_pos.x)-15, S_Y(video_enterdata_pos.y)+20);
cairo_line_to(cr, S_X(video_enterdata_pos.x)-20, S_Y(video_enterdata_pos.y)+20);
cairo_line_to(cr, S_X(video_enterdata_pos.x)-20, S_Y(video_enterdata_pos.y)+15);
cairo_move_to(cr, S_X(video_enterdata_pos.x)+15, S_Y(video_enterdata_pos.y)+20);
cairo_line_to(cr, S_X(video_enterdata_pos.x)+20, S_Y(video_enterdata_pos.y)+20);
cairo_line_to(cr, S_X(video_enterdata_pos.x)+20, S_Y(video_enterdata_pos.y)+15);
cairo_stroke(cr);
}
else {
//
// draw red cross
cairo_set_line_width(cr, 1.0);
color.blue = 0.0;
color.red = 1.0;
color.green = 0.0;
color.alpha = 1.0;
gdk_cairo_set_source_rgba(cr, &color);
x = atoi (gtk_entry_get_text(GTK_ENTRY(e_x)));
y = atoi (gtk_entry_get_text(GTK_ENTRY(e_y)));
w1 = atoi (gtk_entry_get_text(GTK_ENTRY(e_w)));
h1 = atoi (gtk_entry_get_text(GTK_ENTRY(e_h)));
cairo_move_to(cr, S_X(x), S_Y(y)-10);
cairo_line_to(cr, S_X(x), S_Y(y)+10);
cairo_move_to(cr, S_X(x)-10, S_Y(y));
cairo_line_to(cr, S_X(x)+10, S_Y(y));
cairo_stroke(cr);
// //
// draw red cross // green width border
cairo_set_line_width(cr, 1.0); color.blue = 0.0;
color.blue = 0.0; color.red = 0.0;
color.red = 1.0; color.green = 1.0;
color.green = 0.0; color.alpha = 1.0;
color.alpha = 1.0; gdk_cairo_set_source_rgba(cr, &color);
gdk_cairo_set_source_rgba(cr, &color);
cairo_move_to(cr, S_X(x-w1/2), S_Y(y-h1/2)+10);
x = atoi (gtk_entry_get_text(GTK_ENTRY(e_x))); cairo_line_to(cr, S_X(x-w1/2), S_Y(y-h1/2));
y = atoi (gtk_entry_get_text(GTK_ENTRY(e_y))); cairo_line_to(cr, S_X(x+w1/2), S_Y(y-h1/2));
w1 = atoi (gtk_entry_get_text(GTK_ENTRY(e_w))); cairo_line_to(cr, S_X(x+w1/2), S_Y(y-h1/2)+10);
h1 = atoi (gtk_entry_get_text(GTK_ENTRY(e_h)));
cairo_move_to(cr, S_X(x-w1/2), S_Y(y+h1/2)-10);
cairo_move_to(cr, S_X(x), S_Y(y)-10); cairo_line_to(cr, S_X(x-w1/2), S_Y(y+h1/2));
cairo_line_to(cr, S_X(x), S_Y(y)+10); cairo_line_to(cr, S_X(x+w1/2), S_Y(y+h1/2));
cairo_move_to(cr, S_X(x)-10, S_Y(y)); cairo_line_to(cr, S_X(x+w1/2), S_Y(y+h1/2)-10);
cairo_line_to(cr, S_X(x)+10, S_Y(y));
cairo_stroke(cr); cairo_stroke(cr);
}
//
// green width border
color.blue = 0.0;
color.red = 0.0;
color.green = 1.0;
color.alpha = 1.0;
gdk_cairo_set_source_rgba(cr, &color);
cairo_move_to(cr, S_X(x-w1/2), S_Y(y-h1/2)+10);
cairo_line_to(cr, S_X(x-w1/2), S_Y(y-h1/2));
cairo_line_to(cr, S_X(x+w1/2), S_Y(y-h1/2));
cairo_line_to(cr, S_X(x+w1/2), S_Y(y-h1/2)+10);
cairo_move_to(cr, S_X(x-w1/2), S_Y(y+h1/2)-10);
cairo_line_to(cr, S_X(x-w1/2), S_Y(y+h1/2));
cairo_line_to(cr, S_X(x+w1/2), S_Y(y+h1/2));
cairo_line_to(cr, S_X(x+w1/2), S_Y(y+h1/2)-10);
cairo_stroke(cr);
}; };
@ -325,6 +360,7 @@ void videoctrl_set(std::string name, int value) {
videodev.SetCtrlValue(name, value); videodev.SetCtrlValue(name, value);
} }
// //
// callback video control scale change // callback video control scale change
void cb_vidctrl_scale_change (GtkRange *range, gpointer data) { void cb_vidctrl_scale_change (GtkRange *range, gpointer data) {
@ -360,3 +396,50 @@ void cb_vidctrl_entry_change (GtkWidget *widget, gpointer data) {
videoctrl_set((std::string)gtk_label_get_text(GTK_LABEL(label)), (int)value); videoctrl_set((std::string)gtk_label_get_text(GTK_LABEL(label)), (int)value);
}; };
void cb_videoda_motionevent (GtkWidget *widget, GdkEvent *event, gpointer data) {
int dw, dh, sw, sh;
float sar, dar;
if (video_pixbuf != NULL) {
sh = gtk_widget_get_allocated_height(video_da);
sw = gtk_widget_get_allocated_width(video_da);
dw = gdk_pixbuf_get_width(video_pixbuf);
dh = gdk_pixbuf_get_height(video_pixbuf);
sar = (float)sw/(float)sh;
dar = (float)dw/(float)dh;
if (dar < sar) {
sw = (dar * (float) sh);
}
else {
sh = ((float) sw / dar);
}
video_enterdata_pos.x = event->motion.x * dw / sw;
video_enterdata_pos.y = event->motion.y * dh / sh;
gdk_window_invalidate_rect(gtk_widget_get_window(video_da), NULL, true);
}
};
void cb_videoda_btnpress (GtkWidget *widget, GdkEvent *event, gpointer data) {
int x = event->motion.x;
int y = event->motion.y;
printf ("%s:%d %s %d, %d\n", __FILE__, __LINE__, __FUNCTION__, x, y);
};
void cb_videoda_btnrelease (GtkWidget *widget, GdkEvent *event, gpointer data) {
if (video_enterdata == VID_ENTERDATA_POS) {
detect.SetObjectPos(video_enterdata_pos.x, video_enterdata_pos.y);
video_enterdata = VID_ENTERDATA_NONE;
}
};

Loading…
Cancel
Save