Пример #1
0
void extrema_locator::locate(void)
{
	find_extrema();
	find_objects();
	merge_objects();
	ex_points_from_objects();
}
Пример #2
0
CK_RV find_objects_by_name(bee b, const char *name, CK_OBJECT_HANDLE_PTR *found, CK_ULONG_PTR how_many)
{
    attrs search_me;
    init_attrs(&search_me);
    add_attribute(&search_me, CKA_LABEL, (CK_VOID_PTR) name, strlen(name));

    return find_objects(b, search_me, found, how_many);
}
Пример #3
0
int
find_objects(xmlNodePtr curr_node,
	     struct ldap_object_node **objs,
	     struct ldap_attr_node **attrs,
	     struct idinfo *ids)
{
	struct ldap_object_node *obj = NULL;
	int ret = 0;

	if (!curr_node)
		/* no objects found */
		return 0;

	for (; curr_node; curr_node = curr_node->next) {
		if (curr_node->type != XML_ELEMENT_NODE)
			continue;
		if (!strcasecmp((char *)curr_node->name, "element")) {
			obj = parse_element_tag(curr_node, objs, attrs, ids);
			ret = 1;
		} else {
			dbg_printf("Descend on %s\n", curr_node->name);
		}

		if (find_objects(curr_node->xmlChildrenNode, 
		    		 objs, attrs, ids)) {
			ret = 1;
		} else if (obj) {
			/*
			 * We have an object, but when we 
			 * looked for children, it did not
			 * have any.  So, we can omit the
			 * requirement for 'cn' in the
			 * output LDIF here
			 */
			if (obj->need_cn) {
				dbg_printf("Object class %s does not have"
					   " any children; not outputting "
					   "'MUST ( cn )'\n", obj->name);
			}
			obj->need_cn = 0;
		}
	}

	/* Child objects were found */
	return ret;
}
Пример #4
0
void cmex_object_list(int nlhs, mxArray *plhs[], /**< entlist */
					  int nrhs, const mxArray *prhs[] ) /**< () */
{
	OBJECT *obj;
	char criteria[1024]="(undefined)";
	FINDPGM *search = NULL;
	char *fields[] = {"name","class","parent","flags","location","service","rank","clock","handle"};
	FINDLIST *list = NULL;
	if (nrhs>0 && mxGetString(prhs[0],criteria,sizeof(criteria))!=0)
		output_error("gl('list',type='object'): unable to read search criteria (arg 2)");
	else if (nrhs>0 && (search=find_mkpgm(criteria))==NULL)
		output_error("gl('list',type='object'): unable to run search '%s'",criteria);
	else if (search==NULL && (list=find_objects(NULL,NULL))==NULL)
		output_error("gl('list',type='object'): unable to obtain default list");
	else if (list==NULL && (list=find_runpgm(NULL,search))==NULL)
		output_error("gl('list',type='object'): unable search failed");
	else if ((plhs[0] = mxCreateStructMatrix(list->hit_count,1,sizeof(fields)/sizeof(fields[0]),fields))==NULL)
		output_error("gl('list',type='object'): unable to allocate memory for result list");
	else
	{
		unsigned int n;
		for (n=0, obj=find_first(list); obj!=NULL; n++, obj=find_next(list,obj))
		{
			char tmp[1024];
			mxArray *data;
			double *pDouble;
			unsigned int *pInt;
			mxSetFieldByNumber(plhs[0], n, 0, mxCreateString(object_name(obj)));
			mxSetFieldByNumber(plhs[0], n, 1, mxCreateString(obj->oclass->name));
			mxSetFieldByNumber(plhs[0], n, 2, mxCreateString(obj->parent?object_name(obj->parent):NONE));
			mxSetFieldByNumber(plhs[0], n, 3, mxCreateString(convert_from_set(tmp,sizeof(tmp),&(obj->flags),object_flag_property())?tmp:ERROR));
			pDouble = mxGetPr(data=mxCreateDoubleMatrix(1,2,mxREAL)); pDouble[0] = obj->longitude; pDouble[1] = obj->latitude;
			mxSetFieldByNumber(plhs[0], n, 4, data);
			pDouble = mxGetPr(data=mxCreateDoubleMatrix(1,2,mxREAL)); pDouble[0] = (double)obj->in_svc/TS_SECOND; pDouble[1] = (double)obj->out_svc/TS_SECOND;
			mxSetFieldByNumber(plhs[0], n, 5, data);
			pInt = (unsigned int*)mxGetPr(data=mxCreateNumericMatrix(1,1,mxINT32_CLASS,mxREAL)); pInt[0] = obj->rank;
			mxSetFieldByNumber(plhs[0], n, 6, data);
			pDouble = mxGetPr(data=mxCreateDoubleMatrix(1,1,mxREAL)); pDouble[0] = (double)obj->clock/TS_SECOND; 
			mxSetFieldByNumber(plhs[0], n, 7, data);
			mxSetFieldByNumber(plhs[0], n, 8, make_handle(MH_OBJECT,obj));
		}
	}
}
Пример #5
0
STATUS original_test_end(int argc, char *argv[])
{
	FINDLIST *find = find_objects(FL_GROUP,"class=node;");
	OBJECT *obj;
	AGGREGATION *aggr;
	char *exp = "class=node";
	char *agg = "max(V.ang)";

	for (obj=find_first(find); obj!=NULL; obj=find_next(find,obj))
		output_message("object %s found", object_name(obj));
	free(find);

	output_message("Aggregation of %s over %s...", agg,exp);
	aggr = aggregate_mkgroup(agg,exp);
	if (aggr)
		output_message("Result is %lf", aggregate_value(aggr));
	else
		output_message("Aggregation failed!");

	if (!saveall("-"))
		perror("save failed");

	return SUCCESS;
}
Пример #6
0
NSS_IMPLEMENT nssCryptokiObject *
nssToken_FindCertificateByIssuerAndSerialNumber (
  NSSToken *token,
  nssSession *sessionOpt,
  NSSDER *issuer,
  NSSDER *serial,
  nssTokenSearchType searchType,
  PRStatus *statusOpt
)
{
    CK_ATTRIBUTE_PTR attr;
    CK_ATTRIBUTE_PTR serialAttr;
    CK_ATTRIBUTE cert_template[4];
    CK_ULONG ctsize;
    nssCryptokiObject **objects;
    nssCryptokiObject *rvObject = NULL;
    NSS_CK_TEMPLATE_START(cert_template, attr, ctsize);

    if (!token) {
    	PORT_SetError(SEC_ERROR_NO_TOKEN);
	if (statusOpt) 
	    *statusOpt = PR_FAILURE;
	return NULL;
    }
    /* Set the search to token/session only if provided */
    if (searchType == nssTokenSearchType_SessionOnly) {
	NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false);
    } else if ((searchType == nssTokenSearchType_TokenOnly) ||
               (searchType == nssTokenSearchType_TokenForced)) {
	NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true);
    }
    /* Set the unique id */
    NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS,         &g_ck_class_cert);
    NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_ISSUER,         issuer);
    serialAttr = attr;
    NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_SERIAL_NUMBER,  serial);
    NSS_CK_TEMPLATE_FINISH(cert_template, attr, ctsize);
    /* get the object handle */
    if (searchType == nssTokenSearchType_TokenForced) {
	objects = find_objects(token, sessionOpt,
	                       cert_template, ctsize,
	                       1, statusOpt);
    } else {
	objects = find_objects_by_template(token, sessionOpt,
                                       cert_template, ctsize,
                                       1, statusOpt);
    }
    if (objects) {
	rvObject = objects[0];
	nss_ZFreeIf(objects);
    }

    /*
     * NSS used to incorrectly store serial numbers in their decoded form.
     * because of this old tokens have decoded serial numbers.
     */
    if (!objects) {
	NSSItem serialDecode;
	PRStatus status;

	status = nssToken_decodeSerialItem(serial, &serialDecode);
	if (status != PR_SUCCESS) {
	    return NULL;
	}
    	NSS_CK_SET_ATTRIBUTE_ITEM(serialAttr,CKA_SERIAL_NUMBER,&serialDecode);
	if (searchType == nssTokenSearchType_TokenForced) {
	    objects = find_objects(token, sessionOpt,
	                       cert_template, ctsize,
	                       1, statusOpt);
	} else {
	    objects = find_objects_by_template(token, sessionOpt,
                                       cert_template, ctsize,
                                       1, statusOpt);
	}
	if (objects) {
	    rvObject = objects[0];
	    nss_ZFreeIf(objects);
	}
    }
    return rvObject;
}
Пример #7
0
void process_image(IplImage* frame, int draw)
{
	int i, j;
	float t;

	uint8_t* pixels;
	int nrows, ncols, ldim;

	#define MAXNDETECTIONS 2048
	int ndetections;
	float qs[MAXNDETECTIONS], rs[MAXNDETECTIONS], cs[MAXNDETECTIONS], ss[MAXNDETECTIONS];

	static IplImage* gray = 0;
	static IplImage* pyr[5] = {0, 0, 0, 0, 0};

	/*
		...
	*/

	//
	if(!pyr[0])
	{
		//
		gray = cvCreateImage(cvSize(frame->width, frame->height), frame->depth, 1);

		//
		pyr[0] = gray;
		pyr[1] = cvCreateImage(cvSize(frame->width/2, frame->height/2), frame->depth, 1);
		pyr[2] = cvCreateImage(cvSize(frame->width/4, frame->height/4), frame->depth, 1);
		pyr[3] = cvCreateImage(cvSize(frame->width/8, frame->height/8), frame->depth, 1);
		pyr[4] = cvCreateImage(cvSize(frame->width/16, frame->height/16), frame->depth, 1);
	}

	// get grayscale image
	if(frame->nChannels == 3)
		cvCvtColor(frame, gray, CV_RGB2GRAY);
	else
		cvCopy(frame, gray, 0);

	// perform detection with the pico library
	t = getticks();

	if(usepyr)
	{
		int nd;

		//
		pyr[0] = gray;

		pixels = (uint8_t*)pyr[0]->imageData;
		nrows = pyr[0]->height;
		ncols = pyr[0]->width;
		ldim = pyr[0]->widthStep;

		ndetections = find_objects(rs, cs, ss, qs, MAXNDETECTIONS, cascade, angle, pixels, nrows, ncols, ldim, scalefactor, stridefactor, MAX(16, minsize), MIN(128, maxsize));

		for(i=1; i<5; ++i)
		{
			cvResize(pyr[i-1], pyr[i], CV_INTER_LINEAR);

			pixels = (uint8_t*)pyr[i]->imageData;
			nrows = pyr[i]->height;
			ncols = pyr[i]->width;
			ldim = pyr[i]->widthStep;

			nd = find_objects(&rs[ndetections], &cs[ndetections], &ss[ndetections], &qs[ndetections], MAXNDETECTIONS-ndetections, cascade, angle, pixels, nrows, ncols, ldim, scalefactor, stridefactor, MAX(64, minsize>>i), MIN(128, maxsize>>i));

			for(j=ndetections; j<ndetections+nd; ++j)
			{
				rs[j] = (1<<i)*rs[j];
				cs[j] = (1<<i)*cs[j];
				ss[j] = (1<<i)*ss[j];
			}

			ndetections = ndetections + nd;
		}
	}
	else
	{
Пример #8
0
				ss[j] = (1<<i)*ss[j];
			}

			ndetections = ndetections + nd;
		}
	}
	else
	{
		//
		pixels = (uint8_t*)gray->imageData;
		nrows = gray->height;
		ncols = gray->width;
		ldim = gray->widthStep;

		//
		ndetections = find_objects(rs, cs, ss, qs, MAXNDETECTIONS, cascade, angle, pixels, nrows, ncols, ldim, scalefactor, stridefactor, minsize, MIN(nrows, ncols));
	}

	if(!noclustering)
		ndetections = cluster_detections(rs, cs, ss, qs, ndetections);

	t = getticks() - t;

	// if the flag is set, draw each detection
	if(draw)
		for(i=0; i<ndetections; ++i)
			if(qs[i]>=qthreshold) // check the confidence threshold
				cvCircle(frame, cvPoint(cs[i], rs[i]), ss[i]/2, CV_RGB(255, 0, 0), 4, 8, 0); // we draw circles here since height-to-width ratio of the detected face regions is 1.0f

	// if the `verbose` flag is set, print the results to standard output
	if(verbose)
Пример #9
0
int process_image(IplImage* frame, int draw, int print)
{
	int i, j;
	float t;

	uint8_t* pixels;
	int nrows, ncols, ldim;

	#define MAXNDETECTIONS 2048
	int ndetections=0;
	float qs[MAXNDETECTIONS], rs[MAXNDETECTIONS], cs[MAXNDETECTIONS], ss[MAXNDETECTIONS];

	static IplImage* gray = 0;
	static IplImage* pyr[5] = {0, 0, 0, 0, 0};

	/*
		IMPORTANT:
			* these parameters are highly specific for each detection cascade
			  (determine them experimentally)
	*/

	// * this function should be generated with picogen from a detection cascade output by picolrn
	int (*run_detection_cascade)(float*, int, int, int, void*, int, int, int)
		= run_facefinder;

	// * detection quality threshold (must be >= 0.0f)
	// * you can vary the TPR and FPR with this value
	// * if you're experiencing too many false positives, try a larger number here (for example, 7.5f)
	float qthreshold = 5.0f;

	// * how much to rescale the window during the multiscale detection process
	// * increasing this value leads to lower number of detections and higher processing speed
	// * for example, set to 1.2f if you're using pico on a mobile device
	float scalefactor = 1.1f;

	// * how much to move the window between neighboring detections
	// * increasing this value leads to lower number of detections and higher processing speed
	// * for example, set to 0.05f if you want really high recall
	float stridefactor = 0.1f;

	// * coarse image pyramid support
	// * can improve noise and aliasing problems in some applications
	// * set to 1 if pico fails to detect large objects
	int usepyr = 0;

	/*
		...
	*/

	//
	if(!pyr[0])
	{
		//
		gray = cvCreateImage(cvSize(frame->width, frame->height), frame->depth, 1);

		//
		pyr[0] = gray;
		pyr[1] = cvCreateImage(cvSize(frame->width/2, frame->height/2), frame->depth, 1);
		pyr[2] = cvCreateImage(cvSize(frame->width/4, frame->height/4), frame->depth, 1);
		pyr[3] = cvCreateImage(cvSize(frame->width/8, frame->height/8), frame->depth, 1);
		pyr[4] = cvCreateImage(cvSize(frame->width/16, frame->height/16), frame->depth, 1);
	}

	// get grayscale image
	if(frame->nChannels == 3)
		cvCvtColor(frame, gray, CV_RGB2GRAY);
	else
		cvCopy(frame, gray, 0);

	// perform detection with the pico library
	t = getticks();

	if(usepyr)
	{
		int nd;

		//
		pyr[0] = gray;

		pixels = (uint8_t*)pyr[0]->imageData;
		nrows = pyr[0]->height;
		ncols = pyr[0]->width;
		ldim = pyr[0]->widthStep;

		ndetections = find_objects(rs, cs, ss, qs, MAXNDETECTIONS, run_detection_cascade, pixels, nrows, ncols, ldim, scalefactor, stridefactor, MAX(16, minsize), MIN(128, maxsize));

		for(i=1; i<5; ++i)
		{
			cvResize(pyr[i-1], pyr[i], CV_INTER_LINEAR);

			pixels = (uint8_t*)pyr[i]->imageData;
			nrows = pyr[i]->height;
			ncols = pyr[i]->width;
			ldim = pyr[i]->widthStep;

			nd = find_objects(&rs[ndetections], &cs[ndetections], &ss[ndetections], &qs[ndetections], MAXNDETECTIONS-ndetections, run_detection_cascade, pixels, nrows, ncols, ldim, scalefactor, stridefactor, MAX(64, minsize>>i), MIN(128, maxsize>>i));

			for(j=ndetections; j<ndetections+nd; ++j)
			{
				rs[j] = (1<<i)*rs[j];
				cs[j] = (1<<i)*cs[j];
				ss[j] = (1<<i)*ss[j];
			}

			ndetections = ndetections + nd;
		}
	}
	else
	{
Пример #10
0
/*
 * input : grayscale image
 */
int pico_facedetection(void* frame, int width, int height,
	int maxdetect, float *frs, float *fcs, float *fss)
{
	int i, j;
//	float t;

	uint8_t* pixels;
	int nrows, ncols, ldim;

	#define MAXNDETECTIONS 2048
	int ndetections=0;
	float qs[MAXNDETECTIONS], rs[MAXNDETECTIONS], cs[MAXNDETECTIONS], ss[MAXNDETECTIONS];

	void* gray = NULL;
	void* pyr[5] = {NULL, NULL, NULL, NULL, NULL};
	pr_debug(1, "%s: %d %d %d\n", __func__, width, height, maxdetect);
	/*
		IMPORTANT:
			* these parameters are highly specific for each detection cascade
			  (determine them experimentally)
	*/

	// * this function should be generated with picogen from a detection cascade output by picolrn
	int (*run_detection_cascade)(float*, int, int, int, void*, int, int, int)
		= run_facefinder;

	// * detection quality threshold (must be >= 0.0f)
	// * you can vary the TPR and FPR with this value
	// * if you're experiencing too many false positives, try a larger number here (for example, 7.5f)
	float qthreshold = 5.0f;

	// * how much to rescale the window during the multiscale detection process
	// * increasing this value leads to lower number of detections and higher processing speed
	// * for example, set to 1.2f if you're using pico on a mobile device
	float scalefactor = 1.1f;

	// * how much to move the window between neighboring detections
	// * increasing this value leads to lower number of detections and higher processing speed
	// * for example, set to 0.05f if you want really high recall
	float stridefactor = 0.1f;

	// * coarse image pyramid support
	// * can improve noise and aliasing problems in some applications
	// * set to 1 if pico fails to detect large objects
	int usepyr = 0;

	// perform detection with the pico library
//	t = getticks();

	if( (gray = malloc(width*height)) == NULL ){
		pr_debug(1, "!!!!gray malloc failure\n");
		return 0;
	}else{
		memcpy(gray, frame, width*height);
	}
	if(usepyr)
	{
#if 0
		int nd;
		//
		pyr[0] = gray;
		//pyr[1] = cvCreateImage(cvSize(frame->width/2, frame->height/2), frame->depth, 1);
		pyr[1] = malloc((width/2)*(height/2));
		//pyr[2] = cvCreateImage(cvSize(frame->width/4, frame->height/4), frame->depth, 1);
		pyr[2] = malloc((width/4)*(height/4));
		//pyr[3] = cvCreateImage(cvSize(frame->width/8, frame->height/8), frame->depth, 1);
		pyr[3] = malloc((width/8)*(height/8));
		//pyr[4] = cvCreateImage(cvSize(frame->width/16, frame->height/16), frame->depth, 1);
		pyr[4] = malloc((width/16)*(height/16));

		pixels = (uint8_t*)pyr[0];
		nrows = height;
		ncols = width;
		ldim = width;//widthStep;TODO TODO .... if this is the same width for row-major image, 8 bit gray pixel

		ndetections = find_objects(rs, cs, ss, qs, MAXNDETECTIONS, run_detection_cascade,
								   pixels, nrows, ncols, ldim, scalefactor, stridefactor,
							 MAX(16, MIN_SIZE), MIN(128, MAX_SIZE));

		for(i=1; i<5; ++i)
		{
			cvResize(pyr[i-1], pyr[i], CV_INTER_LINEAR);

			pixels = (uint8_t*)pyr[i];
			nrows = height/(1<<i);	//1/(2^n)
			ncols = width/(1<<i);
			ldim = ncols;	//pyr[i]->widthStep;

			nd = find_objects(&rs[ndetections], &cs[ndetections], &ss[ndetections],
							  &qs[ndetections], MAXNDETECTIONS-ndetections,
					 run_detection_cascade, pixels, nrows, ncols, ldim, scalefactor,
					 stridefactor, MAX(64, MIN_SIZE>>i), MIN(128, MAX_SIZE>>i));

			for(j=ndetections; j<ndetections+nd; ++j)
			{
				rs[j] = (1<<i)*rs[j];
				cs[j] = (1<<i)*cs[j];
				ss[j] = (1<<i)*ss[j];
			}

			ndetections = ndetections + nd;
		}
		for(i=0; i<5; ++i){
			if(pyr[i]){
				free(pyr[i]);
				pyr[i]=NULL;
			}
		}
#endif
	}
	else
	{