diff options
| author | Comment <tim@gray.(none)> | 2013-08-20 02:47:59 +0100 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-08-20 02:47:59 +0100 |
| commit | ad0e8b3e7f1d8889244f15134a00d1ac4803d9c3 (patch) | |
| tree | 31e49910fdd64db3f2c46869ab93b51c427e04fc /rotord/src/rotor.h | |
| parent | f485d31d2dd2e80f835b648115067a341f1b4fb3 (diff) | |
difference matte
Diffstat (limited to 'rotord/src/rotor.h')
| -rwxr-xr-x | rotord/src/rotor.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index eb00104..a2e5876 100755 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -20,6 +20,7 @@ #include "cvimage.h" #include "libavwrapper.h" +//using namespace cv; namespace Rotor { //forward declarations class Node; @@ -723,6 +724,7 @@ namespace Rotor { create_image_input("image input","Image input"); create_image_input("background input","Background input"); create_parameter("threshold","number","Difference threshold","Threshold",0.05f,0.0f,1.0f); + create_attribute("mode","Output {image|alpha}","output mode","alpha",{"image","alpha"}); title="Difference matte"; description="Create an alpha channel using a background reference picture"; }; @@ -734,15 +736,21 @@ namespace Rotor { Image *output(const Frame_spec &frame){ Image *in1=image_inputs[0]->get(frame); if (in1){ - //copy incoming image **writable Image *in2=image_inputs[1]->get(frame); if (in2) { cv::cvtColor(in1->rgb,greyfg,CV_RGB2GRAY); cv::cvtColor(in2->rgb,greybg,CV_RGB2GRAY); - //cv::absDiff(greybg,greyfg,greyDiff); - //adaptiveThreshold(greyDiff,parameters["threshold"].value,20,true,false); //int blockSize, int offset=0,bool invert=false, bool gauss=false); + cv::absdiff(greyfg,greybg,greyDiff); - image.alpha_merge(*in2); + //parameters["threshold"]->value + cv::threshold(greyDiff,mask,parameters["threshold"]->value,255,CV_THRESH_BINARY); //int block_size=3, double param1=5); //int blockSize, int offset=0,bool invert=false, bool gauss=false); + + //cv::adaptiveThreshold(greyDiff,mask,255,CV_ADAPTIVE_THRESH_GAUSSIAN_C,CV_THRESH_BINARY, 3,5); //int block_size=3, double param1=5); //int blockSize, int offset=0,bool invert=false, bool gauss=false); + image=(*in1); + if (attributes["mode"]->value=="image"){ + image.setup_fromMat(mask); + } + else image.alpha_from_cv(mask); return ℑ } //if there aren't 2 image inputs connected just return the first @@ -751,7 +759,7 @@ namespace Rotor { return nullptr; } private: - cv::Mat greyfg,greybg,greyDiff; + cv::Mat greyfg,greybg,greyDiff,mask; }; #define VIDEOFRAMES_still 1 #define VIDEOFRAMES_blend 2 |
