From 39fc781abbbfcc7fbb2f4b2ac391aafa8cd19b9f Mon Sep 17 00:00:00 2001 From: Vincent Tavernier <vincent.tavernier@inria.fr> Date: Sat, 17 Jun 2017 15:56:34 +0200 Subject: [PATCH] More samples and config support --- CMakeLists.txt | 82 ++++++++++++++++++++++++++++++++++++++++-- include/AppConfig.hpp | 7 ++++ samples/ccblending.fsh | 2 +- samples/procmarble.fsh | 10 +++--- samples/wn_raw.fsh | 4 +++ samples/wn_rawstep.fsh | 36 +++++++++++++++++++ samples/wn_rawstep.ini | 6 ++++ src/AppConfig.cpp | 6 ++++ src/GLcvApp.cpp | 3 ++ 9 files changed, 147 insertions(+), 9 deletions(-) create mode 100644 samples/wn_rawstep.fsh create mode 100644 samples/wn_rawstep.ini diff --git a/CMakeLists.txt b/CMakeLists.txt index 03ed52d..c8195aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,7 +184,8 @@ if (GLCV_FULL_BUILD) find_program(FFMPEG ffmpeg) if (FFMPEG) # The base ffmpeg command - set(FFMPEG_COMMAND ${FFMPEG} -y -r 60) + set(FPS 25) + set(FFMPEG_COMMAND ${FFMPEG} -y -r ${FPS}) # Render format set(RENDER_FORMAT mp4) @@ -195,9 +196,21 @@ if (GLCV_FULL_BUILD) add_custom_command( OUTPUT ${RENDER_DIRECTORY}/${sample_name}.${RENDER_FORMAT} DEPENDS $<TARGET_FILE:GLcv> ${render_config} ${deps} - COMMAND $<TARGET_FILE:GLcv> ${render_config} --render.dir ${RENDER_DIRECTORY}/${sample_name} ${optargs} + COMMAND $<TARGET_FILE:GLcv> ${render_config} -f ${FPS} --render.dir ${RENDER_DIRECTORY}/${sample_name} ${optargs} COMMAND ${FFMPEG_COMMAND} -i '${RENDER_DIRECTORY}/${sample_name}/${CONFIG_BASENAME}-%04d.png' - ${RENDER_DIRECTORY}/${sample_name}.${RENDER_FORMAT} + -pix_fmt yuv420p ${RENDER_DIRECTORY}/${sample_name}.${RENDER_FORMAT} + ) + set(SAMPLE_OUTPUTS "${SAMPLE_OUTPUTS}" "${RENDER_DIRECTORY}/${sample_name}.${RENDER_FORMAT}" PARENT_SCOPE) + endfunction() + + function(render_sample_cv sample_name cvalg render_config optargs deps) + get_filename_component(CONFIG_BASENAME ${render_config} NAME_WE) + add_custom_command( + OUTPUT ${RENDER_DIRECTORY}/${sample_name}.${RENDER_FORMAT} + DEPENDS $<TARGET_FILE:GLcv> ${render_config} ${deps} + COMMAND $<TARGET_FILE:GLcv> ${render_config} -f ${FPS} --render.dir ${RENDER_DIRECTORY}/${sample_name} ${optargs} --cv=${cvalg} + COMMAND ${FFMPEG_COMMAND} -i '${RENDER_DIRECTORY}/${sample_name}/${CONFIG_BASENAME}-${cvalg}%04d.png' + -pix_fmt yuv420p ${RENDER_DIRECTORY}/${sample_name}.${RENDER_FORMAT} ) set(SAMPLE_OUTPUTS "${SAMPLE_OUTPUTS}" "${RENDER_DIRECTORY}/${sample_name}.${RENDER_FORMAT}" PARENT_SCOPE) endfunction() @@ -233,11 +246,56 @@ if (GLCV_FULL_BUILD) "-DFIXMODE=1;-W256;--render.end=376" ${SAMPLES_DIR}/3advect.fsh) + render_sample(wn_rawstep_0 + ${SAMPLES_DIR}/wn_rawstep.ini + "-DTEXSTEP=0;-W512;--render.end=600;-Dh=.125" + ${SAMPLES_DIR}/wn_rawstep.fsh) + + render_sample(wn_rawstep_1 + ${SAMPLES_DIR}/wn_rawstep.ini + "-DTEXSTEP=1;-W512;--render.end=600;-Dh=.125" + ${SAMPLES_DIR}/wn_rawstep.fsh) + + render_sample(wn_rawstep_2 + ${SAMPLES_DIR}/wn_rawstep.ini + "-DTEXSTEP=2;-W512;--render.end=600;-Dh=.125" + ${SAMPLES_DIR}/wn_rawstep.fsh) + + render_sample_cv(wn_rawspec_0 spectrum + ${SAMPLES_DIR}/wn_raw.ini + "-DNORM_METHOD=0;-W512;--render.end=600;-Dh=.667;--cv.split;--postprocess=../configs/pp_fftscale.fsh;--mouse.y=0.05" + ${SAMPLES_DIR}/wn_raw.fsh) + + render_sample_cv(wn_rawspec_1 spectrum + ${SAMPLES_DIR}/wn_raw.ini + "-DNORM_METHOD=0;-W512;--render.end=600;-Dh=.250;--cv.split;--postprocess=../configs/pp_fftscale.fsh;--mouse.y=0.07" + ${SAMPLES_DIR}/wn_raw.fsh) + render_sample(wn_raw_00 ${SAMPLES_DIR}/wn_raw.ini "-DNORM_METHOD=0;-W512;--render.end=600;-Dh=.125" ${SAMPLES_DIR}/wn_raw.fsh) + render_sample(tn_temporal_nofix + ${SAMPLES_DIR}/tuning_noise_temporal.ini + "--render.end=600;-DFIXMODE=0" + ${SAMPLES_DIR}/tuning_noise_temporal.fsh) + + render_sample(tn_temporal_fix + ${SAMPLES_DIR}/tuning_noise_temporal.ini + "--render.end=600;-DFIXMODE=1" + ${SAMPLES_DIR}/tuning_noise_temporal.fsh) + + render_sample_cv(tn_temporal_nofix_flow optical_flow + ${SAMPLES_DIR}/tuning_noise_temporal.ini + "--render.end=600;-DFIXMODE=0;--postprocess=${CONFIGS_DIR}/pp_optical_flow.fsh" + ${SAMPLES_DIR}/tuning_noise_temporal.fsh) + + render_sample_cv(tn_temporal_fix_flow optical_flow + ${SAMPLES_DIR}/tuning_noise_temporal.ini + "--render.end=600;-DFIXMODE=1;--postprocess=${CONFIGS_DIR}/pp_optical_flow.fsh" + ${SAMPLES_DIR}/tuning_noise_temporal.fsh) + # Normal and contrast corrected, no rnd render_sample(wn_raw_01 ${SAMPLES_DIR}/wn_raw.ini @@ -302,6 +360,11 @@ if (GLCV_FULL_BUILD) "-DNORM_METHOD=0;-W512;--render.end=600;-Dh=.0833;-Dai_fun=ai_fun_exp" ${SAMPLES_DIR}/wn_raw.fsh) + render_sample(wn_sliding_split + ${SAMPLES_DIR}/wn_raw.ini + "-DNORM_METHOD=0;-W512;--render.end=600;-Dh=.125;-Dai_fun=ai_fun_exp;-DSPLIT_AI=1" + ${SAMPLES_DIR}/wn_raw.fsh) + render_sample(ccblending_fix_nosprite ${SAMPLES_DIR}/ccblending.ini "-DFIXMODE=1;-DDRAWPATCHES=0;--render.end=600" @@ -322,6 +385,19 @@ if (GLCV_FULL_BUILD) "-DFIXMODE=1;-DDRAWPATCHES=1;--render.end=600" ${SAMPLES_DIR}/ccblending.fsh) + macro(render_sample_npext name texture) + render_sample(npext-${name} + ${SAMPLES_DIR}/wn_raw.ini + "-Dai_fun=ai_fun_exp;-Dpos_fun=pos_fun_rnd;-Dh=.25;-W512;--image.0.type=texture;--image.0.source=textures/${texture};--render.end=600" + "${WN_DEPS};configs/textures/${texture}") + endmacro() + + render_sample_npext(bricks tex00.jpg) + render_sample_npext(wood tex05.jpg) + render_sample_npext(iron tex02.jpg) + render_sample_npext(stone tex09.jpg) + render_sample_npext(pebbles tex10.png) + add_custom_target(samples DEPENDS ${SAMPLE_OUTPUTS}) if (OLD_RENDER_DIRECTORY) set(CMD "([ ! -e ${OLD_RENDER_DIRECTORY} ] && ln -fs ${RENDER_DIRECTORY} ${OLD_RENDER_DIRECTORY}) | true") diff --git a/include/AppConfig.hpp b/include/AppConfig.hpp index 310a339..a576872 100644 --- a/include/AppConfig.hpp +++ b/include/AppConfig.hpp @@ -235,6 +235,13 @@ public: * @brief Set the render format */ void SetRenderFormat(ScreenshotFormat format); + + /** + * @brief Return a value indicating if the view mode should be split + * + * @return true for split mode, false for default (full CV). + */ + bool GetCvSplit() const; #endif }; diff --git a/samples/ccblending.fsh b/samples/ccblending.fsh index 73e27b3..167fcdb 100644 --- a/samples/ccblending.fsh +++ b/samples/ccblending.fsh @@ -23,7 +23,7 @@ void mainImage( out vec4 O, vec2 U ) float s=0., s2=0., v; for (int i=0; i<150; i++) { - vec2 V = U-rnd(vec2(i))*r + .1*cos(vec2(i)+iDate.w+vec2(0,1.6)); // sprite position + vec2 V = U-rnd(vec2(i))*r + .1*cos(vec2(i)+iGlobalTime+vec2(0,1.6)); // sprite position v = K(V); s += v; s2 += v*v; // kernel and momentums O += v*T(V); diff --git a/samples/procmarble.fsh b/samples/procmarble.fsh index f73a90e..681e571 100644 --- a/samples/procmarble.fsh +++ b/samples/procmarble.fsh @@ -44,7 +44,7 @@ float doModel( vec3 p ) //------------------------------------------------------------------------ vec3 doMaterial( in vec3 pos, in vec3 nor ) { - return texelFetch(iChannel1, ivec2(511*(1. + sin(floor(scale*(length(pos.xy - .5) + .1*(sin(12.*pos.x))*texture(iChannel0, pos.xy).r))))/2., 0), 0).rgb/4.; + return texelFetch(iChannel1, ivec2(511*(1. + sin(scale*(length(pos.xy - .5) + .1*(sin(12.*pos.x))*texture(iChannel0, pos.xy).r)))/2., 0), 0).rgb/4.; } //------------------------------------------------------------------------ @@ -138,13 +138,13 @@ mat3 calcLookAtMatrix( in vec3 ro, in vec3 ta, in float roll ) void mainImage(out vec4 O, in vec2 U) { #if TEXSTEP==0 - O = vec4((1. + sin(floor(scale*(length(U/iResolution.xy - .5))))))/2.; + O = vec4((1. + sin(scale*(length(U/iResolution.xy - .5)))))/2.; #elif TEXSTEP==1 - O = vec4((1. + sin(floor(scale*(length(U/iResolution.xy - .5) + .1*texture(iChannel0, U/iResolution.xy).r)))))/2.; + O = vec4((1. + sin(scale*(length(U/iResolution.xy - .5) + .1*texture(iChannel0, U/iResolution.xy).r))))/2.; #elif TEXSTEP==2 - O = vec4((1. + sin(floor(scale*(length(U/iResolution.xy - .5) + .1*(sin(12.*U.x/iResolution.x))*texture(iChannel0, U/iResolution.xy).r)))))/2.; + O = vec4((1. + sin(scale*(length(U/iResolution.xy - .5) + .1*(sin(12.*U.x/iResolution.x))*texture(iChannel0, U/iResolution.xy).r))))/2.; #elif TEXSTEP==3 - O = texelFetch(iChannel1, ivec2(511*(1. + sin(floor(scale*(length(U/iResolution.xy - .5) + .1*(sin(12.*U.x/iResolution.x))*texture(iChannel0, U/iResolution.xy).r))))/2., 0), 0); + O = texelFetch(iChannel1, ivec2(511*(1. + sin(scale*(length(U/iResolution.xy - .5) + .1*(sin(12.*U.x/iResolution.x))*texture(iChannel0, U/iResolution.xy).r)))/2., 0), 0); #elif TEXSTEP==4 vec2 p = (-iResolution.xy + 2.0*U.xy)/iResolution.y; diff --git a/samples/wn_raw.fsh b/samples/wn_raw.fsh index f65ad5f..5a877c2 100644 --- a/samples/wn_raw.fsh +++ b/samples/wn_raw.fsh @@ -36,7 +36,11 @@ void mainImage(out vec4 O, in vec2 U) // Add up gaussian-intensity modulated samples of noise for (float sf = 0.; sf < H; sf += h) { +#ifdef SPLIT_AI + float k = uv.x < 0. ? ai_fun_def(sf) : ai_fun_exp(sf), +#else float k = ai_fun(sf), +#endif e = k - 1., C = exp(-(e*e) / s); // Intensity scaling gaussian diff --git a/samples/wn_rawstep.fsh b/samples/wn_rawstep.fsh new file mode 100644 index 0000000..72692aa --- /dev/null +++ b/samples/wn_rawstep.fsh @@ -0,0 +1,36 @@ +void mainImage(out vec4 O, in vec2 U) +{ + // screen-centered coordinates + vec2 uv = (U.xy / iResolution.xy - .5); + + // Initial acc + O = vec4(0.); + +#if TEXSTEP==0 + O += texture(iChannel0, pos_fun(uv, ai_fun(0.), 0.)); +#elif TEXSTEP==1 + float a = 0.; + for (float sf = 0.; sf < H; sf += h) + { + float k = ai_fun(sf); + vec2 P = pos_fun(uv, k, sf); + O += texture(iChannel0, P); + a++; + } + O /= a; +#elif TEXSTEP==2 + float a = 0.; + // Add up gaussian-intensity modulated samples of noise + for (float sf = 0.; sf < H; sf += h) + { + float k = ai_fun(sf), + e = k - 1., + C = exp(-(e*e) / s); // Intensity scaling gaussian + + vec2 P = pos_fun(uv, k, sf); + O += C * texture(iChannel0, P); + a += C; + } + O /= a; +#endif +} diff --git a/samples/wn_rawstep.ini b/samples/wn_rawstep.ini new file mode 100644 index 0000000..f16003d --- /dev/null +++ b/samples/wn_rawstep.ini @@ -0,0 +1,6 @@ +[image] +shader = ../configs/np_def.fsh;wn_rawstep.fsh + +[image.0] +type = noise +filter = linear diff --git a/src/AppConfig.cpp b/src/AppConfig.cpp index a8f5b03..c520ca4 100644 --- a/src/AppConfig.cpp +++ b/src/AppConfig.cpp @@ -59,6 +59,7 @@ AppConfig::AppConfig() #if GLCV_FULL_BUILD ("no-gui", "hide the GUI when starting the application") ("cv", po::value<string>()->default_value(""), "OpenCV algorithm to apply") + ("cv.split", "enable split mode") ("render.dir", po::value<fs::path>()->default_value(fs::path("frames")), "screenshot output folder") ("render.start", po::value<int>()->default_value(-1), "starting frame for render") ("render.end", po::value<int>()->default_value(-1), "exclusive ending frame for render") @@ -384,4 +385,9 @@ void AppConfig::SetRenderFormat(ScreenshotFormat format) { renderFormat = format; } + +bool AppConfig::GetCvSplit() const +{ + return vm.count("cv.split") > 0; +} #endif \ No newline at end of file diff --git a/src/GLcvApp.cpp b/src/GLcvApp.cpp index 1287a16..9ba65ba 100644 --- a/src/GLcvApp.cpp +++ b/src/GLcvApp.cpp @@ -90,6 +90,9 @@ GLcvApp::GLcvApp(GLFWwindow *window, AppConfig &config) : if (!config.GetNoGui()) frameMode |= FM_GUI; + + if (config.GetCvSplit()) + frameMode |= FM_SPLIT; #endif } -- GitLab