Commit d3a1a460f4cf9a4a98812db9e03a156456195885

Authored by Arnaud Blanchard
1 parent c7dc8b9a

Tool to split a channel in two

... ... @@ -12,7 +12,7 @@ subdirs(f_max)
subdirs(f_point_of_interest)
subdirs(f_tee)
subdirs(f_arg_max)
subdirs(serial)
#subdirs(serial) i_arduino deprecated
subdirs(i_fread)
subdirs(o_fwrite)
... ...
... ... @@ -5,51 +5,38 @@
#include "blc_channel.h"
#include "blc_program.h"
#include <unistd.h>
#include <math.h>
#define DEFAULT_OUTPUT_NAME ":point_of_interest<pid>"
#define IN(x,y) input.uchars[(x)+(y)*in_width]
int main(int argc, char **argv){
blc_channel input, output;
char const *output_name, *input_name;
int out_width, out_height, in_width, in_height;
int i, j, sobel;
blc_channel input, output1, output2;
char const *output_name1, *output_name2, *input_name;
blc_program_set_description("Find a points of interest on a image");
blc_program_add_option(&output_name, 'o', "output", "blc_channel-out", "channel name", DEFAULT_OUTPUT_NAME);
blc_program_add_parameter(&input_name, "blc_channel-in", 1, "image from where you want to find the points of interest", NULL);
blc_program_init(&argc, &argv, blc_quit);
blc_program_set_description("Duplicate a channel");
blc_program_add_parameter(&input_name, "blc_channel-in", 1, "input channel to split", NULL);
blc_program_add_parameter(&output_name1, "blc_channel-out", 1, "first copy of input", NULL);
blc_program_add_parameter(&output_name2, "blc_channel-out", 1, "second_copy of input", NULL);
if (strcmp(output_name, DEFAULT_OUTPUT_NAME)==0) SYSTEM_ERROR_CHECK(asprintf((char**)&output_name,":point_of_interest%d", getpid()), -1, NULL);
blc_program_init(&argc, &argv, blc_quit);
input.open(input_name, BLC_CHANNEL_READ);
blc_loop_try_add_waiting_semaphore(input.sem_new_data);
blc_loop_try_add_posting_semaphore(input.sem_ack_data);
in_width=input.dims[0].length;
in_height=input.dims[1].length;
out_width=in_width-1;
out_height=in_height-1;
output.create_or_open(output_name, BLC_CHANNEL_WRITE, input.type, 'Y800', 2, out_width, out_height);
output.publish();
blc_loop_try_add_waiting_semaphore(output.sem_ack_data);
blc_loop_try_add_posting_semaphore(output.sem_new_data);
output1.create_or_open(output_name1, BLC_CHANNEL_WRITE, input.type, input.format, input.dims_nb, input.dims);
output2.create_or_open(output_name2, BLC_CHANNEL_WRITE, input.type, input.format, input.dims_nb, input.dims);
BLC_COMMAND_LOOP(0){
FOR(j, out_height){
FOR(i, out_width){
output.uchars[i+j*out_width]=(IN(i, j)+IN(i+1, j)+IN(i+2,j)\
+ IN(i, j+1)+IN(i+1, j+1)+IN(i+2,j+1)\
+ IN(i, j+2)+IN(i+1, j+2)+IN(i+2,j+2))/9;
}
}
}
if (output1.sem_ack_data) sem_wait(output1.sem_ack_data);
memcpy(output1.data, input.data, output1.size);
if (output1.sem_new_data) sem_post(output1.sem_new_data);
if (output2.sem_ack_data) sem_wait(output2.sem_ack_data);
memcpy(output2.data, input.data, output2.size);
if (output2.sem_new_data) sem_post(output2.sem_new_data);
}
return EXIT_SUCCESS;
}
... ...