Commit cf38ee54 authored by Arnaud Blanchard's avatar Arnaud Blanchard

Add funtions for image processing and profiling

parent 74b39499
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
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