14 using std::const_mem_fun_ref_t;
32 const int BUFSIZE = 255;
33 char buffer[BUFSIZE+1];
38 vsnprintf(buffer, BUFSIZE,
format, args);
42 buffer[BUFSIZE] =
'\0';
51 arr.
at(
"Size").toInt(),
52 arr.
at(
"Thresh").toFloat(),
53 arr.
at(
"Eps").toFloat(),
54 arr.
at(
"Prob").toFloat());
74 s.
set(
"TypeId",
string(
typeid(*p).name()));
82 s.
set(
"TypeId",
string(
typeid(*p).name()));
98 s.
set(
"TypeId",
string(
typeid(*p).name()));
113 s.
set(
"TypeId",
string(
typeid(*p).name()));
131 s.
set(
"TypeId",
string(
typeid(*p).name()));
141 s.
set(
"TypeId",
string(
typeid(*p).name()));
156 s.
set(
"TypeId",
string(
typeid(*p).name()));
174 s.
set(
"TypeId",
string(
typeid(*p).name()));
189 s.
set(
"TypeId",
string(
typeid(*p).name()));
206 s.
set(
"TypeId",
string(
typeid(*p).name()));
238 s.
set(
"TypeId",
string(
typeid(*p).name()));
252 s.
set(
"TypeId",
string(
typeid(*p).name()));
286 s.
set(
"TypeId",
string(
typeid(*p).name()));
303 if (
type ==
"LogToMATLAB")
304 p = makePtr<LogToMATLAB>();
305 else if (
type ==
"LogToStdout")
306 p = makePtr<LogToStdout>();
307 else if (
type ==
"NullLog")
308 p = makePtr<NullLog>();
311 "Unrecognized logger type %s",
type.c_str());
314 "Failed to create ILog");
324 string path(first->toString()); ++first;
325 bool volatileFrame =
false;
326 for (; first != last; first += 2) {
327 string key(first->toString());
328 const MxArray& val = *(first + 1);
329 if (key ==
"VolatileFrame")
330 volatileFrame = val.
toBool();
333 "Unrecognized option %s", key.c_str());
335 return makePtr<VideoFileSource>(path, volatileFrame);
345 if (
type ==
"VideoFileSource")
347 else if (
type ==
"NullFrameSource") {
349 p = makePtr<NullFrameSource>();
353 "Unrecognized frame source %s",
type.c_str());
356 "Failed to create IFrameSource");
369 "Failed to create WeightingDeblurer");
370 for (; first != last; first += 2) {
371 string key(first->toString());
372 const MxArray& val = *(first + 1);
376 else if (key ==
"Sensitivity")
380 "Unrecognized option %s", key.c_str());
392 if (
type ==
"WeightingDeblurer")
394 else if (
type ==
"NullDeblurer") {
396 p = makePtr<NullDeblurer>();
400 "Unrecognized deblurer %s",
type.c_str());
403 "Failed to create DeblurerBase");
414 for (; first != last; first += 2) {
415 string key(first->toString());
416 const MxArray& val = *(first + 1);
417 if (key ==
"MotionModel")
421 "Unrecognized option %s", key.c_str());
423 return makePtr<MotionEstimatorL1>(model);
434 float minInlierRatio = 0.1f;
435 for (; first != last; first += 2) {
436 string key(first->toString());
437 const MxArray& val = *(first + 1);
438 if (key ==
"MotionModel")
440 else if (key ==
"RansacParams")
443 else if (key ==
"MinInlierRatio")
444 minInlierRatio = val.toFloat();
447 "Unrecognized option %s", key.c_str());
452 "Failed to create MotionEstimatorRansacL2");
464 if (
type ==
"MotionEstimatorL1")
466 else if (
type ==
"MotionEstimatorRansacL2")
470 "Unrecognized motion estimator %s",
type.c_str());
473 "Failed to create MotionEstimatorBase");
486 "Failed to create SparsePyrLkOptFlowEstimator");
487 for (; first != last; first += 2) {
488 string key(first->toString());
489 const MxArray& val = *(first + 1);
490 if (key ==
"WinSize")
492 else if (key ==
"MaxLevel")
496 "Unrecognized option %s", key.c_str());
507 if (
type ==
"SparsePyrLkOptFlowEstimator")
511 "Unrecognized sparse optical flow estimator %s",
type.c_str());
514 "Failed to create ISparseOptFlowEstimator");
524 if (
type ==
"DensePyrLkOptFlowEstimatorGpu")
529 "Unrecognized dense optical flow estimator %s",
type.c_str());
532 "Failed to create IDenseOptFlowEstimator");
543 makePtr<TranslationBasedLocalOutlierRejector>();
546 "Failed to create TranslationBasedLocalOutlierRejector");
547 for (; first != last; first += 2) {
548 string key(first->toString());
549 const MxArray& val = *(first + 1);
550 if (key ==
"CellSize")
552 else if (key ==
"RansacParams")
557 "Unrecognized option %s", key.c_str());
569 if (
type ==
"TranslationBasedLocalOutlierRejector")
571 else if (
type ==
"NullOutlierRejector") {
573 p = makePtr<NullOutlierRejector>();
577 "Unrecognized outlier rejector %s",
type.c_str());
580 "Failed to create IOutlierRejector");
595 args[0].toString(), args.
begin() + 1, args.
end());
596 p = makePtr<KeypointBasedMotionEstimator>(estimator);
600 "Failed to create KeypointBasedMotionEstimator");
601 for (; first != last; first += 2) {
602 string key(first->toString());
603 const MxArray& val = *(first + 1);
604 if (key ==
"MotionModel")
606 else if (key ==
"Detector") {
610 args[0].toString(), args.
begin() + 1, args.
end());
613 else if (key ==
"OpticalFlowEstimator") {
617 args[0].toString(), args.
begin() + 1, args.
end());
620 else if (key ==
"OutlierRejector") {
624 args[0].toString(), args.
begin() + 1, args.
end());
629 "Unrecognized option %s", key.c_str());
640 string path(first->toString()); ++first;
644 "Failed to create FromFileMotionReader");
645 for (; first != last; first += 2) {
646 string key(first->toString());
647 const MxArray& val = *(first + 1);
648 if (key ==
"MotionModel")
652 "Unrecognized option %s", key.c_str());
665 string path(first->toString()); ++first;
669 args[0].toString(), args.
begin() + 1, args.
end());
670 p = makePtr<ToFileMotionWriter>(path, estimator);
674 "Failed to create ToFileMotionWriter");
675 for (; first != last; first += 2) {
676 string key(first->toString());
677 const MxArray& val = *(first + 1);
678 if (key ==
"MotionModel")
682 "Unrecognized option %s", key.c_str());
693 if (
type ==
"KeypointBasedMotionEstimator")
695 else if (
type ==
"FromFileMotionReader")
697 else if (
type ==
"ToFileMotionWriter")
701 "Unrecognized image motion estimator %s",
type.c_str());
704 "Failed to create ImageMotionEstimatorBase");
715 double radius2 = 2.0;
718 for (; first != last; first += 2) {
719 string key(first->toString());
720 const MxArray& val = *(first + 1);
724 else if (key ==
"Radius2")
725 radius2 = val.toDouble();
726 else if (key ==
"MotionModel")
728 else if (key ==
"Radius")
729 radius = val.toInt();
732 "Unrecognized option %s", key.c_str());
737 "Failed to create ColorInpainter");
752 "Failed to create ColorAverageInpainter");
753 for (; first != last; first += 2) {
754 string key(first->toString());
755 const MxArray& val = *(first + 1);
757 if (key ==
"MotionModel")
759 else if (key ==
"Radius")
763 "Unrecognized option %s", key.c_str());
777 "Failed to create ConsistentMosaicInpainter");
778 for (; first != last; first += 2) {
779 string key(first->toString());
780 const MxArray& val = *(first + 1);
782 if (key ==
"MotionModel")
784 else if (key ==
"Radius")
786 else if (key ==
"StdevThresh")
790 "Unrecognized option %s", key.c_str());
804 "Failed to create MotionInpainter");
805 for (; first != last; first += 2) {
806 string key(first->toString());
807 const MxArray& val = *(first + 1);
809 if (key ==
"MotionModel")
811 else if (key ==
"Radius")
813 else if (key ==
"FlowErrorThreshold")
815 else if (key ==
"DistThreshold")
817 else if (key ==
"BorderMode")
819 else if (key ==
"OptFlowEstimator") {
823 args[0].toString(), args.
begin() + 1, args.
end());
828 "Unrecognized option %s", key.c_str());
842 "Failed to create InpaintingPipeline");
846 &MxArray::toVector<MxArray>))); ++first;
850 (*it)[0].toString(), it->begin() + 1, it->end());
854 for (; first != last; first += 2) {
855 string key(first->toString());
856 const MxArray& val = *(first + 1);
858 if (key ==
"MotionModel")
860 else if (key ==
"Radius")
864 "Unrecognized option %s", key.c_str());
876 if (
type ==
"ColorInpainter")
878 else if (
type ==
"ColorAverageInpainter")
880 else if (
type ==
"ConsistentMosaicInpainter")
882 else if (
type ==
"MotionInpainter")
884 else if (
type ==
"InpaintingPipeline")
886 else if (
type ==
"NullInpainter") {
888 p = makePtr<NullInpainter>();
892 "Unrecognized inpainter %s",
type.c_str());
895 "Failed to create InpainterBase");
907 for (; first != last; first += 2) {
908 string key(first->toString());
909 const MxArray& val = *(first + 1);
911 radius = val.
toInt();
912 else if (key ==
"Stdev")
913 stdev = val.toFloat();
916 "Unrecognized option %s", key.c_str());
918 return makePtr<GaussianMotionFilter>(radius, stdev);
927 if (
type ==
"GaussianMotionFilter")
931 "Unrecognized motion filter %s",
type.c_str());
934 "Failed to create MotionFilterBase");
947 "Failed to create LpMotionStabilizer");
948 for (; first != last; first += 2) {
949 string key(first->toString());
950 const MxArray& val = *(first + 1);
951 if (key ==
"MotionModel")
953 else if (key ==
"FrameSize")
955 else if (key ==
"TrimRatio")
957 else if (key ==
"Weight1")
959 else if (key ==
"Weight2")
961 else if (key ==
"Weight3")
963 else if (key ==
"Weight4")
967 "Unrecognized option %s", key.c_str());
981 "Failed to create MotionStabilizationPipeline");
985 &MxArray::toVector<MxArray>))); ++first;
989 (*it)[0].toString(), it->begin() + 1, it->end());
1002 if (
type ==
"LpMotionStabilizer")
1004 else if (
type ==
"GaussianMotionFilter")
1006 else if (
type ==
"MotionStabilizationPipeline")
1010 "Unrecognized motion stabilizer %s",
type.c_str());
1013 "Failed to create IMotionStabilizer");
1024 makePtr<MoreAccurateMotionWobbleSuppressor>();
1027 "Failed to create MoreAccurateMotionWobbleSuppressor");
1028 for (; first != last; first += 2) {
1029 string key(first->toString());
1030 const MxArray& val = *(first + 1);
1032 if (key ==
"MotionEstimator") {
1036 args[0].toString(), args.
begin() + 1, args.
end());
1039 else if (key ==
"Period")
1043 "Unrecognized option %s", key.c_str());
1055 if (
type ==
"MoreAccurateMotionWobbleSuppressor")
1057 else if (
type ==
"NullWobbleSuppressor") {
1059 p = makePtr<NullWobbleSuppressor>();
1063 "Unrecognized wobble suppressor %s",
type.c_str());
1066 "Failed to create WobbleSuppressorBase");
Ptr< VideoFileSource > createVideoFileSource(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of VideoFileSource using options in arguments.
void setWeight1(float val)
void setCellSize(Size val)
float flowErrorThreshold() const
Ptr< FromFileMotionReader > createFromFileMotionReader(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of FromFileMotionReader using options in arguments.
Common definitions for the videostab module.
int toInt() const
Convert MxArray to int.
Ptr< ImageMotionEstimatorBase > createImageMotionEstimator(const string &type, vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of ImageMotionEstimatorBase using options in arguments.
void setBorderMode(int val)
Ptr< MotionStabilizationPipeline > createMotionStabilizationPipeline(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of MotionStabilizationPipeline using options in arguments.
Ptr< WeightingDeblurer > createWeightingDeblurer(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of WeightingDeblurer using options in arguments.
T at(mwIndex index) const
Template for numeric array element accessor.
Ptr< ConsistentMosaicInpainter > createConsistentMosaicInpainter(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of ConsistentMosaicInpainter using options in arguments.
void setMotionEstimator(Ptr< ImageMotionEstimatorBase > val)
Ptr< ColorInpainter > createColorInpainter(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of ColorInpainter using options in arguments.
virtual void setRadius(int val)
MxArray toStruct(const RansacParams ¶ms)
Convert RansacParams to MxArray.
Ptr< WobbleSuppressorBase > createWobbleSuppressorBase(const string &type, vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of WobbleSuppressorBase using options in arguments.
Ptr< MotionEstimatorL1 > createMotionEstimatorL1(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of MotionEstimatorL1 using options in arguments.
void setSensitivity(float val)
Ptr< SparsePyrLkOptFlowEstimator > createSparsePyrLkOptFlowEstimator(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of SparsePyrLkOptFlowEstimator using options in arguments.
Ptr< GaussianMotionFilter > createGaussianMotionFilter(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of GaussianMotionFilter using options in arguments.
virtual Size winSize() const
virtual MotionModel motionModel() const
void setFrameSize(Size val)
virtual void setWinSize(Size val)
void pushBack(Ptr< IMotionStabilizer > stabilizer)
Ptr< IMotionStabilizer > createIMotionStabilizer(const string &type, vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of IMotionStabilizer using options in arguments.
float stdevThresh() const
Ptr< MoreAccurateMotionWobbleSuppressor > createMoreAccurateMotionWobbleSuppressor(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of MoreAccurateMotionWobbleSuppressor using options in arguments.
Ptr< ImageMotionEstimatorBase > motionEstimator() const
Ptr< ColorAverageInpainter > createColorAverageInpainter(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of ColorAverageInpainter using options in arguments.
Ptr< MotionEstimatorBase > createMotionEstimatorBase(const string &type, vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of MotionEstimatorBase using options in arguments.
void setOpticalFlowEstimator(Ptr< ISparseOptFlowEstimator > val)
RansacParams(int size, float thresh, float eps, float prob)
Ptr< ISparseOptFlowEstimator > opticalFlowEstimator() const
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
virtual int radius() const
virtual void setPeriod(int val)
virtual int radius() const
RansacParams ransacParams() const
void setOptFlowEstimator(Ptr< IDenseOptFlowEstimator > val)
Ptr< MotionInpainter > createMotionInpainter(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of MotionInpainter using options in arguments.
Ptr< InpainterBase > createInpainterBase(const string &type, vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of InpainterBase using options in arguments.
Ptr< IDenseOptFlowEstimator > createIDenseOptFlowEstimator(const string &type, vector< MxArray >::const_iterator, vector< MxArray >::const_iterator)
Create an instance of IDenseOptFlowEstimator using options in arguments.
virtual void setMotionModel(MotionModel val)
void setDetector(Ptr< FeatureDetector > val)
virtual void setRadius(int val)
LIBMWMEX_API_EXTERN_C int mexPrintf(const char *fmt,...)
mex equivalent to MATLAB's "disp" function
const ConstMap< int, std::string > BorderTypeInv
Inverse border type map for option processing.
Ptr< LpMotionStabilizer > createLpMotionStabilizer(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of LpMotionStabilizer using options in arguments.
const ConstMap< cv::videostab::MotionModel, std::string > MotionModelInvMap
inverse motion model types for option processing
Ptr< IOutlierRejector > outlierRejector() const
Ptr< DeblurerBase > createDeblurerBase(const string &type, vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of DeblurerBase using options in arguments.
virtual void setMotionModel(MotionModel val)
void setWeight3(float val)
bool toBool() const
Convert MxArray to bool.
void setStdevThresh(float val)
Ptr< Y > dynamicCast() const
const ConstMap< std::string, cv::videostab::MotionModel > MotionModelMap
motion model types for option processing
cv::Ptr< cv::FeatureDetector > createFeatureDetector(const std::string &type, std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Factory function for FeatureDetector creation.
void setRansacParams(const RansacParams &val)
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
const ConstMap< std::string, int > BorderType
Border type map for option processing.
float minInlierRatio() const
void setWeight4(float val)
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
Ptr< FeatureDetector > detector() const
static MxArray Struct(const char **fields=NULL, int nfields=0, mwSize m=1, mwSize n=1)
Create a new struct array.
Ptr< ISparseOptFlowEstimator > createISparseOptFlowEstimator(const string &type, vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of ISparseOptFlowEstimator using options in arguments.
Ptr< IFrameSource > createIFrameSource(const string &type, vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of IFrameSource using options in arguments.
void setFlowErrorThreshold(float val)
Ptr< ILog > createILog(const string &type)
Create an instance of ILog of the specified type.
MotionModel motionModel() const
void setOutlierRejector(Ptr< IOutlierRejector > val)
const ConstMap< string, int > InpaintingAlgMap
inpainting algorithm types for option processing
virtual void setMaxLevel(int val)
Ptr< IDenseOptFlowEstimator > optFlowEstimator() const
RansacParams ransacParams() const
Ptr< IOutlierRejector > createIOutlierRejector(const string &type, vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of IOutlierRejector using options in arguments.
Ptr< TranslationBasedLocalOutlierRejector > createTranslationBasedLocalOutlierRejector(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of createTranslationBasedLocalOutlierRejector using options in arguments...
virtual int maxLevel() const
void setTrimRatio(float val)
Ptr< MotionEstimatorRansacL2 > createMotionEstimatorRansacL2(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of MotionEstimatorRansacL2 using options in arguments.
virtual int period() const
void setRansacParams(RansacParams val)
virtual void print(const char *format,...)
void pushBack(Ptr< InpainterBase > inpainter)
Ptr< ToFileMotionWriter > createToFileMotionWriter(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of ToFileMotionWriter using options in arguments.
virtual MotionModel motionModel() const
virtual void setMotionModel(MotionModel val)
RansacParams toRansacParams(const MxArray &arr)
Convert MxArray to RansacParams.
std::map wrapper with one-line initialization and lookup method.
virtual void setMotionModel(MotionModel val)
virtual void setRadius(int val)
void setMotionModel(MotionModel val)
void setMinInlierRatio(float val)
virtual MotionModel motionModel() const
void setDistThreshold(float val)
Ptr< InpaintingPipeline > createInpaintingPipeline(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of InpaintingPipeline using options in arguments.
void setWeight2(float val)
Ptr< MotionFilterBase > createMotionFilterBase(const string &type, vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of MotionFilterBase using options in arguments.
Ptr< KeypointBasedMotionEstimator > createKeypointBasedMotionEstimator(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of KeypointBasedMotionEstimator using options in arguments.
static RansacParams default2dMotion(MotionModel model)
virtual void setMotionModel(MotionModel val)
float sensitivity() const