Commit 375cdaa5 authored by Arnaud Blanchard's avatar Arnaud Blanchard

Add image processing scripts

parent 6a197c09
[submodule "gtk"]
path = gtk
url = https://framagit.org/blaar/gtk
[submodule "i_QTKit_camera"]
path = i_QTKit_camera
url = https://framagit.org/blaar/i_QTKit_camera
[submodule "blibs/blQTkit"]
path = blibs/blQTkit
url = https://framagit.org/blibs/blQTkit
......@@ -5,7 +5,7 @@ Integration with blc_loop
output channel
--------------
Exeample defineing a synchronous (':', '/' for asynchronous) channel of unsigned char ('UIN8') of 4096 values with no specific format ('NDEF').
Example defining a synchronous (':', '/' for asynchronous) channel of unsigned char ('UIN8') of 4096 values with no specific format ('NDEF').
#include "blc_channel.h"
#include "blc_program.h"
......@@ -16,8 +16,7 @@ Exeample defineing a synchronous (':', '/' for asynchronous) channel of unsigned
output.create_or_open(":toto", BLC_CHANNEL_WRITE, 'UIN8', 'NDEF', 1, 4096);
output.publish();
//Synchronize the loop with the output channel
//Synchronize the BLC_COMMAND_LOOP with the output channel
blc_loop_try_add_waiting_semaphore(output.sem_ack_data);
blc_loop_try_add_posting_semaphore(output.sem_new_data);
......@@ -34,8 +33,7 @@ Open this same channel in reading synchronous (':', '/' for asynchronous) mode.
blc_channel input;
input.open(":toto", BLC_CHANNEL_READ);
//Synchronize the loop with the input channel
//Synchronize the BLC_COMMAND_LOOP with the output channel
blc_loop_try_add_waiting_semaphore(input.sem_new_data);
blc_loop_try_add_posting_semaphore(input.sem_ack_data);
gtk @ c3d99649
Subproject commit c3d996494007244588fa1425d3bfdad4c517dbd2
i_QTKit_camera @ a4863a8a
Subproject commit a4863a8aa1cd5ed74c3e0ccf8c60da5a6bcaab63
......@@ -45,12 +45,21 @@ blaar_module(){
test_run "$@"
}
blaar_init_options(){
[ $# = 1 ] || { usage; echo "You need a program desciption line. But you do not have argument"; exit 1; }
export blaar_options_nb=0
export blaar_parameters_nb=0
export blaar_program_desciption="$1"
}
blaar_add_option(){
(( $# < 5 )) && { echo "Wrong arguments number with add_option. You use '$#' instead of 5 or 6 with '$*'"; exit 1; }
(( $# > 6 )) && { echo "Wrong arguments number with add_option. You use '$#' instead of 5 or 6 with '$*'"; exit 1; }
[ $3 ] && { echo "Longname not yet in implemented. Use \"\" instead of '$3'"; exit 1; }
index=$blaar_options_nb
local index=$blaar_options_nb
blaar_options_variable[$index]="$1"
blaar_options_letter[$index]="$2"
......@@ -68,6 +77,28 @@ blaar_add_option(){
blaar_options_nb=$(( $blaar_options_nb + 1 ))
}
blaar_add_parameter(){
(( $# < 4 )) && { echo "Wrong arguments number with add_parameter. You use '$#' instead of 4 or 5 with '$*'"; exit 1; }
(( $# > 5 )) && { echo "Wrong arguments number with add_parameter. You use '$#' instead of 4 or 5 with '$*'"; exit 1; }
local index=$blaar_parameters_nb
blaar_parameters_variable[$index]="$1"
blaar_parameters_prompt[$index]="$2"
blaar_parameters_required[$index]="$3"
blaar_parameters_help[$index]="$4"
export ${blaar_parameters_variable[$index]}=""
if [ $# = 5 ]; then
blaar_parameters_default[$index]="$5"
else
blaar_parameters_default[$index]=""
fi
blaar_parameters_nb=$(( $blaar_parameters_nb + 1 ))
}
blaar_display_help(){
echo
[ $# = 0 ] || { echo "You should not have argument but you have '$*'"; exit 1; }
......@@ -88,11 +119,7 @@ blaar_display_help(){
done
}
blaar_init_options(){
[ $# = 1 ] || { usage; echo "You need a program desciption line. But you do not have argument"; exit 1; }
export blaar_options_nb=0
export blaar_program_desciption="$1"
}
blaar_parse_args(){
default_needed_indexes=''
......@@ -101,6 +128,7 @@ blaar_parse_args(){
do
default_needed_indexes[$i]=$i
done
blaar_add_option help "h" "" "" "display this help"
optstring=""
for ((i = 0; i < $blaar_options_nb; i++))
......@@ -119,15 +147,20 @@ blaar_parse_args(){
if [ ${blaar_options_parameter[$i]} ]; then
export ${blaar_options_variable[$i]}=$2
unset default_needed_indexes[$i]
shift
shift
else
${blaar_options_variable[$i]}="1"
fi
shift;
break
fi
[ $i = $blaar_options_nb ] && { blaar_display_help; echo "Unexpected option '$1'"; return 1; }
[[ $i = $blaar_options_nb ]] && { blaar_display_help; echo "Unexpected option '$1'"; return 1; }
done
shift
if [ $1 = "--" ];then
shift
break
fi
done
#We set default values
......@@ -135,6 +168,20 @@ blaar_parse_args(){
do
export ${blaar_options_variable[$i]}="${blaar_options_default[$i]}"
done
for ((i = 0; i < $blaar_parameters_nb; i++))
do
if (( ${blaar_parameters_required[$i]} > $# ))
then
[ -t 0 ] &&echo "${blaar_parameters_prompt[$i]} ?"
read ${blaar_parameters_variable[$i]}
export ${blaar_parameters_variable[$i]}
else
export ${blaar_parameters_variable[$i]}=$1
shift
fi
done
return 0
}
......
source blaar.sh
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 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; }
# 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
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 size s "" "(integer)x(interger)" "size of the filter" "3x3"
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 gradient on"
blaar_parse_args "$@"
[ "$direction" = "x" ] && option="-x1" || { [ "$direction" = "y" ] && option="-y1"; } || { echo "Wrong direction option '$direction'"; exit 1; }
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; }
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$$
blaar_add_option size s "" "(integer)x(interger)" "size of the filter" "3x3"
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
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