New filter color: tends to a given color; sepia is grey + color filter
This commit is contained in:
parent
4e5521c564
commit
b6b2e9c24f
@ -14,7 +14,7 @@ AC_CONFIG_MACRO_DIR([m4])
|
|||||||
# Look for a C++ compiler.CXXFLAGS_save="$CXXFLAGS"
|
# Look for a C++ compiler.CXXFLAGS_save="$CXXFLAGS"
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
AC_PROG_RANLIB
|
AC_PROG_RANLIB
|
||||||
CXXFLAGS="$CXXFLAGS_save -std=c++11 -g -O0"
|
CXXFLAGS="$CXXFLAGS_save -std=c++0x -g -O0"
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
|
|
||||||
AC_ARG_ENABLE(debug,
|
AC_ARG_ENABLE(debug,
|
||||||
|
@ -7,4 +7,4 @@ AM_CXXFLAGS = \
|
|||||||
$(DEBUG_CXXFLAGS)
|
$(DEBUG_CXXFLAGS)
|
||||||
|
|
||||||
______lib_libfilterSample_a_SOURCES = grey.cc reverse.cc merge.cc \
|
______lib_libfilterSample_a_SOURCES = grey.cc reverse.cc merge.cc \
|
||||||
interlace.cc inlay.cc blur.cc cartoon.cc count.cc
|
interlace.cc inlay.cc blur.cc cartoon.cc count.cc color.cc
|
||||||
|
20
src/filterSample/color.cc
Normal file
20
src/filterSample/color.cc
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include "color.hh"
|
||||||
|
#include "opencv2/opencv.hpp"
|
||||||
|
|
||||||
|
void* Color::operator()(void* para)
|
||||||
|
{
|
||||||
|
cv::Mat* mat = (cv::Mat*)para;
|
||||||
|
|
||||||
|
if (mat == nullptr)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < mat->rows; ++i)
|
||||||
|
for (size_t j = 0; j < mat->cols; ++j)
|
||||||
|
{
|
||||||
|
mat->at<cv::Vec3b>(i, j)[0] = mat->at<cv::Vec3b>(i, j)[0] * this->ref_[0] / 255;
|
||||||
|
mat->at<cv::Vec3b>(i, j)[1] = mat->at<cv::Vec3b>(i, j)[1] * this->ref_[1] / 255;
|
||||||
|
mat->at<cv::Vec3b>(i, j)[2] = mat->at<cv::Vec3b>(i, j)[2] * this->ref_[2] / 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mat;
|
||||||
|
}
|
17
src/filterSample/color.hh
Normal file
17
src/filterSample/color.hh
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef COLOR_HH_
|
||||||
|
# define COLOR_HH_
|
||||||
|
|
||||||
|
# include "tbb/pipeline.h"
|
||||||
|
# include "opencv2/opencv.hpp"
|
||||||
|
|
||||||
|
class Color: public tbb::filter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Color(cv::Vec3b ref)
|
||||||
|
: filter(tbb::filter::parallel), ref_(ref) {}
|
||||||
|
void* operator()(void*);
|
||||||
|
private:
|
||||||
|
cv::Vec3b ref_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* !COLOR_HH_ */
|
@ -110,7 +110,7 @@ int main (int argc, char** argv)
|
|||||||
if (!pipe.add_filter(filter.first, filter.second))
|
if (!pipe.add_filter(filter.first, filter.second))
|
||||||
{
|
{
|
||||||
std::cerr << argv[0] << ": Unknown filter `"
|
std::cerr << argv[0] << ": Unknown filter `"
|
||||||
<< filter.first << "'" << std::endl;
|
<< filter.first << "'" << filter.second.size() << std::endl;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "filterSample/interlace.hh"
|
#include "filterSample/interlace.hh"
|
||||||
#include "filterSample/inlay.hh"
|
#include "filterSample/inlay.hh"
|
||||||
#include "filterSample/count.hh"
|
#include "filterSample/count.hh"
|
||||||
|
#include "filterSample/color.hh"
|
||||||
|
|
||||||
Pipeline::Pipeline(std::list<VideoReader> input, VideoWriter output)
|
Pipeline::Pipeline(std::list<VideoReader> input, VideoWriter output)
|
||||||
: input_(input), output_(output)
|
: input_(input), output_(output)
|
||||||
@ -33,6 +34,17 @@ bool Pipeline::add_filter(std::string filter, std::vector<int> args)
|
|||||||
this->pipeline_.add_filter(*(new Cartoon()));
|
this->pipeline_.add_filter(*(new Cartoon()));
|
||||||
else if (filter == "count")
|
else if (filter == "count")
|
||||||
this->pipeline_.add_filter(*(new Count()));
|
this->pipeline_.add_filter(*(new Count()));
|
||||||
|
else if (filter == "color" && args.size() >= 3)
|
||||||
|
this->pipeline_.add_filter(*(new Color(cv::Vec3b {
|
||||||
|
(unsigned char) args[0],
|
||||||
|
(unsigned char) args[1],
|
||||||
|
(unsigned char) args[2]
|
||||||
|
})));
|
||||||
|
else if (filter == "sepia")
|
||||||
|
{
|
||||||
|
this->pipeline_.add_filter(*(new Grey()));
|
||||||
|
this->pipeline_.add_filter(*(new Color(cv::Vec3b { 40, 74, 130 })));
|
||||||
|
}
|
||||||
else if (filter == "blur")
|
else if (filter == "blur")
|
||||||
{
|
{
|
||||||
if (args.size() >= 1)
|
if (args.size() >= 1)
|
||||||
|
Reference in New Issue
Block a user