summaryrefslogtreecommitdiff
path: root/rotord/src/rotor.h
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src/rotor.h')
-rwxr-xr-xrotord/src/rotor.h39
1 files changed, 36 insertions, 3 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index a2e5876..fc557cd 100755
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -126,6 +126,7 @@ namespace Rotor {
virtual ~Attribute(){};
Attribute(const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={}): description(_desc),title(_title),value(_value),intVal(0){
vals=_vals;
+ init(_value);
};
void init(const string &_key){ //inits int value from set::string vals index
value=_key;
@@ -157,6 +158,14 @@ namespace Rotor {
void create_attribute(const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={}) {
attributes[_attr]=new Attribute(_desc,_title,_value,_vals);
};
+ void create_attribute(string *alias,const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={}) {
+ attributes[_attr]=new Attribute(_desc,_title,_value,_vals);
+ alias=&(attributes[_attr]->value);
+ };
+ void create_attribute(int *alias,const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={}) {
+ attributes[_attr]=new Attribute(_desc,_title,_value,_vals);
+ alias=&(attributes[_attr]->intVal);
+ };
string description;
string type;
string ID;
@@ -227,6 +236,29 @@ namespace Rotor {
virtual void print_summary(){};
int channels,bits,samples,rate;
};
+ class LUT {
+ LUT(){
+ lut=nullptr;
+ };
+ ~LUT(){if (lut) { delete[] lut;} };
+ void generate(float black_in,float white_in,float black_out,float white_out,float gamma){
+ //can check here if anything has changed
+ if (lut) delete[] lut;
+ lut=new unsigned char[256];
+ float fltmax=(255.0f/256.0f);
+ for (int i=0;i<256;i++){
+ lut[i]=(unsigned char)(((pow(min(fltmax,max(0.0f,(((((float)i)/256.0f)-black_in)/(white_in-black_in)))),(1.0/gamma))*(white_out-black_out))+black_out)*255.0f);
+ }
+ }
+ void apply(const cv::Mat& in,cv::Mat &out){ //facility to apply to other images for inherited classes
+ out.create(in.rows,in.cols,in.type());
+ for (int i=0;i<in.rows*in.cols*in.channels();i++){
+ out.data[i]=lut[in.data[i]];
+ }
+ }
+ protected:
+ unsigned char *lut;
+ };
//actual nodes-------------------------------------------------
class Time: public Signal_node {
public:
@@ -752,6 +784,8 @@ namespace Rotor {
}
else image.alpha_from_cv(mask);
return &image;
+
+ //cv::cvtColor
}
//if there aren't 2 image inputs connected just return the first
return in1;
@@ -761,7 +795,7 @@ namespace Rotor {
private:
cv::Mat greyfg,greybg,greyDiff,mask;
};
-#define VIDEOFRAMES_still 1
+#define VIDEOFRAMES_frame 1
#define VIDEOFRAMES_blend 2
class Video_loader: public Image_node {
public:
@@ -769,7 +803,7 @@ namespace Rotor {
create_parameter("speed","number","video playback speed","Speed",1.0f,0.0f,0.0f);
create_parameter("framerate","number","framerate override","Frame rate",0.0f,0.0f,0.0f);
create_attribute("filename","name of video file to load","File name","");
- create_attribute("mode","frame mode","Mode","still",{"still","blend"});
+ create_attribute("mode","frame mode","Mode","frame",{"frame","blend"});
title="Video loader";
description="Loads a video file";
};
@@ -788,7 +822,6 @@ namespace Rotor {
bool isLoaded;
private:
libav::decoder player;
- int mode;
int lastframe;
};
class Video_output: public Image_node {