Added quiet mode into videostab sample

pull/13383/head
Alexey Spizhevoy 13 years ago
parent e4651fa697
commit be73f8e29c
  1. 10
      modules/videostab/src/motion_filtering.cpp
  2. 17
      samples/cpp/videostab.cpp

@ -66,9 +66,13 @@ Mat GaussianMotionFilter::apply(int idx, vector<Mat> &motions) const
{ {
const Mat &cur = at(idx, motions); const Mat &cur = at(idx, motions);
Mat res = Mat::zeros(cur.size(), cur.type()); Mat res = Mat::zeros(cur.size(), cur.type());
for (int i = -radius_; i <= radius_; ++i) float sum = 0.f;
res += weight_[radius_ + i] * getMotion(idx, idx + i, motions); for (int i = std::max(idx - radius_, 0); i <= idx + radius_; ++i)
return res; {
res += weight_[radius_ + i - idx] * getMotion(idx, i, motions);
sum += weight_[radius_ + i - idx];
}
return res / sum;
} }
} // namespace videostab } // namespace videostab

@ -15,6 +15,7 @@ using namespace cv::videostab;
Ptr<Stabilizer> stabilizer; Ptr<Stabilizer> stabilizer;
double outputFps; double outputFps;
string outputPath; string outputPath;
bool quietMode;
void run(); void run();
void printHelp(); void printHelp();
@ -32,10 +33,13 @@ void run()
writer.open(outputPath, CV_FOURCC('X','V','I','D'), outputFps, stabilizedFrame.size()); writer.open(outputPath, CV_FOURCC('X','V','I','D'), outputFps, stabilizedFrame.size());
writer << stabilizedFrame; writer << stabilizedFrame;
} }
imshow("stabilizedFrame", stabilizedFrame); if (!quietMode)
char key = static_cast<char>(waitKey(3)); {
if (key == 27) imshow("stabilizedFrame", stabilizedFrame);
break; char key = static_cast<char>(waitKey(3));
if (key == 27)
break;
}
} }
cout << "\nfinished\n"; cout << "\nfinished\n";
@ -83,6 +87,8 @@ void printHelp()
" Set output file path explicitely. The default is stabilized.avi.\n" " Set output file path explicitely. The default is stabilized.avi.\n"
" --fps=<int_number>\n" " --fps=<int_number>\n"
" Set output video FPS explicitely. By default the source FPS is used.\n" " Set output video FPS explicitely. By default the source FPS is used.\n"
" -q, --quiet\n"
" Don't show output video frames.\n"
" -h, --help\n" " -h, --help\n"
" Print help.\n" " Print help.\n"
"\n"; "\n";
@ -112,6 +118,7 @@ int main(int argc, const char **argv)
"{ | color-inpaint | | }" "{ | color-inpaint | | }"
"{ o | output | stabilized.avi | }" "{ o | output | stabilized.avi | }"
"{ | fps | | }" "{ | fps | | }"
"{ q | quiet | false | }"
"{ h | help | false | }"; "{ h | help | false | }";
CommandLineParser cmd(argc, argv, keys); CommandLineParser cmd(argc, argv, keys);
@ -213,6 +220,8 @@ int main(int argc, const char **argv)
if (!cmd.get<string>("fps").empty()) if (!cmd.get<string>("fps").empty())
outputFps = cmd.get<double>("fps"); outputFps = cmd.get<double>("fps");
quietMode = cmd.get<bool>("quiet");
// run video processing // run video processing
run(); run();
} }

Loading…
Cancel
Save