Example #1
0
void imageBase :: setProperties(gem::Properties&props) {
    // nada
    m_properties=props;
#if 0
    std::vector<std::string> keys=props.keys();
    int i=0;
    for(i=0; i<keys.size(); i++) {
        enum gem::Properties::PropertyType typ=props.type(keys[i]);
        std::cerr  << "key["<<keys[i]<<"]: "<<typ<<" :: ";
        switch(typ) {
        case (gem::Properties::NONE):
            props.erase(keys[i]);
            break;
        case (gem::Properties::DOUBLE):
            std::cerr << gem::any_cast<double>(props.get(keys[i]));
            break;
        case (gem::Properties::STRING):
            std::cerr << "'" << gem::any_cast<std::string>(props.get(keys[i])) << "'";
            break;
        default:
            std::cerr << "<unknown:" << props.get(keys[i]).get_type().name() << ">";
            break;
        }
    }
    std::cerr << std::endl;
#endif
}
Example #2
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);
    }
  }
}
Example #3
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);
    }
}
Example #4
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
  }
}
Example #5
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);
    }
  }


}
Example #6
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);
    }
  }
}
Example #7
0
void modelASSIMP3 :: setProperties(gem::Properties&props) {
  double d;

#if 0
  std::vector<std::string>keys=props.keys();
  unsigned int i;
  for(i=0; i<keys.size(); i++) {
    post("key[%d]=%s ... %d", i, keys[i].c_str(), props.type(keys[i]));
  }
#endif

  std::string s;
  if(props.get("textype", s)) {
    // if there are NO texcoords, we only accept 'linear' and 'spheremap'
    // else, we also allow 'UV'
    // not-accepted textype, simply use the last one
    if(m_have_texcoords && "UV" == s)
      m_textype = "";
    else
    if(("linear" == s) || ("spheremap" == s))
      m_textype = s;
    m_rebuild = true;
  }

  if(props.get("rescale", d)) {
    bool b=(bool)d;
    if(b) {
      float tmp;
      tmp = m_max.x-m_min.x;
      tmp = aisgl_max(m_max.y - m_min.y,tmp);
      tmp = aisgl_max(m_max.z - m_min.z,tmp);
      m_scale = 2.f / tmp;

      m_offset.x=-m_center.x;
      m_offset.y=-m_center.y;
      m_offset.z=-m_center.z;
    } else {
      // FIXXME shouldn't this be the default???
      m_scale=1.;
      m_offset.x=m_offset.y=m_offset.z=0.f;
    }
  }
  if(props.get("usematerials", d)) {
    bool useMaterial=d;
    if(useMaterial!=m_useMaterial)
      m_rebuild=true;
    m_useMaterial=useMaterial;
  }

  render();
}
Example #8
0
void filmTEST::getProperties(gem::Properties&props) {
  std::vector<std::string> keys=props.keys();
  unsigned int i=0;
  for(i=0; i<keys.size(); i++) {
    std::string key=keys[i];
    props.erase(key);
#define SETPROP(k, v) } else if(k == key) { double d=(double)v; props.set(key, v)
    if(""==key) {
      SETPROP("fps", m_fps);
      SETPROP("frames", m_numFrames);
      SETPROP("width", m_image.image.xsize);
      SETPROP("height", m_image.image.ysize);
    }
  }
}
Example #9
0
bool videoVLC::open(gem::Properties&props)
{
  if(m_mediaplayer) {
    close();
  }
  m_pixBlock.image.xsize=0;
  m_pixBlock.image.ysize=0;

  setProperties(props);


  if(m_devname.empty()) {
    return false;
  }

  libvlc_media_t*media = libvlc_media_new_location (m_instance,
                         m_devname.c_str());
  if(!media) {
    media = libvlc_media_new_path (m_instance, m_devname.c_str());
  }

  if(!media) {
    return false;
  }

  char buf[MAXVLCSTRING];

  libvlc_media_add_option(media,":noaudio");
  libvlc_media_add_option(media,":no-video-title-show");


  int w=m_pixBlock.image.xsize;
  int h=m_pixBlock.image.ysize;


  std::vector<std::string>keys=props.keys();
  unsigned int i;
  for(i=0; i<keys.size(); i++) {
    std::string key=keys[i];
    double d;
    std::string s;
    buf[0]=0;
    if(0) {}
    else if("width"==key) {
      if(props.get(key, d)&&(d>0)) {
        w=d;
      }
    } else if("height"==key) {
      if(props.get(key, d)&&(d>0)) {
        h=d;
      }
    } else {
      gem::Properties::PropertyType type = props.type(key);
      switch(type) {
      case gem::Properties::NONE:
        snprintf(buf, MAXVLCSTRING, ":%s", key.c_str());
        break;
      case gem::Properties::DOUBLE:
        if(props.get(key, d)) {
          snprintf(buf, MAXVLCSTRING, ":%s=%g", key.c_str(), d);
        }
        break;
      case gem::Properties::STRING:
        if(props.get(key, s)) {
          /* need to find an option that actually takes strings, so i can test this with spaces */
          snprintf(buf, MAXVLCSTRING, ":%s=%s", key.c_str(), s.c_str());
        }
        break;
      default:
        break;
      }
      if(0!=buf[0]) {
        buf[MAXVLCSTRING-1]=0;
        libvlc_media_add_option(media,buf);
      }
    }

  }
  resize(w,h,0);
  m_pixBlock.image.setWhite();

  m_mediaplayer=libvlc_media_player_new_from_media(media);
  libvlc_media_release(media);

  /* helper classes to register callbacks */
  struct _callbackObj {
    static void*lock(void*opaque, void**plane )
    {
      videoVLC*obj=(videoVLC*)opaque;
      if(obj) {
        return obj->lockFrame(plane);
      }
      return NULL;
    }
    static void unlock(void*opaque, void*picture, void*const*plane)
    {
      videoVLC*obj=(videoVLC*)opaque;
      if(obj) {
        obj->unlockFrame(picture, plane);
      }
    }
    static void display(void*opaque, void*picture)
    {
      videoVLC*obj=(videoVLC*)opaque;
    }
    _callbackObj(videoVLC*data)
    {
      libvlc_video_set_callbacks(data->m_mediaplayer,
                                 lock,
                                 unlock,
                                 NULL,
                                 data);
    }
  };
  struct _formatCallbackObj {
    static unsigned format(void**opaque, char *chroma, unsigned *width,
                           unsigned *height, unsigned *pitches, unsigned *lines)
    {
      videoVLC**objptr=(videoVLC**)opaque;
      if(objptr && *objptr) {
        return (*objptr)->setFormat(chroma, *width, *height, *pitches, *lines);
      }
      return 0;
    }
    _formatCallbackObj(videoVLC*data)
    {
      libvlc_video_set_format_callbacks(data->m_mediaplayer,
                                        format,
                                        NULL
                                       );

    }
  };
  /* instantiate helper-classes (which registers callbacks) */
  _callbackObj(this);
  _formatCallbackObj(this);

  return true;
}
Example #10
0
void videoUNICAP :: setProperties(gem::Properties&props) {
  m_props=props;
  debugPost("handle=%p", m_handle);
  if(!m_handle)
    return;

  unicap_status_t status = 0;
  bool restart=false;

  unsigned int width=0, height=0;

  std::vector<std::string> keys=props.keys();
  int i=0;
  for(i=0; i<keys.size(); i++) {
    std::string key=keys[i];

    double d=0;
    std::string s;


    if(("width"==key) && props.get(key, d)) {
      width=d;
      if(m_width!=width) {
        m_width=width;
        restart=true;
      }
      continue;
    }
    if(("height"==key) && props.get(key, d)) {
      height=d;
      if(m_height!=height) {
        m_height=height;
        restart=true;
      }
      continue;
    }

    unicap_property_t prop;
    strncpy(prop.identifier, key.c_str(), 128);
    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: 
        if(props.get(key, d)) {
          prop.value=d;
          status= unicap_set_property(m_handle, &prop );
        }
        break;
      case UNICAP_PROPERTY_TYPE_MENU:
        if(props.get(key, d)) {
          if(d>=0 && d < prop.menu.menu_item_count) {
            int i=d;
            /* unfortunately we must use the symbolic value and cannot simply set using the index... */
            strncpy(prop.menu_item, prop.menu.menu_items[i], 128);
            status= unicap_set_property(m_handle, &prop );
          }
        } else if (props.get(key, s)) {
          strncpy(prop.menu_item, s.c_str(), 128);
          status= unicap_set_property(m_handle, &prop );
        }
        break;
      default:
        // ?
        break;
      }
      
      if(!SUCCESS(status)) {
        verbose(1, "could not set property '%s'", key.c_str());
#if 0
      } else {
        verbose(1, "successfully set property '%s'", key.c_str());
#endif
      }
    }
  }

  while(restart) { restart=false;
    debugPost("restarting stream due to property change");
    bool running=stop();
    debugPost("running=%d", running);
    if (running)start();
  }
}
Example #11
0
void videoDECKLINK::setProperties(gem::Properties&props)
{
  std::vector<std::string>keys=props.keys();
  int i=0;
  for(i=0; i<keys.size(); i++) {
    const std::string key =keys[i];
    if("format" == key) {
      std::string s;
      double d;
      switch(props.type(key)) {
      case gem::Properties::STRING:
        if(props.get(key, s)) {
          m_formatnum =-1;
          m_formatname=s;
        }
        break;
      case gem::Properties::DOUBLE:
        if(props.get(key, d)) {
          m_formatnum =(int)d;
          m_formatname="";
        }
        break;
      }
    }
    if("connection" == key) {
      BMDVideoConnection vconn = m_connectionType;
      std::string s;
      double d;
      switch(props.type(key)) {
      case gem::Properties::STRING:
        if(props.get(key, s)) {
          if      ("SDI"        == s) {
            vconn=bmdVideoConnectionSDI;
          } else if ("HDMI"       == s) {
            vconn=bmdVideoConnectionHDMI;
          } else if ("OpticalSDI" == s) {
            vconn=bmdVideoConnectionOpticalSDI;
          } else if ("Component"  == s) {
            vconn=bmdVideoConnectionComponent;
          } else if ("Composite"  == s) {
            vconn=bmdVideoConnectionComposite;
          } else if ("SVideo"     == s) {
            vconn=bmdVideoConnectionSVideo;
          }
        }
        break;
      case gem::Properties::DOUBLE:
        if(props.get(key, d)) {
          int idx =(int)d;
          switch(idx) {
          default:
          case 0:
            vconn=bmdVideoConnectionSDI;
            break;
          case 1:
            vconn=bmdVideoConnectionHDMI;
            break;
          case 2:
            vconn=bmdVideoConnectionOpticalSDI;
            break;
          case 3:
            vconn=bmdVideoConnectionComponent;
            break;
          case 4:
            vconn=bmdVideoConnectionComposite;
            break;
          case 5:
            vconn=bmdVideoConnectionSVideo;
            break;
          }
        }
        break;
      }
      if(m_dlConfig && (m_connectionType != vconn)) {
        m_dlConfig->SetInt(bmdDeckLinkConfigVideoInputConnection, vconn);
      }
      m_connectionType = vconn;
    }
  }
  m_props=props;
}