• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * stablizer.h - abstract header for DVS (Digital Video Stabilizer)
3  *
4  *    Copyright (c) 2014-2016 Intel Corporation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Author: Zong Wei <wei.zong@intel.com>
19  */
20 
21 #ifndef _STABILIZER_H_
22 #define _STABILIZER_H_
23 
24 #include <vector>
25 #include <opencv2/core.hpp>
26 #include <opencv2/opencv.hpp>
27 #include <opencv2/videostab.hpp>
28 
29 #include "libdvs.h"
30 
31 class OnePassVideoStabilizer : public cv::videostab::OnePassStabilizer
32 {
33 public:
~OnePassVideoStabilizer()34     virtual ~OnePassVideoStabilizer() {};
35 
36     virtual cv::Mat nextStabilizedMotion(DvsData* frame, int& stablizedPos);
37 
38 protected:
39     virtual cv::Mat estimateMotion();
40     virtual void setUpFrame(const cv::Mat &firstFrame);
41 
42 private:
43 
44 };
45 
46 class TwoPassVideoStabilizer : public cv::videostab::TwoPassStabilizer
47 {
48 public:
~TwoPassVideoStabilizer()49     virtual ~TwoPassVideoStabilizer() {};
50 
51     virtual cv::Mat nextStabilizedMotion(DvsData* frame, int& stablizedPos);
52 
53 protected:
54     virtual cv::Mat estimateMotion();
55     virtual void setUpFrame(const cv::Mat &firstFrame);
56 
57 private:
58 
59 };
60 
61 class VideoStabilizer
62 {
63 public:
64     VideoStabilizer(bool isTwoPass = false,
65                     bool wobbleSuppress = false,
66                     bool deblur = false,
67                     bool inpainter = false);
68     virtual ~VideoStabilizer();
69 
stabilizer()70     cv::Ptr<cv::videostab::StabilizerBase> stabilizer() const {
71         return stabilizer_;
72     }
73 
74     cv::Mat nextFrame();
75     cv::Mat nextStabilizedMotion(DvsData* frame, int& stablizedPos);
76 
77     cv::Size trimedVideoSize(cv::Size frameSize);
78     cv::Mat cropVideoFrame(cv::Mat& frame);
79 
80     void setFrameSize(cv::Size frameSize);
getFrameSize()81     cv::Size getFrameSize() const {
82         return frameSize_;
83     }
84 
85     void configFeatureDetector(int features, double minDistance);
86     void configMotionFilter(int radius, float stdev);
87     void configDeblurrer(int radius, double sensitivity);
88 
89 public:
90     cv::VideoWriter writer_;
91 
92 private:
93     bool isTwoPass_;
94     float trimRatio_;
95     cv::Size frameSize_;
96     cv::Ptr<cv::videostab::StabilizerBase> stabilizer_;
97 };
98 
99 
100 #endif
101