Example #1
0
Eigen::Vector3d getSubPx(const cv::Mat & M, const double x, const double y)
{
    const int nx_lo = intFloor(x);
    const int nx_hi = nx_lo + 1;

    const double x_lo = (double) nx_lo;

    double dWeightHi = x - x_lo;
    double dWeightLo = 1 - dWeightHi;

    if(IS_DEBUG) CHECK(dWeightHi < 0 || dWeightHi > 1, "Weight OOB");
    if(IS_DEBUG) CHECK(dWeightLo < 0 || dWeightLo > 1, "Weight OOB");

    return dWeightLo * getSubPx_intx(M, nx_lo, y) + dWeightHi * getSubPx_intx(M, nx_hi, y);
}
Example #2
0
Eigen::Vector3d getSubPx_intx(const cv::Mat & M, const int nx, const double y)
{
    const int ny_lo = intFloor(y);
    const int ny_hi = ny_lo + 1;

    const double y_lo = (double) ny_lo;

    if(IS_DEBUG) CHECK(y_lo > y, "floor failed");

    double dWeightHi = y - y_lo;
    double dWeightLo = 1 - dWeightHi;

    if(IS_DEBUG) CHECK(dWeightHi < 0 || dWeightHi > 1, "Weight OOB");
    if(IS_DEBUG) CHECK(dWeightLo < 0 || dWeightLo > 1, "Weight OOB");

    return dWeightLo * getPx(M, nx, ny_lo) + dWeightHi * getPx(M, nx, ny_hi);
}
Example #3
0
void VibratoTimeAxis::paintEvent( QPaintEvent * )
{
  beginDrawing(false);

  fillBackground(colorGroup().background());

  doUpdate();

  if (currentChunkToUse >= 0) {
    QFontMetrics fm = p.fontMetrics();
    QString s;
    p.setBrush(Qt::black);
    p.setFont(QFont("AnyStyle", 12));

    int polyLengthInPixels = toInt((endChunkToUse - startChunkToUse) * zoomFactorX);
    float pixelsPerSecond = polyLengthInPixels / noteLengthToUse;
    int notchesDivider = 2;
    double secondsPerNotch = 5;
    int calculationStep = 1;

    // Calculate which notches and labels to draw
    for (int pixelsPerSecondThreshold = 25; ;pixelsPerSecondThreshold *= 2) {
      if (pixelsPerSecond < pixelsPerSecondThreshold) {
        break;
      } else {
        switch (calculationStep) {
          case 1:
            notchesDivider = 5;
            secondsPerNotch /= 5;
            calculationStep = 2;
            break;
          case 2:
            notchesDivider = 2;
            secondsPerNotch = secondsPerNotch;
            calculationStep = 3;
            break;
          case 3:
            notchesDivider = 2;
            secondsPerNotch /= 2;
            calculationStep = 1;
            break;
        }
      }
    }

    // Draw the notches + labels
    for (int i = 0; i < (noteLengthToUse / secondsPerNotch); i++) {
      int x = toInt((((endChunkToUse - startChunkToUse) * zoomFactorX) / noteLengthToUse) * i * secondsPerNotch - windowOffsetToUse);
      if ((x >= 0) && (x < width())) {
        if (i % notchesDivider == 0) {  // Even: bigger notch + label
          p.drawLine(x, height()-6, x, height()-1);
          // The 1.000001 factors in the following statements prevent freaky rounding/floor errors...
          int minutes = intFloor(i*secondsPerNotch*1.000001) / 60;
          int seconds = intFloor(i*secondsPerNotch*1.000001) % 60;
          int thousandthseconds = intFloor(1000*i*secondsPerNotch*1.000001) % 1000;
          if (thousandthseconds == 0) {  // Label: m:ss
            s.sprintf("%1d:%02d", minutes, seconds);
          } else if (thousandthseconds % 100 == 0) {  // Label: m:ss.h
            s.sprintf("%1d:%02d.%01d", minutes, seconds, thousandthseconds / 100);
          } else if (thousandthseconds % 10 == 0) {  // Label: m:ss.hh
            s.sprintf("%1d:%02d.%02d", minutes, seconds, thousandthseconds / 10);
          } else {  // Label: m:ss.hhh
            s.sprintf("%1d:%02d.%03d", minutes, seconds, thousandthseconds);
          }
          p.drawText(x - fm.width(s)/2, 12, s);
          } else {  // Odd: smaller notch
          p.drawLine(x, height()-3, x, height()-1);
        }
      }
    }

    // Draw the horizontal line at the bottom of the axis
    p.drawLine(0, height()-1, width(), height()-1);
  }
  endDrawing();
}