Exemplo n.º 1
0
RawImage CaptureFlycap::getFrame() {
  mutex.lock();
  Error error;
  Image image;
  RawImage result;
  result.setColorFormat(capture_format);
  result.setWidth(0);
  result.setHeight(0);
  result.setTime(0.0);
  result.setData(0);
  error = camera->RetrieveBuffer(&image);
  if (error != PGRERROR_OK) {
    error.PrintErrorTrace();
    mutex.unlock();
    return result;
  }

  stored_image = new Image;
  stored_image->DeepCopy(&image);

  result.setData(stored_image->GetData());
  struct timeval tv;
  gettimeofday(&tv,NULL);
  result.setTime((double)tv.tv_sec + tv.tv_usec*(1.0E-6));
  result.setHeight(stored_image->GetRows());
  result.setWidth(stored_image->GetCols());
  result.setColorFormat(pixelFormatToColorFormat(stored_image->GetPixelFormat()));

  mutex.unlock();
  return result;
}
Exemplo n.º 2
0
RawImage CaptureFromFile::getFrame()
{
#ifndef VDATA_NO_QT
   mutex.lock();
#endif

  RawImage result;
  result.setColorFormat(COLOR_RGB8); 
  result.setTime(0.0);
  rgba* rgba_img = 0;
  int width;
  int height;
  if(images.size())
  {
    rgba_img = images[currentImageIndex];
    width = widths[currentImageIndex];
    height = heights[currentImageIndex];
    currentImageIndex = (currentImageIndex + 1) % images.size();
  }
  if (rgba_img == 0)
  {
    fprintf (stderr, "CaptureFromFile Error, no images available");
    is_capturing=false;
    result.setData(0);
    result.setWidth(640);
    result.setHeight(480);
    frame = 0;
  }
  else
  {
    frame = new unsigned char[width*height*3];
    unsigned char* p = &frame[0];
    for (int i=0; i < width * height; i++)
    {
      *p = rgba_img[i].r;
      p++;
      *p = rgba_img[i].g;
      p++;
      *p = rgba_img[i].b;
      p++;
    }
    result.setWidth(width);
    result.setHeight(height);
    result.setData(frame);
    tval tv;    
    gettimeofday(&tv,0);
    result.setTime((double)tv.tv_sec + tv.tv_usec*(1.0E-6));
  }
#ifndef VDATA_NO_QT
  mutex.unlock();
#endif 
  return result;
}