void ProcessBlobs::process(const Frame8 &frame, uint32_t *numBlobs, BlobA **blobs, uint32_t *numCCBlobs, BlobB **ccBlobs, uint32_t *numQvals, Qval **qMem)
{
#if 0
#if 0
    uint16_t boxes[] = {
        1, 20, 30, 10, 20,
        1, 35, 45, 25, 35,
        1, 20, 30, 10, 20,
        1, 21, 22, 11, 12,
        1, 25, 35, 20, 50,
        1, 25, 35, 20, 50,
        1, 25, 35, 20, 50,
        1, 80, 90, 40, 50,
        1, 80, 90, 60, 61
    };

    combine(boxes, 9);
    combine2(boxes, 9);
    compress(boxes, 9);
    return;
#endif

    rls(frame);
    m_blobs->blobify();
    m_blobs->getBlobs(blobs, numBlobs, ccBlobs, numCCBlobs);
    *numQvals = m_numQvals;
    *qMem = m_qMem;

    //processCoded();
#if 0 // uncomment if we only want to show structured blobs
    if (m_numCodedBoxes>0)
    {
        int i;
        for (i=0; i<m_numBoxes; i++)
        {
            m_boxes[i*4+0]=0;
            m_boxes[i*4+1]=0;
            m_boxes[i*4+2]=0;
            m_boxes[i*4+3]=0;
        }
    }
#endif
#endif
}
Beispiel #2
0
void Blobs::blobify()
{
    uint32_t i, j, k;
    bool colorCode;
    CBlob *blob;
    uint16_t *blobsStart;
    uint16_t numBlobsStart, invalid, invalid2;
    uint16_t left, top, right, bottom;
    //uint32_t timer, timer2=0;

    unpack();

    // copy blobs into memory
    invalid = 0;
    // mutex keeps interrupt routine from stepping on us
    m_mutex = true;
    for (i=0, m_numBlobs=0; i<NUM_MODELS; i++)
    {
        colorCode = m_clut->getType(i+1)==CL_MODEL_TYPE_COLORCODE;

        for (j=m_numBlobs*5, k=0, blobsStart=m_blobs+j, numBlobsStart=m_numBlobs, blob=m_assembler[i].finishedBlobs;
             blob && m_numBlobs<m_maxBlobs && k<m_maxBlobsPerModel; blob=blob->next, k++)
        {
            if ((colorCode && blob->GetArea()<MIN_COLOR_CODE_AREA) ||
                    (!colorCode && blob->GetArea()<(int)m_minArea))
                continue;
            blob->getBBox((short &)left, (short &)top, (short &)right, (short &)bottom);
            m_blobs[j + 0] = i+1;
            m_blobs[j + 1] = left;
            m_blobs[j + 2] = right;
            m_blobs[j + 3] = top;
            m_blobs[j + 4] = bottom;
            m_numBlobs++;
            j += 5;

        }
        //setTimer(&timer);
        if (!colorCode) // do not combine color code models
        {
            while(1)
            {
                invalid2 = combine2(blobsStart, m_numBlobs-numBlobsStart);
                if (invalid2==0)
                    break;
                invalid += invalid2;
            }
        }
        //timer2 += getTimer(timer);
    }
    //setTimer(&timer);
    invalid += combine(m_blobs, m_numBlobs);
    if (m_codedMode)
    {
        m_codedBlobs = (BlobB *)(m_blobs + m_numBlobs*5);
        // calculate number of codedblobs left
        processCoded();
    }
    if (invalid || m_codedMode)
    {
        invalid2 = compress(m_blobs, m_numBlobs);
        m_numBlobs -= invalid2;
    }
    //timer2 += getTimer(timer);
    //cprintf("time=%d\n", timer2); // never seen this greater than 200us.  or 1% of frame period

    // reset read index-- new frame
    m_blobReadIndex = 0;
    m_mutex = false;

    // free memory
    for (i=0; i<NUM_MODELS; i++)
        m_assembler[i].Reset();

#if 0
    static int frame = 0;
    if (m_numBlobs>0)
        cprintf("%d: blobs %d %d %d %d %d\n", frame, m_numBlobs, m_blobs[1], m_blobs[2], m_blobs[3], m_blobs[4]);
    else
        cprintf("%d: blobs 0\n", frame);
    frame++;
#endif
}
Beispiel #3
0
void Blobs::blobify()
{
	//mm not entirely sure yet, but I think this function might just "draw" the blobs, based on the color model of each pixel. the color model is already determined in the "packed" data (see unpack...color model information is extracted from the packed data there...)
	
	
    uint32_t i, j, k;
    CBlob *blob;
    uint16_t *blobsStart;
    uint16_t numBlobsStart, invalid, invalid2;
    uint16_t left, top, right, bottom;
    //uint32_t timer, timer2=0;

    unpack(); //mm as is clear in unpack(), at this point, we already know the model to which each blob belongs.

    // copy blobs into memory //mm does this refer to the unpack() above??
    invalid = 0;
	
    // mutex keeps interrupt routine from stepping on us
    m_mutex = true;
	
	//mm iterate through models:
    for (i=0, m_numBlobs=0; i<NUM_MODELS; i++)
    {
		//mm iterate through blobs in this model:
        for (j=m_numBlobs*5, k=0, blobsStart=m_blobs+j, numBlobsStart=m_numBlobs, blob=m_assembler[i].finishedBlobs;
             blob && m_numBlobs<m_maxBlobs && k<m_maxBlobsPerModel; blob=blob->next, k++)
        {
            if (blob->GetArea()<(int)m_minArea)
                continue;
            blob->getBBox((short &)left, (short &)top, (short &)right, (short &)bottom);
            m_blobs[j + 0] = i+1;
            m_blobs[j + 1] = left;
            m_blobs[j + 2] = right;
            m_blobs[j + 3] = top;
            m_blobs[j + 4] = bottom;
            m_numBlobs++;
            j += 5;

        }
        //setTimer(&timer);
        if (true)
        {
            while(1)
            {
                invalid2 = combine2(blobsStart, m_numBlobs-numBlobsStart);
                if (invalid2==0)
                    break;
                invalid += invalid2;
            }
        }
        //timer2 += getTimer(timer);
    }
    //setTimer(&timer);
    invalid += combine(m_blobs, m_numBlobs);
    if (false)
    {
        m_codedBlobs = (BlobB *)(m_blobs + m_numBlobs*5);
        processCoded();
    }
    if (invalid)
    {
        invalid2 = compress(m_blobs, m_numBlobs);
        m_numBlobs -= invalid2;
        if (invalid2!=invalid)
            cprintf("**** %d %d\n", invalid2, invalid);

    }
    //timer2 += getTimer(timer);
    //cprintf("time=%d\n", timer2); // never seen this greater than 200us.  or 1% of frame period

    // reset read index-- new frame
    m_blobReadIndex = 0;
    m_mutex = false;

    // free memory
    for (i=0; i<NUM_MODELS; i++)
        m_assembler[i].Reset();

#if 0
    static int frame = 0;
    if (m_numBlobs>0)
        cprintf("%d: blobs %d %d %d %d %d\n", frame, m_numBlobs, m_blobs[1], m_blobs[2], m_blobs[3], m_blobs[4]);
    else
        cprintf("%d: blobs 0\n", frame);
    frame++;
#endif
}
Beispiel #4
0
int main(int argc, char *argv[])
{
  vec_ptr vector;
  data_t result;
  long vector_size;
  clock_t time_start, time_end;

  if( argc != 3)
    {
      printf("Program usage: %s <algorithm-num> <vector-size>\n", argv[0]);
      return 1;
    }

  vector_size=atol(argv[2]);
  printf("Processing vector:\n");
  printf(" * Elements: %ld\n", vector_size);
  printf(" * Data type: %s\n", DATA_NAME);
  printf(" * Operation: %s\n", OP_NAME);

  // Allocate vector in memory
  vector = new_vec(vector_size);
  if(vector == NULL)
    {
      printf("Error: Unable to allocate vector\n");
      return 1;
    }

  // Initialize vector with values
  init_vec(vector);

  // Process the vector with different algorithms
  // (that all produce the same result)
  // based on user input
  time_start = clock();
  if(strcmp(argv[1], "1") == 0)
    combine1(vector, &result);
  else if(strcmp(argv[1], "2") == 0)
    combine2(vector, &result);
  else if(strcmp(argv[1], "3") == 0)
    combine3(vector, &result);
  else if(strcmp(argv[1], "4") == 0)
    combine4(vector, &result);
  else if(strcmp(argv[1], "5x2") == 0)
    combine5x2(vector, &result);
  else if(strcmp(argv[1], "5x3") == 0)
    combine5x3(vector, &result);
  else if(strcmp(argv[1], "6") == 0)
    combine6(vector, &result);
  else
    {
      printf("ERROR: Invalid combine algorithm. Must specifiy 1,2,3,4,5x2,5x3, or 6\n");
      free_vec(vector);
      return 1;
    }
  time_end = clock();

  printf("Finished running combine() operation\n");
  // Don't care about the actual results. The array
  // is so big that surely the calculation has
  // overflowed by now... 
  
  printf("Time for combineN(): %.03f seconds\n", ((double)(time_end - time_start))/CLOCKS_PER_SEC);

  // Clean up memory when finished
  free_vec(vector);
  
  return 0;
}