Added a drunk filter and wrote the README.
This commit is contained in:
parent
59d0764071
commit
327c00ac18
66
README
66
README
@ -0,0 +1,66 @@
|
||||
PRPA
|
||||
====
|
||||
|
||||
Apply a video-filtering chain with full exploitation of multi-threading.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
./prpa [options] [file...]
|
||||
|
||||
Options are one or more of the following:
|
||||
-h [ --help ] produce help message
|
||||
-f [ --filter ] arg apply a filter (see below)
|
||||
-i [ --input-file ] arg file to treat
|
||||
-o [ --output ] arg output file
|
||||
-c [ --codec ] arg output codec
|
||||
-d [ --disable ] disable parallelism
|
||||
|
||||
Codecs
|
||||
------
|
||||
Codec name are 4-character codes that can be found on this page
|
||||
http://www.fourcc.org/codecs.php
|
||||
|
||||
Codec name *must* match the output file extension.
|
||||
Exemples are:
|
||||
-c MP42 -o .avi # MPEG4
|
||||
-c MP42 -o .mp4 # MPEG4
|
||||
-c XVID -o .avi # Xvid
|
||||
-c theo -o .ogg # OGG Theora
|
||||
|
||||
Note that MP42 and XVID are two of the quickest output codecs and thus will not
|
||||
be a bottleneck for the parallelism.
|
||||
|
||||
Filter
|
||||
------
|
||||
|
||||
Available filters are:
|
||||
* grey Produce black and white ouput.
|
||||
* reverse Reverse colors.
|
||||
* cartoon Try to apply a "cartoon" effect (VERY SLOW).
|
||||
* drunk Simulate alcool abuse.
|
||||
* count Count frame per thread (debug?).
|
||||
* color=B,G,R Apply the B,G,R color filter.
|
||||
* sepia Apply a sepia effect.
|
||||
* blur[=X] Blurs the video, X is the strength of the blur effect.
|
||||
* merge Merge 2 videos pixel per pixel with a transparent effect.
|
||||
* interlace Merge 2 videos, alterning between one pixel of each.
|
||||
* inlay=B,G,R Inlay a video into another one at the place of the
|
||||
B, G or R color, trying to replace the whole color, not
|
||||
just the particular value.
|
||||
* strictinlay=B,G,R Inlay a video into another one at the place of the
|
||||
precise BGR color asked.
|
||||
|
||||
For the merge, interlace, inlay and strict inlay filters, at least two videos
|
||||
must be passed in the input files list.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
./prpa -f drunk -f sepia -o bar.avi -c MP42 foo.avi
|
||||
./prpa -f blur=50 -f reverse -o bar.avi -c XVID foo.avi
|
||||
./prpa -f inlay=1,0,0 -o bar.avi -c XVID foo.avi
|
||||
./prpa -f strictinlay=255,137,42 -o bar.avi -c XVID orig.avi inlayed.avi
|
||||
|
||||
time ./prpa -f drunk -f sepia -o bar.avi -c MP42 foo.avi
|
||||
time ./prpa -d -f drunk -f sepia -o bar.avi -c MP42 foo.avi
|
@ -8,4 +8,4 @@ AM_CXXFLAGS = \
|
||||
|
||||
______lib_libfilterSample_a_SOURCES = grey.cc reverse.cc merge.cc \
|
||||
interlace.cc inlay.cc blur.cc cartoon.cc count.cc color.cc \
|
||||
rotate.cc
|
||||
rotate.cc drunk.cc
|
||||
|
33
src/filterSample/drunk.cc
Normal file
33
src/filterSample/drunk.cc
Normal file
@ -0,0 +1,33 @@
|
||||
#include "drunk.hh"
|
||||
|
||||
#include "opencv2/opencv.hpp"
|
||||
|
||||
void* Drunk::operator()(void* para)
|
||||
{
|
||||
cv::Mat* mat = (cv::Mat*)para;
|
||||
|
||||
if (mat == nullptr)
|
||||
return nullptr;
|
||||
|
||||
if (this->last_ == nullptr)
|
||||
{
|
||||
this->last_ = new cv::Mat();
|
||||
*this->last_ = mat->clone();
|
||||
}
|
||||
|
||||
auto it1 = mat->begin<cv::Vec3b>();
|
||||
auto it2 = this->last_->begin<cv::Vec3b>();
|
||||
while (it1 != mat->end<cv::Vec3b>() && it2 != this->last_->end<cv::Vec3b>())
|
||||
{
|
||||
(*it2)[0] = (*it1)[0] / 8 + (*it2)[0] * 7 / 8;
|
||||
(*it2)[1] = (*it1)[1] / 8 + (*it2)[1] * 7 / 8;
|
||||
(*it2)[2] = (*it1)[2] / 8 + (*it2)[2] * 7 / 8;
|
||||
(*it1)[0] = (*it2)[0];
|
||||
(*it1)[1] = (*it2)[1];
|
||||
(*it1)[2] = (*it2)[2];
|
||||
++it1;
|
||||
++it2;
|
||||
}
|
||||
|
||||
return mat;
|
||||
}
|
16
src/filterSample/drunk.hh
Normal file
16
src/filterSample/drunk.hh
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef DRUNK_HH_
|
||||
# define DRUNK_HH_
|
||||
|
||||
# include "tbb/pipeline.h"
|
||||
# include "opencv2/opencv.hpp"
|
||||
|
||||
class Drunk: public tbb::filter
|
||||
{
|
||||
public:
|
||||
Drunk(): filter(tbb::filter::parallel), last_(nullptr) {}
|
||||
void* operator()(void*);
|
||||
private:
|
||||
cv::Mat* last_;
|
||||
};
|
||||
|
||||
#endif /* !DRUNK_HH_ */
|
@ -19,7 +19,7 @@ bool parse_cli(Configuration& conf, int argc, char** argv)
|
||||
desc.add_options()
|
||||
("help,h", "produce help message")
|
||||
("filter,f", po::value<std::vector<std::string>>(), "apply a filter; "
|
||||
"choose between grey, reverse, cartoon, count, color=B,G,R, sepia, "
|
||||
"choose between grey, reverse, cartoon, drunk, count, color=B,G,R, sepia,"
|
||||
" blur[=X], merge, interlace, inlay=B,G,R, strictinlay=B,G,R")
|
||||
("input-file,i", po::value<std::vector<std::string>>(), "file to treat")
|
||||
("output,o", po::value<std::string>(), "output file")
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "filterSample/count.hh"
|
||||
#include "filterSample/color.hh"
|
||||
#include "filterSample/rotate.hh"
|
||||
#include "filterSample/drunk.hh"
|
||||
|
||||
Pipeline::Pipeline(std::list<VideoReader> input, VideoWriter output)
|
||||
: input_(input), output_(output)
|
||||
@ -35,6 +36,8 @@ bool Pipeline::add_filter(std::string filter, std::vector<int> args)
|
||||
this->pipeline_.add_filter(*(new Cartoon()));
|
||||
else if (filter == "count")
|
||||
this->pipeline_.add_filter(*(new Count()));
|
||||
else if (filter == "drunk")
|
||||
this->pipeline_.add_filter(*(new Drunk()));
|
||||
else if (filter == "rotate-h")
|
||||
this->pipeline_.add_filter(*(new Rotate(0)));
|
||||
else if (filter == "rotate-v")
|
||||
|
Reference in New Issue
Block a user