/* Function to compare two images */
int compareImages(char *imgFileName_sequential, char *imgFileName_parallel)
{
  int32_t i;
  int32_t imgSize_sequential,imgSize_parallel;
int pixel_count = 0;
//uint8_t fracLen = 20;
//int32_t seq_pixel,par_pixel;

  /*import image data*/
  GraylevelImage gray_sequential = DefaultPgmImage;
  if (readPgm(imgFileName_sequential, &gray_sequential)) {
    printf("ERROR: Could not read from %s\n", imgFileName_sequential);
    return -1;
  }
  imgSize_sequential = gray_sequential.width * gray_sequential.height;

  /*import image data*/
  GraylevelImage gray_parallel = DefaultPgmImage;
  if (readPgm(imgFileName_parallel, &gray_parallel)) {
    printf("ERROR: Could not read from %s\n", imgFileName_parallel);
    return -1;
  }

  imgSize_parallel = gray_parallel.width * gray_parallel.height;

  assert(imgSize_sequential  == imgSize_parallel);
  assert(gray_parallel.depth == gray_sequential.depth);

  /* Compare images pixel-wise */
  for (i = 0; i < imgSize_sequential; i++) {

        /* seq_pixel = fmul32((gray_sequential.data[i] << fracLen), */
        /* (double2fix((1./IMAGE_SCALING(gray_sequential.depth)), fracLen)), */
        /* fracLen); */

        /* par_pixel = fmul32((gray_parallel.data[i] << fracLen), */
        /* (double2fix((1./IMAGE_SCALING(gray_parallel.depth)), fracLen)), */
        /* fracLen); */

        /* if( abs(gray_sequential.data[i] - gray_parallel.data[i]) > 50) */
        /* if( abs(seq_pixel - par_pixel) > 50) */
        if( gray_sequential.data[i] != gray_parallel.data[i])
	{
          pixel_count++;
          /* printf("%d (%d,%d):  %d != %d\n",i,i/gray_parallel.width,i%gray_parallel.width,gray_sequential.data[i],gray_parallel.data[i]); */
          /* printf("%d:  %d != %d\n",i,gray_sequential.data[i],gray_parallel.data[i]); */
          /* printf("%d: %d != %d ->  %d != %d\n",i,seq_pixel,par_pixel,gray_sequential.data[i],gray_parallel.data[i]); */
          /* assert( gray_sequential.data[i] == gray_parallel.data[i]); */
        }
  }
  freePgm(&gray_sequential);
  freePgm(&gray_parallel);

  return pixel_count;
}
示例#2
0
int main()
{
  int flag=0;
  flag=readPgm();
  return 0;
}
示例#3
0
int hrt_main (int argc, char **argv) 
{
    int flag;

    int i;

    // detection parameters
    float scaleFactor = 1.2;
    int minNeighbours = 3;
    int size;

    printf("-- entering main function --\r\n");

    printf("-- loading image --\r\n");

    MyImage imageObj;
    MyImage *image = &imageObj;

    flag = readPgm((char *)INPUT_FILENAME, image);
    if (flag == -1)
    {
        printf( "Unable to open input image\n");
        return 1;
    }

    printf("-- loading cascade classifier --\r\n");

    myCascade cascadeObj;
    myCascade *cascade = &cascadeObj;
    MySize minSize = {20, 20};
    MySize maxSize = {0, 0};

    // classifier properties
    cascade->n_stages=25;
    cascade->total_nodes=2913;
    cascade->orig_window_size.height = 24;
    cascade->orig_window_size.width = 24;

    readTextClassifier(cascade);

    struct MyRect *result[NUM] = {};

    //Load the program 
    hrt_cell_load_program_id(CELL, haar);

    hrt_scalar_store(CELL, MyImage, myimage, image);
    hrt_indexed_store(CELL, MySize, mysize, 0, minSize);
    hrt_indexed_store(CELL, MySize, mysize, 1, maxSize);
    hrt_scalar_store(CELL, myCascade, mycascade, cascade);
    hrt_scalar_store(CELL, float, scalefactor, scaleFactor);
    hrt_scalar_store(CELL, int, minneighbours, minNeighbours); 
    hrt_scalar_store(CELL, MyRect, myrect, result); 

    printf("-- detecting faces --\r\n");
    
    //size = detectObjects(image, minSize, maxSize, cascade, scaleFactor, minNeighbours, result);
    detectObjects();
    size = hrt_scalar_load(CELL, int, size);


    printf("-- drawing boxes --\r\n");
    for(i = 0; i < NUM; i++ )
    {
        if ( result[i] != NULL) {
            struct MyRect *r = result[i];
            drawRectangle(image, r);
        }
        else
            break;
    }

    printf("-- saving output --\r\n");
    flag = writePgm((char *)OUTPUT_FILENAME, image);

    printf("-- image saved --\r\n");

    //    delete image and free classifier
    releaseTextClassifier(cascade);
    freeImage(image);

    

    return 0;
}