From ad0e8b3e7f1d8889244f15134a00d1ac4803d9c3 Mon Sep 17 00:00:00 2001 From: Comment Date: Tue, 20 Aug 2013 02:47:59 +0100 Subject: difference matte --- rotord/src/cvimage.cpp | 12 ++++++++++++ rotord/src/cvimage.h | 11 ++++++++--- rotord/src/rotor.cpp | 1 + rotord/src/rotor.h | 18 +++++++++++++----- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/rotord/src/cvimage.cpp b/rotord/src/cvimage.cpp index 361999b..adf4267 100644 --- a/rotord/src/cvimage.cpp +++ b/rotord/src/cvimage.cpp @@ -126,6 +126,18 @@ namespace Rotor { } return *this; } + Image & Image::alpha_from_cv(cv::Mat &other){ + //if (other.w!=w||other.h!=h) { + // cerr<<"Rotor: cannot merge alpha with different size! (wanted "<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 -- cgit v1.2.3