static COMMAND_FUNC( do_new_fb_pan ) { #ifdef HAVE_FB_DEV __u32 dx,dy; INSURE_FB("do_fb_pan") dx = HOW_MANY("xoffset"); dy = HOW_MANY("yoffset"); /* BUG make sure values are valid */ curr_fbip->fbi_var_info.xoffset = dx; curr_fbip->fbi_var_info.yoffset = dy; curr_fbip->fbi_var_info.activate |= FB_ACTIVATE_VBL; if(ioctl(curr_fbip->fbi_fd, FBIOPAN_DISPLAY, &curr_fbip->fbi_var_info)<0) { tell_sys_error("ioctl"); sprintf(ERROR_STRING,"do_new_fb_pan: ioctl iopan %d %d error\n",dx,dy); WARN(ERROR_STRING); return; } return; #else /* ! HAVE_FB_DEV */ ERROR1("do_new_fb_pan: Program not configured with framebuffer device support."); #endif /* ! HAVE_FB_DEV */ }
static COMMAND_FUNC( do_fmt7_setposn ) { uint32_t h,v; h=HOW_MANY("horizontal position (left)"); v=HOW_MANY("vertical position (top)"); CHECK_CAM // What are the constraints as to what this can be??? // At least on the flea, the position has to be even... if( h & 1 ){ sprintf(ERROR_STRING,"Horizontal position (%d) should be even, rounding down to %d.",h,h&(~1)); advise(ERROR_STRING); h &= ~1; } if( v & 1 ){ sprintf(ERROR_STRING,"Vertical position (%d) should be even, rounding down to %d.",v,v&(~1)); advise(ERROR_STRING); v &= ~1; } UNIMP_MSG("fmt7_posn"); }
static Viewer * mk_new_viewer(QSP_ARG_DECL int viewer_type) { const char *s; char name[256]; int dx,dy; Viewer *vp; s=NAMEOF("viewer name"); strcpy(name,s); dx=(int)HOW_MANY("width"); dy=(int)HOW_MANY("height"); if( viewer_name_in_use(QSP_ARG name) ) return NO_VIEWER; if( dx <= 0 || dy <= 0 ){ WARN("viewer sizes must be positive"); return NO_VIEWER; } vp = viewer_init(QSP_ARG name,dx,dy,viewer_type); if( vp == NO_VIEWER ) return NO_VIEWER; #ifdef HAVE_X11 default_cmap(QSP_ARG VW_DPYABLE(vp) ); #endif /* HAVE_X11 */ #ifndef BUILD_FOR_IOS /* default state is to be shown, * but in IOS we can only see one at a time, so * we leave them on the bottom until we ask. */ show_viewer(QSP_ARG vp); #endif /* ! BUILD_FOR_IOS */ select_viewer(QSP_ARG vp); return vp; }
static COMMAND_FUNC( do_fb_pan ) { #ifdef HAVE_FB_DEV __u32 dx,dy; INSURE_FB("do_fb_pan") dx = HOW_MANY("xoffset"); dy = HOW_MANY("yoffset"); /* BUG make sure values are valid */ /* with genlock running, we need to lock... */ curr_fbip->fbi_var_info.xoffset = dx; curr_fbip->fbi_var_info.yoffset = dy; /* mutex might be needed for multi-threaded operation */ /* if( genlock_active ) get_genlock_mutex(); */ if(ioctl(curr_fbip->fbi_fd, FBIOPAN_DISPLAY, &curr_fbip->fbi_var_info)<0) { tell_sys_error("ioctl"); sprintf(ERROR_STRING,"do_fb_pan: ioctl iopan %d %d error\n",dx,dy); WARN(ERROR_STRING); return; } /* if( genlock_active ) rls_genlock_mutex(); */ return; #else /* ! HAVE_FB_DEV */ ERROR1("do_fb_pan: Program not configured with framebuffer device support."); #endif /* ! HAVE_FB_DEV */ }
static COMMAND_FUNC( do_setalpha ) { int index,val; index=(int)HOW_MANY("index"); val=(int)HOW_MANY("alpha value"); CHECK_DPYP("do_setalpha") set_alpha(index,val); }
static COMMAND_FUNC( do_grayscale ) { int base,n; base=(int)HOW_MANY("base index"); n=(int)HOW_MANY("number of colors"); CHECK_DPYP("do_grayscale") make_grayscale(base,n); }
static COMMAND_FUNC( do_index_alpha ) { int index,hv,lv; /* set alpha entries */ index = (int)HOW_MANY("index to display"); lv = (int)HOW_MANY("alpha value for zero bit"); hv = (int)HOW_MANY("alpha value for one bit"); CHECK_DPYP("do_index_alpha") index_alpha(index,lv,hv); }
static COMMAND_FUNC( do_poke ) { int c,r,g,b; c=(int)HOW_MANY("color index"); r=(int)HOW_MANY("red value"); g=(int)HOW_MANY("green value"); b=(int)HOW_MANY("blue value"); CHECK_DPYP("do_poke") poke_lut(c,r,g,b); }
static COMMAND_FUNC( do_make_rgb ) { int r,g,b,base; base=(int)HOW_MANY("base color index"); r=(int)HOW_MANY("number of red levels"); g=(int)HOW_MANY("number of green levels"); b=(int)HOW_MANY("number of blue levels"); CHECK_DPYP("do_make_rgb") make_rgb(base,r,g,b); }
static COMMAND_FUNC( do_setcolor ) { int c,r,g,b; c=(int)HOW_MANY("lut index"); r=(int)HOW_MANY("red value"); g=(int)HOW_MANY("green value"); b=(int)HOW_MANY("blue value"); CHECK_DPYP("do_setcolor") setcolor(c,r,g,b); }
static COMMAND_FUNC( do_const_cmap ) { int r,g,b; int base,n; base=(int)HOW_MANY("start color"); n=(int)HOW_MANY("number of colors"); r=(int)HOW_MANY("red"); g=(int)HOW_MANY("green"); b=(int)HOW_MANY("blue"); CHECK_DPYP("do_const_cmap") const_cmap(base,n,r,g,b); }
// Binary threshold. static COMMAND_FUNC( do_ocv_binary_threshold ) { OpenCV_Image *src, *dst; double threshold; double max_value; dst = PICK_OCVI("destination image"); src = PICK_OCVI("source image"); threshold = HOW_MANY("threshold above which will be on"); max_value = HOW_MANY("on value"); if( dst == NO_OPENCV_IMAGE || src == NO_OPENCV_IMAGE ) return; cvThreshold(src->ocv_image, dst->ocv_image, threshold, max_value, CV_THRESH_BINARY); }
static PF_COMMAND_FUNC( fill2 ) { Data_Obj *dp; int x,y; float fill_val, tol; dp = PICK_OBJ("image"); x=HOW_MANY("seed point x"); y=HOW_MANY("seed point y"); fill_val=HOW_MUCH("fill value"); tol = HOW_MUCH("tolerance"); h_sp_ifl2(dp,x,y,tol,fill_val); }
static COMMAND_FUNC( do_load_fb ) { Data_Obj *dp; int x,y; dp=PICK_OBJ(""); x=(int)HOW_MANY("x origin"); y=(int)HOW_MANY("y origin"); if( dp == NO_OBJ ) return; INSIST_RAM_OBJ(dp,"load_fb") fb_load(QSP_ARG dp,x,y); }
static void getparm(QSP_ARG_DECL Param *p) { if( IS_ARRAY_PARAM(p) ) getarrp(QSP_ARG p); else if( IS_FLOAT_PARAM(p) ) *p->u.fp = fnum= (float)HOW_MUCH( p->p_comment ); else if( IS_SHORT_PARAM(p) ) *p->u.sp = (short)HOW_MANY( p->p_comment ); else if( IS_INT_PARAM(p) ) *p->u.ip = (int)HOW_MANY( p->p_comment ); else if( IS_STRING_PARAM(p) ) strcpy( p->u.strp, NAMEOF(p->p_comment) ); else ERROR1(badpstr); }
static COMMAND_FUNC( do_find_face ) { OpenCV_Image *src; OpenCV_Cascade *casc_p; CvPoint2D32f* features; int frame_number; src = PICK_OCVI("input OpenCV image"); casc_p = PICK_CASCADE("classifier cascade"); frame_number = HOW_MANY("frame number"); if( src == NO_OPENCV_IMAGE || casc_p == NO_CASCADE ) return; if( storage == NULL ) storage = cvCreateMemStorage(0); // what is the arg here? features = FindFace(QSP_ARG src->ocv_image, storage, casc_p->ocv_cascade, frame_number); //cvReleaseImage(&src->ocv_image); /* BUG need to do something with the feature array */ if( features == NULL ) WARN("find_face: Null feature array!?"); // Deallocate memory. cvReleaseMemStorage(&storage); }
static COMMAND_FUNC( do_xp_select ) { int color; color=(int)HOW_MANY("color index"); xp_select(color); }
static COMMAND_FUNC( do_create_fb ) { Framebuffer *fbp; const char *s; int w,h; s = NAMEOF("name for framebuffer"); w = (int)HOW_MANY("width in pixels"); h = (int)HOW_MANY("height in pixels"); fbp = create_framebuffer(QSP_ARG s,w,h); if( fbp == NULL ) { sprintf(ERROR_STRING,"Error creating framebuffer %s",s); WARN(ERROR_STRING); } }
static COMMAND_FUNC( do_creat_img ) { const char *s; long w,h,n_channels; OpenCV_Image *ocvi_p; s=NAMEOF("name for image"); w=HOW_MANY("width"); h=HOW_MANY("height"); n_channels = HOW_MANY("number of components"); /* BUG should have a precision switch here, using which_one... */ ocvi_p = create_ocv_image(QSP_ARG s,w,h,IPL_DEPTH_8U,n_channels); if( ocvi_p == NULL ) WARN("Error creating openCV image!?"); }
static COMMAND_FUNC( do_vbl_wait ) { int n; n = (int)HOW_MANY("number of frames to wait"); wait_video_sync(n); }
static COMMAND_FUNC( do_test_clock ) { int i,n; struct timeval *tv_tbl; n = (int)HOW_MANY("number of times to read the clock"); tv_tbl = (struct timeval *) getbuf(n*sizeof(struct timeval)); /* We've observed on poisson that vblank loops have gaps of around 80 msec which double the elapsed time!? * Can we observe this effect with a simple clock read? * The number of values we have to store depends on the time per read... * If it's 1 usec, then we need 100k reads to take 100 msec... */ for(i=0;i<n;i++){ gettimeofday(&tv_tbl[i],NULL); } /* Now show */ for(i=0;i<n;i++){ sprintf(msg_str,"%ld\t%ld",(long)tv_tbl[i].tv_sec,(long)tv_tbl[i].tv_usec); prt_msg(msg_str); } givbuf(tv_tbl); }
static COMMAND_FUNC( do_fmt7_setsize ) { uint32_t w,h; w=HOW_MANY("width"); h=HOW_MANY("height"); CHECK_CAM /* Don't try to set the image size if capture is running... */ if( IS_RUNNING(the_cam_p) ){ WARN("can't set image size while camera is running!?"); return; } UNIMP_MSG("set_fmt7_size"); }
static COMMAND_FUNC( do_ocv_canny ) { OpenCV_Image *src, *dst; int edge_thresh; int edge_thresh2; dst = PICK_OCVI("destination image"); src = PICK_OCVI("source image"); edge_thresh = HOW_MANY("edge threshold"); edge_thresh2 = HOW_MANY("edge threshold 2"); if( dst == NO_OPENCV_IMAGE || src == NO_OPENCV_IMAGE ) return; // Run the edge detector on grayscale. // The optional aperture_size parameter has been omitted. cvCanny(src->ocv_image, dst->ocv_image, (float)edge_thresh, (float)edge_thresh2, 3); }
static COMMAND_FUNC( do_const_alpha ) { int value; value=(int)HOW_MANY("value"); CHECK_DPYP("do_const_alpha") const_alpha(value); }
static COMMAND_FUNC( do_push_name ) { int n; n=(int)HOW_MANY("'name' number"); if( debug & gl_debug ){ sprintf(ERROR_STRING,"glPushName %d",n); advise(ERROR_STRING); } glPushName(n); }
static COMMAND_FUNC( do_set_n_linear ) { int n; n=(int)HOW_MANY("number of linearization table entries"); set_n_linear(QSP_ARG n); CHECK_DPYP("do_set_n_linear") #ifdef HAVE_X11 lin_setup(QSP_ARG DPA_LINTBL_OBJ(current_dpyp),crt_gamma,crt_vzero); #endif /* HAVE_X11 */ }
static COMMAND_FUNC( do_seek_frm ) { Image_File *ifp; dimension_t n; ifp = PICK_IMG_FILE(""); n = (dimension_t)HOW_MANY("frame index"); if( ifp == NO_IMAGE_FILE ) return; image_file_seek(QSP_ARG ifp,n); }
static COMMAND_FUNC( do_load_name ) { int n; n=(int)HOW_MANY("'name' number"); if( debug & gl_debug ){ sprintf(ERROR_STRING,"glLoadName %d",n); advise(ERROR_STRING); } glLoadName(n); check_gl_error("glLoadName"); }
static COMMAND_FUNC( do_set_raw_sizes ) { dimension_t arr[N_DIMENSIONS]; int i; for(i=0;i<N_DIMENSIONS;i++){ char pmt[LLEN]; sprintf(pmt,"number of raw %ss",dimension_name[i]); arr[i] = (dimension_t)HOW_MANY(pmt); } set_raw_sizes(arr); }
static COMMAND_FUNC( do_open_do ) { const char *s; int d; s=NAMEOF("display"); d=HOW_MANY("desired bit depth"); #ifdef HAVE_X11 if( open_display(s,d) == NULL ){ sprintf(ERROR_STRING,"unable to open %s",s); WARN(ERROR_STRING); } #endif /* HAVE_X11 */ }