Beispiel #1
0
  static void addProperties(gem::Properties&props, int argc, t_atom*argv)
  {
    if(!argc)return;
    
    if(argv->a_type != A_SYMBOL) {
      ::error("no key given...");
      return;
    }
    std::string key=std::string(atom_getsymbol(argv)->s_name);
    std::vector<gem::any> values;
    argc--; argv++;
    while(argc-->0) {
      values.push_back(atom2any(argv++));
    }
    switch(values.size()) {
    default:
      props.set(key, values);
      break;
    case 1:
      props.set(key, values[0]);
      break;
    case 0: 
      {
	gem::any dummy;
	props.set(key, dummy);
      }
      break;
    }
  }
Beispiel #2
0
 void setParameters(gem::Properties&parms) {
   unsigned int i=0;
   for(i=0; i<m_parameterNames.size(); i++) {
     std::string key=m_parameterNames[i];
     std::string s1, s2;
     double d1, d2;
     switch(m_parameter.type(key)) {
     case gem::Properties::NONE:
       if(gem::Properties::NONE==parms.type(key)) {
         parms.erase(key);
         setParameter(i);
       }
       break;
     case gem::Properties::DOUBLE:
       if(m_parameter.get(key, d1) && parms.get(key, d2)) {
         if(d1!=d2) {
           m_parameter.set(key, d2);
           setParameter(i, d2);
         }
       }
       break;
     case gem::Properties::STRING:
       if(m_parameter.get(key, s1) && parms.get(key, s2)) {
         if(s1!=s2) {
           m_parameter.set(key, s2);
           setParameter(i, s2);
         }
       }
       break;
     default: break;
     }
   }
 }
Beispiel #3
0
void filmQT4L::getProperties(gem::Properties&props) {
  std::vector<std::string> keys=props.keys();
  gem::any value;
  double d;
  unsigned int i=0;
  for(i=0; i<keys.size(); i++) {
    std::string key=keys[i];
    props.erase(key);
    if("fps"==key) {
      d=m_fps;
      value=d; props.set(key, value);
    }
    if("frames"==key) {
      d=m_numFrames;
      value=d; props.set(key, value);
    }
    if("tracks"==key) {
      d=m_numTracks;
      value=d; props.set(key, value);
    }
    if("width"==key) {
      d=m_image.image.xsize;
      value=d; props.set(key, value);
    }
    if("height"==key) {
      d=m_image.image.ysize;
      value=d; props.set(key, value);
    }
  }
}
Beispiel #4
0
bool videoUNICAP :: enumProperties(gem::Properties&readable,
                                   gem::Properties&writeable) {
  readable.clear();
  writeable.clear();

  if(m_handle) {
    int count=0;
    unicap_status_t status= unicap_reenumerate_properties(m_handle, &count );
    if(!SUCCESS(status))
      return false;

    int id=0;
    for(id=0; id<count; id++) {
      unicap_property_t prop;
      gem::any typ;

      status = unicap_enumerate_properties(m_handle, NULL, &prop, id);
      if(!SUCCESS(status))
        continue;

      debugPost("id='%s'\tcat='%s'\tunit='%s'\tflags=%d", 
                prop.identifier,
                prop.category,
                prop.unit,
                prop.flags);


      switch(prop.type) {
      case UNICAP_PROPERTY_TYPE_RANGE: 
        debugPost("range %f-%f", prop.range.min, prop.range.min);
        typ=prop.range.max; 
        break;
      case UNICAP_PROPERTY_TYPE_VALUE_LIST: 
        debugPost("value_list %d", prop.value_list.value_count);
        typ=prop.value_list.value_count;
        break;
      case UNICAP_PROPERTY_TYPE_MENU: 
        debugPost("menu '%s' of %d", prop.menu_item, prop.menu.menu_item_count);
        typ=std::string(prop.menu_item);//prop.menu.menu_item_count;
        break;
      case UNICAP_PROPERTY_TYPE_FLAGS: 
        debugPost("flags");
        break;
      default:
        debugPost("unknown");
        // ?
        break;
      }

      readable.set(prop.identifier, typ);
      if(!(prop.flags & UNICAP_FLAGS_READ_ONLY))
        writeable.set(prop.identifier, typ);

#warning check UNICAP_FLAGS_ON_OFF & UNICAP_FLAGS_ONE_PUSH
    }
  }
  return true;
}
Beispiel #5
0
void videoOptiTrack::getProperties(gem::Properties&props)
{
  std::vector<std::string>keys=props.keys();
  double d;
  std::string s;

  props.clear();
  if(!m_camera) {
    return;
  }

  unsigned int i;
  for(i=0; i<keys.size(); i++) {
    const std::string key=keys[i];
    if("width"==key) {
      props.set(key, m_pixBlock.image.xsize);
      continue;
    }
    if("height"==key) {
      props.set(key, m_pixBlock.image.ysize);
      continue;
    }
    if("fanspeed"==key && m_camera->IsCameraFanSpeedValid()) {
      d=m_camera->CameraFanSpeed();
      props.set(key, d);
      continue;
    }
    if("temperature"==key && m_camera->IsCameraTempValid()) {
      d=m_camera->CameraTemp();
      props.set(key, d);
      continue;
    }

#define GETCAMERAPROP_BOOL(name) if(#name == key) {d=m_camera->##name(); props.set(key, d); continue; } else d=0
#define GETCAMERAPROP_INT(name)  if(#name == key) {d=m_camera->##name(); props.set(key, d); continue; } else d=0
#define GETCAMERAPROP_STR(name)  if(#name == key) {s=m_camera->##name(); props.set(key, s); continue; } else d=0
    GETCAMERAPROP_BOOL(AEC);
    GETCAMERAPROP_BOOL(AGC);
    GETCAMERAPROP_BOOL(ContinuousIR);
    GETCAMERAPROP_BOOL(HighPowerMode);
    GETCAMERAPROP_BOOL(IRFilter);
    GETCAMERAPROP_BOOL(MarkerOverlay);
    GETCAMERAPROP_BOOL(TextOverlay);
    GETCAMERAPROP_INT(Exposure);
    GETCAMERAPROP_INT(FrameDecimation);
    GETCAMERAPROP_INT(FrameRate);
    GETCAMERAPROP_INT(GrayscaleDecimation);
    GETCAMERAPROP_INT(Intensity);
    GETCAMERAPROP_INT(PrecisionCap);
    GETCAMERAPROP_INT(ShutterDelay);
    GETCAMERAPROP_INT(Threshold);
    GETCAMERAPROP_STR(Name);
#undef GETCAMERAPROP_BOOL
#undef GETCAMERAPROP_INT
#undef GETCAMERAPROP_STR
  }
}
Beispiel #6
0
void videoUNICAP :: getProperties(gem::Properties&props) {
  if(!m_handle)return;
  unicap_status_t status=0;

  std::vector<std::string> keys=props.keys();

  bool getwidth=false, getheight=false;
  int i=0;
  for(i=0; i<keys.size(); i++) {
    std::string key=keys[i];
    unicap_property_t prop;
    strncpy(prop.identifier, key.c_str(), 128);

    if("width"==key) {
      getwidth=true;
      continue;
    }
    if("height"==key) {
      getheight=true;
      continue;
    }

    status= unicap_get_property(m_handle, &prop );

    if(SUCCESS(status)) {
      switch(prop.type) {
      case UNICAP_PROPERTY_TYPE_VALUE_LIST: 
      case UNICAP_PROPERTY_TYPE_FLAGS: 
      case UNICAP_PROPERTY_TYPE_RANGE: 
        props.set(key, prop.value);
        break;
      case UNICAP_PROPERTY_TYPE_MENU:
        props.set(key, std::string(prop.menu_item));
        break;
      default:
        props.erase(key);
        // ?
        break;
      }
    }
  }


  if(getwidth||getheight) {
    unicap_format_t fmt;
    status=unicap_get_format(m_handle, &fmt);
    post("getting dimen");post_fmt(&fmt);
    if(SUCCESS(status)) {
      if(getwidth )props.set("width" , fmt.size.width);
      if(getheight)props.set("height", fmt.size.height);
    }
  }


}
Beispiel #7
0
bool videoVFW :: enumProperties(gem::Properties&readable, gem::Properties&writeable) {
    readable.clear();
    writeable.clear();

    gem::any type=0;

    writeable.set("width", type);
    writeable.set("height", type);


    return true;
}
Beispiel #8
0
bool videoTEST::enumProperties(gem::Properties&readable,
			       gem::Properties&writeable) {
  readable.clear();
  writeable.clear();


  writeable.set("width", 64);  readable.set("width", 64);
  writeable.set("height", 64); readable.set("height", 64);

  writeable.set("type", std::string("noise"));
  return true;
}
Beispiel #9
0
bool videoVLC::enumProperties(gem::Properties&readable,
                              gem::Properties&writeable)
{
  readable.clear();
  writeable.clear();

  writeable.set("width",  m_pixBlock.image.xsize);
  readable.set("width",  m_pixBlock.image.xsize);
  writeable.set("height",  m_pixBlock.image.ysize);
  readable.set("height",  m_pixBlock.image.ysize);
  return false;
}
Beispiel #10
0
void videoDECKLINK::getProperties(gem::Properties&props)
{
  std::vector<std::string>keys=props.keys();
  unsigned int i;
  for(i=0; i<keys.size(); i++) {
    if("width"==keys[i]) {
      props.set(keys[i], m_pixBlock.image.xsize);
    }
    if("height"==keys[i]) {
      props.set(keys[i], m_pixBlock.image.ysize);
    }
  }
}
Beispiel #11
0
bool filmTEST::enumProperties(gem::Properties&readprops, gem::Properties&writeprops) {
  readprops.clear();
  writeprops.clear();

  double d=0;

  readprops.set("width", d);
  readprops.set("height", d);
  readprops.set("fps", d);
  readprops.set("frames", d);

  return true;
}
Beispiel #12
0
///////////////////////////////
// Properties
bool filmAVIPLAY::enumProperties(gem::Properties&readable,
                                 gem::Properties&writeable) {
    readable.clear();
    writeable.clear();

    gem::any value;
    value=0.;
    readable.set("fps", value);
    readable.set("frames", value);
    readable.set("width", value);
    readable.set("height", value);

    return false;
}
Beispiel #13
0
  bool initParameters_(void) {
    m_parameterNames.clear();
    m_parameter.clear();
    unsigned int count=getNumParameters_();
    unsigned int i;

    m_parameterNames.push_back(""); // dummy parameter
    for(i=0; i<count; i++) {
      std::string name=getParameterName_(i);
      FFUInt32 type = getParameterType_ (i);
      FFMixed def = getParameterDefault_(i);

      gem::any val;
      switch(type) {
      case FF_TYPE_EVENT:
        //?
        break;
      case FF_TYPE_TEXT:
        val = std::string(reinterpret_cast<const char*>(def.PointerValue));
        break;
      default:
        val = def.FloatValue;
      }
      std::cout << "param#"<<i<<": "<<name<<std::endl;
      m_parameterNames.push_back(name);
      m_parameter.set(name, val);
    }
    return true;
  }
Beispiel #14
0
///////////////////////////////
// Properties
bool filmQT4L::enumProperties(gem::Properties&readable,
			      gem::Properties&writeable) {
  readable.clear();
  writeable.clear();

  gem::any value;
  value=0.;
  readable.set("fps", value);
  readable.set("frames", value);
  readable.set("tracks", value);
  readable.set("width", value);
  readable.set("height", value);

  writeable.set("colorspace", value);

  return false;
}
Beispiel #15
0
bool videoDECKLINK::enumProperties(gem::Properties&readable,
                                   gem::Properties&writeable)
{
  std::string dummy_s;
  int dummy_i=0;
  readable.clear();
  writeable.clear();

  readable.set("width", m_pixBlock.image.xsize);
  readable.set("height", m_pixBlock.image.ysize);

  dummy_s="auto";
  writeable.set("format", dummy_s);
  writeable.set("connection", dummy_s);

  return true;
}
Beispiel #16
0
void imageBase :: getProperties(gem::Properties&props) {
    // nada
    std::vector<std::string>keys=props.keys();
    unsigned int i=0;
    for(i=0; i<keys.size(); i++) {
        gem::any unset;
        props.set(keys[i], unset);
    }
}
Beispiel #17
0
void imageMAGICK::getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props) {
    mimetypes.clear();
    props.clear();

    mimetypes = m_mimetypes;

    gem::any value;

    value=100.f;
    props.set("quality", value);
}
Beispiel #18
0
void imageJPEG::getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props) {
  mimetypes.clear();
  props.clear();

  mimetypes.push_back("image/jpeg");
  mimetypes.push_back("image/pjpeg");

  gem::any value;

  value=100.f;
  props.set("quality", value);
}
Beispiel #19
0
void imageTIFF::getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props) {
  mimetypes.clear();
  props.clear();

  mimetypes.push_back("image/tiff");
  mimetypes.push_back("image/x-tiff");

  gem::any value;


  value=72.f;
  props.set("xresolution", value);
  props.set("yresolution", value);

  value=std::string("inch");
  props.set("resolutionunit", value);
  value=std::string("PD/GEM");
  props.set("software", value);
  value=std::string("");
  props.set("artist", value);
  props.set("hostcomputer", value);
}
Beispiel #20
0
void imageQT::getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props) {
  mimetypes.clear();
  props.clear();

  std::map<std::string, OSType>::iterator it;
  for(it = s_mime2type.begin(); it!=s_mime2type.end(); ++it) {
    mimetypes.push_back(it->first);
  }

  gem::any value;

  value=100.f;
  props.set("quality", value);
}
Beispiel #21
0
  virtual void getProperties(gem::Properties&props) {
    std::vector<std::string> ids;
    if(props.type("backends")!=gem::Properties::UNSET) {
      unsigned int i;
      for(i=0; i<m_ids.size(); i++) {
        ids.push_back(m_ids[i]);
      }
    }
    props.erase("backends");

    if(m_handle)
      m_handle->getProperties(props);
    else
      props.clear();

    if(!ids.empty()) {
      props.set("backends", ids);
    }
  }
Beispiel #22
0
    virtual void getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props) {
      mimetypes.clear();
      props.clear();

      unsigned int i;
      for(i=0; i<m_savers.size(); i++) {
	unsigned int j;

	std::vector<std::string>mimetypes_;
	gem::Properties props_;
	m_savers[i]->getWriteCapabilities(mimetypes_, props_);

	for(j=0; j<mimetypes_.size(); j++) {
	  const std::string&mimetype=mimetypes_[j];
	  if(std::find(mimetypes.begin(), mimetypes.end(), mimetype)==mimetypes.end()) {
	    mimetypes.push_back(mimetypes_[j]);
	  }
	}
	std::vector<std::string>keys=props_.keys();
	for(j=0; j<keys.size(); j++) {
	  props.set(keys[j], props_.get(keys[j]));
	}
      }
    }
Beispiel #23
0
/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
bool imageTIFF :: load(std::string filename, imageStruct&result, gem::Properties&props)
{
  ::verbose(2, "reading '%s' with libTIFF", filename.c_str());
  TIFF *tif = TIFFOpen(filename.c_str(), "r");
  if (tif == NULL) {
      return(NULL);
    }

  uint32 width, height;
  short bits, samps;
  TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
  TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
  TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bits);
  TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samps);

  int npixels = width * height;

  result.xsize=width;
  result.ysize=height;
  result.upsidedown=true;
  result.type=GL_UNSIGNED_BYTE; //?

  bool knownFormat = false;
  // Is it a gray8 image?
  if (bits == 8 && samps == 1)
    {
      result.setCsizeByFormat(GL_LUMINANCE);
      knownFormat = true;
    }
  // Is it an RGB image?
  else if (bits == 8 && samps == 3)
    {
      result.setCsizeByFormat(GL_RGBA);
      knownFormat = true;
    }
  // Is it an RGBA image?
  else if (bits == 8 && samps == 4)
    {
      result.setCsizeByFormat(GL_RGBA);
      knownFormat = true;
    }

  // can we handle the raw data?
  if (knownFormat) {
    unsigned char *buf = new unsigned char [TIFFScanlineSize(tif)];
    if (buf == NULL) {
      error("GemImageLoad(TIFF): can't allocate memory for scanline buffer: %s", filename.c_str());
      TIFFClose(tif);
      return(false);
    }

    result.reallocate();
    unsigned char *dstLine = result.data;
    int yStride = result.xsize * result.csize;
    for (uint32 row = 0; row < height; row++)
      {
	unsigned char *pixels = dstLine;
	if (TIFFReadScanline(tif, buf, row, 0) < 0) {
	  error("GemImageLoad(TIFF): bad image data read on line: %d: %s", row, filename.c_str());
	  TIFFClose(tif);
	  return false;
	}
	unsigned char *inp = buf;
	if (samps == 1) {
	  for (uint32 i = 0; i < width; i++) {
	    *pixels++ = *inp++;         // Gray8
	  }
	}
	else if (samps == 3)  {
	  for (uint32 i = 0; i < width; i++) {
	    pixels[chRed]   = inp[0];   // Red
	    pixels[chGreen] = inp[1];   // Green
	    pixels[chBlue]  = inp[2];   // Blue
	    pixels[chAlpha] = 255;      // Alpha
	    pixels += 4;
	    inp += 3;
	  }
	} else {
	  for (uint32 i = 0; i < width; i++) {
	    pixels[chRed]   = inp[0];   // Red
	    pixels[chGreen] = inp[1];   // Green
	    pixels[chBlue]  = inp[2];   // Blue
	    pixels[chAlpha] = inp[3];   // Alpha
	    pixels += 4;
	    inp += 4;
	  }
	}
	dstLine += yStride;
      }
    delete [] buf;
  }
  // nope, so use the automatic conversion
  else {
    char emsg[1024];
    TIFFRGBAImage img;
    if (TIFFRGBAImageBegin(&img, tif, 0, emsg) == 0) {
      //error("GemImageLoad(TIFF): Error reading in image file: %s : %s", filename, emsg);
      TIFFClose(tif);
      return(false);
    }

    uint32*raster = reinterpret_cast<uint32*>(_TIFFmalloc(npixels * sizeof(uint32)));
    if (raster == NULL) {
      error("GemImageLoad(TIFF): Unable to allocate memory for image: %s", filename.c_str());
      TIFFClose(tif);
      return(false);
    }

    if (TIFFRGBAImageGet(&img, raster, width, height) == 0) {
      //error("GemImageLoad(TIFF): Error getting image data in file: %s, %s", filename, emsg);
      _TIFFfree(raster);
      TIFFClose(tif);
      return(false);
    }

    TIFFRGBAImageEnd(&img);
    result.setCsizeByFormat(GL_RGBA);
    result.reallocate();

    unsigned char *dstLine = result.data;
    int yStride = result.xsize * result.csize;
    // transfer everything over
    int k = 0;
    for (uint32 i = 0; i < height; i++) {
      unsigned char *pixels = dstLine;
      for (uint32 j = 0; j < width; j++) {
	pixels[chRed]   = static_cast<unsigned char>(TIFFGetR(raster[k])); // Red
	pixels[chGreen] = static_cast<unsigned char>(TIFFGetG(raster[k])); // Green
	pixels[chBlue]  = static_cast<unsigned char>(TIFFGetB(raster[k])); // Blue
	pixels[chAlpha] = static_cast<unsigned char>(TIFFGetA(raster[k])); // Alpha
	k++;
	pixels += 4;
      }
      dstLine += yStride;
    }
    _TIFFfree(raster);
  }


  double value_d;
  short value_i16;
  char value_s[MAXPDSTRING];
  if(TIFFGetField(tif, TIFFTAG_XRESOLUTION, &value_d)) props.set("xresolution", value_d);
  if(TIFFGetField(tif, TIFFTAG_YRESOLUTION, &value_d)) props.set("yresolution", value_d);
  if(TIFFGetField(tif, TIFFTAG_XRESOLUTION, &value_d)) props.set("xresolution", value_d);
  if(TIFFGetField(tif, TIFFTAG_RESOLUTIONUNIT, &value_i16)) {
    std::string resunit;
    switch(value_i16) {
    case RESUNIT_INCH:
      resunit="inch";
      break;
    case RESUNIT_CENTIMETER:
      resunit="centimeter";
      break;
    default:
      resunit="none";
      break;
    }
    props.set("resolutionunit", resunit);
  }
  if(TIFFGetField(tif, TIFFTAG_SOFTWARE, &value_s)) props.set("software", std::string(value_s));
  if(TIFFGetField(tif, TIFFTAG_ARTIST, &value_s)) props.set("artist", std::string(value_s));
  if(TIFFGetField(tif, TIFFTAG_HOSTCOMPUTER, &value_s)) props.set("hostcomputer", std::string(value_s));

  TIFFClose(tif);
  return true;
}
Beispiel #24
0
bool videoOptiTrack::enumProperties(gem::Properties&readable,
                                    gem::Properties&writeable)
{
  readable.clear();
  writeable.clear();

  writeable.set("width",  m_pixBlock.image.xsize);
  readable.set("width",  m_pixBlock.image.xsize);
  writeable.set("height",  m_pixBlock.image.ysize);
  readable.set("height",  m_pixBlock.image.ysize);

#define SETCAMERAPROP_BOOL(name) writeable.set(#name, 1);
#define SETCAMERAPROP_INT(name)  writeable.set(#name, 1);
#define SETCAMERAPROP_STR(name)  writeable.set(#name, std::string(""));
  SETCAMERAPROP_BOOL(AEC);
  SETCAMERAPROP_BOOL(AGC);
  SETCAMERAPROP_BOOL(ContinuousIR);
  SETCAMERAPROP_BOOL(EnableBlockingMask);
  SETCAMERAPROP_BOOL(HighPowerMode);
  SETCAMERAPROP_BOOL(IRFilter);
  SETCAMERAPROP_BOOL(MarkerOverlay);
  SETCAMERAPROP_BOOL(TextOverlay);
  SETCAMERAPROP_INT(Exposure);
  SETCAMERAPROP_INT(FrameDecimation);
  SETCAMERAPROP_INT(FrameRate);
  SETCAMERAPROP_INT(GrayscaleDecimation);
  SETCAMERAPROP_INT(Intensity);
  SETCAMERAPROP_INT(PrecisionCap);
  SETCAMERAPROP_INT(ShutterDelay);
  SETCAMERAPROP_INT(StatusIntensity);
  SETCAMERAPROP_INT(Threshold);
  SETCAMERAPROP_STR(Name);
#undef SETCAMERAPROP_BOOL
#undef SETCAMERAPROP_INT
#undef SETCAMERAPROP_STR

#define GETCAMERAPROP_BOOL(name) readable.set(#name, 1);
#define GETCAMERAPROP_INT(name)  readable.set(#name, 0);
#define GETCAMERAPROP_FLT(name)  readable.set(#name, 0);
#define GETCAMERAPROP_STR(name)  readable.set(#name, std::string(""));
  GETCAMERAPROP_BOOL(AEC);
  GETCAMERAPROP_BOOL(AGC);
  GETCAMERAPROP_BOOL(ContinuousIR);
  GETCAMERAPROP_BOOL(HighPowerMode);
  GETCAMERAPROP_BOOL(IRFilter);
  GETCAMERAPROP_BOOL(MarkerOverlay);
  GETCAMERAPROP_BOOL(TextOverlay);
  GETCAMERAPROP_INT(Exposure);
  GETCAMERAPROP_INT(FrameDecimation);
  GETCAMERAPROP_INT(FrameRate);
  GETCAMERAPROP_INT(GrayscaleDecimation);
  GETCAMERAPROP_INT(Intensity);
  GETCAMERAPROP_INT(PrecisionCap);
  GETCAMERAPROP_INT(ShutterDelay);
  GETCAMERAPROP_INT(Threshold);
  GETCAMERAPROP_FLT(fanspeed);
  GETCAMERAPROP_FLT(temperature);
  GETCAMERAPROP_STR(Name);
#undef GETCAMERAPROP_BOOL
#undef GETCAMERAPROP_INT
#undef GETCAMERAPROP_STR

  return true;
}