void ofxNUIWidgetNode::updateSuperCanvasPosition()
{
    if (!getCam()) { return; }
    ofVec2f current = getCam()->worldToScreen(
                getPosition()+ofVec3f(getNodeRadius(),-getNodeRadius()/2.0f,0) );
    getCanvas()->setPosition(current.x, current.y);
}
示例#2
0
 void
 copyCam( ::pcl::visualization::PCLVisualizer::Ptr from,
          ::pcl::visualization::PCLVisualizer::Ptr to )
 {
     Eigen::Vector3d pos, up, dir;
     getCam( pos, up, dir, from );
     setCam( pos, up, dir, to );
 }
示例#3
0
bool UCamPool::findDevices()
{
  UCamDevBase * testDev = NULL;
  UCamPush * testCam = NULL;
  int i;
  const int MKL = 30;
  char key[MKL];
  const int MSL = 130;
  char s[MSL];
  const char * posName = "none";
  UPosition pos;
  URotation rot;
  UComCam settings;
  int panPos, tiltPos;
  UVarPool * vpd, vpnew;
  enum UCamType {USB, REPLAY, IEEE1394, GIGE, GRABBER};
  UCamType camType;
  //
  lock();
  camType = USB;
  for (i = 0; i < MAX_MOUNTED_CAMERAS; i++)
  { // test if device with this number is known already
    switch (camType)
    { // set new device number within allocated number range
      case REPLAY:
        if (i < FIRST_REPLAY_DEVICE_NUMBER)
          i = FIRST_REPLAY_DEVICE_NUMBER;
        break;
      case IEEE1394:
        if (i < FIRST_IEEE1394_DEVICE_NUMBER)
          i = FIRST_IEEE1394_DEVICE_NUMBER;
        break;
      case GIGE:
        if (i < FIRST_GIGE_DEVICE_NUMBER)
          i = FIRST_GIGE_DEVICE_NUMBER;
        break;
      case GRABBER:
        if (i < FIRST_GRABBER_DEVICE_NUMBER)
          i = FIRST_GRABBER_DEVICE_NUMBER;
        break;
      default:
        break;
    }
    // is this device number available already
    testCam = getCam(i);
    if (testCam == NULL)
    { // not known to exist, so try make a new camera device
      switch (camType)
      { // need new structure
        case USB:
          testDev = new UCamPwc();
          break;
        case REPLAY:
          testDev = new UCamDevReplay();
          break;
        case IEEE1394:
#ifdef USE_GUPPY
            testDev = new UCamDevGuppy();
#else
            testDev = new UCamDevIeee1394();
#endif
          break;
        case GIGE:
          testDev = new UCamDevGigE();
          break;
        case GRABBER:
          testDev = new UCamDevGrabber();
          break;
        default: break;
      }
      //
      if (testDev == NULL)
      {
        if (camType >= GRABBER)
          break;
        // continue with next type
        camType = UCamType(camType + 1);
        continue;
      }
      // camera is not set before, so test
      testDev->setDeviceNumber(i);
      if (testDev->deviceExist())
      { // try open this device number
        testDev->openDeviceDefault();
      }
      if (not testDev->isCameraOpen())
        // no such camera type - advance to next
        camType = UCamType(camType + 1);
      else
      { // camera can be opened - register
        // debug print
        // printf("New device %d : %s\n", i, testDev->getCameraName());
        // debug end
        if (true)
        { // create a camera for the device
          testCam = new UCamPush(testDev);
          // allow push commands
          testCam->setCmdExe(cmdExe);
          // set image logger
          testCam->setImageLogging(imageLog);
          // get default lens and position data from camera type
          snprintf(key, MKL, "device%d", i);
          // load relevant settings to camera structure.
          settings.setFromCam(testDev, true, true);
          vpd = getVarPool()->getStruct(key);
          if (vpd == NULL)
          {
            snprintf(s, MSL, "a %s camera device", testDev->getCameraName());
            vpd = addStruct(key, s, true);
            if (vpd == NULL)
              printf("Failed to make global variable structure for camera\n");
          }
          if (vpd != NULL)
            testCam->setVarPool(vpd);
          //vpd->addVar("open", 0.0, "d", "is device open");
          //vpd->addVar("imageCnt", 0.0, "d", "number of images fetched");
          // set also pan-tilt position
          if (i < 7 and testCam->setPantiltStatus())
          { // reset to home
            testCam->pantiltToHomePosition();
            panPos = 0; // ini.intGet(posName, "panPos", 0);
            tiltPos = 0; //ini.intGet(posName, "tiltPos", 0);
            // debug
            // printf("Cam %s 1 pan %d, tilt %d\n", posName,
            //       testCam->getPanPos(), testCam->getTiltPos());
            // debug end
            if ((panPos != 0) or (tiltPos != 0))
            {
              Wait(3.5);
              testCam->pantiltSetPosition(false, panPos, tiltPos);
              // debug
              printf("Cam %s 2 pan %d, tilt %d\n", posName,
                    testCam->getPanPos(), testCam->getTiltPos());
              // debug end
            }
          }
        }
        testDev->closeDevice();
        testDev->setInitialized(true);
        // put in pool
        // set device list
        varCams->setInt(i, camCnt, true);
        cam[camCnt++] = testCam;
        varCamsCnt->setInt(camCnt);
        testDev = NULL;
      }
      if (testDev != NULL)
      {
        delete testDev;
        testDev = NULL;
      }
    }
  }
  //
  //
  unlock();
  if (verboseMessages)
    print("Cams:");
  //
  return camCnt > 0;
}
示例#4
0
UCamPush * UCamPool::makeDevice(int devNum, const char * posName)
{
  bool result = true;
  UCamPush * testCam = NULL;
  int n;
  //Uconfig ini;
  UCamDevBase * dev = NULL;
  UVarPool * vpd;
  const int MKL = 30;
  char key[MKL];
  const int MSL = 100;
  char s[MSL];
  //
  lock();
  //ini.clear();
  // read camera configuration from config-file
  //err = ini.readConfig(configFileCam);
  //result = (err == 0);
  //
  if (posName != NULL)
  {
    testCam = getCam(posName);
    if (testCam != NULL)
    {
      n = testCam->getDev()->getDeviceNumber();
      if (n != devNum)
        printf("Device name error failed to make new device %s (%d) but with number %d!\n",posName, n, devNum);
      result = false;
    }
  }
  if (result)
  {
    testCam = getCam(devNum);
    result = (testCam == NULL);
    if (not result)
    { // camera known already
      printf("Trying to create a known device - device %d %s exists already!\n",
             devNum, testCam->getDev()->getCameraName());
    }
  }
  if (result and (camCnt < MAX_MOUNTED_CAMERAS))
  { // make new camera of type specified by device number
    if (devNum < 7)
      dev = new UCamPwc();
    else if (devNum < 10)
      dev = new UCamDevReplay();
    else if (devNum < 14)
#ifdef USE_GUPPY
      dev = new UCamDevGuppy();
#else
      dev = new UCamDevIeee1394();
#endif
    else if (devNum < FIRST_GRABBER_DEVICE_NUMBER)
      dev = new UCamDevGigE();
    else if (devNum < FIRST_USERCAM_DEVICE_NUMBER)
      dev = new UCamDevGrabber();
    else
      dev = new UCamDevReplay();
    dev->setDeviceNumber(devNum);
    if (not dev->deviceExist())
    {
      if (not dev->isThisA(UCamDevBase::CAM_DEV_REPLAY))
      { // not a real device, so make a replay device
        delete dev;
        dev = new UCamDevReplay();
        dev->setDeviceNumber(devNum);
      }
    }
    testCam = new UCamPush(dev);
    result = (testCam != NULL);
  }