void makeHistFutTablewithRearrange_api(const mxArray * const prhs[4], const
  mxArray *plhs[1])
{
  emxArray_uint8_T *testm;
  emxArray_real_T *rmat;
  emxArray_real_T *y;
  real_T range;
  real_T dims;
  emlrtStack st = { NULL, NULL, NULL };

  st.tls = emlrtRootTLSGlobal;
  emlrtHeapReferenceStackEnterFcnR2012b(&st);
  emxInit_uint8_T(&st, &testm, 2, &h_emlrtRTEI, true);
  emxInit_real_T1(&st, &rmat, 1, &h_emlrtRTEI, true);
  emxInit_real_T(&st, &y, 2, &h_emlrtRTEI, true);

  /* Marshall function inputs */
  emlrt_marshallIn(&st, emlrtAlias((const mxArray *)prhs[0]), "testm", testm);
  range = c_emlrt_marshallIn(&st, emlrtAliasP((const mxArray *)prhs[1]), "range");
  dims = c_emlrt_marshallIn(&st, emlrtAliasP((const mxArray *)prhs[2]), "dims");
  e_emlrt_marshallIn(&st, emlrtAlias((const mxArray *)prhs[3]), "rmat", rmat);

  /* Invoke the target function */
  makeHistFutTablewithRearrange(&st, testm, range, dims, rmat, y);

  /* Marshall function outputs */
  plhs[0] = emlrt_marshallOut(y);
  y->canFreeData = false;
  emxFree_real_T(&y);
  rmat->canFreeData = false;
  emxFree_real_T(&rmat);
  testm->canFreeData = false;
  emxFree_uint8_T(&testm);
  emlrtHeapReferenceStackLeaveFcnR2012b(&st);
}
//
// Arguments    : int numDimensions
//                int *size
// Return Type  : emxArray_uint8_T *
//
emxArray_uint8_T *emxCreateND_uint8_T(int numDimensions, int *size)
{
  emxArray_uint8_T *emx;
  int numEl;
  int i;
  emxInit_uint8_T(&emx, numDimensions);
  numEl = 1;
  for (i = 0; i < numDimensions; i++) {
    numEl *= size[i];
    emx->size[i] = size[i];
  }

  emx->data = (unsigned char *)calloc((unsigned int)numEl, sizeof(unsigned char));
  emx->numDimensions = numDimensions;
  emx->allocatedSize = numEl;
  return emx;
}
//
// Arguments    : unsigned char *data
//                int numDimensions
//                int *size
// Return Type  : emxArray_uint8_T *
//
emxArray_uint8_T *emxCreateWrapperND_uint8_T(unsigned char *data, int
  numDimensions, int *size)
{
  emxArray_uint8_T *emx;
  int numEl;
  int i;
  emxInit_uint8_T(&emx, numDimensions);
  numEl = 1;
  for (i = 0; i < numDimensions; i++) {
    numEl *= size[i];
    emx->size[i] = size[i];
  }

  emx->data = data;
  emx->numDimensions = numDimensions;
  emx->allocatedSize = numEl;
  emx->canFreeData = false;
  return emx;
}
//
// Arguments    : int rows
//                int cols
// Return Type  : emxArray_uint8_T *
//
emxArray_uint8_T *emxCreate_uint8_T(int rows, int cols)
{
  emxArray_uint8_T *emx;
  int size[2];
  int numEl;
  int i;
  size[0] = rows;
  size[1] = cols;
  emxInit_uint8_T(&emx, 2);
  numEl = 1;
  for (i = 0; i < 2; i++) {
    numEl *= size[i];
    emx->size[i] = size[i];
  }

  emx->data = (unsigned char *)calloc((unsigned int)numEl, sizeof(unsigned char));
  emx->numDimensions = 2;
  emx->allocatedSize = numEl;
  return emx;
}
//
// Arguments    : unsigned char *data
//                int rows
//                int cols
// Return Type  : emxArray_uint8_T *
//
emxArray_uint8_T *emxCreateWrapper_uint8_T(unsigned char *data, int rows, int
  cols)
{
  emxArray_uint8_T *emx;
  int size[2];
  int numEl;
  int i;
  size[0] = rows;
  size[1] = cols;
  emxInit_uint8_T(&emx, 2);
  numEl = 1;
  for (i = 0; i < 2; i++) {
    numEl *= size[i];
    emx->size[i] = size[i];
  }

  emx->data = data;
  emx->numDimensions = 2;
  emx->allocatedSize = numEl;
  emx->canFreeData = false;
  return emx;
}
示例#6
0
/* Function Definitions */
void imshift(uint8_T I[270000], const real_T disparity[2])
{
  real_T xStart2;
  real_T yStart2;
  real_T xEnd2;
  real_T yEnd2;
  int32_T i2;
  int32_T i3;
  int32_T i4;
  int32_T i5;
  int32_T tmp_size_idx_0;
  int32_T loop_ub;
  int32_T i6;
  int32_T tmp_data[225];
  int32_T b_tmp_size_idx_0;
  int32_T b_tmp_data[400];
  emxArray_uint8_T *b_I;
  int32_T iv3[3];
  int32_T i7;
  int32_T b_loop_ub;
  int32_T i8;
  int32_T c_I[3];
  int32_T c_tmp_data[400];
  int32_T d_tmp_data[225];
  emxArray_uint8_T *d_I;
  emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal);
  xStart2 = muDoubleScalarMax(1.0, 1.0 + disparity[0]);
  yStart2 = muDoubleScalarMax(1.0, 1.0 + disparity[1]);
  xEnd2 = muDoubleScalarMin(225.0, 225.0 + disparity[0]);
  yEnd2 = muDoubleScalarMin(400.0, 400.0 + disparity[1]);
  i2 = (int32_T)muDoubleScalarMax(1.0, 1.0 - disparity[0]) - 1;
  i3 = (int32_T)muDoubleScalarMin(225.0, 225.0 - disparity[0]);
  i4 = (int32_T)muDoubleScalarMax(1.0, 1.0 - disparity[1]) - 1;
  i5 = (int32_T)muDoubleScalarMin(400.0, 400.0 - disparity[1]);
  tmp_size_idx_0 = ((int32_T)xEnd2 - (int32_T)xStart2) + 1;
  loop_ub = (int32_T)xEnd2 - (int32_T)xStart2;
  for (i6 = 0; i6 <= loop_ub; i6++) {
    tmp_data[i6] = ((int32_T)xStart2 + i6) - 1;
  }

  b_tmp_size_idx_0 = ((int32_T)yEnd2 - (int32_T)yStart2) + 1;
  loop_ub = (int32_T)yEnd2 - (int32_T)yStart2;
  for (i6 = 0; i6 <= loop_ub; i6++) {
    b_tmp_data[i6] = ((int32_T)yStart2 + i6) - 1;
  }

  emxInit_uint8_T(&b_I, 3, &emlrtRTEI, TRUE);
  iv3[0] = tmp_size_idx_0;
  iv3[1] = b_tmp_size_idx_0;
  iv3[2] = 3;
  i6 = b_I->size[0] * b_I->size[1] * b_I->size[2];
  b_I->size[0] = i3 - i2;
  b_I->size[1] = i5 - i4;
  b_I->size[2] = 3;
  emxEnsureCapacity((emxArray__common *)b_I, i6, (int32_T)sizeof(uint8_T),
                    &emlrtRTEI);
  for (i6 = 0; i6 < 3; i6++) {
    loop_ub = i5 - i4;
    for (i7 = 0; i7 < loop_ub; i7++) {
      b_loop_ub = i3 - i2;
      for (i8 = 0; i8 < b_loop_ub; i8++) {
        b_I->data[(i8 + b_I->size[0] * i7) + b_I->size[0] * b_I->size[1] * i6] =
          I[((i2 + i8) + 225 * (i4 + i7)) + 90000 * i6];
      }
    }
  }

  for (i6 = 0; i6 < 3; i6++) {
    c_I[i6] = b_I->size[i6];
  }

  emxFree_uint8_T(&b_I);
  emlrtSubAssignSizeCheckR2012b(iv3, 3, c_I, 3, &emlrtECI, emlrtRootTLSGlobal);
  for (i6 = 0; i6 < b_tmp_size_idx_0; i6++) {
    c_tmp_data[i6] = b_tmp_data[i6];
  }

  for (i6 = 0; i6 < tmp_size_idx_0; i6++) {
    d_tmp_data[i6] = tmp_data[i6];
  }

  emxInit_uint8_T(&d_I, 3, &emlrtRTEI, TRUE);
  i6 = d_I->size[0] * d_I->size[1] * d_I->size[2];
  d_I->size[0] = i3 - i2;
  d_I->size[1] = i5 - i4;
  d_I->size[2] = 3;
  emxEnsureCapacity((emxArray__common *)d_I, i6, (int32_T)sizeof(uint8_T),
                    &emlrtRTEI);
  for (i6 = 0; i6 < 3; i6++) {
    loop_ub = i5 - i4;
    for (i7 = 0; i7 < loop_ub; i7++) {
      b_loop_ub = i3 - i2;
      for (i8 = 0; i8 < b_loop_ub; i8++) {
        d_I->data[(i8 + d_I->size[0] * i7) + d_I->size[0] * d_I->size[1] * i6] =
          I[((i2 + i8) + 225 * (i4 + i7)) + 90000 * i6];
      }
    }
  }

  for (i2 = 0; i2 < 3; i2++) {
    loop_ub = d_I->size[1];
    for (i3 = 0; i3 < loop_ub; i3++) {
      b_loop_ub = d_I->size[0];
      for (i4 = 0; i4 < b_loop_ub; i4++) {
        I[(d_tmp_data[i4] + 225 * c_tmp_data[i3]) + 90000 * i2] = d_I->data[(i4
          + d_I->size[0] * i3) + d_I->size[0] * d_I->size[1] * i2];
      }
    }
  }

  emxFree_uint8_T(&d_I);
  if (xStart2 == 1.0) {
    if (xEnd2 + 1.0 > 225.0) {
      i2 = 0;
      i3 = 0;
    } else {
      i2 = (int32_T)(xEnd2 + 1.0);
      i2 = emlrtDynamicBoundsCheckFastR2012b(i2, 1, 225, &b_emlrtBCI,
        emlrtRootTLSGlobal) - 1;
      i3 = 225;
    }

    tmp_size_idx_0 = i3 - i2;
    for (i3 = 0; i3 < 3; i3++) {
      for (i4 = 0; i4 < 400; i4++) {
        for (i5 = 0; i5 < tmp_size_idx_0; i5++) {
          I[((i2 + i5) + 225 * i4) + 90000 * i3] = 0;
        }
      }
    }
  } else {
    for (i2 = 0; i2 < 3; i2++) {
      for (i3 = 0; i3 < 400; i3++) {
        loop_ub = (int32_T)(xStart2 - 1.0);
        for (i4 = 0; i4 < loop_ub; i4++) {
          I[(i4 + 225 * i3) + 90000 * i2] = 0;
        }
      }
    }
  }

  if (yStart2 == 1.0) {
    if (yEnd2 + 1.0 > 400.0) {
      i2 = 0;
      i3 = 0;
    } else {
      i2 = (int32_T)(yEnd2 + 1.0);
      i2 = emlrtDynamicBoundsCheckFastR2012b(i2, 1, 400, &emlrtBCI,
        emlrtRootTLSGlobal) - 1;
      i3 = 400;
    }

    tmp_size_idx_0 = i3 - i2;
    for (i3 = 0; i3 < 3; i3++) {
      for (i4 = 0; i4 < tmp_size_idx_0; i4++) {
        for (i5 = 0; i5 < 225; i5++) {
          I[(i5 + 225 * (i2 + i4)) + 90000 * i3] = 0;
        }
      }
    }
  } else {
    for (i2 = 0; i2 < 3; i2++) {
      loop_ub = (int32_T)(yStart2 - 1.0);
      for (i3 = 0; i3 < loop_ub; i3++) {
        for (i4 = 0; i4 < 225; i4++) {
          I[(i4 + 225 * i3) + 90000 * i2] = 0;
        }
      }
    }
  }

  emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal);
}
示例#7
0
// Main function
int main (void) 
{  
// Local variable definations
emxArray_uint8_T *xaxis;
emxArray_uint8_T *yaxis;
emxArray_uint8_T *norm_xaxis_filt;
emxArray_uint8_T *norm_yaxis_filt;

uint16_T count;
uint8_T xaxis2,yaxis2;

long j = 0;

int again = 1;

char letter;
char letterstr[10];
int i=0;
letterstr[i] = '\0';

// Variable Initialisation
	for(j=0;j<MAX_VALUE;j++)
	{
		xdata[j] = 0;
		ydata[j] = 0;
	}

	
// Function Initialisation
	PINSEL2 &= ~((1<<2)|(1<<3));
	GLCD_Initalize();				  //Initialize the LCD
	Init_UART();
	InitADC();

// Welcome message
	GLCD_ClearScreen();
	GLCD_GoTo(10,4);	
	GLCD_WriteString("Intelligent e-book");
//	for(j=0;j<999999;j++);
	delay_ms(2000);

// Calibration
	//Left bottom
	GLCD_ClearScreen();
	GLCD_GoTo(10,0);	
	GLCD_WriteString("Calibration");
	GLCD_GoTo(10,4);	
	GLCD_WriteString("Touch the point");
	GLCD_GoTo(0,7);	
	GLCD_WriteString("o");

	do
	{
	xaxis1 = Read_xaxis();
	yaxis1 = Read_yaxis();

	if(xaxis1<10)
		xaxis1 = 0;
	if(yaxis1<10)
		yaxis1 = 0;
	}while(xaxis1==0 && yaxis1==0);
	for(j=0;j<25;j++)
	capture();


	x1 = xaxis1;
	y1 = yaxis1;

	GLCD_GoTo(10,5);	
	GLCD_WriteString("Stored");
	delay_ms(1000);

	//Right top
	GLCD_ClearScreen();
	GLCD_GoTo(10,0);	
	GLCD_WriteString("Calibration");
	GLCD_GoTo(10,4);	
	GLCD_WriteString("Touch the point");
	GLCD_GoTo(120,0);	
	GLCD_WriteString("o");

	do
	{
	xaxis1 = Read_xaxis();
	yaxis1 = Read_yaxis();

	if(xaxis1<10)
		xaxis1 = 0;
	if(yaxis1<10)
		yaxis1 = 0;
	}while(xaxis1==0 && yaxis1==0);
	for(j=0;j<25;j++)
	capture();

	x2 = xaxis1;
	y2 = yaxis1;

	GLCD_GoTo(10,5);	
	GLCD_WriteString("Stored");
	delay_ms(1000);


while(again==1)
{
again = 0;

// Capturing xaxis and yaxis

GLCD_ClearScreen();
GLCD_GoTo(10,0);	
GLCD_WriteString("Intelligent e-book");
GLCD_GoTo(12,4);		
GLCD_WriteString("Waiting for input");
do
{
xaxis1 = Read_xaxis();
yaxis1 = Read_yaxis();

if(xaxis1<10)
	xaxis1 = 0;
if(yaxis1<10)
	yaxis1 = 0;

}while(xaxis1==0 && yaxis1==0);

xyelem = 0;
count = 0;
GLCD_ClearScreen();
GLCD_GoTo(0,0);		

// Eliminate first 25 samples
	for(j=0;j<25;j++)
	capture();

while(count!=250)
{
	capture();

	if(xaxis1!=0 && yaxis1!=0 && count==0)
	{
		
//	xaxis2 = (uint8_T)(((xaxis1-80)*255)/730);
//	yaxis2 = (uint8_T)(((yaxis1-100)*255)/650);
	xaxis2 = (uint8_T)(((xaxis1-x1)*255)/(x2-x1));
	yaxis2 = (uint8_T)(((yaxis1-y1)*255)/(y2-y1));

		count = 0;
	  	xdata[xyelem] = xaxis2;
		ydata[xyelem] = yaxis2;
		xyelem = xyelem + 1;
		GLCD_SetPixel(xaxis2/2,255-(yaxis2/4),1);

		if(xyelem>MAX_VALUE - 1)
		{
			GLCD_ClearScreen();
			GLCD_GoTo(10,0);	
			GLCD_WriteString("Intelligent e-book");
			GLCD_GoTo(10,4);		
			GLCD_WriteString("Overflow!!!");
			while(1);
		}
	}
	else if(xaxis1!=0 && yaxis1!=0)
	{
		xyelem = xyelem - 2;
		// Eliminate first 25 samples
		for(j=0;j<25;j++)
		capture();
		count = 0;
	}
	else
	{
	 	count = count + 1;
	}

//	delay(1000);
}
GLCD_ClearScreen();
GLCD_GoTo(10,0);	
GLCD_WriteString("Intelligent e-book");
GLCD_GoTo(0,1);	
GLCD_WriteString(letterstr);

//GLCD_GoTo(10,4);		
//GLCD_WriteString("Scanning ended");
//delay_ms(500);


// Transmitting data to PC
//	transmit();

// Remove noise
	remove_noise();

// Allocating space for pointers  
	xaxis = emxCreateWrapper_uint8_T(xdata,1,xyelem);	//xdata1
	yaxis = emxCreateWrapper_uint8_T(ydata,1,xyelem);	//ydata1
	emxInit_uint8_T(&norm_xaxis_filt, 2);
	emxInit_uint8_T(&norm_yaxis_filt, 2);

/*	GLCD_ClearScreen();
	GLCD_GoTo(10,0);	
	GLCD_WriteString("Intelligent e-book");
	GLCD_GoTo(0,2);		
	GLCD_WriteString("Step1");
	GLCD_GoTo(37,2);		
	GLCD_WriteString("In");
*/
//	for(j=0;j<999999;j++);

	step1(xaxis, yaxis, norm_xaxis_filt, norm_yaxis_filt);

//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(54,2);	
//	GLCD_WriteString("Out");
//	for(j=0;j<999999;j++);

	emxDestroyArray_uint8_T(xaxis);
	emxDestroyArray_uint8_T(yaxis);
	
//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(0,3);	
//	GLCD_WriteString("Step2");
//	GLCD_GoTo(37,3);		
//	GLCD_WriteString("In");
//	for(j=0;j<999999;j++);

// char_bin is stored in column first fashion... each column vector are concatenated	
	step2(norm_xaxis_filt, norm_yaxis_filt, char_bin);

//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(54,3);	
//	GLCD_WriteString("Out");
//	for(j=0;j<999999;j++);
	
	emxFree_uint8_T(&norm_xaxis_filt);
	emxFree_uint8_T(&norm_yaxis_filt);

//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(0,4);	
//	GLCD_WriteString("Step3");
//	GLCD_GoTo(37,4);		
//	GLCD_WriteString("In");
//	for(j=0;j<999999;j++);

	for(j=0;j<10;j++)
	char_vec[j] = 1;
	
	step3(char_bin, char_vec);
	
//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(54,4);	
//	GLCD_WriteString("Out");
//	for(j=0;j<999999;j++);
  

	for(j=0;j<26;j++)
	char_vec1[j] = char_vec[j];
	
	// Feeding char_vec to trained neural network
	char_recog_nn(char_vec1,Y);

	letter = character();

	letterstr[i] = letter;
	letterstr[i+1] = '\0';

//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(0,6);	
//	GLCD_WriteString("Letter is: ");
	GLCD_GoTo(0,1);	
	GLCD_WriteString(letterstr);
	GLCD_GoTo(0,7);	
	GLCD_WriteString("Continue");

	do
	{
	xaxis1 = Read_xaxis();
	yaxis1 = Read_yaxis();

	if(xaxis1<10)
		xaxis1 = 0;
	if(yaxis1<10)
		yaxis1 = 0;

	}while(xaxis1==0 && yaxis1==0);

again = 1;
i = i + 1;
/*
GLCD_ClearScreen();
GLCD_GoTo(10,0);	
GLCD_WriteString("Intelligent e-book");
GLCD_GoTo(20,4);		
GLCD_WriteString("Restarting.");
delay_ms(200);
GLCD_WriteString(".");
delay_ms(200);
GLCD_WriteString(".");
delay_ms(200);
GLCD_WriteString(".");
*/
delay_ms(400);
}

  while(1); 
}
//
// Arguments    : emxArray_uint8_T **pEmxArray
//                int numDimensions
// Return Type  : void
//
void emxInitArray_uint8_T(emxArray_uint8_T **pEmxArray, int numDimensions)
{
  emxInit_uint8_T(pEmxArray, numDimensions);
}