From: Alexey Spizhevoy Date: Tue, 20 Mar 2012 08:12:58 +0000 (+0000) Subject: Added quiet mode into videostab sample X-Git-Tag: accepted/2.0/20130307.220821~1087 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be73f8e29c1f021f35c86e899a9d4a3aecf3c79f;p=profile%2Fivi%2Fopencv.git Added quiet mode into videostab sample --- diff --git a/modules/videostab/src/motion_filtering.cpp b/modules/videostab/src/motion_filtering.cpp index f9f2cbf..d7413e5 100644 --- a/modules/videostab/src/motion_filtering.cpp +++ b/modules/videostab/src/motion_filtering.cpp @@ -66,9 +66,13 @@ Mat GaussianMotionFilter::apply(int idx, vector &motions) const { const Mat &cur = at(idx, motions); Mat res = Mat::zeros(cur.size(), cur.type()); - for (int i = -radius_; i <= radius_; ++i) - res += weight_[radius_ + i] * getMotion(idx, idx + i, motions); - return res; + float sum = 0.f; + for (int i = std::max(idx - radius_, 0); i <= idx + radius_; ++i) + { + res += weight_[radius_ + i - idx] * getMotion(idx, i, motions); + sum += weight_[radius_ + i - idx]; + } + return res / sum; } } // namespace videostab diff --git a/samples/cpp/videostab.cpp b/samples/cpp/videostab.cpp index 08fd65b..6616624 100644 --- a/samples/cpp/videostab.cpp +++ b/samples/cpp/videostab.cpp @@ -15,6 +15,7 @@ using namespace cv::videostab; Ptr stabilizer; double outputFps; string outputPath; +bool quietMode; void run(); void printHelp(); @@ -32,10 +33,13 @@ void run() writer.open(outputPath, CV_FOURCC('X','V','I','D'), outputFps, stabilizedFrame.size()); writer << stabilizedFrame; } - imshow("stabilizedFrame", stabilizedFrame); - char key = static_cast(waitKey(3)); - if (key == 27) - break; + if (!quietMode) + { + imshow("stabilizedFrame", stabilizedFrame); + char key = static_cast(waitKey(3)); + if (key == 27) + break; + } } cout << "\nfinished\n"; @@ -83,6 +87,8 @@ void printHelp() " Set output file path explicitely. The default is stabilized.avi.\n" " --fps=\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" " Print help.\n" "\n"; @@ -112,6 +118,7 @@ int main(int argc, const char **argv) "{ | color-inpaint | | }" "{ o | output | stabilized.avi | }" "{ | fps | | }" + "{ q | quiet | false | }" "{ h | help | false | }"; CommandLineParser cmd(argc, argv, keys); @@ -213,6 +220,8 @@ int main(int argc, const char **argv) if (!cmd.get("fps").empty()) outputFps = cmd.get("fps"); + quietMode = cmd.get("quiet"); + // run video processing run(); }