コード例 #1
0
extern "C" JNIEXPORT jint JNICALL Java_com_almalence_plugins_processing_sequence_AlmaCLRShot_MovObjProcess
(
	JNIEnv* env,
	jobject thiz,
	jint nFrames,
	jobject size,
	jint sensitivity,
	jint minSize,
	jintArray jcrop,
	jint ghosting,
	jint ratio,
	jintArray jsports_order
)
{
	Uint8 *layout;
	int *crop;
	int x,y;
	int tmp;
	int *sports_mode_order;
	int base_area[4];

	LOGD("MovObjProcess - start");

	jclass src_size = env->GetObjectClass(size);
	jfieldID id_srcW = env->GetFieldID(src_size, "width", "I");
	jint sx = env->GetIntField(size,id_srcW);
	jfieldID id_srcH = env->GetFieldID(src_size, "height", "I");
	jint sy = env->GetIntField(size,id_srcH);

	OutPic = (Uint8 *)malloc(sx*sy+2*((sx+1)/2)*((sy+1)/2));

	crop = (int*)env->GetIntArrayElements(jcrop, NULL);
	sports_mode_order = (int*)env->GetIntArrayElements(jsports_order, NULL);

	int use_sports_mode = 1;
	int fastmode = 0;

	layout = (Uint8 *) malloc ((sx/ratio)*(sy/ratio)*sizeof(Uint8));
	memset (layout, 0, (sx/ratio)*(sy/ratio)*sizeof(Uint8));

	MovObj_Process(&instance, inputFrame, OutPic, layout, NULL, 256, sx, sy, nFrames,
			sensitivity, minSize,	// sensitivity and min size of moving object
			5, ghosting,//ghosting,
			1, // extraBorder
			use_sports_mode, sports_mode_order,
			0, 0, 2,	// 2 = keep aspect ratio in output
			&base_area[0], &base_area[1], &base_area[2], &base_area[3],
			&crop[0], &crop[1], &crop[2], &crop[3],
			0, ratio == 16 ? 1:0, 0);

	free(layout);

	env->ReleaseIntArrayElements(jcrop, (jint*)crop, JNI_ABORT);
	env->ReleaseIntArrayElements(jsports_order, (jint*)sports_mode_order, JNI_ABORT);

	LOGD("MovObjProcess - end");

	return (jint)OutPic;
}
コード例 #2
0
extern "C" JNIEXPORT jint JNICALL Java_com_almalence_plugins_processing_objectremoval_AlmaCLRShot_MovObjProcess
(
	JNIEnv* env,
	jobject thiz,
	jint nFrames,
	jobject size,
	jint sensitivity,
	jint minSize,
	jintArray jbase_area,
	jintArray jcrop,
	jbyteArray jlayout,
	jint ghosting,
	jint ratio,
	jintArray jsports_order
)
{
	Uint8 *layout;
	int *base_area;
	int *crop;
	int x,y;
	int tmp;
	int *sports_mode_order;

	LOGE("MovObjProcess - start");

	jclass src_size = env->GetObjectClass(size);
	jfieldID id_srcW = env->GetFieldID(src_size, "width", "I");
	jint sx = env->GetIntField(size,id_srcW);
	jfieldID id_srcH = env->GetFieldID(src_size, "height", "I");
	jint sy = env->GetIntField(size,id_srcH);

	OutPic = (Uint8 *)malloc(sx*sy+2*((sx+1)/2)*((sy+1)/2));

	crop = (int*)env->GetIntArrayElements(jcrop, NULL);

	int use_sports_mode = 1;
	int fastmode = 0;
	if(jsports_order != NULL)
		sports_mode_order = (int*)env->GetIntArrayElements(jsports_order, NULL);
	else
	{
		sports_mode_order = NULL;
		use_sports_mode = 0;
	}


	if(jlayout != NULL)
		layout = (Uint8 *)env->GetByteArrayElements(jlayout, NULL);
	else
	{
		layout = (Uint8 *) malloc ((sx/ratio)*(sy/ratio)*sizeof(Uint8));
		memset (layout, -1, (sx/ratio)*(sy/ratio)*sizeof(Uint8));
	}

	if(jbase_area != NULL)
		base_area = (int*)env->GetIntArrayElements(jbase_area, NULL);
	else
	{
		base_area = (int *) malloc(4*sizeof(int));
		memset(base_area, 0, 4*sizeof(int));
	}

	MovObj_Process(&instance, inputFrame, OutPic,
					layout, NULL, // used in manual removal mode
					256, // gain (sensor specific, might need adjustment)
					sx, sy, nFrames,
					sensitivity, // sensitivity
					minSize,	// smallest detectable object size
					5, // do not detect weak objects (with little movement or low contrast)
					ghosting,// prevent ghosting
					0, // no extra border around detected object
					use_sports_mode, sports_mode_order, // sports-mode parameters
					0, // default maximum displacement between input frames
					0, // do not use post-filter
					2,	// re-scale output (2 = keep aspect ratio)
					&base_area[0], &base_area[1], &base_area[2], &base_area[3], // area covered in base frame by Layout
					&crop[0], &crop[1], &crop[2], &crop[3], &crop[4],
					ratio == 16 ? 1:0, // use fast mode (recommended for sensors >= 8Mpix)
					0);

	if(jlayout != NULL)
	{
		env->ReleaseByteArrayElements(jlayout, (jbyte*)layout, JNI_COMMIT);
	}
	else
		free(layout);

	if(jbase_area != NULL)
		env->ReleaseIntArrayElements(jbase_area, (jint*)base_area, JNI_COMMIT);
	else
		free(base_area);

	env->ReleaseIntArrayElements(jcrop, (jint*)crop, JNI_COMMIT);

	if(jsports_order != NULL)
		env->ReleaseIntArrayElements(jsports_order, (jint*)sports_mode_order, JNI_ABORT);

	LOGE("MovObjProcess - end");

	return (jint)OutPic;
}