Exemplo n.º 1
0
    void buildFrame(void* data, uint32_t timestamp)
    {
      if (!running)
        return;

      OniFrame* frame = getServices().acquireFrame();
      frame->frameIndex = frame_id++;
      frame->videoMode = video_mode;
      frame->width = video_mode.resolutionX;
      frame->height = video_mode.resolutionY;

      // Handle overflow, input timestamp comes from a 60MHz clock and overflows
      // in ~70s
      if (timestamp < prev_timestamp)
      {
        uint32_t prev_int = static_cast<uint32_t>(prev_timestamp);
        uint64_t temp_delta = std::abs(timestamp - prev_int);
        prev_timestamp += temp_delta;
      } else {
        prev_timestamp = timestamp;
      }

      // OpenNI wants the value in microseconds
      frame->timestamp = prev_timestamp / 60;

      populateFrame(data, frame);
      raiseNewFrame(frame);
      getServices().releaseFrame(frame);
    }
Exemplo n.º 2
0
    bool buildFrame(libfreenect2::Frame* lf2Frame)
    {
      if (!running)
        return false;

      OniFrame* oniFrame = getServices().acquireFrame();
      oniFrame->frameIndex = frame_id++;
      oniFrame->timestamp = lf2Frame->timestamp;
      oniFrame->videoMode = video_mode;
      oniFrame->width = video_mode.resolutionX;
      oniFrame->height = video_mode.resolutionY;

      if (cropping.enabled)
      {
        oniFrame->height = cropping.height;
        oniFrame->width = cropping.width;
        oniFrame->cropOriginX = cropping.originX;
        oniFrame->cropOriginY = cropping.originY;
        oniFrame->croppingEnabled = true;
      }
      else
      {
        oniFrame->cropOriginX = 0;
        oniFrame->cropOriginY = 0;
        oniFrame->croppingEnabled = false;
      }
      int width = std::min(oniFrame->width, (int)lf2Frame->width);
      int height = std::min(oniFrame->height, (int)lf2Frame->height);

      populateFrame(lf2Frame, oniFrame->cropOriginX, oniFrame->cropOriginY, oniFrame, 0, 0, width, height);
      raiseNewFrame(oniFrame);
      getServices().releaseFrame(oniFrame);

      return false;
    }
    void buildFrame(void* data, uint32_t timestamp) {
      if (!running)
        return;     

      OniFrame* frame = getServices().acquireFrame();
      frame->frameIndex = frame_id++;
      frame->timestamp = timestamp;
      frame->videoMode = video_mode;
      frame->width = video_mode.resolutionX;
      frame->height = video_mode.resolutionY;
      
      populateFrame(data, frame);
      raiseNewFrame(frame);
      getServices().releaseFrame(frame);
    }