Exemple #1
0
static StabData* init_detect(mlt_properties properties, mlt_image_format *format, int *width, int *height)
{
	StabData *data = new StabData;
	memset(data, 0, sizeof(StabData));
	data->animation = mlt_animation_new();

	VSPixelFormat pf = convertImageFormat(*format);
	VSFrameInfo fi;
	vsFrameInfoInit(&fi, *width, *height, pf);

	const char* filterName = mlt_properties_get(properties, "mlt_service");

	VSMotionDetectConfig conf = vsMotionDetectGetDefaultConfig(filterName);
	conf.shakiness = mlt_properties_get_int(properties, "shakiness");
	conf.accuracy = mlt_properties_get_int(properties, "accuracy");
	conf.stepSize = mlt_properties_get_int(properties, "stepsize");
	conf.algo = mlt_properties_get_int(properties, "algo");
	conf.contrastThreshold = mlt_properties_get_double(properties, "mincontrast");
	conf.show = mlt_properties_get_int(properties, "show");
	conf.virtualTripod = mlt_properties_get_int(properties, "tripod");
	vsMotionDetectInit(&data->md, &conf, &fi);

	// add vectors to properties
	mlt_properties_set_data(properties, "vectors", data->animation, 1, (mlt_destructor) mlt_animation_close,
					(mlt_serialiser) vectors_serializer);
	return data;
}
void test_checkCompareImg(const TestData* testdata){
  VSMotionDetect md;
  VSMotionDetectConfig conf = vsMotionDetectGetDefaultConfig("test_checkCompareImg");
  conf.shakiness=6;
  conf.accuracy=12;
  test_bool(vsMotionDetectInit(&md, &conf, &testdata->fi) == VS_OK);
  fflush(stdout);
  test_bool(checkCompareImg(&md,&testdata->frames[0]));
  vsMotionDetectionCleanup(&md);
}
Exemple #3
0
int init_deshake(DeshakeData *data, mlt_properties properties,
		mlt_image_format *format, int *width, int *height, char* interps)
{
	VSPixelFormat pf = convertImageFormat(*format);
	VSFrameInfo fiIn, fiOut;
	vsFrameInfoInit(&fiIn, *width, *height, pf);
	vsFrameInfoInit(&fiOut, *width, *height, pf);

	VSMotionDetectConfig conf = vsMotionDetectGetDefaultConfig(FILTER_NAME);
	conf.shakiness = mlt_properties_get_int(properties, "shakiness");
	conf.accuracy = mlt_properties_get_int(properties, "accuracy");
	conf.stepSize = mlt_properties_get_int(properties, "stepsize");
	conf.algo = mlt_properties_get_int(properties, "algo");
	conf.contrastThreshold = mlt_properties_get_double(properties, "mincontrast");
	conf.show = 0;

	vsMotionDetectInit(&data->md, &conf, &fiIn);

	VSTransformConfig tdconf = vsTransformGetDefaultConfig(FILTER_NAME);
	tdconf.smoothing = mlt_properties_get_int(properties, "smoothing");
	tdconf.maxShift = mlt_properties_get_int(properties, "maxshift");
	tdconf.maxAngle = mlt_properties_get_double(properties, "maxangle");
	tdconf.crop = (VSBorderType) mlt_properties_get_int(properties, "crop");
	tdconf.zoom = mlt_properties_get_int(properties, "zoom");
	tdconf.optZoom = mlt_properties_get_int(properties, "optzoom");
	tdconf.zoomSpeed = mlt_properties_get_double(properties, "zoomspeed");
	tdconf.relative = 1;
	tdconf.invert = 0;

	// by default a bilinear interpolation is selected
	tdconf.interpolType = VS_BiLinear;
	if (strcmp(interps, "nearest") == 0 || strcmp(interps, "neighbor") == 0)
		tdconf.interpolType = VS_Zero;
	else if (strcmp(interps, "tiles") == 0 || strcmp(interps, "fast_bilinear") == 0)
		tdconf.interpolType = VS_Linear;

	vsTransformDataInit(&data->td, &tdconf, &fiIn, &fiOut);

	data->avg.initialized = 0;
	return 0;
}
Exemple #4
0
static void init_analyze_data( mlt_filter filter, mlt_frame frame, VSPixelFormat vs_format, int width, int height )
{
	mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
	vs_data* data = (vs_data*)filter->child;
	vs_analyze* analyze_data = (vs_analyze*)calloc( 1, sizeof(vs_analyze) );
	memset( analyze_data, 0, sizeof(vs_analyze) );

	// Initialize a VSMotionDetectConfig
	const char* filterName = mlt_properties_get( properties, "mlt_service" );
	VSMotionDetectConfig conf = vsMotionDetectGetDefaultConfig( filterName );
	conf.shakiness = mlt_properties_get_int( properties, "shakiness" );
	conf.accuracy = mlt_properties_get_int( properties, "accuracy" );
	conf.stepSize = mlt_properties_get_int( properties, "stepsize" );
	conf.contrastThreshold = mlt_properties_get_double( properties, "mincontrast" );
	conf.show = mlt_properties_get_int( properties, "show" );
	conf.virtualTripod = mlt_properties_get_int( properties, "tripod" );

	// Initialize a VSFrameInfo
	VSFrameInfo fi;
	vsFrameInfoInit( &fi, width, height, vs_format );

	// Initialize the saved VSMotionDetect
	vsMotionDetectInit( &analyze_data->md, &conf, &fi );

	// Initialize the file to save results to
	char* filename = mlt_properties_get( properties, "filename" );
	analyze_data->results = fopen( filename, "w" );
	if ( vsPrepareFile( &analyze_data->md, analyze_data->results ) != VS_OK )
	{
		mlt_log_error( MLT_FILTER_SERVICE(filter), "Can not write to results file: %s\n", filename );
		destory_analyze_data( analyze_data );
		data->analyze_data = NULL;
	}
	else
	{
		data->analyze_data = analyze_data;
	}
}