From 4aa1d62480c9fc1c252cdc74c8de6deb6dddcedf Mon Sep 17 00:00:00 2001 From: micuat Date: Mon, 19 Oct 2020 17:03:34 +0200 Subject: [PATCH] color remapping --- zoneb/bin/data/gradient.png | Bin 0 -> 5795 bytes zoneb/bin/data/shaders/render.frag | 4 +++- zoneb/src/ofApp.cpp | 5 +++++ zoneb/src/ofApp.h | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 zoneb/bin/data/gradient.png diff --git a/zoneb/bin/data/gradient.png b/zoneb/bin/data/gradient.png new file mode 100644 index 0000000000000000000000000000000000000000..c4259007fbbe19e4046db519627a117bded37c16 GIT binary patch literal 5795 zcmeI#TU1kL+Q4z9*3Ux?C^Uj7GK_;(jw2SRA~G`-5G)ds>;#e;iik)cFxW!&p7;Sj0j@L_4FR9gS-7k@1L*7~8t!>7NGGD|y?HgizbCk0p=P{Sl`Buh{Xd0PcgII`WwVA29t6@Kg1BnZ5^rS-lN2-~ex(euwNY z2e^6qRdWfqnyqsYmylaTX^x*u)UC$ST%k#IAsPR0BqwxB6TuxR4|Qn5KOV^s-RePn zHBuVt=z(t-Id{+Qd*ZW^YxlN&kGqXryk~!uNZM4ve$pKx+i{JxuRB%dx{Y(YJ3_W= zTLjb{BlFzGe$)Lo;E&r_Rk@4!7mw>Z*CIf5OE9zOl*Yw69aF^AFL+I|di3eQfh3Nz zo(Fg(Mbzp~0{fHLarz*@Cy6zthk=6)9Hw3X>`{2*?8ru!TmTP^#PA#@E{JTxbK^`z z3zuBmg_XzT;mpm%P|PLVW;3phIg8uAAQmcyC-+?BSLi<>_gw^z>Fr4G zUvFr$2XMr$7S6ha$JU9oagUVRt=q?IQVOfB2%^0`62@Y;Qk6i6dV%=H!aRhhAYpIorkDS4}~= z$)@^#pm5zW4xqKH}4-8tbxnCaRwu#&9>@ z?EgH>%3!?M&oyiaGdA=`8Y~Nq*ZNro2E%xV6>TV1Rth$n@a*a$!G~g^r@BmFEykby zouU5t>)NtxlNeIg@v?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cawOc_5)B!Yxn=Ps*xu?;f&M0fI& z#Ok}kFTMX+j#V{c3q9q^yurw@wjgnvH<#0Jc7Zez7%x0br4?(*h`kN%MUn@unB>%@%;UkDq|7$&Fn9m+MzMAB{{am7YPuwxa_j9WnN`Od@ z`!(spWOeUpOjpL4Qf(7=#qrm;$@ia%BAxClEQKf2zVpIr$|4+88%(!q`McaI_9rBe zyN}cy6^hgDvN2T|yF&G$=}tzSN95_Wfl};98TVNGpH2DBJpL3X&0vj9l(C++yl<-O z;cMI~wUSiQp`d13kd)SU9DBQ&o3xqx;ULd*a>rap zhH|OJ%2+ku2`9{8{P`wWGNbgJZ(q2-RJ+u!F$OHZS?XG*gelPS0&1Qgru}BXna&BF zxzfD!mR{osI%dAg`1z7~wwK;j1v-Hd3NWGu9#B97HOQXh;GS5x^*Hn{)?7vZl#P1T zqAoIYzZ%_Hi25|59u??89qM!*-BW|^zKrfuq0R-UH-Wm#(RZN+3Csrr3*hL?ai;4F zrsuTmqY;_gxXfit<}oGPJt}jbkh#8;dCmaJAAyEf?;=enb^R>WQcWo@QMX#D8+p`C zjB2<_-MLLEvZ=OO3YSq@HC0zgwKq~t71X;xBYM^;>dM^of1xQcPibiBGw9iwnZ=*Z z`+_az(PFy9iSDna-^Ce)Z$har)aDzPZ=PtTjTn71f&O`%zPN>caFuR|q9>ow*Y?pr z+@|k9^sjH|cVPye7=$J$WUCLj)fblgKyqJ1*bWLc@NhdctU>(JK|d+nkq&i85o8{G z7iEz6@4@&!_~rM|%Ra=`1GM#oQ4a|9MEFf0zZs^QAgUShO$L2aU`;agF33zT&gPn5 zR?+uSn&8tD6fO6qqt8HRmZuh97yo|htjtP*l>#dTRtl^XSShelV5PwSbAfM`9W8zd Y$SE^Pz1tMKe*Ziq@aUnYzkhM=zcst`vH$=8 literal 0 HcmV?d00001 diff --git a/zoneb/bin/data/shaders/render.frag b/zoneb/bin/data/shaders/render.frag index 4cd307c..9008a1f 100644 --- a/zoneb/bin/data/shaders/render.frag +++ b/zoneb/bin/data/shaders/render.frag @@ -6,6 +6,7 @@ precision mediump float; uniform sampler2D uColorTex; // Sampler for the color registered data uniform sampler2D u_v4l2cam; +uniform sampler2D u_gradient; in vec2 gTexCoord; @@ -18,7 +19,8 @@ void main() st += vec2(0.5); st.s += 0.15; st.t += 0.16; - gl_FragColor = texture2D(u_v4l2cam, st); + float thermo = texture2D(u_v4l2cam, st).r; + gl_FragColor = vec4(texture2D(u_gradient, vec2(thermo, 0.5)).rgb, 1); // gl_FragColor = texture2D(uColorTex, gTexCoord); // gl_FragColor = vec4(1); } \ No newline at end of file diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index 2b5cd23..2833a29 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -68,6 +68,8 @@ void ofApp::setup() // we use a texture because the ofxV4L2 class has no draw method (yet) // we use GL_LUMINANCE because the ofxV4L2 class supports only grayscale (for now) v4l2Tex.allocate(camWidth, camHeight, GL_LUMINANCE); + + gradient.load("gradient.png"); } //-------------------------------------------------------------- @@ -121,6 +123,7 @@ void ofApp::draw() shader.setUniformTexture("uWorldTex", kinectDevice.getColorToWorldTex(), 2); shader.setUniformTexture("uColorTex", kinectDevice.getColorTex(), 3); shader.setUniformTexture("u_v4l2cam", v4l2Tex, 4); + shader.setUniformTexture("u_gradient", gradient, 5); shader.setUniform2i("uFrameSize", kinectDevice.getColorTex().getWidth(), kinectDevice.getColorTex().getHeight()); shader.setUniform2i("uDepthFrameSize", kinectDevice.getDepthInColorTex().getWidth(), kinectDevice.getDepthInColorTex().getHeight()); @@ -132,6 +135,7 @@ void ofApp::draw() shader.setUniformTexture("uWorldTex", kinectDevice.getDepthToWorldTex(), 2); shader.setUniformTexture("uColorTex", kinectDevice.getColorInDepthTex(), 3); shader.setUniformTexture("u_v4l2cam", v4l2Tex, 4); + shader.setUniformTexture("u_gradient", gradient, 5); shader.setUniform2i("uFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight()); shader.setUniform2i("uDepthFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight()); @@ -149,6 +153,7 @@ void ofApp::draw() boundShader.setUniformTexture("u_depth", tex); boundShader.setUniformTexture("u_ofcam", fbos.at("ofcam")); boundShader.setUniformTexture("u_v4l2cam", v4l2Tex); + boundShader.setUniformTexture("u_gradient", gradient); boundShader.setUniform1i("u_init", 1); boundShader.render(); boundShader.setUniform1i("u_init", 0); diff --git a/zoneb/src/ofApp.h b/zoneb/src/ofApp.h index b4cd475..03b4596 100644 --- a/zoneb/src/ofApp.h +++ b/zoneb/src/ofApp.h @@ -43,4 +43,6 @@ private: bool useColorSpace; ofxV4L2 v4l2Cam; ofTexture v4l2Tex; + + ofImage gradient; };