Ejemplo n.º 1
0
void STWarp<T>::setVideos(const Video<stwarp_video_t> &A, const Video<stwarp_video_t> &B) {
    videoA = new Video<stwarp_video_t>(A);
    videoB = new Video<stwarp_video_t>(B);

    if(videoA->getHeight()!= videoB->getHeight() ||
        videoA->getWidth() != videoB->getWidth() ||
        videoA->frameCount() != videoB->frameCount()){
        if(params.verbosity >0) {
            fprintf(stderr, "Dimensions do not match\n");
        }
    }

    int chan = 3;

    // Use gradient features (requires color)
    if(params.useColor && params.useFeatures) {
        if(params.verbosity > 0) {
            cout << "+ Adding gradient features" << endl;
        }
        videoA->addChannels(3);
        videoB->addChannels(3);

        Video<T> copyA(videoA->size());
        Video<T> copyB(videoA->size());
        copyA.copy(*videoA);
        copyB.copy(*videoB);
        copyA.collapse();
        copyB.collapse();
        Video<T> temp(copyA.size());

        VideoProcessing::dx(copyA, temp);
        videoA->writeChannel(chan, temp);

        VideoProcessing::dy(copyA, temp);
        videoA->writeChannel(chan+1, temp);

        VideoProcessing::dt(copyA, temp);
        videoA->writeChannel(chan+2, temp);

        VideoProcessing::dx(copyB, temp);
        videoB->writeChannel(chan, temp);

        VideoProcessing::dy(copyB, temp);
        videoB->writeChannel(chan+1, temp);

        VideoProcessing::dt(copyB, temp);
        videoB->writeChannel(chan+2, temp);
    }

    // TODO: nullptr
    VideoSize sz  = videoA->size();
    dimensions[0] = sz.height;
    dimensions[1] = sz.width;
    dimensions[2] = sz.nFrames;
    dimensions[3] = sz.nChannels;

    if(params.verbosity > 0) {
        printf("done.\n");
    }
}
Ejemplo n.º 2
0
bool solveLinear(const DMatZZpFFPACK& A,
                 const DMatZZpFFPACK& B,
                 bool right_side,
                 DMatZZpFFPACK& X,
                 bool declare_A_is_invertible)  // this parameter is unused
{
  //    std::cerr << "inside FFpackSolveLinear" << std::endl;

  size_t a_rows = A.numRows();
  size_t a_cols = A.numColumns();

  size_t b_rows = B.numRows();
  size_t b_cols = B.numColumns();

  DMatZZpFFPACK copyA(A);
  DMatZZpFFPACK copyB(B);

  // preallocate the space for the solutions:
  size_t x_rows = (right_side ? a_cols : b_rows);
  size_t x_cols = (right_side ? b_cols : a_rows);

  X.resize(x_rows, x_cols);  // sets it to 0 too.

  int info = 0;  // >0 if the system is inconsistent, ==0 means success

  FFPACK::fgesv(A.ring().field(),
                (right_side ? FFLAS::FflasLeft : FFLAS::FflasRight),
                a_rows,
                a_cols,
                (right_side ? b_cols : b_rows),
                copyA.array(),
                a_cols,  // leading dim of A
                X.array(),
                x_cols,
                copyB.array(),
                b_cols,
                &info);

  if (info > 0)
    {
      // the system is inconsistent
      return false;
    }

  return true;
}