void tell_plot_space(SINGLE_QSP_ARG_DECL) { sprintf(msg_str,"Viewer %s:",VW_NAME(plot_vp)); prt_msg(msg_str); sprintf(msg_str,"\twidth = %d\theight = %d",VW_WIDTH(plot_vp),VW_HEIGHT(plot_vp)); prt_msg(msg_str); sprintf(msg_str,"\txmin = %g\txdel = %g",VW_XMIN(plot_vp),VW_XDEL(plot_vp)); prt_msg(msg_str); sprintf(msg_str,"\tymin = %g\tydel = %g",VW_YMIN(plot_vp),VW_YDEL(plot_vp)); prt_msg(msg_str); }
void report_mpeg_info(Image_File *ifp) { sprintf(msg_str,"\timage depth (bits) %d", ifp->hdr->idp->Depth); prt_msg(msg_str); sprintf(msg_str,"\tbits per pixel %d", ifp->hdr->idp->PixelSize); prt_msg(msg_str); sprintf(msg_str,"\tsize of image %d bytes", ifp->hdr->idp->Size); prt_msg(msg_str); }
void weibull_out(QSP_ARG_DECL Trial_Class * tcp) /** verbose analysis report */ { sprintf(msg_str,"\nTrial_Class %s\n",CLASS_NAME(tcp)); prt_msg(msg_str); sprintf(msg_str,"alpha (threshold):\t\t%f",alpha); prt_msg(msg_str); sprintf(msg_str,"beta (slope):\t\t%f",beta); prt_msg(msg_str); /* BUG print out chi-square like statistic */ }
static PF_COMMAND_FUNC( about_platform ) { #ifdef HAVE_OpenCL sprintf(MSG_STR,"OpenCL version: %d.%d", OpenCL_VERSION/1000,(OpenCL_VERSION%100)/10); prt_msg(MSG_STR); #else // ! HAVE_OpenCL prt_msg("No OpenCL support in this build"); #endif // ! HAVE_OpenCL #ifdef FOOBAR report_npp_version(SINGLE_QSP_ARG); #endif // FOOBAR }
static void _display_fmt_chunk(QSP_ARG_DECL Wav_Header *wh_p) { Wav_Fmt_Data *wfd_p; wfd_p = (&wh_p->wh_fhc.fhc_wfd); sprintf(MSG_STR,"%d channels",wfd_p->wfd_n_channels); prt_msg(MSG_STR); sprintf(MSG_STR,"%d samples per sec",wfd_p->wfd_samp_rate); prt_msg(MSG_STR); sprintf(MSG_STR,"%d bytes per sec",wfd_p->wfd_bytes_per_sec); prt_msg(MSG_STR); sprintf(MSG_STR,"%d bits per sample",wfd_p->wfd_bits_per_sample); prt_msg(MSG_STR); }
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); }
int list_framerates(QSP_ARG_DECL PGR_Cam *pgcp) { unsigned int i; dc1394framerates_t framerates; const char *s; // format7 doesn't have a framerate!? if( mode_is_format7(pgcp) ){ WARN("list_framerates: No framerates associated with format7 video mode!?"); return -1; } if ( dc1394_video_get_supported_framerates( pgcp->pc_cam_p, pgcp->pc_video_mode, &framerates ) != DC1394_SUCCESS ){ warn("error fetching framerates"); return -1; } if( framerates.num <= 0 ){ warn("no framerates for this video mode!?"); return -1; } for(i=0;i<framerates.num; i++){ s=name_for_framerate(framerates.framerates[i]); assert( s != NULL ); prt_msg_frag("\t"); prt_msg(s); } return 0; }
void print_camera_info(QSP_ARG_DECL PGR_Cam *pgcp) { int i; prt_msg("\nCurrent camera:"); i=index_of_video_mode(pgcp->pc_video_mode); sprintf(msg_str,"\tmode: %s",all_video_modes[i].nvm_name); prt_msg(msg_str); i=index_of_framerate(pgcp->pc_framerate); sprintf(msg_str,"\trate: %s",all_framerates[i].nfr_name); prt_msg(msg_str); report_camera_features(pgcp); }
static void ocl_info(QSP_ARG_DECL Compute_Platform *cpp) { int s; sprintf(MSG_STR,"Vendor: %s",OCLPF_VENDOR(cpp)); prt_msg(MSG_STR); sprintf(MSG_STR,"Version: %s",OCLPF_VERSION(cpp)); prt_msg(MSG_STR); sprintf(MSG_STR,"Profile: %s",OCLPF_PROFILE(cpp)); prt_msg(MSG_STR); // The extensions can be long... s = (int) strlen(OCLPF_EXTENSIONS(cpp))+strlen(EXTENSIONS_PREFIX)+2; if( s > sb_size(QS_SCRATCH) ) enlarge_buffer( QS_SCRATCH, s ); sprintf(sb_buffer(QS_SCRATCH),"%s%s\n",EXTENSIONS_PREFIX,OCLPF_EXTENSIONS(cpp)); prt_msg(sb_buffer(QS_SCRATCH)); }
void list_trig(QSP_ARG_DECL PGR_Cam *pgcp) { dc1394bool_t has_p; dc1394trigger_mode_t tm; if( dc1394_external_trigger_has_polarity(pgcp->pc_cam_p,&has_p) != DC1394_SUCCESS ){ warn("error querying for trigger polarity capability"); return; } if( has_p ){ prt_msg("external trigger has polarity"); } else { prt_msg("external trigger does not have polarity"); } if( dc1394_external_trigger_get_mode(pgcp->pc_cam_p,&tm) != DC1394_SUCCESS ){ warn("error querying trigger mode"); return; } switch(tm){ case DC1394_TRIGGER_MODE_0: prt_msg("Mode 0: falling edge + shutter"); break; case DC1394_TRIGGER_MODE_1: prt_msg("Mode 1: falling edge to rising edge"); break; case DC1394_TRIGGER_MODE_2: prt_msg("Mode 2: falling edge to nth falling edge"); break; case DC1394_TRIGGER_MODE_3: prt_msg("Mode 3: internal trigger"); break; case DC1394_TRIGGER_MODE_4: prt_msg("Mode 4: multiple exposure (shuttered)"); break; case DC1394_TRIGGER_MODE_5: prt_msg("Mode 5: multiple exposure (triggered)"); break; case DC1394_TRIGGER_MODE_14: prt_msg("Mode 14: vendor-specific"); break; case DC1394_TRIGGER_MODE_15: prt_msg("Mode 15: vendor-specific"); break; default: warn("unrecognized trigger mode"); break; } }
static COMMAND_FUNC( do_pipe_info ) { Pipe *pp; int i; pp = pick_pipe(""); if( pp == NULL ) return; if( pp->p_flgs & READ_PIPE ) i=0; else if( pp->p_flgs & READ_PIPE ) i=1; #ifdef CAUTIOUS else { warn("CAUTIOUS: bad pipe r/w flag"); return; } #endif /* CAUTIOUS */ sprintf(msg_str,"Pipe:\t\t\"%s\", %s",pp->p_name,rw_choices[i]); prt_msg(msg_str); sprintf(msg_str,"Command:\t\t\"%s\"",pp->p_cmd); prt_msg(msg_str); }
void print_dump_legend(SINGLE_QSP_ARG_DECL) { /* blank line */ prt_msg(""); /* first line */ prt_msg_frag("node\t"); if( SHOWING_LHS_REFS ) prt_msg_frag("n_lhs\t"); if( SHOWING_COST ) prt_msg_frag("depth,\tflops\tnmath"); prt_msg("\top\t\tchildren"); /* second line */ if( SHOWING_COST ) prt_msg("\tnelts"); /* blank line */ prt_msg(""); }
void report_bandwidth(QSP_ARG_DECL PGR_Cam *pgcp ) { unsigned int bw; if( dc1394_video_get_bandwidth_usage(pgcp->pc_cam_p,&bw) != DC1394_SUCCESS ){ warn("error querying bandwidth usage"); return; } /* What are the units of bandwidth??? */ sprintf(msg_str,"%s bandwidth: %d",pgcp->pc_name,bw); prt_msg(msg_str); }
static COMMAND_FUNC(do_spink_node_info) { Spink_Node *skn_p; CHECK_CURRENT_MAP skn_p = pick_spink_node(""); if( skn_p == NULL ) return; sprintf(MSG_STR,"Map %s, Node %s:",skn_p->skn_skm_p->skm_name,skn_p->skn_name); prt_msg(MSG_STR); print_spink_node_info(skn_p,0); }
static PF_COMMAND_FUNC( prt_cap ) { #ifdef HAVE_OpenCL #ifdef OpenCL_COMP_CAP sprintf(MSG_STR,"Compiled for compute capability %d.%d", OpenCL_COMP_CAP/10,OpenCL_COMP_CAP%10); #else // ! OpenCL_COMP_CAP ERROR1("CAUTIOUS: HAVE_OpenCL is defined, but OpenCL_COMP_CAP is not!?!?"); #endif // ! OpenCL_COMP_CAP #else // ! HAVE_OpenCL sprintf(MSG_STR,"No OpenCL support in this build"); #endif // ! HAVE_OpenCL prt_msg(MSG_STR); }
static void _vf_info(QSP_ARG_DECL Vector_Function *vfp) { int i; int n_printed=0; sprintf(msg_str,"Vector function %s:",VF_NAME(vfp)); prt_msg(msg_str); #define MAX_PER_LINE 4 prt_msg_frag("\tallowable precisions:"); for(i=0;i<N_MACHINE_PRECS;i++){ if( VF_PRECMASK(vfp) & (1<<i) ){ /* BUG? is 0 a legal precision code? it is PREC_NONE... */ sprintf(msg_str,"%s%s", (n_printed>=MAX_PER_LINE?",\n\t\t\t": (n_printed>0?", ":"")), PREC_NAME(prec_for_code(i)) ); prt_msg_frag(msg_str); if( n_printed >= MAX_PER_LINE ) n_printed=0; n_printed++; } } prt_msg(""); prt_msg_frag("\tallowable types:"); n_printed=0; for(i=0;i<N_ARGSET_TYPES;i++){ if( VF_TYPEMASK(vfp) & VL_TYPE_MASK(i) ){ sprintf(msg_str,"%s%s", n_printed>0?", ":"", number_type_name[i]); prt_msg_frag(msg_str); n_printed++; } } prt_msg(""); }
static COMMAND_FUNC( do_wrt_obj ) { Data_Obj *dp; FILE *fp; /* BUG what if pathname is longer than 256??? */ const char *filename; dp=PICK_OBJ(""); filename = NAMEOF("output file"); if( dp==NO_OBJ ) return; if( strcmp(filename,"-") && strcmp(filename,"stdout") ){ // BUG? we don't check append flag here, // but there is a separate append command... fp=TRYNICE( filename, "w" ); if( !fp ) return; } else { // If the invoking script has redirected stdout, // then use that if( QS_MSG_FILE(THIS_QSP)!=NULL ) fp = QS_MSG_FILE(THIS_QSP); else fp = stdout; } if( IS_IMAGE(dp) || IS_SEQUENCE(dp) ) if( !CONFIRM( "are you sure you want to write an image/sequence in ascii") ){ fclose(fp); return; } dp = insure_ram_obj(QSP_ARG dp); if( dp == NO_OBJ ) return; pntvec(QSP_ARG dp,fp); if( fp != stdout && QS_MSG_FILE(THIS_QSP)!=NULL && fp != QS_MSG_FILE(THIS_QSP) ) { if( verbose ){ sprintf(MSG_STR,"closing file %s",filename); prt_msg(MSG_STR); } fclose(fp); } DELETE_IF_COPY(dp) }
static COMMAND_FUNC( do_cam_info ) { Spink_Cam *scp; scp = pick_spink_cam("camera"); if( scp == NULL ) return; if( scp == the_cam_p ){ sprintf(MSG_STR,"%s is selected as current camera.",scp->skc_name); prt_msg(MSG_STR); } #ifdef HAVE_LIBSPINNAKER //print_spink_cam_info(QSP_ARG scp); #else NO_LIB_MSG("do_list_spink_cam"); #endif }
int list_video_modes(QSP_ARG_DECL PGR_Cam *pgcp) { dc1394video_modes_t video_modes; const char *s; unsigned int i; if ( dc1394_video_get_supported_modes( pgcp->pc_cam_p, &video_modes ) != DC1394_SUCCESS ) return -1; for( i = 0; i< video_modes.num; i++ ){ s=name_for_video_mode(video_modes.modes[i]); assert( s != NULL ); prt_msg_frag("\t"); prt_msg(s); } return 0; }
static COMMAND_FUNC(do_disp_chunk) { Chunk_Data *cd_p; Data_Obj *dp; char buf[64]; cd_p = pick_chunk_data(""); dp = pick_obj("camera buffer"); if( cd_p == NULL || dp == NULL ) return; fetch_chunk_data(cd_p,dp); format_chunk_data(buf,cd_p); sprintf(MSG_STR,"\t%s: ",cd_p->cd_name); prt_msg_frag(MSG_STR); prt_msg(buf); }
void display_formatted_point(QSP_ARG_DECL Fmt_Pt * fpp, Polh_Record_Format *prfp ) { int i; if( fpp == NULL ) return; separator=""; /* no leading tab before the first record */ for(i=0;i<prfp->rf_n_data;i++){ Polh_Output_Type type; type = prfp->rf_output[i]; disp_one(QSP_ARG fpp,type); separator="\t"; /* for succeeding records, prepend a tab */ } prt_msg(""); }
void opt_param_info(QSP_ARG_DECL Opt_Param *opp) { sprintf(msg_str,"Parameter %s:",opp->op_name); prt_msg(msg_str); sprintf(msg_str,"\tvalue:\t%f",opp->ans); prt_msg(msg_str); sprintf(msg_str,"\tmin:\t%f",opp->minv); prt_msg(msg_str); sprintf(msg_str,"\tmax:\t%f",opp->maxv); prt_msg(msg_str); sprintf(msg_str,"\tdelta:\t%f",opp->delta); prt_msg(msg_str); sprintf(msg_str,"\tmindel:\t%f",opp->mindel); prt_msg(msg_str); }
static void report_genlock_status( FB_Info *fbip ) { int i,index; float l2,l3; if( ! genlock_active ){ WARN("report_genlock_status: genlock is not active!?"); return; } index = -1; for(i=0;i<gli1.gli_n_heads;i++) if( gli1.gli_fbip[i] == fbip ) index=i; if( index < 0 ){ sprintf(ERROR_STRING,"report_genlock_status: genlock is not active for frame buffer %s!?",fbip->fbi_name); WARN(ERROR_STRING); return; } l2 = gli1.gli_fb_latency[index] /1000.0; l3 = gli1.gli_drift[index] / 1000.0; sprintf(msg_str,"%s:\t\tvbl %g msec after ext pulse\t\tdrift = %g",fbip->fbi_name,l2,l3); prt_msg(msg_str); }
static COMMAND_FUNC( do_list_spink_cams ) { prt_msg("Spinnaker cameras:"); list_spink_cams(tell_msgfile()); prt_msg(""); }
static COMMAND_FUNC( do_list_spink_interfaces ) { prt_msg("Spinnaker interfaces:"); list_spink_interfaces(tell_msgfile()); prt_msg(""); }
static void ocl_dev_info(QSP_ARG_DECL Platform_Device *pdp) { sprintf(MSG_STR,"%s:",PFDEV_NAME(pdp)); prt_msg(MSG_STR); prt_msg("Sorry, no OpenCL-specific device info yet."); }
static void _dump_node_basic(QSP_ARG_DECL Vec_Expr_Node *enp) { Tree_Code code; int i; const char *s; if( enp==NULL ) return; /* print the node "name", and a code that tells about shape knowledge */ // Temporarily print to stderr instead of stdout for debugging... prt_node(enp,msg_str); prt_msg_frag(msg_str); if( SHOWING_LHS_REFS ){ sprintf(msg_str,"\t%d",VN_LHS_REFS(enp)); prt_msg_frag(msg_str); } if( SHOWING_COST ){ if( VN_SHAPE(enp) != NULL ){ sprintf(msg_str,"\t%d", SHP_N_MACH_ELTS(VN_SHAPE(enp))); } prt_msg_frag(msg_str); sprintf(msg_str,"\t%d\t%d", VN_FLOPS(enp),VN_N_MATH(enp)); prt_msg_frag(msg_str); } if( IS_CURDLED(enp) ){ sprintf(msg_str,"\t%s (curdled!?)", NNAME(enp)); prt_msg(msg_str); return; } sprintf(msg_str,"\t%s", NNAME(enp)); prt_msg_frag(msg_str); /* print the special op-dependent args in human-readable form */ code = VN_CODE(enp); if( code==T_DYN_OBJ || code == T_UNDEF || code == T_PROTO || code==T_POINTER || code==T_FUNCPTR || code==T_STR_PTR ){ sprintf(msg_str,"\t%s",VN_STRING(enp)); prt_msg_frag(msg_str); if( code == T_POINTER ){ Identifier *idp; /* We don't use get_set_ptr() here because we don't want an error msg... */ idp = id_of(VN_STRING(enp)); if( idp != NULL && IS_POINTER(idp) && POINTER_IS_SET(idp) ){ if( PTR_REF(ID_PTR(idp)) == NULL ){ /* how could this ever happen??? */ prt_msg_frag("->???"); } else { Data_Obj *dp; dp = REF_OBJ(PTR_REF(ID_PTR(idp))); sprintf(msg_str,"->%s",OBJ_NAME(dp)); prt_msg_frag(msg_str); } } } } else if( code == T_STATIC_OBJ ){ sprintf(msg_str,"\t%s",OBJ_NAME(VN_OBJ(enp))); prt_msg_frag(msg_str); #ifdef SCALARS_NOT_OBJECTS } else if( code == T_SCALAR_VAR ){ sprintf(msg_str,"\t%s",VN_STRING(enp)); prt_msg_frag(msg_str); #endif // SCALARS_NOT_OBJECTS } else if ( code == T_FUNCREF ){ Subrt *srp; srp=VN_SUBRT(enp); sprintf(msg_str,"\t%s",SR_NAME(srp)); prt_msg_frag(msg_str); } else if( code == T_SIZE_FN ){ sprintf(msg_str,"\t%s",FUNC_NAME(VN_FUNC_PTR(enp))); prt_msg_frag(msg_str); } #ifdef NOT_YET else if(code == T_CALL_NATIVE ){ // was kw_token??? // curr_native_func_tbl... sprintf(msg_str,"\t%s",FUNC_NAME(VN_FUNC_PTR(enp))); prt_msg_frag(msg_str); } #endif /* NOT_YET */ else if(code == T_TYPECAST ){ // BUG not how we do precision any more!!! //sprintf(msg_str," %s",NAME_FOR_PREC_CODE(VN_INTVAL(enp))); if( VN_SHAPE(enp) == NULL ) error1("CAUTIOUS: null node shape for typecast node!?"); else { sprintf(msg_str," %s",PREC_NAME(VN_PREC_PTR(enp))); prt_msg_frag(msg_str); } } else if( code == T_SUBRT_DECL || code == T_SCRIPT ){ Subrt *srp; srp=VN_SUBRT(enp); sprintf(msg_str,"\t%s",SR_NAME(srp)); prt_msg_frag(msg_str); } else if( code==T_DECL_STAT ){ //sprintf(msg_str," %s",NAME_FOR_PREC_CODE(VN_INTVAL(enp))); sprintf(msg_str," %s",PREC_NAME(VN_DECL_PREC(enp))); prt_msg_frag(msg_str); } else if( IS_DECL(code) ){ sprintf(msg_str," %s",VN_STRING(enp)); prt_msg_frag(msg_str); } else if( code==T_ADVISE ){ /* BUG need to elim yylex_qsp */ s=eval_string(VN_CHILD(enp,0)); sprintf(msg_str,"\t\"%s\"",s); prt_msg_frag(msg_str); } else if( code==T_WARN ){ /* BUG need to elim yylex_qsp */ s=eval_string(VN_CHILD(enp,0)); sprintf(msg_str,"\t\"%s\"",s); prt_msg_frag(msg_str); } else if( code==T_STRING ){ sprintf(msg_str,"\t\"%s\"",VN_STRING(enp)); prt_msg_frag(msg_str); } else if( code == T_LABEL || code ==T_GO_BACK || code == T_GO_FWD ){ sprintf(msg_str," %s",VN_STRING(enp)); prt_msg_frag(msg_str); } else if( code==T_LIT_DBL ){ sprintf(msg_str," %g",VN_DBLVAL(enp)); prt_msg_frag(msg_str); } else if( code == T_MATH0_FN ){ sprintf(msg_str," %s",FUNC_NAME(VN_FUNC_PTR(enp))); prt_msg_frag(msg_str); } else if( code == T_MATH1_FN ){ sprintf(msg_str," %s",FUNC_NAME(VN_FUNC_PTR(enp))); prt_msg_frag(msg_str); } else if( code == T_MATH2_FN ){ sprintf(msg_str," %s",FUNC_NAME(VN_FUNC_PTR(enp))); prt_msg_frag(msg_str); } else if ( code == T_MATH0_VFN || code == T_MATH1_VFN || code == T_MATH2_VFN || code == T_MATH2_VSFN || code == T_CHAR_VFN /* BUG? shouldn't there bre a VSFN2 ??? */ || code == T_VS_FUNC || code == T_VV_FUNC ){ sprintf(msg_str," %s",VF_NAME(FIND_VEC_FUNC(VN_VFUNC_CODE(enp)))); prt_msg_frag(msg_str); } else if( code==T_CALLFUNC ){ assert(VN_SUBRT(enp)!=NULL); sprintf(msg_str," %s", SR_NAME(VN_SUBRT(enp))); prt_msg_frag(msg_str); } else if( code==T_LIT_INT ){ sprintf(msg_str," %"PRId64, VN_INTVAL(enp) ); prt_msg_frag(msg_str); } else if( code==T_ASSIGN ){ prt_msg_frag("\t"); } else if( code==T_MAXVAL ){ prt_msg_frag("\t"); } else if( code==T_MINVAL ){ prt_msg_frag("\t"); } else if( code==T_RAMP ){ prt_msg_frag("\t"); } /* Now print the addresses of the child nodes */ if( VN_CHILD(enp,0)!=NULL){ sprintf(msg_str,"\t\tn%d",VN_SERIAL(VN_CHILD(enp,0))); prt_msg_frag(msg_str); } for(i=1;i<MAX_CHILDREN(enp);i++){ if( VN_CHILD(enp,i)!=NULL){ sprintf(msg_str,", n%d",VN_SERIAL(VN_CHILD(enp,i))); prt_msg_frag(msg_str); } } prt_msg(""); if( SHOWING_SHAPES && VN_SHAPE(enp) != NULL ){ prt_msg_frag("\t"); if( OWNS_SHAPE(enp) ){ sprintf(msg_str,"* 0x%lx ",(u_long)VN_SHAPE(enp)); prt_msg_frag(msg_str); } else { sprintf(msg_str,"@ 0x%lx ",(u_long)VN_SHAPE(enp)); prt_msg_frag(msg_str); } prt_msg_frag("\t"); describe_shape(VN_SHAPE(enp)); } if( SHOWING_RESOLVERS && VN_RESOLVERS(enp)!=NULL ){ Node *np; Vec_Expr_Node *enp2; prt_msg("\tResolvers:"); np=QLIST_HEAD(VN_RESOLVERS(enp)); while(np!=NULL){ enp2=(Vec_Expr_Node *)NODE_DATA(np); sprintf(msg_str,"\t\t%s",node_desc(enp2)); prt_msg(msg_str); np=NODE_NEXT(np); } } }
void print_shape_key(SINGLE_QSP_ARG_DECL) { prt_msg("_\tno shape\n?\tunknown shape\n*\towns shape\n@\tshape ref\n#\tunknown leaf"); }
void w_tersout(QSP_ARG_DECL Trial_Class * tcp) { sprintf(msg_str,"%s\t%f\t%f",CLASS_NAME(tcp),alpha,beta); prt_msg(msg_str); /* BUG should print out chi sq stat */ }
static CvPoint2D32f* FindFace(QSP_ARG_DECL IplImage* img, CvMemStorage* storage, CvHaarClassifierCascade* cascade, int frame_number) { bool face_found = false; CvPoint2D32f* features = NULL; int max_faces = 4; //int scale = 1; //CvPoint pt1, pt2; // two points to represent the face locations. int i; int k; if( cascade == NULL ){ WARN("FindFace: cascade is NULL !?"); return(NULL); } /* IplImage* img_copy = cvCreateImage(cvSize(img->width, img->height), IPL_DEPTH_8U, img->nChannels); if(img->origin == IPL_ORIGIN_TL) { cvCopy(img, img_copy, 0); } else { cvFlip(img, img_copy,0); } */ // Clear the memory storage which was used before. cvClearMemStorage(storage); if (cascade) { // Detect the objects and store them in the sequence. /* CVAPI(CvSeq*) cvHaarDetectObjects( const CvArr* image, CvHaarClassifierCascade* cascade, CvMemStorage* storage, double scale_factor CV_DEFAULT(1.1), int min_neighbors CV_DEFAULT(3), int flags CV_DEFAULT(0), CvSize min_size CV_DEFAULT(cvSize(0,0)), CvSize max_size CV_DEFAULT(cvSize(0,0))); */ //#if CV_VERSION_INT > MAKE_VERSION_INT(1,1,0) #if CV_VERSION_INT > MAKE_VERSION_INT(2,0,0) CvSeq* faces = cvHaarDetectObjects( img, cascade, storage, 1.1, 4, CV_HAAR_DO_CANNY_PRUNING, cvSize(30,30),cvSize(60,60) ); #else CvSeq* faces = cvHaarDetectObjects( img, cascade, storage, 1.1, 4, CV_HAAR_DO_CANNY_PRUNING, cvSize(30,30) ); #endif if (faces != NULL) { if( verbose ){ sprintf(ERROR_STRING,"%d faces found in frame %d.",faces->total, frame_number); advise(ERROR_STRING); } } else { /* is this a CAUTIOUS check? */ sprintf(ERROR_STRING,"faces is NULL."); advise(ERROR_STRING); } char msg[60]; sprintf(msg,"%d",faces->total); ASSIGN_VAR("n_faces",msg); sprintf(ERROR_STRING, "faces %d %d ", frame_number, faces->total); for (i=0; i<(faces ? faces->total:0); ++i) { char vname[64], vval[64]; CvRect* r = (CvRect*)cvGetSeqElem(faces, i); sprintf(msg, "%d %d %d %d ", r->x, r->y, r->width, r->height); strcat(ERROR_STRING, msg); sprintf(vname,"face%d_x",i+1); sprintf(vval,"%d",r->x); ASSIGN_VAR(vname,vval); sprintf(vname,"face%d_y",i+1); sprintf(vval,"%d",r->y); ASSIGN_VAR(vname,vval); sprintf(vname,"face%d_w",i+1); sprintf(vval,"%d",r->width); ASSIGN_VAR(vname,vval); sprintf(vname,"face%d_h",i+1); sprintf(vval,"%d",r->height); ASSIGN_VAR(vname,vval); #ifdef FOOBAR /* don't draw here - we might not be viewing... */ // Draw rectangle. CvPoint pt1, pt2; pt1.x = r->x; pt2.x = r->x+r->width; pt1.y = r->y; pt2.y = r->y+r->height; cvRectangle(img, pt1,pt2, CV_RGB(255,0,0), 3, 8, 0); #endif /* FOOBAR */ } if (faces->total < max_faces) { // Append zeros to make the output always have a fixed // number of columns. for (k=0; k< (max_faces - faces->total); ++k) { sprintf(msg, "0 0 0 0 "); strcat(ERROR_STRING, msg); } } prt_msg(ERROR_STRING); //cvSaveImage("output.jpg", img); } if (!face_found) { features = NULL; // cvCircle(img, cvPoint(img->width/2, img->height/2), 30, CV_RGB(255,0,0), 2, 8); } //cvReleaseImage(&img_copy); return features; } // end FindFace