Ejemplo n.º 1
0
int main( int argc, char** argv )
{

	if (parse_arguments(argc, argv, &haar_cascade_path, &asef_locator_path))
		return -1;
#if 0
	struct sigaction act;
	act.sa_handler = termination_handler; 
	sigemptyset(&act.sa_mask);
	act.sa_flags = 0;
	sigaction(SIGINT, &act, NULL);
#endif

	int frame_width, frame_height;

	if ( asef_initialze(&asef, asef_locator_path, haar_cascade_path) )
		return -1;

	if( !(capture = cvCaptureFromCAM(-1)) ) {
		fprintf( stderr, "ERROR: capture is NULL \n" );
		return -1;
	}

	get_camera_properties(capture, &frame_width, &frame_height, NULL);

	CvSize frame_size = cvSize(frame_width, frame_height);

	IplImage* frame = NULL;
	color_img = cvCreateImage( frame_size, IPL_DEPTH_8U, 3 );
	gray_img = cvCreateImage( frame_size, IPL_DEPTH_8U, 1);

	cvNamedWindow(window_title, 0);
	while (1){
		printf("\r"); fflush(stdout); 
		printf("FPS: %f  ", calculate_fps());

		frame = cvQueryFrame(capture);
		cvCopyImage(frame, color_img);
		cvCvtColor(color_img, gray_img, CV_RGB2GRAY);
		asef.input_image = gray_img;

		if( asef_detect_face(&asef) ){
			asef_locate_eyes(&asef);
			draw_markers(color_img, asef.face_rect, asef.left_eye, asef.right_eye);
		}

    // Mirroring results. assuming you're using a frontal facing camera
		cvFlip(color_img, color_img, 1);
		cvShowImage( window_title, color_img);
                cvWaitKey(1);
	} 
	return 0;
}
Ejemplo n.º 2
0
int do_load_desktop (Desktop * d, char *filename)
{
    int f;
    if ((f = open (filename, O_RDONLY)) >= 0) {
	int i, x = 40, y = 40;
	char *sign;
	sign = strread (f);
	if (strcmp (sign, "stereo\n - saved desktop\n\n")) {
	    close (f);
	    Cerrordialogue (CMain, 20, 20, " Load Desktop ", \
		    " This is not a desktop file ");
	    free (sign);
	    return 1;
	}
	free (sign);
	for (i = 0; i < d->num_views; i++)
	    destroy_view (&(d->view[i]));
	clear (d, Desktop);
	read (f, d, sizeof (Desktop));
	destroy ((void *) &d->cal_points);
	d->cal_points = Cmalloc (d->num_cal_points * sizeof (Vec));
	read (f, d->cal_points, d->num_cal_points * sizeof (Vec));
	d->cal_file = strread (f);
	d->temp_dir = strread (f);
	d->image_dir = strread (f);
	if (d->num_views)
	    for (i = 0; i < d->num_views; i++) {
		char *v;
		v = strread (f);
		if (v) {
		    setup_view (d, v, x += 20, y += 20, i);
		    d->view[i].filename = v;
		}
	    }
	draw_markers (d);
	close (f);
	return 0;
    } else {
	Cerrordialogue (CMain, 20, 20, " Load Desktop ", \
			get_sys_error (" Error trying to save file. "));
    }
    return 1;
}
Ejemplo n.º 3
0
void ISR(_TIMER_1_VECTOR,IPL1AUTO) clock_refresh(void)
{
    uint32_t static average;
    uint16_t        tmp;

    draw_markers();
    /*  hours ---------------------------------- */
    tmp = (5 * (date.hours % 12)) + date.minutes / 11;
    libpixel_set(pixels, (tmp + 59) % 60,
        color.hr.r,
        color.hr.g,
        color.hr.b);
    libpixel_set(pixels, tmp % 60,
        color.hr.r,
        color.hr.g,
        color.hr.b);
    libpixel_set(pixels, (tmp +  1) % 60,
        color.hr.r,
        color.hr.g,
        color.hr.b);
    /* minutes --------------------------------- */
    libpixel_set(pixels, date.minutes,
       color.mn.r - color.mn.r * (date.seconds) / 59,
       color.mn.g - color.mn.g * (date.seconds) / 59,
       color.mn.b - color.mn.b * (date.seconds) / 59);
    libpixel_set(pixels, (date.minutes + 1) % 60,
        color.mn.r * (date.seconds) / 59,
        color.mn.g * (date.seconds) / 59,
        color.mn.b * (date.seconds / 59));
    /* seconds --------------------------------- */
    libpixel_set(pixels, date.seconds,
        color.sc.r,
        color.sc.g,
        color.sc.b);
    sample_brightness(&average);
    libpixel_brightness(pixels, 255 * (average - 130) / 1023);
    libpixel_show(pixels);
    if (!(date.millis))
        menu_update(menu, lcd);
    date.millis = (date.millis + 100) % 1000    ;
    if (!date.millis) {
        date.seconds = (date.seconds + 1) % 60;
        if (!date.seconds) {
            date.minutes = (date.minutes + 1) % 60;
            if (!date.minutes) {
                date.hours = (date.hours + 1) % 24;
                if (!date.hours) {
                    date.day = date.day % 31 + 1;
                    if (!date.day) {
                        date.month = date.month % 12 + 1;
                        if (!date.month) {
                            date.year = (date.year + 1);
                        }
                    }
                    if (date.day > long_month(date.month, date.year))
                        date.day = 1;
                    date.day_of_week = tondering_day_of_week();
                }
            }
        }
    }
    IFS0bits.T1IF = 0;
}
Ejemplo n.º 4
0
void draw_text_main(SpaceText *st, ARegion *ar)
{
	Text *text= st->text;
	TextLine *tmp;
	rcti scroll, back;
	char linenr[12];
	int i, x, y, winx, linecount= 0, lineno= 0;
	int wraplinecount= 0, wrap_skip= 0;

	/* if no text, nothing to do */
	if(!text)
		return;
	
	text_update_drawcache(st, ar);

	/* make sure all the positional pointers exist */
	if(!text->curl || !text->sell || !text->lines.first || !text->lines.last)
		txt_clean_text(text);
	
	if(st->lheight) st->viewlines= (int)ar->winy/st->lheight;
	else st->viewlines= 0;
	
	/* update rects for scroll */
	calc_text_rcts(st, ar, &scroll, &back);	/* scroll will hold the entire bar size */

	/* update syntax formatting if needed */
	tmp= text->lines.first;
	lineno= 0;
	for(i= 0; i<st->top && tmp; i++) {
		if(st->showsyntax && !tmp->format)
			txt_format_line(st, tmp, 0);

		if(st->wordwrap) {
			int lines= text_get_visible_lines_no(st, lineno);

			if (wraplinecount+lines>st->top) {
				wrap_skip= st->top-wraplinecount;
				break;
			} else {
				wraplinecount+= lines;
				tmp= tmp->next;
				linecount++;
			}
		} else {
			tmp= tmp->next;
			linecount++;
		}

		lineno++;
	}

	text_font_begin(st);
	st->cwidth= BLF_fixed_width(mono);
	st->cwidth= MAX2(st->cwidth, 1);

	/* draw line numbers background */
	if(st->showlinenrs) {
		x= TXT_OFFSET + TEXTXLOC;

		UI_ThemeColor(TH_GRID);
		glRecti((TXT_OFFSET-12), 0, (TXT_OFFSET-5) + TEXTXLOC, ar->winy - 2);
	}
	else {
		st->linenrs_tot= 0; /* not used */
		x= TXT_OFFSET;
	}
	y= ar->winy-st->lheight;
	winx= ar->winx - TXT_SCROLL_WIDTH;
	
	/* draw cursor */
	draw_cursor(st, ar);

	/* draw the text */
	UI_ThemeColor(TH_TEXT);

	for(i=0; y>0 && i<st->viewlines && tmp; i++, tmp= tmp->next) {
		if(st->showsyntax && !tmp->format)
			txt_format_line(st, tmp, 0);

		if(st->showlinenrs && !wrap_skip) {
			/* draw line number */
			if(tmp == text->curl)
				UI_ThemeColor(TH_HILITE);
			else
				UI_ThemeColor(TH_TEXT);

			sprintf(linenr, "%d", i + linecount + 1);
			/* itoa(i + linecount + 1, linenr, 10); */ /* not ansi-c :/ */
			text_font_draw(st, TXT_OFFSET - 7, y, linenr);

			UI_ThemeColor(TH_TEXT);
		}

		if(st->wordwrap) {
			/* draw word wrapped text */
			int lines = text_draw_wrapped(st, tmp->line, x, y, winx-x, tmp->format, wrap_skip);
			y -= lines*st->lheight;
		}
		else {
			/* draw unwrapped text */
			text_draw(st, tmp->line, st->left, ar->winx/st->cwidth, 1, x, y, tmp->format);
			y -= st->lheight;
		}

		wrap_skip= 0;
	}
	
	/* draw other stuff */
	draw_brackets(st, ar);
	draw_markers(st, ar);
	glTranslatef(0.375f, 0.375f, 0.0f); /* XXX scroll requires exact pixel space */
	draw_textscroll(st, &scroll, &back);
	draw_documentation(st, ar);
	draw_suggestion_list(st, ar);
	
	text_font_end(st);
}