Esempio n. 1
0
File: Eyes.c Progetto: aosm/X11
static void computePupils (
    TPoint	mouse,
    TPoint	pupils[2])
{
    pupils[0] = computePupil (0, mouse);
    pupils[1] = computePupil (1, mouse);
}
Esempio n. 2
0
static void computePupils (
    EyesWidget	w,
    TPoint	mouse,
    TPoint	pupils[2])
{
    TRectangle screen, *sp = NULL;
    if (w->eyes.distance) {
	Window r, cw;
	int x, y;
	r = RootWindowOfScreen(w->core.screen);
	XTranslateCoordinates(XtDisplay(w), XtWindow(w), r, 0, 0, &x, &y, &cw);
	screen.x = Tx(-x, -y, &w->eyes.t);
	screen.y = Ty(-x, -y, &w->eyes.t);
	screen.width  = Twidth (w->core.screen->width, w->core.screen->height,
				&w->eyes.t);
	screen.height = Theight(w->core.screen->width, w->core.screen->height,
				&w->eyes.t);
	sp = &screen;
    }
    pupils[0] = computePupil (0, mouse, sp);
    pupils[1] = computePupil (1, mouse, sp);
}
Esempio n. 3
0
void Faze::assign(dlib::full_object_detection shape , cv::Mat image, int modePupil, int modeGaze) {
	assert(modePupil == MODE_PUPIL_SP || modePupil == MODE_PUPIL_CDF ||
		modeGaze == MODE_GAZE_VA || modeGaze == MODE_GAZE_QE);
	faceShape = shape;
	image.copyTo(imageColor);
	cv::cvtColor(imageColor, imageGray, CV_BGR2GRAY);

	descriptors.clear();
	normal.clear();
	normal.resize(3);
	localYAxis.clear();
	localYAxis.resize(3);

	computeFacialParams();
	computePupil(modePupil);
	computeGaze(modeGaze);
}
Esempio n. 4
0
static void
paint_eyes(ModeInfo * mi, Eyes * e, Fly * f, Eyes * eyes, int num_eyes)
{
	EyeScrInfo *ep = &eye_info[MI_SCREEN(mi)];
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);
	GC          gc = ep->eyeGC;
	Bool        iconic = MI_IS_ICONIC(mi);
	int         focusx = (f->x + (f->width / 2)) - e->x;
	int         focusy = (f->y + (f->height / 2)) - e->y;
	Pixmap      pix = e->pixmap;
	TPoint      point;
	int         i;

	if (pix == None) {
		e->time_to_die = 0;	/* "should not happen" */
	}
	if (ep->time >= e->time_to_die) {
		/* Sorry Bud, your time is up */
		if (e->painted) {
			/* only unpaint it if previously painted */
			XSetForeground(display, gc, MI_BLACK_PIXEL(mi));
			XFillRectangle(display, window, gc, e->x, e->y, e->width, e->height);
		}
		/* randomly place the eyes elsewhere */
		create_eyes(mi, e, eyes, num_eyes);
		pix = e->pixmap;	/* pixmap may have changed */
	}
	/* If the bouncer would intersect this pair of eyes, force the
	 * eyes to move.  This simplifies the code, because we do not
	 * have to deal with drawing the bouncer on top of the eyes.
	 * When trying to do so, there was too much annoying flashing
	 * and ghost images from the undraw.  I decided to observe the
	 * KISS principle and keep it simple.  I think the effect is
	 * better also.
	 * We must draw the flyer on the eyes when iconic, but that is
	 * easy because the eyes repaint the whole box each time.
	 */
	if ((!iconic) && (fly_touches_eye(f, e))) {
		e->time_to_die = 0;
	}
	if (e->time_to_die == 0) {
		return;		/* collides with something */
	}
	/* set the point to look at and compute the pupil position  */
	point.x = Tx(focusx, focusy, &e->transform);
	point.y = Ty(focusx, focusy, &e->transform);
	computePupil(0, point, &(e->pupil[0]));
	computePupil(1, point, &(e->pupil[1]));

	if (e->painted) {
		/* if still looking at the same point, do nothing further */
		if (TPointEqual(e->pupil[0], e->last_pupil[0]) &&
		    TPointEqual(e->pupil[1], e->last_pupil[1])) {
			return;
		}
	}
	for (i = 0; i < 2; i++) {
		/* update the eye, calculates the changed rectangle */
		make_eye(mi, pix, e, i, False);

		/* Only blit the change if the full image has been painted */
		if (e->painted) {
			/* copy the changed rectangle out to the screen */
			XCopyArea(display, pix, window, gc,
				  e->bbox.x, e->bbox.y,
				  (int) e->bbox.width, (int) e->bbox.height,
				  e->x + e->bbox.x, e->y + e->bbox.y);
		}
		/* remember where we're looking, for the next time around */
		e->last_pupil[i] = e->pupil[i];
	}

	/* always do full paint when iconic, eliminates need to track fly */
	if (iconic || (!e->painted)) {
		XCopyArea(display, pix, window, gc, 0, 0,
			  e->width, e->height, e->x, e->y);
	}
	/* when iconic, pretend to never paint, causes full paint each time */
	if (!iconic) {
		e->painted++;	/* note that a paint has been done */
	}
}