本文整理汇总了C++中Frame::Columns方法的典型用法代码示例。如果您正苦于以下问题:C++ Frame::Columns方法的具体用法?C++ Frame::Columns怎么用?C++ Frame::Columns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frame
的用法示例。
在下文中一共展示了Frame::Columns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SmoothFrame
void LucasKanade::SmoothFrame(int index) {
Frame* frame = frames[index];
int rows = frame->Rows();
int cols = frame->Columns();
// x-Spatial Smoothing
int* pixels = new int[kSpatialSmoothSize];
for (int i = 0; i < rows; ++i) {
int pix_sum = 0, this_pix;
std::fill(pixels, pixels + kSpatialSmoothSize, 0);
for (int j = 0; j < cols; ++j) {
this_pix = frame->GetPixel(i, j);
pix_sum += this_pix - pixels[j % kSpatialSmoothSize];
pixels[j % kSpatialSmoothSize] = this_pix;
this_pix = static_cast<double>(pix_sum) / std::min(kSpatialSmoothSize, j + 1);
frame->SetPixel(i, j, this_pix);
}
}
// y-Spatial Smoothing
for (int i = 0; i < frame->Columns(); ++i) {
int pix_sum = 0, this_pix;
std::fill(pixels, pixels + kSpatialSmoothSize, 0);
for (int j = 0; j < frame->Rows(); ++j) {
this_pix = frame->GetPixel(j, i);
pix_sum += this_pix - pixels[j % kSpatialSmoothSize];
pixels[j % kSpatialSmoothSize] = this_pix;
this_pix = static_cast<double>(pix_sum) / std::min(kSpatialSmoothSize, j + 1);
frame->SetPixel(j, i, this_pix);
}
}
delete[] pixels;
// Temporal Smoothing
if (index > 0) {
double kalpha = 1.0 - kAlpha;
Frame* prev = frames[index - 1];
for (int i = 0; i < frame->Rows(); ++i) {
for (int j = 0; j < frame->Columns(); ++j) {
int prev_pix = prev->GetPixel(i, j);
int this_pix = frame->GetPixel(i, j);
frame->SetPixel(i, j, kalpha * prev_pix + kAlpha * this_pix);
}
}
}
}
示例2: GradientEstimationAtY
double* LucasKanade::GradientEstimationAtY() {
Frame* frame = frames[frames.size() / 2];
int rows = frame->Rows();
int cols = frame->Columns();
double* iy = new double[rows * cols];
double* ptr = iy;
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j, ++ptr) {
int pix_sum = 0;
for (int k = kGradientBegin; k <= kGradientEnd; ++k) {
if (i + k < 0 || rows <= i + k) continue;
pix_sum += frame->GetPixel(i + k, j) * kGradient[k - kGradientBegin];
}
*ptr = static_cast<double>(pix_sum) / 12.0;
}
}
return iy;
}