Exemplo n.º 1
0
CvMatND* FeatPyramid::padArray (CvMatND *mat, int dimPad[3], float val)
{
  int dims[3];

  if (mat == NULL)
  {
    for (int i = 0; i < 2; i++)
      dims[i] = dimPad[i] * 2;

    dims[2] = 32 + (dimPad[2] * 2);
  }

  else
  {
    for (int i = 0; i < 3; i++)
      dims[i] = mat->dim[i].size + (dimPad[i] * 2);
  }

  // New bigger matrix is created
  assert (dims[0] > 0);
  assert (dims[1] > 0);
  assert (dims[2] > 0);

  //CvMatND *padMat = createNDMatrix (3, dims, CV_64FC1);
	CvMatND *padMat;
	createMatrix (3, dims, CV_64FC1, &padMat);
  assert (padMat != NULL);

  // Firstable, all the elements are setted to val
  for ( int i = 0; i < padMat->dim[0].size; i++ )
    for ( int j = 0; j < padMat->dim[1].size; j++ )
      for ( int k = 0; k < padMat->dim[2].size; k++ )
        cvSetReal3D (padMat, i, j, k, val);

  if (mat != NULL)
  {
    // Original values are setted
    for ( int i = dimPad[0]; i < padMat->dim[0].size - dimPad[0]; i++ )
      for ( int j = dimPad[1]; j < padMat->dim[1].size - dimPad[1]; j++ )
        for ( int k = dimPad[2]; k < padMat->dim[2].size - dimPad[2]; k++ )
          cvSetReal3D (padMat, i, j, k, cvGetReal3D (mat, i-dimPad[0], j-dimPad[1], k-dimPad[2]));
  }

  return padMat;
}
Exemplo n.º 2
0
double cveGetReal3D(CvArr* arr, int idx0, int idx1, int idx2)
{
   return cvGetReal3D(arr, idx0, idx1, idx2);
}
Exemplo n.º 3
0
void CV_QueryHistTest::run_func(void)
{
    int i, iters = values->cols;
    CvArr* h = hist[0]->bins;
    const int* idx = indices->data.i;
    float* val = values->data.fl;
    float default_value = 0.f;

    // stage 1: write bins
    if( cdims == 1 )
        for( i = 0; i < iters; i++ )
        {
            float v0 = values0->data.fl[i];
            if( fabs(v0 - default_value) < FLT_EPSILON )
                continue;
            if( !(i % 2) )
            {
                if( !(i % 4) )
                    cvSetReal1D( h, idx[i], v0 );
                else
                    *(float*)cvPtr1D( h, idx[i] ) = v0;
            }
            else
                cvSetRealND( h, idx+i, v0 );
        }
    else if( cdims == 2 )
        for( i = 0; i < iters; i++ )
        {
            float v0 = values0->data.fl[i];
            if( fabs(v0 - default_value) < FLT_EPSILON )
                continue;
            if( !(i % 2) )
            {
                if( !(i % 4) )
                    cvSetReal2D( h, idx[i*2], idx[i*2+1], v0 );
                else
                    *(float*)cvPtr2D( h, idx[i*2], idx[i*2+1] ) = v0;
            }
            else
                cvSetRealND( h, idx+i*2, v0 );
        }
    else if( cdims == 3 )
        for( i = 0; i < iters; i++ )
        {
            float v0 = values0->data.fl[i];
            if( fabs(v0 - default_value) < FLT_EPSILON )
                continue;
            if( !(i % 2) )
            {
                if( !(i % 4) )
                    cvSetReal3D( h, idx[i*3], idx[i*3+1], idx[i*3+2], v0 );
                else
                    *(float*)cvPtr3D( h, idx[i*3], idx[i*3+1], idx[i*3+2] ) = v0;
            }
            else
                cvSetRealND( h, idx+i*3, v0 );
        }
    else
        for( i = 0; i < iters; i++ )
        {
            float v0 = values0->data.fl[i];
            if( fabs(v0 - default_value) < FLT_EPSILON )
                continue;
            if( !(i % 2) )
                cvSetRealND( h, idx+i*cdims, v0 );
            else
                *(float*)cvPtrND( h, idx+i*cdims ) = v0;
        }

    // stage 2: read bins
    if( cdims == 1 )
        for( i = 0; i < iters; i++ )
        {
            if( !(i % 2) )
                val[i] = *(float*)cvPtr1D( h, idx[i] );
            else
                val[i] = (float)cvGetReal1D( h, idx[i] );
        }
    else if( cdims == 2 )
        for( i = 0; i < iters; i++ )
        {
            if( !(i % 2) )
                val[i] = *(float*)cvPtr2D( h, idx[i*2], idx[i*2+1] );
            else
                val[i] = (float)cvGetReal2D( h, idx[i*2], idx[i*2+1] );
        }
    else if( cdims == 3 )
        for( i = 0; i < iters; i++ )
        {
            if( !(i % 2) )
                val[i] = *(float*)cvPtr3D( h, idx[i*3], idx[i*3+1], idx[i*3+2] );
            else
                val[i] = (float)cvGetReal3D( h, idx[i*3], idx[i*3+1], idx[i*3+2] );
        }
    else
        for( i = 0; i < iters; i++ )
        {
            if( !(i % 2) )
                val[i] = *(float*)cvPtrND( h, idx+i*cdims );
            else
                val[i] = (float)cvGetRealND( h, idx+i*cdims );
        }
}