/************************************************************************************************************
Execution Kernel
*************************************************************************************************************/
static vx_status VX_CALLBACK CV_sepFilter2D_Kernel(vx_node node, const vx_reference *parameters, vx_uint32 num)
{
	vx_status status = VX_SUCCESS;

	vx_image image_in = (vx_image) parameters[0];
	vx_image image_out = (vx_image) parameters[1];
	vx_scalar scalar = (vx_scalar) parameters[2];
	vx_matrix KERNELX = (vx_matrix) parameters[3];
	vx_matrix KERNELY = (vx_matrix) parameters[4];
	vx_scalar A_X = (vx_scalar) parameters[5];
	vx_scalar A_Y = (vx_scalar) parameters[6];
	vx_scalar DELTA = (vx_scalar) parameters[7];
	vx_scalar BORDER = (vx_scalar) parameters[8];

	Mat *mat, bl;
	int ddepth, a_x = -1, a_y = -1, border = 4;
	float delta = 0;
	vx_int32 value = 0;
	vx_float32 value_f = 0;

	//Extracting Values from the Scalar into Ksize and Ddepth
	STATUS_ERROR_CHECK(vxReadScalarValue(scalar, &value)); ddepth = value;
	STATUS_ERROR_CHECK(vxReadScalarValue(A_X, &value)); a_x = value;
	STATUS_ERROR_CHECK(vxReadScalarValue(A_Y, &value)); a_y = value;
	STATUS_ERROR_CHECK(vxReadScalarValue(DELTA, &value_f)); delta = value_f;
	STATUS_ERROR_CHECK(vxReadScalarValue(BORDER, &value)); border = value;

	//Converting VX Image to OpenCV Mat
	STATUS_ERROR_CHECK(match_vx_image_parameters(image_in, image_out));
	STATUS_ERROR_CHECK(VX_to_CV_Image(&mat, image_in));

	//Compute using OpenCV
	Point point;
	point.x = a_x;
	point.y = a_y;
	Mat *kernelX, *kernelY;
	STATUS_ERROR_CHECK(VX_to_CV_MATRIX(&kernelX, KERNELX));
	STATUS_ERROR_CHECK(VX_to_CV_MATRIX(&kernelY, KERNELY));
	cv::sepFilter2D(*mat, bl, ddepth, *kernelX, *kernelY, point, delta, border);

	//Converting OpenCV Mat into VX Image
	STATUS_ERROR_CHECK(CV_to_VX_Image(image_out, &bl));

	return status;
}
/************************************************************************************************************
Execution Kernel
*************************************************************************************************************/
static vx_status VX_CALLBACK CV_warpPerspective_Kernel(vx_node node, const vx_reference *parameters, vx_uint32 num)
{
	vx_status status = VX_SUCCESS;

	vx_image image_in = (vx_image) parameters[0];
	vx_image image_out = (vx_image) parameters[1];
	vx_matrix KERNEL = (vx_matrix) parameters[2];
	vx_scalar A_X = (vx_scalar) parameters[3];
	vx_scalar A_Y = (vx_scalar) parameters[4];
	vx_scalar FLAGS = (vx_scalar) parameters[5];
	vx_scalar BORDER = (vx_scalar) parameters[6];

	Mat *mat, bl;
	int flags;
	int a_x = -1, a_y = -1, border = 4;
	vx_int32 value = 0;

	//Extracting Values from the Scalar into Ksize and Ddepth
	STATUS_ERROR_CHECK(vxReadScalarValue(FLAGS, &value)); flags = value;
	STATUS_ERROR_CHECK(vxReadScalarValue(A_X, &value)); a_x = value;
	STATUS_ERROR_CHECK(vxReadScalarValue(A_Y, &value)); a_y = value;
	STATUS_ERROR_CHECK(vxReadScalarValue(BORDER, &value)); border = value;

	//Converting VX Image to OpenCV Mat
	STATUS_ERROR_CHECK(match_vx_image_parameters(image_in, image_out));
	STATUS_ERROR_CHECK(VX_to_CV_Image(&mat, image_in));

	//Compute using OpenCV
	Mat *M;
	STATUS_ERROR_CHECK(VX_to_CV_MATRIX(&M, KERNEL));
	cv::warpPerspective(*mat, bl, *M, Size(a_x, a_y), flags, border);

	//Converting OpenCV Mat into VX Image
	STATUS_ERROR_CHECK(CV_to_VX_Image(image_out, &bl));

	return status;
}