コード例 #1
0
ファイル: max.jit.concat.c プロジェクト: CICM/max6-sdk
void *max_jit_concat_new(t_symbol *s, long argc, t_atom *argv)
{
	t_max_jit_concat *x;
	void *o;

	if (x=(t_max_jit_concat *)max_jit_obex_new(max_jit_concat_class,gensym("jit_concat"))) {
		if (o=jit_object_new(gensym("jit_concat"))) {
			max_jit_mop_setup_simple(x,o,argc,argv);			
			max_jit_attr_args(x,argc,argv);
		} else {
			jit_object_error((t_object *)x,"jit.concat: could not allocate object");
			freeobject((t_object *) x);
			x = NULL;
		}
	}
	return (x);
}
コード例 #2
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);
}
コード例 #3
0
void *max_jit_la_diagproduct_new(t_symbol *s, long argc, t_atom *argv)
{
	t_max_jit_la_diagproduct *x;
	void *o;

	if (x=(t_max_jit_la_diagproduct *)max_jit_obex_new(max_jit_la_diagproduct_class,gensym("jit_la_diagproduct"))) {
		if (o=jit_object_new(gensym("jit_la_diagproduct"))) {
			max_jit_mop_setup_simple(x,o,argc,argv);			
			//add additional non-matrix output
			x->valout 	= outlet_new(x,0L);	
			max_jit_attr_args(x,argc,argv);
		} else {
			jit_object_error((t_object *)x,"jit.la.diagproduct: could not allocate object");
			freeobject((t_object *) x);
			x = NULL;
		}
	}
	return (x);
}
コード例 #4
0
ファイル: max.jit.kinect2.c プロジェクト: josja/jit.kinect2
void *max_jit_kinect2_new(t_symbol *s, long argc, t_atom *argv)
{
	t_max_jit_kinect2	*x;
	void                *o;

	x = (t_max_jit_kinect2 *)max_jit_object_alloc(max_jit_kinect2_class, gensym("jit_kinect2"));
	if (x) {
		o = jit_object_new(gensym("jit_kinect2"));
		if (o) {
			max_jit_mop_setup_simple(x, o, argc, argv);
			max_jit_attr_args(x, argc, argv);
		}
		else {
			jit_object_error((t_object *)x, "jit.kinect2: could not allocate object");
			object_free((t_object *)x);
			x = NULL;
		}
	}
	return (x);
}
コード例 #5
0
void *MaxStencilNew(t_symbol *s, long argc, t_atom *argv)
{
	MaxStencilObjectPtr	self;
	void				*o;
	
	self = (MaxStencilObjectPtr)max_jit_obex_new(sMaxStencilClass, gensym("jcom_stencil"));
	if (self) {
		o = jit_object_new(gensym("jcom_stencil"));
		if (o) {
			max_jit_mop_setup_simple(self, o, argc, argv);			
			max_jit_attr_args(self, argc, argv);
		} 
		else {
			jit_object_error(SELF, (char*)"could not allocate object");
			object_free(SELF);
			self = NULL;
		}
	}
	return self;
}
コード例 #6
0
ファイル: max.jit.print.c プロジェクト: Cycling74/max5-sdk
void *max_jit_print_new(t_symbol *s, long argc, t_atom *argv)
{
	t_max_jit_print *x;
	void *o;

	if (x = (t_max_jit_print *)max_jit_obex_new(max_jit_print_class,gensym("jit_print"))) {
		max_jit_obex_dumpout_set(x,outlet_new(x,NULL));	
		x->matrixout = outlet_new(x,"jit_matrix");

		if (o = jit_object_new(gensym("jit_print"))) {
			max_jit_obex_jitob_set(x,o);
			max_jit_attr_args(x,argc,argv);
		}
		else {
			jit_object_error((t_object *)x,"jit.print: could not allocate object");
			freeobject(x);
			x=NULL;
		}
	}
	return (x);
}
コード例 #7
0
ファイル: max.cicm.jit.leap.cpp プロジェクト: CICM/CicmLeap
void *max_jit_leap_new(t_symbol *s, long argc, t_atom *argv)
{
	t_max_jit_leap *x;
	void *o;

	if ((x = (t_max_jit_leap *)max_jit_object_alloc(max_jit_leap_class,gensym("jit_leap"))))
	{
		if ((o = jit_object_new(gensym("jit_leap"))))
		{
			max_jit_mop_setup_simple(x,o,argc,argv);			
			max_jit_attr_args(x,argc,argv);
		}
		else
		{
			jit_object_error((t_object *)x, (char*)"jit.noise: could not allocate object");
			freeobject((t_object *) x);
			x = NULL;
		}
	}
	return (x);
}
コード例 #8
0
ファイル: max.jit.op.c プロジェクト: Cycling74/max5-sdk
void *max_jit_op_new(t_symbol *s, long argc, t_atom *argv)
{
	t_max_jit_op *x;
	void *o;
	long i;

	if (x=(t_max_jit_op *)max_jit_obex_new(max_jit_op_class,gensym("jit_op"))) {
		if (o=jit_object_new(gensym("jit_op"))) {
			max_jit_mop_setup_simple(x,o,argc,argv);			
			x->last = OP_LAST_MATRIX;
			x->valcount = 0;
			for (i=0;i<JIT_MATRIX_MAX_PLANECOUNT;i++) 
				jit_atom_setlong(&x->val[i],0);
			max_jit_attr_args(x,argc,argv);
		} else {
			jit_object_error((t_object *)x,"jit.op: could not allocate object");
			freeobject(x);
			x = NULL;
		}
	}
	return (x);
}
コード例 #9
0
void jit_gl_videoplane_jit_matrix(t_jit_gl_videoplane *x, t_symbol *s, int argc, t_atom *argv)
{
	t_symbol *name;
	void *m;
	t_jit_matrix_info info;
	long dim[2];
	
	if ((name=jit_atom_getsym(argv)) != _jit_sym_nothing) {
		m = jit_object_findregistered(name);
		if (!m) {
			jit_object_error((t_object *)x,"jit.gl.videoplane: couldn't get matrix object!");
			return;
		}
	}
	
	if (x->texture) {				
		jit_object_method(m, _jit_sym_getinfo, &info);
		jit_attr_getlong_array(x->texture,_jit_sym_dim,2,dim);
		jit_object_method(x->texture,s,s,argc,argv);
		// switch back to matrix input
		jit_attr_setsym(x,ps_texture,x->texturename);
	}
}	
コード例 #10
0
ファイル: max.jit.3m.c プロジェクト: CICM/max6-sdk
void *max_jit_3m_new(t_symbol *s, long argc, t_atom *argv)
{
	t_max_jit_3m *x;
	void *o;

	if (x=(t_max_jit_3m *)max_jit_obex_new(max_jit_3m_class,gensym("jit_3m"))) {
		x->av = NULL;
		if (o=jit_object_new(gensym("jit_3m"))) {
			max_jit_mop_setup_simple(x,o,argc,argv);			
			//add additional non-matrix outputs
			x->maxout 	= outlet_new(x,0L);	
			x->meanout 	= outlet_new(x,0L); 
			x->minout 	= outlet_new(x,0L);
			x->av		= jit_getbytes(sizeof(t_atom)*JIT_MATRIX_MAX_PLANECOUNT);
			max_jit_attr_args(x,argc,argv);
		} else {
			jit_object_error((t_object *)x,"jit.3m: could not allocate object");
			freeobject((t_object *)x);
			x=NULL;
		}
	}
	return (x);
}
コード例 #11
0
void max_jit_peek_matrix_name(t_max_jit_peek *x, void *attr, long argc, t_atom *argv)
{
	t_symbol *name=_jit_sym_nothing;
	void *p;

	if (argc&&argv) {
		name = jit_atom_getsym(argv);
	}

	//if already something registered with this name, check class_jit_matrix, and handle accordingly
	if (p=jit_object_findregistered(name)) {
		if (!jit_object_method(p,_jit_sym_class_jit_matrix)) {
			jit_object_error((t_object *)x,"jit.peek~: %s exists and is not a matrix");
			while (x->inperform) ; 	// lightweight spinwait
			x->mvalid = 0;			// mark invalid for perform loop
			if (x->matrix_name!=_jit_sym_nothing)
				jit_object_detach(x->matrix_name, x);
			x->matrix_name = _jit_sym_nothing;
			x->mdata = NULL;
			return;
		}
	}

	while (x->inperform) ; 	// lightweight spinwait
	x->mvalid = 0;			// mark invalid for perform loop

	jit_object_detach(x->matrix_name, x);
	x->matrix_name = name;
	jit_object_attach(x->matrix_name, x);

	max_jit_peek_update(x);

	while (x->inperform) ; 	// lightweight spinwait
	x->mvalid = 1;			// mark valid for perform loop

}
コード例 #12
0
ファイル: jit.gl.hap.c プロジェクト: HsienYu/jit.gl.hap
t_jit_err jit_gl_hap_draw(t_jit_gl_hap *x)
{
	t_jit_err result = JIT_ERR_NONE;
	t_jit_gl_drawinfo drawinfo;

	if(x->newfile) {
		if(x->texture && x->deletetex) {
			glDeleteTextures(1, &x->texture);
			x->deletetex = 0;
		}
		
		x->texture = 0;
		jit_gl_hap_load_file(x);
	}
	
	if(!x->movieloaded)
		return JIT_ERR_NONE;
		
	if(jit_gl_drawinfo_setup(x,&drawinfo))
		return JIT_ERR_GENERIC;
		
	jit_gl_hap_getcurrentframe(x);
	
	if(x->validframe) {

		GLint previousFBO;	// make sure we pop out to the right FBO
#ifdef MAC_VERSION
		GLint previousReadFBO;
		GLint previousDrawFBO;
#endif		
		// We are going to bind our FBO to our internal jit.gl.texture as COLOR_0 attachment
		// We need the ID, width/height.
		GLuint texid = jit_attr_getlong(x->texoutput,ps_glid);
		GLuint width = jit_attr_getlong(x->texoutput,ps_width);
		GLuint height = jit_attr_getlong(x->texoutput,ps_height);

		glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &previousFBO);
#ifdef MAC_VERSION
		glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &previousReadFBO);
		glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &previousDrawFBO);
#endif
		
		if(width!=x->dim[0] || height!=x->dim[1]) {
			width = x->dim[0];
			height = x->dim[1];
			jit_attr_setlong_array(x->texoutput, gensym("dim"), 2, x->dim);
			jit_attr_user_touch(x, gensym("dim"));
		}
		
		if(x->hap_format == JIT_GL_HAP_PF_HAP) {
			jit_gl_hap_submit_texture(x);
			jit_gl_report_error("jit.gl.hap submit texture");
		}
		else if(x->hap_format != JIT_GL_HAP_PF_GL) {
			jit_gl_hap_submit_nonhap_texture(x);
			jit_gl_report_error("jit.gl.hap submit non-hap texture");
		}
		
		if(jit_gl_hap_draw_begin(x, texid, width, height)) {
			jit_gl_report_error("jit.gl.hap draw begin");
			jit_gl_hap_dodraw(x, width, height);
			jit_gl_report_error("jit.gl.hap draw texture to FBO");
			jit_gl_hap_draw_end(x);
			jit_gl_report_error("jit.gl.hap draw end");
		}
		else {
			jit_object_error((t_object*)x, "could not bind to FBO");
		}

		glPopClientAttrib();
		glPopAttrib();
		
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previousFBO);
#ifdef MAC_VERSION
		glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, previousReadFBO);
		glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, previousDrawFBO);
#endif

		x->validframe = 0;
		
		jit_object_notify(x, ps_draw, NULL);
		jit_gl_hap_do_report(x);
	}
	
	jit_gl_hap_releaseframe(x);

	return result;
}
コード例 #13
0
ファイル: cv.jit.calibration.cpp プロジェクト: fourks/cv.jit
void cv_jit_calibration_findcorners(t_cv_jit_calibration *x, 
									t_jit_matrix_info in_minfo, 
									t_jit_matrix_info out_minfo, 
									void *in_matrix, void *out_matrix, 
									CvMat in_cv, char *out_bp ){
	
	int					board_point_nb = x->pattern_size[0]*x->pattern_size[1];
	CvPoint2D32f		*corners = new CvPoint2D32f[board_point_nb];
	int					corner_count;
	int					step;
	CvSize				pattern_size, image_size;
	IplImage			*gray_image, *color_image, in_image;
	
	//in_image = cvCreateImageHeader(cvSize(in_minfo.dim[0], in_minfo.dim[1]), 8, in_minfo.planecount);
	
	if ( x->pattern_size[0] < 3 || x->pattern_size[1] < 3 ) {
		jit_object_error((t_object *) x, "pattern_size must be at least 3 x 3");
		return;
	}
	pattern_size = cvSize( x->pattern_size[0], x->pattern_size[1] );
	image_size = cvSize(in_minfo.dim[0], in_minfo.dim[1]);
	cvGetImage	(&in_cv,	&in_image);	// create an IplImage from a CvMat
	
	// Here we create 2 copies of input matrix, a color and a grayscale
	// This is to avoid modifying the original 
	// and also to deal with different kind of images supported by the following functions
	
	color_image	=	cvCreateImage(image_size, 8, 4);
	gray_image	=	cvCreateImage(image_size, 8, 1);
	
	// convert image colorspace
	if ( in_minfo.planecount == 1 ) {
		cvCvtColor(&in_image, color_image, CV_GRAY2RGBA);
		memcpy(gray_image->imageData, in_image.imageData, in_image.imageSize);
	}
	
	else {
		cvCvtColor(&in_image, gray_image, CV_RGBA2GRAY);
		memcpy(color_image->imageData, in_image.imageData, in_image.imageSize);
	}
	
	// find chessboard corners (grayscale or color image)
	int found = cvFindChessboardCorners(&in_cv, 
										pattern_size, 
										corners, 
										&corner_count, 
										CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);
	
	// get subpixel accuracy on those corners (grayscale image only)
	cvFindCornerSubPix(gray_image, 
					   corners, 
					   corner_count, 
					   cvSize(11,11), 
					   cvSize(-1,-1), 
					   cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1));
	
	// draw chessboard corner (color image only)

	cvDrawChessboardCorners(color_image, pattern_size, corners, corner_count, found);
	
	x->frame++;

	if ( x->frame % x->wait_n_frame == 0 ) {

	// update arrays
		if( corner_count == board_point_nb ) {

			step = x->success_count*board_point_nb;
			for( int i=step, j=0; j<board_point_nb; ++i,++j ) {
				CV_MAT_ELEM(*x->image_points, float,i,0) = corners[j].x; 
				CV_MAT_ELEM(*x->image_points, float,i,1) = corners[j].y; 
				CV_MAT_ELEM(*x->object_points,float,i,0) = j/x->pattern_size[0]; 
				CV_MAT_ELEM(*x->object_points,float,i,1) = j%x->pattern_size[0]; 
				CV_MAT_ELEM(*x->object_points,float,i,2) = 0.0f;
			}
			CV_MAT_ELEM(*x->point_counts, int,x->success_count,0) = board_point_nb; 
			x->success_count++;
			
			// invert view
			cvNot( color_image , color_image );
		}
	}