コード例 #1
0
void *max_ta_jit_kinect2_new(t_symbol *s, long argc, t_atom *argv)
{
    t_max_ta_jit_kinect2	*x;
    void			*o;
    
    x = (t_max_ta_jit_kinect2 *)max_jit_object_alloc(max_ta_jit_kinect2_class, gensym("ta_jit_kinect2"));
    if (x) {
        o = jit_object_new(gensym("ta_jit_kinect2"));
        if (o) {
            max_jit_mop_setup_simple(x, o, argc, argv);
            max_jit_attr_args(x, argc, argv);
            t_atom_long depthdim[2] = {DEPTH_WIDTH, DEPTH_HEIGHT};
            t_atom_long rgbdim[2] = {RGB_WIDTH, RGB_HEIGHT};
            
            //TA: set depth matrix initial attributes
            void *output = max_jit_mop_getoutput(x, 1);
            jit_attr_setsym(output, _jit_sym_type, _jit_sym_float32);
            jit_attr_setlong_array(output, _jit_sym_dim, 2, depthdim);
            jit_attr_setlong(output, _jit_sym_planecount, 1);
            
            //TA: set rgb matrix initial attributes
            output = max_jit_mop_getoutput(x, 2);
            jit_attr_setsym(output, _jit_sym_type, _jit_sym_char);
            jit_attr_setlong_array(output, _jit_sym_dim, 2, rgbdim);
            jit_attr_setlong(output, _jit_sym_planecount, 4);

        }
        else {
            jit_object_error((t_object *)x, "ta.jit.kinect2: could not allocate object");
            object_free((t_object *)x);
            x = NULL;
        }
    }
    return (x);
}
コード例 #2
0
void *max_jit_submatrix_new(t_symbol *s, long argc, t_atom *argv)
{
	t_max_jit_submatrix *x;
	void *o,*m,*mop,*p;
	t_jit_matrix_info info;

	if (x=(t_max_jit_submatrix *)max_jit_obex_new(max_jit_submatrix_class,gensym("jit_submatrix"))) {
		if (o=jit_object_new(gensym("jit_submatrix"))) {
			max_jit_obex_jitob_set(x,o);
			max_jit_obex_dumpout_set(x,outlet_new(x,NULL));
			max_jit_mop_setup(x);
			max_jit_mop_inputs(x);
			max_jit_mop_outputs(x);
			mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop);
			jit_attr_setlong(mop,gensym("adapt"),0);
			jit_attr_setlong(mop,gensym("caninplace"),0);
			jit_attr_setlong(mop,gensym("outputmode"),1);
			//make the output matrix a data reference w/NULL data pointer
			m = max_jit_mop_getoutput(x,1);
			jit_object_method(m,_jit_sym_getinfo,&info);
			jit_object_method(m,gensym("freedata"));
			info.flags = JIT_MATRIX_DATA_REFERENCE;
			info.size = 0;
			p = NULL;
			jit_object_method(m,_jit_sym_setinfo_ex,&info);
			jit_object_method(m,_jit_sym_data,p);
			max_jit_attr_args(x,argc,argv);
		} else {
			jit_object_error((t_object *)x,"jit.submatrix: could not allocate object");
			freeobject((t_object *) x);
			x = NULL;
		}
	}
	return (x);
}
コード例 #3
0
ファイル: cv.jit.lines.c プロジェクト: fourks/cv.jit
t_jit_err cv_jit_lines_init(void) 
{
	long attrflags=0;
	t_jit_object *attr,*mop,*output;
	
	_cv_jit_lines_class = jit_class_new("cv_jit_lines",(method)cv_jit_lines_new,(method)cv_jit_lines_free,
		sizeof(t_cv_jit_lines),0L);

	//add mop
	mop = (t_jit_object *)jit_object_new(_jit_sym_jit_mop,1,1);  //Object has one input and one output

   	jit_mop_single_type(mop,_jit_sym_char);   //Set input type and planecount
   	jit_mop_single_planecount(mop,1);  
   	jit_mop_output_nolink(mop,1); //Turn off output linking so that output matrix does not adapt to input
   	
   	output = (t_jit_object *)jit_object_method(mop,_jit_sym_getoutput,1); //Get a pointer to the output matrix
   	jit_attr_setlong(output,_jit_sym_minplanecount,4);  //Set output plane count
  	jit_attr_setlong(output,_jit_sym_maxplanecount,4); //4 -> Coordinates of start and end points for each line
  	jit_attr_setlong(output,_jit_sym_mindim,1);  //Only one dimension
  	jit_attr_setlong(output,_jit_sym_maxdim,1);
  	jit_attr_setsym(output,_jit_sym_types,_jit_sym_long);
  	
  	jit_class_addadornment(_cv_jit_lines_class,mop);
  	
	//add methods
	jit_class_addmethod(_cv_jit_lines_class, (method)cv_jit_lines_matrix_calc, 		"matrix_calc", 		A_CANT, 0L);
	
	//add attributes	
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"threshold",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_cv_jit_lines,threshold));
	jit_attr_addfilterset_clip(attr,1,255,TRUE,TRUE);	//clip to 1-255
	jit_class_addattr(_cv_jit_lines_class,attr);
	
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"resolution",_jit_sym_long,attrflags,
		(method)0L,(method)0L,calcoffset(t_cv_jit_lines,resolution));
	jit_attr_addfilterset_clip(attr,1,10,TRUE,TRUE);	//clip to 1-10
	jit_class_addattr(_cv_jit_lines_class,attr);
	
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"gap",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_cv_jit_lines,gap));
	jit_class_addattr(_cv_jit_lines_class,attr);
	
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"length",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_cv_jit_lines,length));
	jit_class_addattr(_cv_jit_lines_class,attr);
	
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"sensitivity",_jit_sym_long,attrflags,
		(method)0L,(method)0L,calcoffset(t_cv_jit_lines,sensitivity));
	jit_attr_addfilterset_clip(attr,1,255,TRUE,TRUE);	//clip to 1-255
	jit_class_addattr(_cv_jit_lines_class,attr);
	
	jit_class_register(_cv_jit_lines_class);

	return JIT_ERR_NONE;
}
コード例 #4
0
ファイル: max.jit.unpack.c プロジェクト: Cycling74/max5-sdk
void *max_jit_unpack_new(t_symbol *s, long argc, t_atom *argv)
{
	t_max_jit_unpack *x;
	void *o,*m,*p,*mop;
	t_jit_matrix_info info;
	long i;

	if (x=(t_max_jit_unpack *)max_jit_obex_new(max_jit_unpack_class,gensym("jit_unpack"))) {
		if (o=jit_object_new(gensym("jit_unpack"))) {
			max_jit_obex_jitob_set(x,o);
			max_jit_obex_dumpout_set(x,outlet_new(x,NULL));
			max_jit_mop_setup(x);
			max_jit_mop_inputs(x);
			
			if (argc&&(i=jit_atom_getlong(argv))) {
				CLIP(i,1,JIT_MATRIX_MAX_PLANECOUNT);
			} else {
				i=4;
			}
			
			x->outlets = i;
			max_jit_mop_variable_addoutputs(x,i);
			
			while (i) {
				p=max_jit_mop_getoutput(x,i);
				jit_attr_setlong(p,gensym("minplanecount"),1);
				jit_attr_setlong(p,gensym("maxplanecount"),1);
				i--;
			}
		
			max_jit_mop_outputs(x);
			max_jit_mop_matrix_args(x,argc,argv);
			//set adapt true if only plane argument(should come after matrix_args call)
			if ((max_jit_attr_args_offset(argc,argv)<=1) &&
				(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop)))
			{		
				jit_attr_setlong(mop,_jit_sym_adapt,1);
			}
			
			max_jit_attr_args(x,argc,argv);
		} else {
			jit_object_error((t_object *)x,"jit.unpack: could not allocate object");
			freeobject(x);
			x = NULL;
		}
	}
	return (x);
}
コード例 #5
0
t_jit_tml_gl_videoplane *jit_gl_videoplane_new(t_symbol * dest_name)
{
	t_jit_tml_gl_videoplane *x;
	t_atom rav[4];
	t_atom *av=rav;
	
	// make jit object
	if (x = (t_jit_tml_gl_videoplane *)jit_object_alloc(_jit_tml_gl_videoplane_class)) 
	{
		// create and attach ob3d
		jit_ob3d_new(x, dest_name);
		
		// set instance variable defaults
		x->dim[0] = 20;
		x->dim[1] = 20;	
		x->chunk = jit_glchunk_grid_new(_jit_sym_gl_quad_grid, 12, x->dim[0], x->dim[1]);
		x->recalc = 1;
		x->displaylist = 0;
		x->dlref = 0;
		x->gridmode = 0;
		
		x->interp = 1;
		x->tex_offset_x = 0.;
		x->tex_offset_y = 0.;
		x->tex_scale_x = 1.;
		x->tex_scale_y = 1.;
		
		x->nudge = 0.0001;	// hack for edges
	 			
		x->rect_tex = 1;
		x->client_storage = PLATFORM_DYNAMIC_TEX;
		x->colormode = gensym("argb");

		jit_atom_setfloat(av,1.);
		jit_atom_setfloat(av+1,1.);
		jit_atom_setfloat(av+2,1.);
		jit_atom_setfloat(av+3,1.);
		
		jit_object_method(x,gensym("color"),4,av);

		x->texture = jit_object_new(ps_jit_gl_texture,jit_attr_getsym(x,ps_drawto));
		if (x->texture) {
			x->texturename = jit_symbol_unique();		
			jit_attr_setsym(x->texture,_jit_sym_name,x->texturename);
			jit_attr_setsym(x->texture,gensym("defaultimage"),gensym("black"));
			jit_attr_setlong(x->texture,ps_rectangle,x->rect_tex);
			jit_attr_setsym(x->texture,ps_mode,x->client_storage?ps_dynamic:ps_static);		
			jit_attr_setsym(x,ps_texture,x->texturename);
		} else {
			error("jit.tml.gl.videoplane: could not create texture");
			x->texturename = _jit_sym_nothing;		
		}
	} 
	else 
	{
		error("jit.tml.gl.videoplane: Failed at jit_object_alloc");
		x = NULL;
	}	
	return x;
}
コード例 #6
0
ファイル: jit.glue.c プロジェクト: Cycling74/max5-sdk
t_jit_err jit_glue_init(void) 
{
	long attrflags=0;
	void *attr,*mop,*o;
	
	_jit_glue_class = jit_class_new("jit_glue",(method)jit_glue_new,(method)jit_glue_free,
		sizeof(t_jit_glue),0L);

	//add mop
	mop = jit_object_new(_jit_sym_jit_mop,-1,1); //#inputs,#outputs(variable)
	o = jit_object_method(mop,_jit_sym_getoutput,1);
	jit_attr_setlong(o,_jit_sym_dimlink,0);
	jit_class_addadornment(_jit_glue_class,mop);
	//add methods
	jit_class_addmethod(_jit_glue_class, (method)jit_glue_matrix_calc, 		"matrix_calc", 		A_CANT, 0L);
	//add attributes	
	attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;
	attr = jit_object_new(_jit_sym_jit_attr_offset,"rows",_jit_sym_long,attrflags,
		(method)0,(method)0,calcoffset(t_jit_glue,rows));
	jit_attr_addfilterset_clip(attr,1,16,1,1);
	jit_class_addattr(_jit_glue_class,attr);
	attr = jit_object_new(_jit_sym_jit_attr_offset,"columns",_jit_sym_long,attrflags,
		(method)0,(method)0,calcoffset(t_jit_glue,cols));
	jit_attr_addfilterset_clip(attr,1,16,1,1);
	jit_class_addattr(_jit_glue_class,attr);

	attrflags = JIT_ATTR_GET_OPAQUE_USER | JIT_ATTR_SET_OPAQUE_USER;
	attr = jit_object_new(_jit_sym_jit_attr_offset,"input",_jit_sym_long,attrflags,
		(method)0,(method)0,calcoffset(t_jit_glue,input));
	jit_class_addattr(_jit_glue_class,attr);

	jit_class_register(_jit_glue_class);

	return JIT_ERR_NONE;
}
コード例 #7
0
ファイル: max.jit.str.op.c プロジェクト: Cycling74/max5-sdk
void max_jit_str_op_mproc(t_max_jit_str_op *x, void *mop)
{
	long err;
	void *o;
	long ac = 1;
	t_atom a[2];
	t_symbol *s;
	
	o = max_jit_obex_jitob_get(x);
	
	jit_attr_setlong(o, gensym("adaptflag"), jit_attr_getlong(mop, _jit_sym_adapt));
	
	if (err=(t_jit_err) jit_object_method(
		max_jit_obex_jitob_get(x),
		_jit_sym_matrix_calc,
		jit_object_method(mop,_jit_sym_getinputlist),
		jit_object_method(mop,_jit_sym_getoutputlist))) 
	{
		jit_error_code(x,err); 
	} else {
		s = jit_attr_getsym(o, gensym("op"));
		switch(jit_attr_getlong(o, gensym("outmode"))) {
		case 0:
			max_jit_mop_outputmatrix(x);
			break;
		case 2:
			ac = 2;
			jit_atom_setlong(&a[1], jit_attr_getlong(o, gensym("outlong2")));
		case 1:
			jit_atom_setlong(&a[0], jit_attr_getlong(o, gensym("outlong")));
			max_jit_obex_dumpout(x, s, ac, a);
			break;
		}	
	}
}
コード例 #8
0
void *max_jit_scissors_new(t_symbol *s, long argc, t_atom *argv)
{
	t_max_jit_scissors *x;
	void *o, *p, *mop;
	t_jit_matrix_info info;
	long i;

	if (x=(t_max_jit_scissors *)max_jit_obex_new(max_jit_scissors_class, gensym("jit_scissors"))) {
		if (o=jit_object_new(gensym("jit_scissors"))) {
			max_jit_obex_jitob_set(x, o);
			max_jit_obex_dumpout_set(x, outlet_new(x, NULL));
			max_jit_mop_setup(x);
			max_jit_mop_inputs(x);

			max_jit_attr_args(x, argc, argv); // get attr args to know rows and cols
			x->maxn = jit_attr_getlong(o, ps_rows) * jit_attr_getlong(o, ps_columns);
			max_jit_mop_variable_addoutputs(x, x->maxn);
			max_jit_mop_outputs(x);
			// don't forget the nolink!
			mop = max_jit_obex_adornment_get(x, _jit_sym_jit_mop);
			for (i = 1; i <= x->maxn; i++)
				jit_mop_output_nolink(mop, i);

			jit_attr_setlong(o, gensym("max"), x->maxn);
			max_jit_mop_matrix_args(x, argc, argv); // now set matrix info
		} else {
			jit_object_error((t_object *)x,"jit.scissors: could not allocate object");
			freeobject((t_object *) x);
			x = NULL;
		}
	}
	return (x);
}
コード例 #9
0
ファイル: cv.jit.blob.direction.c プロジェクト: fourks/cv.jit
t_jit_err cv_jit_blobs_direction_init(void) 
{
	long attrflags=0;
	t_jit_object *attr,*mop,*output;
	t_symbol *atsym;
	
	atsym = gensym("jit_attr_offset");
	
	_cv_jit_blobs_direction_class = jit_class_new("cv_jit_blobs_direction",(method)cv_jit_blobs_direction_new,(method)cv_jit_blobs_direction_free,
		sizeof(t_cv_jit_blobs_direction),0L); 

	//add mop
	mop = jit_object_new(_jit_sym_jit_mop,1,1);  //Object has one input and one output

   	jit_mop_single_type(mop,_jit_sym_float32);   //Set input type and planecount
   	jit_mop_single_planecount(mop,17);  
   	jit_mop_output_nolink(mop,1); //Turn off output linking so that output matrix does not adapt to input
   	
   	output = jit_object_method(mop,_jit_sym_getoutput,1); //Get a pointer to the output matrix
   	jit_attr_setlong(output,_jit_sym_minplanecount,1);
  	jit_attr_setlong(output,_jit_sym_maxplanecount,1);
  	jit_attr_setlong(output,_jit_sym_mindim,1);
  	jit_attr_setlong(output,_jit_sym_maxdim,1);
  	jit_attr_setsym(output,_jit_sym_types,_jit_sym_float32);
   	   	
	jit_class_addadornment(_cv_jit_blobs_direction_class,mop);
	
	
	//add methods
	jit_class_addmethod(_cv_jit_blobs_direction_class, (method)cv_jit_blobs_direction_matrix_calc, 		"matrix_calc", 		A_CANT, 0L);	

	//add attributes	
	attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;
	attr = jit_object_new(_jit_sym_jit_attr_offset,"mode",_jit_sym_long,attrflags,
		(method)0L,(method)0L,calcoffset(t_cv_jit_blobs_direction,mode));
	jit_attr_addfilterset_clip(attr,0,1,TRUE,TRUE);	//clip to 0-1
	jit_class_addattr(_cv_jit_blobs_direction_class,attr);
	
	attr = jit_object_new(_jit_sym_jit_attr_offset,"flip",_jit_sym_long,attrflags,
		(method)0L,(method)0L,calcoffset(t_cv_jit_blobs_direction,flip));
	jit_attr_addfilterset_clip(attr,0,1,TRUE,TRUE);	//clip to 0-1
	jit_class_addattr(_cv_jit_blobs_direction_class,attr);
		
	jit_class_register(_cv_jit_blobs_direction_class);

	return JIT_ERR_NONE;
}
コード例 #10
0
ファイル: max.jit.unpack.c プロジェクト: Cycling74/max5-sdk
void max_jit_unpack_jit_matrix(t_max_jit_unpack *x, t_symbol *s, long argc, t_atom *argv)
{
	long i;
	long jump[JIT_MATRIX_MAX_PLANECOUNT];
	void *o, *p;

	o = max_jit_obex_jitob_get(x);
	jit_attr_getlong_array(o, gensym("jump"), JIT_MATRIX_MAX_PLANECOUNT, jump);
	
	for(i=0; i < x->outlets; i++) {
		p=max_jit_mop_getoutput(x,i+1);
		jit_attr_setlong(p,gensym("minplanecount"),jump[i]);
		jit_attr_setlong(p,gensym("maxplanecount"),jump[i]);
	}
	
	max_jit_mop_jit_matrix(x,s,argc,argv);
}
コード例 #11
0
ファイル: jit.gl.hap.c プロジェクト: HsienYu/jit.gl.hap
t_jit_gl_hap *jit_gl_hap_new(t_symbol * dest_name)
{
	t_jit_gl_hap *x;
	
	if (x = (t_jit_gl_hap *)jit_object_alloc(_jit_gl_hap_class)) {
		jit_ob3d_new(x, dest_name);

		jit_gl_hap_new_native(x);
		x->has_video = 0;
		x->file = _jit_sym_nothing;
		x->texoutput = jit_object_new(gensym("jit_gl_texture"), dest_name);
		jit_attr_setsym(x->texoutput,gensym("defaultimage"),gensym("black"));
		jit_attr_setsym(x->texoutput,_jit_sym_name,jit_symbol_unique());
		jit_attr_setlong(x->texoutput, gensym("flip"), 0);
		
		x->hapglsl = jit_object_new(gensym("jit_gl_shader"), dest_name);
		
		x->buffer = NULL;
		x->hap_format = JIT_GL_HAP_PF_NONE;
		x->useshader = 0;
		x->validframe = 0;
		x->movieloaded = 0;
		x->deletetex = 0;
		x->texture = 0;
		x->dim[0] = x->dim[1] = 0;
		x->backingWidth = x->backingHeight = 0;
		x->roundedWidth = x->roundedHeight = 0;
		x->internalFormat = x->newInternalFormat = 0;
		x->newDataLength = x->rowLength = 0;
		x->target = 0;
		x->fboid = 0;
		
		x->direction = 1;
		x->suppress_loopnotify=0;
		x->userloop = 0;
		x->prevtime = 0;
		x->flipped = 0;
		
		x->adapt = 1;
		x->fps = 0;
		x->duration = 0;
		x->timescale = 0;
		x->framecount = 0;
		x->loop = JIT_GL_HAP_LOOP_ON;
		x->loopflags = 0;
		x->autostart = 1;
		x->rate = 1;
		x->vol = 1;
		x->rate_preserves_pitch = 1;
		x->looppoints[0] = x->looppoints[1] = -1;
		x->loopreport = 0;
		x->framereport = 0;
	}
	else {
		x = NULL;
	}	
	return x;
}
コード例 #12
0
void *max_jit_coerce_new(t_symbol *s, long argc, t_atom *argv)
{
	t_max_jit_coerce *x;
	void *o,*m,*mop,*p;
	t_jit_matrix_info info;
	long attrstart;
	t_atom_long planecount=4;
	t_symbol *type=_jit_sym_char;

	if (x=(t_max_jit_coerce *)max_jit_obex_new(max_jit_coerce_class,gensym("jit_coerce"))) {
		if (o=jit_object_new(gensym("jit_coerce"))) {
			max_jit_obex_jitob_set(x,o);
			max_jit_obex_dumpout_set(x,outlet_new(x,NULL));
			max_jit_mop_setup(x);
			max_jit_mop_inputs(x);
			max_jit_mop_outputs(x);
			mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop);
			jit_attr_setlong(mop,gensym("adapt"),0);
			jit_attr_setlong(mop,gensym("caninplace"),0);
			jit_attr_setlong(mop,gensym("outputmode"),1);
			//make the output matrix a data reference w/NULL data pointer
			attrstart = max_jit_attr_args_offset(argc,argv);
			if (attrstart&&argv) {
				jit_atom_arg_getlong(&planecount, 0, attrstart, argv);
				jit_atom_arg_getsym(&type, 1, attrstart, argv);
				jit_attr_setlong(o,_jit_sym_planecount,planecount);
				jit_attr_setsym(o,_jit_sym_type,type);
			}
			m = max_jit_mop_getoutput(x,1);
			jit_object_method(m,_jit_sym_getinfo,&info);
			jit_object_method(m,gensym("freedata"));
			info.flags = JIT_MATRIX_DATA_REFERENCE;
			info.size = 0;
			p = NULL;
			jit_object_method(m,_jit_sym_setinfo_ex,&info);
			jit_object_method(m,_jit_sym_data,p);
			max_jit_attr_args(x,argc,argv);
		} else {
			jit_object_error((t_object *)x,"jit.coerce: could not allocate object");
			freeobject((t_object *) x);
			x = NULL;
		}
	}
	return (x);
}
コード例 #13
0
t_jit_err jit_gl_videoplane_rect_tex(t_jit_gl_videoplane *x, void *attr, long argc, t_atom *argv)
{
	long c=jit_atom_getlong(argv);
	
	x->rect_tex = c;
	if (x->texture)
		jit_attr_setlong(x->texture,ps_rectangle,c);
	return JIT_ERR_NONE;
}
コード例 #14
0
ファイル: jit.gl.lua.cpp プロジェクト: kidaa/Synthesis
t_jit_err jit_gl_lua_setfile(t_jit_gl_lua *x, void *attr, long argc, t_atom *argv)
{
	if(argc && argv) {
		x->file = jit_atom_getsym(argv);
		lua_doread(x, x->file, 0, NULL);
		jit_attr_setlong(x, gensym("autowatch"), x->autowatch);
		jit_gl_lua_load_script(x);
	}
	
	return JIT_ERR_NONE;
}
コード例 #15
0
t_jit_err cv_jit_blobs_centroids_init(void) 
{
	t_jit_object *mop,*output;
	t_symbol *atsym;
	
	atsym = gensym("jit_attr_offset");
	
	_cv_jit_blobs_centroids_class = jit_class_new("cv_jit_blobs_centroids",(method)cv_jit_blobs_centroids_new,(method)cv_jit_blobs_centroids_free,
		sizeof(t_cv_jit_blobs_centroids),0L); 

	//add mop
	mop = jit_object_new(_jit_sym_jit_mop,1,1);  //Object has one input and one output
	output = jit_object_method(mop,_jit_sym_getoutput,1); //Get a pointer to the output matrix

   	jit_mop_single_type(mop,_jit_sym_char);   //Set input type and planecount
   	jit_mop_single_planecount(mop,1);  
   	
   	jit_mop_output_nolink(mop,1); //Turn off output linking so that output matrix does not adapt to input
   	
   	jit_attr_setlong(output,_jit_sym_minplanecount,3); //Output has 3 planes: centroid coordinates + mass
  	jit_attr_setlong(output,_jit_sym_maxplanecount,3);
  	jit_attr_setlong(output,_jit_sym_mindim,1);
  	jit_attr_setlong(output,_jit_sym_maxdim,1);
  	jit_attr_setsym(output,_jit_sym_types,_jit_sym_float32);
   	   	
	jit_class_addadornment(_cv_jit_blobs_centroids_class,mop);
	
	
	//add methods
	jit_class_addmethod(_cv_jit_blobs_centroids_class, (method)cv_jit_blobs_centroids_matrix_calc, 		"matrix_calc", 		A_CANT, 0L);	

	//add attributes	
	
	/*No attributes for this object*/
		
	jit_class_register(_cv_jit_blobs_centroids_class);

	return JIT_ERR_NONE;
}
コード例 #16
0
t_jit_err jit_rgb2luma_init(void)
{
	long attrflags=0;
	t_jit_object *attr, *mop, *o;

	_jit_rgb2luma_class = jit_class_new("jit_rgb2luma",(method)jit_rgb2luma_new,(method)jit_rgb2luma_free,
										sizeof(t_jit_rgb2luma),0L);

	//add mop
	mop = jit_object_new(_jit_sym_jit_mop,1,1); //#inputs,#outputs
	jit_mop_single_planecount(mop, 1);
	jit_mop_single_type(mop, _jit_sym_char);
	o=jit_object_method(mop,_jit_sym_getoutput,1);
	jit_attr_setlong(o,_jit_sym_planelink,0);
	jit_class_addadornment(_jit_rgb2luma_class,mop);

	//add methods
	jit_class_addmethod(_jit_rgb2luma_class, (method)jit_rgb2luma_matrix_calc, 		"matrix_calc", 		A_CANT, 0L);

	//add attributes
	attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;
	attr = jit_object_new(_jit_sym_jit_attr_offset,"ascale",_jit_sym_float64,attrflags,
						  (method)0L,(method)0L,calcoffset(t_jit_rgb2luma,ascale));
	jit_class_addattr(_jit_rgb2luma_class,attr);
	object_addattr_parse(attr,"label",_jit_sym_symbol,0,"\"Alpha Scale\"");
	
	attr = jit_object_new(_jit_sym_jit_attr_offset,"rscale",_jit_sym_float64,attrflags,
						  (method)0L,(method)0L,calcoffset(t_jit_rgb2luma,rscale));
	jit_class_addattr(_jit_rgb2luma_class,attr);
	object_addattr_parse(attr,"label",_jit_sym_symbol,0,"\"Red Scale\"");
	
	attr = jit_object_new(_jit_sym_jit_attr_offset,"gscale",_jit_sym_float64,attrflags,
						  (method)0L,(method)0L,calcoffset(t_jit_rgb2luma,gscale));
	jit_class_addattr(_jit_rgb2luma_class,attr);
	object_addattr_parse(attr,"label",_jit_sym_symbol,0,"\"Green Scale\"");
	
	attr = jit_object_new(_jit_sym_jit_attr_offset,"bscale",_jit_sym_float64,attrflags,
						  (method)0L,(method)0L,calcoffset(t_jit_rgb2luma,bscale));
	jit_class_addattr(_jit_rgb2luma_class,attr);
	object_addattr_parse(attr,"label",_jit_sym_symbol,0,"\"Blue Scale\"");

	jit_class_register(_jit_rgb2luma_class);

	return JIT_ERR_NONE;
}
コード例 #17
0
t_jit_err xray_jit_cellcoords_init(void)
{
	long attrflags=0;
	t_jit_object *attr;
	t_jit_object *mop, *o;

	_xray_jit_cellcoords_class = jit_class_new("xray_jit_cellcoords",(method)xray_jit_cellcoords_new,(method)xray_jit_cellcoords_free,
		sizeof(t_xray_jit_cellcoords),0L);

	//add mop
	mop = jit_object_new(_jit_sym_jit_mop,1,1);
	o = jit_object_method(mop,_jit_sym_getoutput,1);
	jit_attr_setlong(o,_jit_sym_dimlink,0);

	jit_class_addadornment(_xray_jit_cellcoords_class,mop);

	//add methods
	jit_class_addmethod(_xray_jit_cellcoords_class, (method)xray_jit_cellcoords_matrix_calc, "matrix_calc", A_CANT, 0L);

	//add attributes
	attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;

	//plane
	attr = jit_object_new(_jit_sym_jit_attr_offset,"plane",_jit_sym_char,attrflags,
		(method)0L,(method)0L,calcoffset(t_xray_jit_cellcoords,plane));
	jit_class_addattr(_xray_jit_cellcoords_class,attr);

	//out_mode
	attr = jit_object_new(_jit_sym_jit_attr_offset,"out_mode",_jit_sym_char,attrflags,
		(method)0L,(method)0L,calcoffset(t_xray_jit_cellcoords,out_mode));
	jit_class_addattr(_xray_jit_cellcoords_class,attr);

	jit_class_register(_xray_jit_cellcoords_class);

	return JIT_ERR_NONE;
}
コード例 #18
0
ファイル: jit.charmap.c プロジェクト: CICM/max6-sdk
t_jit_err jit_charmap_init(void) 
{	
	t_atom a;
	void *o,*mop;
	
	_jit_charmap_class = jit_class_new("jit_charmap",(method)jit_charmap_new,(method)jit_charmap_free,
		sizeof(t_jit_charmap),0L);
	
	//add mop
	mop = jit_object_new(_jit_sym_jit_mop,2,1);
	jit_mop_single_type(mop,_jit_sym_char);	
	o = jit_object_method(mop,_jit_sym_getinput,2);
	jit_attr_setlong(o,_jit_sym_dimlink,0);
	jit_atom_setlong(&a,256);
	jit_object_method(o,_jit_sym_mindim,1,&a);
	jit_object_method(o,_jit_sym_maxdim,1,&a);
	jit_class_addadornment(_jit_charmap_class,mop);
	//add methods
	jit_class_addmethod(_jit_charmap_class, (method)jit_charmap_matrix_calc, 		"matrix_calc", 		A_CANT, 0L);

	jit_class_register(_jit_charmap_class);

	return JIT_ERR_NONE;
}
コード例 #19
0
t_jit_err jit_freenect_grab_init(void)
{
	long attrflags=0;
	t_jit_object *attr;
	t_jit_object *mop,*output;
	t_atom a[4];
	
	global_id=0;
	x_systhread = NULL;
	x_systhread_cancel=FALSE;
	freenect_active=FALSE;
	open_device_count=0;
	
	s_rgb = gensym("rgb");
	s_RGB = gensym("RGB");
	s_ir = gensym("ir");
	s_IR = gensym("IR");
	
	_jit_freenect_grab_class = jit_class_new("jit_freenect_grab",(method)jit_freenect_grab_new,
											 (method)jit_freenect_grab_free, sizeof(t_jit_freenect_grab),0L);
  	
	//add mop
	mop = (t_jit_object *)jit_object_new(_jit_sym_jit_mop,0,2); //0 inputs, 2 outputs
	
	//Prepare depth image, all values are hard-coded, may need to be queried for safety?
	output = jit_object_method(mop,_jit_sym_getoutput,1);
		
	jit_atom_setsym(a,_jit_sym_float32); //default
	jit_atom_setsym(a+1,_jit_sym_long);
	jit_atom_setsym(a+2,_jit_sym_float64);
	jit_object_method(output,_jit_sym_types,3,a);
	
	jit_atom_setlong(&a[0], DEPTH_WIDTH);
	jit_atom_setlong(&a[1], DEPTH_HEIGHT);
	
	jit_object_method(output, _jit_sym_mindim, 2, a);  //Two dimensions, sizes in atom array
	jit_object_method(output, _jit_sym_maxdim, 2, a);
	
	//Prepare RGB image
	output = jit_object_method(mop,_jit_sym_getoutput,2);
	
	jit_atom_setsym(a,_jit_sym_char); //default
	jit_object_method(output,_jit_sym_types,1,a);
	
	jit_attr_setlong(output,_jit_sym_minplanecount,4);
	jit_attr_setlong(output,_jit_sym_maxplanecount,4);
	
	jit_atom_setlong(&a[0], RGB_WIDTH);
	jit_atom_setlong(&a[1], RGB_HEIGHT);
	
	jit_object_method(output, _jit_sym_mindim, 2, a);
	jit_object_method(output, _jit_sym_maxdim, 2, a);
	
	jit_class_addadornment(_jit_freenect_grab_class,mop);
	
	//add methods
	jit_class_addmethod(_jit_freenect_grab_class, (method)jit_freenect_grab_open, "open", A_GIMME, 0L);
	jit_class_addmethod(_jit_freenect_grab_class, (method)jit_freenect_grab_close, "close", A_GIMME, 0L);
	
	jit_class_addmethod(_jit_freenect_grab_class, (method)jit_freenect_grab_matrix_calc, "matrix_calc", A_CANT, 0L);
	
	//add attributes	
	attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"unique",_jit_sym_char,
										  attrflags,(method)NULL,(method)NULL,calcoffset(t_jit_freenect_grab,unique));
	jit_attr_addfilterset_clip(attr,0,1,TRUE,TRUE);
	jit_class_addattr(_jit_freenect_grab_class,attr);
	
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"threshold",_jit_sym_float32,
										  attrflags,(method)NULL,(method)NULL,calcoffset(t_jit_freenect_grab,threshold));
	jit_attr_addfilterset_clip(attr,0,0,TRUE,FALSE);
	jit_class_addattr(_jit_freenect_grab_class,attr);
	
	//attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"cleardepth",_jit_sym_char,
										  attrflags,(method)NULL,(method)NULL,calcoffset(t_jit_freenect_grab,clear_depth));
	jit_attr_addfilterset_clip(attr,0,1,TRUE,TRUE);
	jit_class_addattr(_jit_freenect_grab_class,attr);
	
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"mode",_jit_sym_char,
										  attrflags,(method)NULL,(method)jit_freenect_grab_set_mode,calcoffset(t_jit_freenect_grab,mode));
	jit_class_addattr(_jit_freenect_grab_class,attr);
	
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"format",_jit_sym_atom,
										  attrflags,(method)NULL,(method)jit_freenect_grab_set_format,calcoffset(t_jit_freenect_grab,format));
	jit_class_addattr(_jit_freenect_grab_class,attr);
	
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"tilt",_jit_sym_long,
										  attrflags,(method)jit_freenect_grab_get_tilt,(method)jit_freenect_grab_set_tilt,
										  calcoffset(t_jit_freenect_grab,tilt));
	jit_class_addattr(_jit_freenect_grab_class,attr);
	
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"aligndepth",_jit_sym_char,
										  attrflags,(method)NULL,(method)NULL,calcoffset(t_jit_freenect_grab,aligndepth));
	jit_attr_addfilterset_clip(attr,0,1,TRUE,TRUE);
	jit_class_addattr(_jit_freenect_grab_class,attr);
	
	attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_OPAQUE;
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"index",_jit_sym_long,
										  attrflags,(method)NULL,(method)NULL,calcoffset(t_jit_freenect_grab,index));
	jit_class_addattr(_jit_freenect_grab_class,attr);
	
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"ndevices",_jit_sym_long,
										  attrflags,(method)jit_freenect_grab_get_ndevices,(method)NULL,calcoffset(t_jit_freenect_grab,ndevices));
	jit_class_addattr(_jit_freenect_grab_class,attr);
	
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset_array, "accel", _jit_sym_float64, 3, 
										  attrflags, (method)jit_freenect_grab_get_accel,(method)NULL, 
										  calcoffset(t_jit_freenect_grab, accelcount),calcoffset(t_jit_freenect_grab,mks_accel));
	jit_class_addattr(_jit_freenect_grab_class,attr);

	
	attrflags = JIT_ATTR_GET_OPAQUE_USER | JIT_ATTR_SET_OPAQUE_USER;
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,"has_frames",_jit_sym_char,
										  attrflags,(method)NULL,(method)NULL,calcoffset(t_jit_freenect_grab,has_frames));
	jit_class_addattr(_jit_freenect_grab_class,attr);
	
	jit_class_register(_jit_freenect_grab_class);
	
	post("jit.freenect.grab: Copyright 2010, Jean-Marc Pelletier, Nenad Popov and Andrew Roth. Built on %s",DEBUG_TIMESTAMP);
	return JIT_ERR_NONE;
}
コード例 #20
0
ファイル: jit.gl.hap.c プロジェクト: HsienYu/jit.gl.hap
void jit_gl_hap_draw_frame(void *jitob, CVImageBufferRef frame)
{
	t_jit_gl_hap * x = (t_jit_gl_hap*)jitob;
	CFTypeID imageType = CFGetTypeID(frame);
	OSType newPixelFormat;

	if(x->validframe)
		return;
		
	if (imageType == CVPixelBufferGetTypeID()) {
        
        // Update the texture
        CVBufferRetain(frame);
		
		if(x->buffer) {
			CVPixelBufferUnlockBaseAddress(x->buffer, kCVPixelBufferLock_ReadOnly);
			CVBufferRelease(x->buffer);
		}
		
		x->buffer = frame;
		CVPixelBufferLockBaseAddress(x->buffer, kCVPixelBufferLock_ReadOnly);
		
		x->dim[0] = CVPixelBufferGetWidth(x->buffer);
		x->dim[1] = CVPixelBufferGetHeight(x->buffer);

		newPixelFormat = CVPixelBufferGetPixelFormatType(x->buffer);

		if(x->buffer && x->hap_format==JIT_GL_HAP_PF_HAP) {
			size_t extraRight, extraBottom;
			unsigned int bitsPerPixel;
			size_t bytesPerRow;
			size_t actualBufferSize;

			CVPixelBufferGetExtendedPixels(x->buffer, NULL, &extraRight, NULL, &extraBottom);
			x->roundedWidth = x->dim[0] + extraRight;
			x->roundedHeight = x->dim[1] + extraBottom;
			if (x->roundedWidth % 4 != 0 || x->roundedHeight % 4 != 0) {
				x->validframe = 0;
				return;
			}			

			switch (newPixelFormat) {
				case kHapPixelFormatTypeRGB_DXT1:
					x->newInternalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
					bitsPerPixel = 4;
					break;
				case kHapPixelFormatTypeRGBA_DXT5:
				case kHapPixelFormatTypeYCoCg_DXT5:
					x->newInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
					bitsPerPixel = 8;
					break;
				default:
					// we don't support non-DXT pixel buffers
					x->validframe = 0;
					return;
					break;
			}
			x->useshader = (newPixelFormat == kHapPixelFormatTypeYCoCg_DXT5);
			
			bytesPerRow = (x->roundedWidth * bitsPerPixel) / 8;
			x->newDataLength = bytesPerRow * x->roundedHeight; // usually not the full length of the buffer
			actualBufferSize = CVPixelBufferGetDataSize(x->buffer);
			
			// Check the buffer is as large as we expect it to be
			if (x->newDataLength > actualBufferSize) {
				x->validframe = 0;
				return;
			}

			// If we got this far we're good to go
			x->validframe = 1;
			x->target = GL_TEXTURE_2D;
			if(!x->flipped) {
				jit_attr_setlong(x->texoutput, gensym("flip"), 1);
				x->flipped = 1;
			}
			//x->drawhap = 1;
		}
		else if(x->buffer) {// && x->hap_format==JIT_GL_HAP_PF_HAP) {
			if( newPixelFormat == k24RGBPixelFormat )
				x->newInternalFormat = GL_RGB8;
			else if( newPixelFormat == k32BGRAPixelFormat )
				x->newInternalFormat = GL_RGBA8;
			else {
				x->validframe = 0;
				return;
			}

			x->roundedWidth = x->dim[0];
			x->roundedHeight = x->dim[1];
			x->newDataLength = CVPixelBufferGetDataSize(x->buffer);
			x->rowLength = CVPixelBufferGetBytesPerRow( x->buffer ) / (x->hap_format==JIT_GL_HAP_PF_RGB ? 3 : 4);
			x->target = GL_TEXTURE_RECTANGLE_EXT;
			
			if(!x->flipped) {
				jit_attr_setlong(x->texoutput, gensym("flip"), 1);
				x->flipped = 1;
			}
			x->validframe = 1;
		}
    }
	else {
#ifdef MAC_VERSION
		CGSize imageSize = CVImageBufferGetEncodedSize(frame);
		bool flipped = CVOpenGLTextureIsFlipped(frame);
		x->texture = CVOpenGLTextureGetName(frame);
		x->useshader = 0;
		x->dim[0] = (t_atom_long)imageSize.width;
		x->dim[1] = (t_atom_long)imageSize.height;
		x->validframe = 1;
		x->target = GL_TEXTURE_RECTANGLE_ARB;
		if(x->flipped!=flipped) {
			jit_attr_setlong(x->texoutput, gensym("flip"), flipped);
			x->flipped = flipped;			
		}
#endif
	}
}
コード例 #21
0
ファイル: cv.jit.features.c プロジェクト: fourks/cv.jit
t_jit_err cv_jit_features_init(void) 
{
	long attrflags=0;
	t_jit_object *attr,*mop,*output;
	t_symbol *atsym;
	
	atsym = gensym("jit_attr_offset");
	
	_cv_jit_features_class = jit_class_new("cv_jit_features",(method)cv_jit_features_new,(method)cv_jit_features_free,
		sizeof(t_cv_jit_features),A_CANT,0L); //A_CANT = untyped

	//add mop
	mop = (t_jit_object *)jit_object_new(_jit_sym_jit_mop,1,1);  //Object has one input and one output
	output = (t_jit_object *)jit_object_method(mop,_jit_sym_getoutput,1); //Get a pointer to the output matrix

   	jit_mop_single_type(mop,_jit_sym_char);   //Set input type and planecount
   	jit_mop_single_planecount(mop,1);  
   	
   	jit_mop_output_nolink(mop,1); //Turn off output linking so that output matrix does not adapt to input
   	
   	jit_attr_setlong(output,_jit_sym_minplanecount,2);  //Two planes, holding the feature's coordinates 
  	jit_attr_setlong(output,_jit_sym_maxplanecount,2);
  	jit_attr_setlong(output,_jit_sym_mindim,1); //Only one dimension
  	jit_attr_setlong(output,_jit_sym_maxdim,1);
  	jit_attr_setsym(output,_jit_sym_types,_jit_sym_float32); //Coordinates are returned with sub-pixel accuracy
   	   	
	jit_class_addadornment(_cv_jit_features_class,mop);
	
	
	//add methods
	jit_class_addmethod(_cv_jit_features_class, (method)cv_jit_features_matrix_calc, 		"matrix_calc", 		A_CANT, 0L);	

	//add attributes	
	attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;
	
	//threshold
	attr = (t_jit_object *)jit_object_new(	_jit_sym_jit_attr_offset,"threshold",_jit_sym_float64,attrflags,(method)0L,(method)0L,calcoffset(t_cv_jit_features,threshold));			
	jit_attr_addfilterset_clip(attr,0.001,1,TRUE,TRUE);	//clip to 0.001-1
	jit_class_addattr(_cv_jit_features_class, attr);
	
	//minimum distance
	attr = (t_jit_object *)jit_object_new(	_jit_sym_jit_attr_offset,"distance",_jit_sym_float64,attrflags,(method)0L,(method)0L,calcoffset(t_cv_jit_features,distance));			
	jit_attr_addfilterset_clip(attr,0,0,TRUE,FALSE);	//clip to 0
	jit_class_addattr(_cv_jit_features_class, attr);
	
	//roi
	attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset_array, "roi", _jit_sym_long, 4, attrflags, (method)0L, (method)0L, calcoffset(t_cv_jit_features, roicount),calcoffset(t_cv_jit_features,roi));
	jit_class_addattr(_cv_jit_features_class, attr);
	
	attr = (t_jit_object *)jit_object_new(	_jit_sym_jit_attr_offset,"useroi",_jit_sym_char,attrflags,(method)0L,(method)0L,calcoffset(t_cv_jit_features,useroi));			
	jit_attr_addfilterset_clip(attr,0,1,TRUE,TRUE);	//clip to 0-1
	jit_class_addattr(_cv_jit_features_class, attr);
	
	//Precision
	attr = (t_jit_object *)jit_object_new(	_jit_sym_jit_attr_offset,"precision",_jit_sym_char,attrflags,(method)0L,(method)0L,calcoffset(t_cv_jit_features,precision));			
	jit_attr_addfilterset_clip(attr,0,1,TRUE,TRUE);	//clip to 0-1
	jit_class_addattr(_cv_jit_features_class, attr);
			
	jit_class_register(_cv_jit_features_class);

	return JIT_ERR_NONE;
}
コード例 #22
0
t_jit_err xray_jit_levelsetseg_init(void)
{
	long attrflags=0;
	t_jit_object *attr,*mop,*o;
	t_symbol *atsym;

	atsym = gensym("jit_attr_offset");

	_xray_jit_levelsetseg_class = jit_class_new("xray_jit_levelsetseg",(method)xray_jit_levelsetseg_new,(method)xray_jit_levelsetseg_free,
		sizeof(t_xray_jit_levelsetseg),0L);

	//add mop
	mop = jit_object_new(_jit_sym_jit_mop,1,2);
	o = jit_object_method(mop,_jit_sym_getoutput,1);
	jit_attr_setlong(o,_jit_sym_dimlink,0);
	jit_attr_setlong(o,_jit_sym_planelink,0);

	jit_class_addadornment(_xray_jit_levelsetseg_class,mop);

	//add methods
	jit_class_addmethod(_xray_jit_levelsetseg_class, (method)xray_jit_levelsetseg_matrix_calc, 		"matrix_calc", 		A_CANT, 0L);

	//add attributes
	attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;

	//evolve
	attr = (t_jit_object*)jit_object_new(_jit_sym_jit_attr_offset,"evolve",_jit_sym_char,attrflags,
		(method)0L,(method)0L,calcoffset(t_xray_jit_levelsetseg, evolve));
	jit_class_addattr(_xray_jit_levelsetseg_class,attr);

	//smooth
	attr = (t_jit_object*)jit_object_new(_jit_sym_jit_attr_offset,"smooth",_jit_sym_char,attrflags,
		(method)0L,(method)0L,calcoffset(t_xray_jit_levelsetseg, smooth));
	jit_class_addattr(_xray_jit_levelsetseg_class,attr);

	//radius
	attr = (t_jit_object*)jit_object_new(_jit_sym_jit_attr_offset,"radius",_jit_sym_long,attrflags,
		(method)0L,(method)0L,calcoffset(t_xray_jit_levelsetseg, radius));
	jit_class_addattr(_xray_jit_levelsetseg_class,attr);

	//point
	attr = (t_jit_object*)jit_object_new(_jit_sym_jit_attr_offset_array,"point",_jit_sym_long,6,attrflags,
		(method)0L,(method)xray_jit_levelsetseg_point,calcoffset(t_xray_jit_levelsetseg,pointcount),calcoffset(t_xray_jit_levelsetseg,point));
	jit_class_addattr(_xray_jit_levelsetseg_class,attr);

	//Na
	attr = (t_jit_object*)jit_object_new(_jit_sym_jit_attr_offset,"Na",_jit_sym_long,attrflags,
		(method)0L,(method)0L,calcoffset(t_xray_jit_levelsetseg,Na));
	jit_class_addattr(_xray_jit_levelsetseg_class,attr);

	//Ng
	attr = (t_jit_object*)jit_object_new(_jit_sym_jit_attr_offset,"Ng",_jit_sym_long,attrflags,
		(method)0L,(method)xray_jit_levelsetseg_Ng,calcoffset(t_xray_jit_levelsetseg,Ng));
	jit_class_addattr(_xray_jit_levelsetseg_class,attr);

	//Ns
	attr = (t_jit_object*)jit_object_new(_jit_sym_jit_attr_offset,"Ns",_jit_sym_long,attrflags,
		(method)0L,(method)0L,calcoffset(t_xray_jit_levelsetseg,Ns));
	jit_class_addattr(_xray_jit_levelsetseg_class,attr);

	//cycles
	attr = (t_jit_object*)jit_object_new(_jit_sym_jit_attr_offset,"cycles",_jit_sym_long,attrflags,
		(method)0L,(method)0L,calcoffset(t_xray_jit_levelsetseg,cycles));
	jit_class_addattr(_xray_jit_levelsetseg_class,attr);

	jit_class_register(_xray_jit_levelsetseg_class);

	return JIT_ERR_NONE;
}
コード例 #23
0
t_jit_err jit_pcl_concavehull_init(void)
{
    long			attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;
    t_jit_object	*attr;
    t_jit_object	*mop;
    t_atom a[1];
    
    s_jit_pcl_concavehull_class = jit_class_new("jit_pcl_concavehull", (method)jit_pcl_concavehull_new, (method)jit_pcl_concavehull_free, sizeof(t_jit_pcl_concavehull), 0);
    
    // add matrix operator (mop)
    // args are  num inputs and num outputs
    mop = (t_jit_object *)jit_object_new(_jit_sym_jit_mop, 1, 1);
    jit_mop_input_nolink(mop,1);
    
    
    attr = (t_jit_object *)jit_object_method(mop, _jit_sym_getinput, 1);
    jit_attr_setlong(attr,_jit_sym_dimlink,0);
    jit_attr_setlong(attr,_jit_sym_typelink,0);
    jit_attr_setlong(attr,_jit_sym_planelink,0);
    jit_object_method(attr,_jit_sym_ioproc,jit_mop_ioproc_copy_adapt);
    jit_atom_setsym(a, _jit_sym_float32);
    jit_object_method(attr, _jit_sym_types,1, a);
    
    attr = (t_jit_object *)jit_object_method(mop, _jit_sym_getoutput, 1);
    jit_attr_setlong(attr, _jit_sym_dimlink,0);
    
    jit_class_addadornment(s_jit_pcl_concavehull_class, mop);
    
    
    
    // add method(s)
    jit_class_addmethod(s_jit_pcl_concavehull_class, (method)jit_pcl_concavehull_matrix_calc, "matrix_calc", A_CANT, 0);
    
    // add attribute(s)
    attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,
                                          "leafsize",
                                          _jit_sym_float64,
                                          attrflags,
                                          (method)NULL, (method)NULL,
                                          calcoffset(t_jit_pcl_concavehull, leafsize));
    
    jit_class_addattr(s_jit_pcl_concavehull_class, attr);
    
    attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,
                                          "npoints",
                                          _jit_sym_long,
                                          attrflags,
                                          (method)NULL, (method)NULL,
                                          calcoffset(t_jit_pcl_concavehull, npoints));
    jit_attr_addfilterget_clip(attr, 1, 10000, true, false);
    jit_class_addattr(s_jit_pcl_concavehull_class, attr);

    attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,
                                          "stdthresh",
                                          _jit_sym_float64,
                                          attrflags,
                                          (method)NULL, (method)NULL,
                                          calcoffset(t_jit_pcl_concavehull, stdthresh));
    
    jit_class_addattr(s_jit_pcl_concavehull_class, attr);
    
    attr = (t_jit_object *)jit_object_new(_jit_sym_jit_attr_offset,
                                          "alpha",
                                          _jit_sym_float64,
                                          attrflags,
                                          (method)NULL, (method)NULL,
                                          calcoffset(t_jit_pcl_concavehull, alpha));
    
    jit_class_addattr(s_jit_pcl_concavehull_class, attr);
    
    // finalize class
    jit_class_register(s_jit_pcl_concavehull_class);
    return JIT_ERR_NONE;
}
コード例 #24
0
ファイル: jit.boids2d.c プロジェクト: diablodale/boids_max
t_jit_err jit_boids2d_init(void) 
{
	long attrflags=0;
	t_jit_object *attr,*mop,*o;
	t_symbol *atsym;
	
	atsym = gensym("jit_attr_offset");
	
	_jit_boids2d_class = jit_class_new("jit_boids2d",(method)jit_boids2d_new,(method)jit_boids2d_free,
		sizeof(t_jit_boids2d),0L); 

	//add mop
	mop = jit_object_new(_jit_sym_jit_mop,0,1);
	o = jit_object_method(mop,_jit_sym_getoutput,1);
	jit_attr_setlong(o,_jit_sym_dimlink,0);
	
	jit_class_addadornment(_jit_boids2d_class,mop);
	//add methods
	jit_class_addmethod(_jit_boids2d_class, (method)jit_boids2d_matrix_calc, 		"matrix_calc", 		A_CANT, 0L);
	jit_class_addmethod(_jit_boids2d_class, (method)Flock_reset, 					"init", 			A_USURP_LOW, 0L);
	jit_class_addmethod(_jit_boids2d_class, (method)Flock_resetBoids, 				"reset", 			A_USURP_LOW, 0L);

	//add attributes	
	attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;
	
	//mode
	attr = jit_object_new(atsym,"mode",_jit_sym_char,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,mode));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//number
	attr = jit_object_new(atsym,"number",_jit_sym_long,attrflags,
		(method)0L,(method)jit_boids2d_number,calcoffset(t_jit_boids2d,number));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//neighbors
	attr = jit_object_new(atsym,"neighbors",_jit_sym_long,attrflags,
		(method)0L,(method)jit_boids2d_neighbors,calcoffset(t_jit_boids2d,neighbors));
	jit_class_addattr(_jit_boids2d_class,attr);

	//flyrect
	attr = jit_object_new(_jit_sym_jit_attr_offset_array,"flyrect",_jit_sym_float64,4,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,flyRectCount),calcoffset(t_jit_boids2d,flyrect));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//minspeed
	attr = jit_object_new(atsym,"minspeed",_jit_sym_float64,attrflags,
		(method)0L,(method)jit_boids2d_minspeed,calcoffset(t_jit_boids2d,minspeed));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//maxspeed
	attr = jit_object_new(atsym,"maxspeed",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,maxspeed));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//center
	attr = jit_object_new(atsym,"center",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,center));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//attract
	attr = jit_object_new(atsym,"attract",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,attract));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//match
	attr = jit_object_new(atsym,"match",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,match));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//avoid
	attr = jit_object_new(atsym,"avoid",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,avoid));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//repel
	attr = jit_object_new(atsym,"repel",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,repel));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//edgedist
	attr = jit_object_new(atsym,"edgedist",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,edgedist));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//speed
	attr = jit_object_new(atsym,"speed",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,speed));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//inertia
	attr = jit_object_new(atsym,"inertia",_jit_sym_float64,attrflags,
		(method)0L,(method)jit_boids2d_inertia,calcoffset(t_jit_boids2d,inertia));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//accel
	attr = jit_object_new(atsym,"accel",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,accel));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//prefdist
	attr = jit_object_new(atsym,"prefdist",_jit_sym_float64,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,prefdist));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//centerPt
	attr = jit_object_new(_jit_sym_jit_attr_offset_array,"centerPt",_jit_sym_float64,2,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,centerPtCount),calcoffset(t_jit_boids2d,centerPt));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	//attractpt.
	attr = jit_object_new(_jit_sym_jit_attr_offset_array,"attractpt",_jit_sym_float64,2,attrflags,
		(method)0L,(method)0L,calcoffset(t_jit_boids2d,attractPtCount),calcoffset(t_jit_boids2d,attractpt));
	jit_class_addattr(_jit_boids2d_class,attr);



	//set_pos.
	attr = jit_object_new(_jit_sym_jit_attr_offset_array,"set_pos",_jit_sym_float64,2,attrflags,
		(method)0L,(method)jit_boids2d_set_pos,calcoffset(t_jit_boids2d,set_pos));
	jit_class_addattr(_jit_boids2d_class,attr);
	//set_dir.
	attr = jit_object_new(_jit_sym_jit_attr_offset_array,"set_dir",_jit_sym_float64,2,attrflags,
		(method)0L,(method)jit_boids2d_set_dir,calcoffset(t_jit_boids2d,set_pos));
	jit_class_addattr(_jit_boids2d_class,attr);
	//set_speed
	attr = jit_object_new(atsym,"set_speed",_jit_sym_float64,attrflags,
		(method)0L,(method)jit_boids2d_set_speed,calcoffset(t_jit_boids2d,set_speed));
	jit_class_addattr(_jit_boids2d_class,attr);
	//set_speed
	attr = jit_object_new(atsym,"set_speedinv",_jit_sym_float64,attrflags,
		(method)0L,(method)jit_boids2d_set_speedinv,calcoffset(t_jit_boids2d,set_speedinv));
	jit_class_addattr(_jit_boids2d_class,attr);
	//number
	attr = jit_object_new(atsym,"set",_jit_sym_long,attrflags,
		(method)0L,(method)jit_boids2d_set,calcoffset(t_jit_boids2d,set));
	jit_class_addattr(_jit_boids2d_class,attr);
	
	
	
	jit_class_register(_jit_boids2d_class);

	return JIT_ERR_NONE;
}
コード例 #25
0
ファイル: cv.jit.calibration.cpp プロジェクト: fourks/cv.jit
t_jit_err cv_jit_calibration_init(void) 
{
	long			attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;
	t_jit_object	*attr, *o, *mop;
	
	_cv_jit_calibration_class = jit_class_new("cv_jit_calibration", (method)cv_jit_calibration_new, (method)cv_jit_calibration_free, sizeof(t_cv_jit_calibration), 0);
	
	// add matrix operator (mop)
	mop = (t_jit_object *)jit_object_new(_jit_sym_jit_mop,1,1); //#inputs,#outputs
	jit_mop_single_type(mop, _jit_sym_char);
	o=(t_jit_object *)jit_object_method(mop,_jit_sym_getoutput,1);
	jit_attr_setlong(o,_jit_sym_planelink,1);
	jit_class_addadornment(_cv_jit_calibration_class,mop);
	
	// add method(s)
	jit_class_addmethod(_cv_jit_calibration_class, (method)cv_jit_calibration_matrix_calc,		"matrix_calc",		A_CANT,		0);
	jit_class_addmethod(_cv_jit_calibration_class, (method)cv_jit_calibration_read,				"read",				A_GIMME,	0L);
	jit_class_addmethod(_cv_jit_calibration_class, (method)cv_jit_calibration_write,			"write",			A_GIMME,	0L);
	
	// add attribute(s)	
	attr = (t_jit_object *)	jit_object_new(_jit_sym_jit_attr_offset_array,
										   "pattern_size",
										   _jit_sym_long,
										   2,
										   attrflags,
										   (method)0L,
										   (method)0L,
										   calcoffset(t_cv_jit_calibration,array_size),
										   calcoffset(t_cv_jit_calibration,pattern_size));
	jit_class_addattr(_cv_jit_calibration_class,attr);

	attr = (t_jit_object *)	jit_object_new(_jit_sym_jit_attr_offset,
										   "calibration",
										   _jit_sym_long,
										   attrflags,
										   (method)0L,
										   (method)cv_jit_calibration_docalibration,
										   calcoffset(t_cv_jit_calibration,calibration));
	jit_class_addattr(_cv_jit_calibration_class,attr);
	
	attr = (t_jit_object *)	jit_object_new(_jit_sym_jit_attr_offset,
										   "views",
										   _jit_sym_long,
										   attrflags,
										   (method)0L,
										   (method)cv_jit_calibration_docalibration,
										   calcoffset(t_cv_jit_calibration,board_view_nb));
	jit_class_addattr(_cv_jit_calibration_class,attr);
	
	attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_OPAQUE; 
	
	attr = (t_jit_object *)	jit_object_new(_jit_sym_jit_attr_offset,
										   "success_count",
										   _jit_sym_long,
										   attrflags,
										   (method)0L,
										   (method)cv_jit_calibration_docalibration,
										   calcoffset(t_cv_jit_calibration,success_count));
	jit_class_addattr(_cv_jit_calibration_class,attr);
	
	
	
	// finalize class
	jit_class_register(_cv_jit_calibration_class);
	post("cv.jit.calibration by Antoine Villeret - build on the %s at %s.",__DATE__, __TIME__);
	
	return JIT_ERR_NONE;
}