Commit 824199bc authored by Arnaud Blanchard's avatar Arnaud Blanchard

Add funtions for image processing and profiling

parent 20c75720
[submodule "blibs/blc_core"]
path = blibs/blc_core
url = https://framagit.org/blibs/blc_core.git
[submodule "blibs/blc_channel"]
path = blibs/blc_channel
url = https://framagit.org/blibs/blc_channel.git
[submodule "blibs/blc_network"]
path = blibs/blc_network
url = https://framagit.org/blibs/blc_network.git
[submodule "blibs/blc_program"]
path = blibs/blc_program
url = https://framagit.org/blibs/blc_program.git
[submodule "blibs/blc_process"]
path = blibs/blc_process
url = https://framagit.org/blibs/blc_process.git
[submodule "blibs/blc_image"]
path = blibs/blc_image
url = https://framagit.org/blibs/blc_image.git
[submodule "blc_channels"]
path = blc_channels
url = https://framagit.org/blaar/blc_channels.git
[submodule "bapps"]
path = bapps
url = https://framagit.org/blaar/bapps.git
[submodule "o_gnuplot"]
path = o_gnuplot
url = https://framagit.org/blaar/o_gnuplot.git
[submodule "fftw"]
path = fftw
url = https://framagit.org/blaar/fftw.git
[submodule "sndfile"]
path = sndfile
url = https://framagit.org/blaar/sndfile.git
[submodule "png"]
path = png
url = https://framagit.org/blaar/png.git
[submodule "gtk"]
path = gtk
url = https://framagit.org/blaar/gtk.git
[submodule "coreaudio"]
path = coreaudio
url = https://framagit.org/blaar/coreaudio.git
[submodule "ipp"]
path = ipp
url = https://framagit.org/blaar/ipp
bapps @ effd4e2f
Subproject commit effd4e2fa58727ca4cc8555b47ffd45dae47fb84
blc_channels @ b13fa9ad
Subproject commit b13fa9ad9af28ee32458acecec97d9a0d38bf64a
blc_channel @ 58796a13
Subproject commit 58796a13355a50b38d5af6df0a1f5cfed7a761b7
blc_core @ 87bdfc48
Subproject commit 87bdfc483a99753fe34bd8d10f76c6cce8a80298
blc_image @ 6f675dd3
Subproject commit 6f675dd32040cc1f650237cd2b22510129df6473
blc_network @ c7ef09ae
Subproject commit c7ef09ae1ab51142d3dfd0a1f2b1d7987faa5fee
blc_process @ f8d7504d
Subproject commit f8d7504d37f57998fa9ea80f9fdc59da14d276e5
blc_program @ ed5ededa
Subproject commit ed5ededa999a5255fd8547482e685405e14513a9
coreaudio @ 24e7c7ed
Subproject commit 24e7c7ed81137ccb0bece8691ef3b86ac87f71f5
fftw @ 1fc6a2a2
Subproject commit 1fc6a2a2241be142eaf94b24bbfbd9aa9a4bf9da
gtk @ c3d99649
Subproject commit c3d996494007244588fa1425d3bfdad4c517dbd2
i_QTKit_camera @ a4863a8a
Subproject commit a4863a8aa1cd5ed74c3e0ccf8c60da5a6bcaab63
ipp @ b560d8d6
Subproject commit b560d8d66c1c52dd42f3d72afc9f6efce1f9ffaa
o_gnuplot @ fe14c8a5
Subproject commit fe14c8a503436f15aad9395962e3ed5f302925eb
png @ 2f380916
Subproject commit 2f380916787a0c585bff6f4787db559d4bb66e47
source blaar.sh
blaar_init_options "Conv image with on black and white camera and display it"
blaar_parse_args "$@"
i_d2gaussian --size=32x32 -o/kernel$$ && i_pngfile $1 --format=Y800 -o/image$$
f_conv /image$$ /kernel$$ -o/conv$$ |o_gtk_image
#remove the used blc_channels
blc_channels --unlink /kernel$$
blc_channels --unlink /image$$
blc_channels --unlink /conv$$
\ No newline at end of file
# Basic Libraries And Applications for Robotics (BLAAR)
# Copyright ETIS — ENSEA, University of Cergy-Pontoise, CNRS (2011 - 2017)
# Author: Arnaud Blanchard
#
# This software is governed by the CeCILL v2.1 license under French law and abiding by the rules of distribution of free software.
# You can use, modify and/ or redistribute the software under the terms of the CeCILL v2.1 license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".
# As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
# users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
# In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge.
# Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured  and, more generally, to use and operate it in the same conditions as regards security.
# The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms.
source blaar.sh
[ $# = 1 ]&&PID=$1||PID=$$
echo $TMP_DIR/processes.dot
echo "digraph{ A }" > $TMP_DIR/processes.dot
if [ $(uname) = "Darwin" ]; then
open -a graphviz $TMP_DIR/processes.dot
#xdot $TMP_DIR/processes.dot
fi
$BLAAR_DIR/run.sh $BLAAR_DIR/graphviz/gv_process --refresh=1000 --file=$TMP_DIR/processes.dot $PID
#blaar_module graphviz gv_process --refresh=1000 --file=$TMP_DIR/processes.dot $PID
source blaar.sh
#gnuplot << EOF #'-' to remove indenting tabulation
#stats '$1' using 2 name 'A'
#set title "Stats"
#set style fill solid 0.3
#set style histogram errorbars linewidth 1
#set bars front
#plot '' using (1):('A_means'):('A_stddev'):xtic(1) with boxerrorbars
#pause mouse close
#EOF
gnuplot <(
echo "stats '$1' every ::::0 using 1 nooutput"
echo "offset=STATS_min"
echo "set grid"
echo "set border 3"
echo "set xlabel 'time (ms)' font ', 16'"
#echo "set ylabel 'process' font ', 16'" >> $TMP_DIR/profile.plt
echo "set yrange[-$#:0.1]"
echo "set ytics font ', 16' scale 0 rotate by 45 right"
i=0
printf "set ytics (" #printf for no line return
for file in "$@"
do
printf "'$(basename $file .tsv)' -$i-0.1, "
((i++))
done
echo ")"
printf "plot "
i=0
for file in "$@"
do
printf "'$file' using ((\$1-offset)/1000):(-$#):(0):($#-$i) every ::0::0 notitle with vector linewidth 1 linecolor $i, "
printf "'$file' using ((\$1-offset)/1000):(-$#):(0):($i) every ::0::0 notitle with vector linewidth 1 linecolor $i, "
printf "'$file' using ((\$1-offset)/1000):(-$i):(0):($i-$#) every ::1 notitle with vector nohead linewidth 1 linecolor $i, "
printf "'$file' using ((\$1-offset)/1000):(-$i-0.1):((\$2-\$1)/1000):(0) every ::1 notitle with vector nohead linewidth 1 linecolor $i , " # every ::1 avoid first point
printf "'$file' using ((\$2-offset)/1000):(-$i):(0):($i-$#) every ::1 notitle with vector nohead linewidth 1 linecolor $i, "
printf "'$file' using ((\$2-offset)/1000):(-$i-0.1):(\$3/1000):(0) every ::1 title '$(basename $file .tsv)' with vector size 2,60 noborder linewidth 10 linecolor $i , " # every ::1 avoid first point
printf "'$file' using ((\$2-offset+\$3)/1000):(-$i):(0):($i-$#) every ::1 notitle with vector nohead linewidth 1 linecolor $i, "
((i++))
done
echo " -$# linewidth 2 notitle"
echo "pause mouse close"
) &
gnuplot <(
#generating duration stats
echo "set print 'durations.dat'"
for file in "$@"
do
echo "stats '$file' every ::1 using 3 nooutput" # every ::1 avoid first point
echo "print STATS_mean, STATS_stddev"
done
echo "set print"
echo "stats '$1' every ::::0 using 1 nooutput"
echo "offset=STATS_min"
echo "delta_v(x) = ( vD = x - old_v, old_v = x, vD)"
echo "old_v = offset"
echo "set xrange [3000000:*]" #We do stat after the first 3 s
echo "set print 'period.dat'"
for file in "$@"
do
echo "stat '$file' every ::1 using (\$1-offset):(delta_v(\$1)) nooutput"
echo "print STATS_mean_y, STATS_stddev_y"
done
echo "set print"
echo "stats 'period.dat' using 1 nooutput"
echo "period=STATS_max"
#graphic stats
echo "set multiplot layout 2, 1 "
echo "set title 'duration' font ',24'"
echo "unset key"
echo "set boxwidth 0.90"
echo "set border 3"
echo "set ylabel 'time (ms)' font ', 16'"
echo "set style fill transparent solid 0.5"
echo "set xrange[-0.5:$#-0.5]"
printf "set xtics (" #printf for no line return
i=0
for file in "$@"
do
printf "'$(basename $file .tsv)' $i, "
((i++))
done
echo ") font ', 16'"
echo "plot 'durations.dat' using 0:(\$1/1000):(\$2/1000):0 with boxerror linecolor variable, '' using 0:(\$1/1000):(sprintf('%.3fms', \$1/1000)) with labels offset 0,1 font ',14'"
echo "set title 'period' font ',24'"
echo "unset key"
echo "plot 'period.dat' using 0:(\$1/1000):(\$2/1000):0 with boxerror linecolor variable, '' using 0:(\$1/1000):(sprintf('%.3fms', \$1/1000)) with labels offset 0,1 font ',14'"
echo "unset multiplot"
echo "pause -1"
)
......@@ -4,12 +4,20 @@ blaar_init_options "Apply a f_filter on black and white camera and display it"
blaar_add_option gain g "" "real" "gain" "1"
blaar_add_option output o "" "blc_channel-out" "convolution output" :corner$$
blaar_add_option size s "" "(integer)x(interger)" "size of the filter" "3x3"
blaar_add_option grad_size G "" "(integer)x(interger)" "size of the gradient filter"
blaar_add_option max_size M "" "(integer)x(interger)" "size of the Max filter"
blaar_add_option sigma S "" "real" "sigma of the filter (-1 for size/6)" -1
blaar_add_parameter image "blc_channel-in" "1" "image you want to apply the gradient on"
blaar_parse_args "$@"
kernel=$(i_gaussian -D2 -o/kernel$$ -p0 2>$TMP_DIR/log ) || { cat $TMP_DIR/log; echo "Error creating the kernel"; exit 2; }
grad_size=${grad_size:-$size}
max_size=${max_size:-$size}
kernel=$(i_gaussian -D2 -s$max_size -o/kernel$$ -p0 2>$TMP_DIR/log ) || { cat $TMP_DIR/log; echo "Error creating the kernel"; exit 2; }
# pipe create a subshell therefore grad_norm is only visible by the subshel. That why we use {} to make all the thing using read in the same subshell.
# The read is needed to put the image before the kernel
f_grad_norm.sh $image | { read grad_norm; f_conv -o/corner $grad_norm $kernel; }
\ No newline at end of file
f_grad_norm.sh -s$grad_size $image |{
read grad_norm
f_conv -o$output $grad_norm $kernel
}
......@@ -3,16 +3,27 @@ source blaar.sh
blaar_init_options "Apply a f_filter on black and white camera and display it"
blaar_add_option direction d "" "string" "direction of the gradient (x, y)"
blaar_add_option gain g "" "real" "gain" "1"
blaar_add_option output o "" "blc_channel-out" "convolution output" :conv$$
blaar_add_option output o "" "blc_channel-out" "convolution output" :grad$$
blaar_add_option size s "" "(integer)x(interger)" "size of the filter" "3x3"
blaar_add_option sigma S "" "real" "sigma of the filterr" -1
blaar_add_option sigma S "" "real" "sigma of the filter" -1
blaar_add_option profile p "" "filename" "profile the script" ""
blaar_add_parameter image "blc_channel-in" "1" "image you want to apply the gradient on"
blaar_parse_args "$@"
[ "$direction" = "x" ] && option="-x1" || { [ "$direction" = "y" ] && option="-y1"; } || { echo "Wrong direction option '$direction'"; exit 1; }
echo "Profile:$profile" >&2
[ "$profile" != "" ] && profile_option="-~$profile" || profile_option=""
kernel=$(i_gaussian $option -g$gain -s$size -S$sigma -o/d${direction}gaussian$$ -p0 2>$TMP_DIR/log ) || { cat $TMP_DIR/log; echo "Error creating the kernel"; exit 2; }
# -p0 is because we do not want block
#./run.sh ipp/
f_ipp_convolute $profile_option -o$output $image $kernel
#./run.sh armadillo/f_arma_convolute -o$output -~grad.tsv $image $kernel
#./run.sh bapps/f_conv -o$output -~grad.tsv $image $kernel
f_conv -o$output $image $kernel
#remove the used blc_channels
blc_channels --unlink /d${direction}gaussian$$
source blaar.sh
function grad {
id=$$
#Tmeporary named pipe to be able to export stdout from subshell to this process
exec 3>&1
tee >(f_grad.sh -g$gain -s$size -dy -o:convy$id $image 1>&3) | f_grad.sh -g$gain -s$size -dx -o:convx$id $image
exec 3>&-
}
blaar_init_options "Apply a f_filter on black and white camera and display it"
blaar_add_option gain g "" "real" "gain" "1"
blaar_add_option output o "" "blc_channel-out" "convolution output" :grad_norm$$
......@@ -17,4 +8,15 @@ blaar_add_option sigma S "" "real" "sigma of the filter (-1 for size/6)" -1
blaar_add_parameter image "blc_channel-in" "1" "image you want to apply the gradient on"
blaar_parse_args "$@"
grad | f_norm -o$output
f_grad.sh -pgrad.tsv -dx -g$gain -s$size $image |
{ read gradx
f_grad.sh -pgrady.tsv -dy -g$gain -s$size -o:grady$$ $image |
f_norm -o$output $gradx
#Cleaning intermediate blc_channels
blc_channels -u$gradx
blc_channels -u/grady$$
}
#read gradx ... needs to be in { } otherwise $gradx is not accessible by f_norm. After | read would have been in a subshell. With {} everything is in the same subshell.
source blaar.sh
blaar_init_options "Apply points of interest on ilage"
blaar_add_option max_nb n "" "interger" "number of max" "100"
blaar_add_option size G "" "(integer)x(interger)" "size of the filter" "8x8"
blaar_add_option size M "" "(integer)x(interger)" "size of the filter" "64x64"
blaar_add_option sigma S "" "real" "sigma of the filterr" -1
blaar_add_parameter image "blc_channel-in" "1" "image you want to apply the point of interest"
blaar_parse_args "$@"
f_corner.sh -G8x8 -M64x64 -o:corner$$ $image |
f_arg_max -n$max_nb -x36 -y36| { read arg_max
o_gnuplot_poi $image $arg_max
}
blc_channels -u /corner$$
blc_channels -u /arg_max
sndfile @ 2321e798
Subproject commit 2321e798d2eeb40f951a004f8df13727984dfe99
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment