|
@@ -5,51 +5,38 @@ |
|
@@ -5,51 +5,38 @@ |
5
|
#include "blc_channel.h"
|
5
|
#include "blc_channel.h"
|
6
|
#include "blc_program.h"
|
6
|
#include "blc_program.h"
|
7
|
#include <unistd.h>
|
7
|
#include <unistd.h>
|
8
|
-#include <math.h>
|
|
|
9
|
-
|
|
|
10
|
-#define DEFAULT_OUTPUT_NAME ":point_of_interest<pid>"
|
|
|
11
|
-
|
|
|
12
|
-#define IN(x,y) input.uchars[(x)+(y)*in_width]
|
|
|
13
|
|
8
|
|
14
|
int main(int argc, char **argv){
|
9
|
int main(int argc, char **argv){
|
15
|
- blc_channel input, output;
|
|
|
16
|
- char const *output_name, *input_name;
|
|
|
17
|
- int out_width, out_height, in_width, in_height;
|
|
|
18
|
- int i, j, sobel;
|
10
|
+ blc_channel input, output1, output2;
|
|
|
11
|
+ char const *output_name1, *output_name2, *input_name;
|
19
|
|
12
|
|
20
|
- blc_program_set_description("Find a points of interest on a image");
|
|
|
21
|
- blc_program_add_option(&output_name, 'o', "output", "blc_channel-out", "channel name", DEFAULT_OUTPUT_NAME);
|
|
|
22
|
- blc_program_add_parameter(&input_name, "blc_channel-in", 1, "image from where you want to find the points of interest", NULL);
|
|
|
23
|
- blc_program_init(&argc, &argv, blc_quit);
|
13
|
+ blc_program_set_description("Duplicate a channel");
|
|
|
14
|
+ blc_program_add_parameter(&input_name, "blc_channel-in", 1, "input channel to split", NULL);
|
|
|
15
|
+ blc_program_add_parameter(&output_name1, "blc_channel-out", 1, "first copy of input", NULL);
|
|
|
16
|
+ blc_program_add_parameter(&output_name2, "blc_channel-out", 1, "second_copy of input", NULL);
|
24
|
|
17
|
|
25
|
- if (strcmp(output_name, DEFAULT_OUTPUT_NAME)==0) SYSTEM_ERROR_CHECK(asprintf((char**)&output_name,":point_of_interest%d", getpid()), -1, NULL);
|
18
|
+ blc_program_init(&argc, &argv, blc_quit);
|
26
|
|
19
|
|
27
|
input.open(input_name, BLC_CHANNEL_READ);
|
20
|
input.open(input_name, BLC_CHANNEL_READ);
|
28
|
blc_loop_try_add_waiting_semaphore(input.sem_new_data);
|
21
|
blc_loop_try_add_waiting_semaphore(input.sem_new_data);
|
29
|
blc_loop_try_add_posting_semaphore(input.sem_ack_data);
|
22
|
blc_loop_try_add_posting_semaphore(input.sem_ack_data);
|
30
|
|
23
|
|
31
|
- in_width=input.dims[0].length;
|
|
|
32
|
- in_height=input.dims[1].length;
|
|
|
33
|
-
|
|
|
34
|
- out_width=in_width-1;
|
|
|
35
|
- out_height=in_height-1;
|
|
|
36
|
-
|
|
|
37
|
- output.create_or_open(output_name, BLC_CHANNEL_WRITE, input.type, 'Y800', 2, out_width, out_height);
|
|
|
38
|
- output.publish();
|
|
|
39
|
-
|
|
|
40
|
- blc_loop_try_add_waiting_semaphore(output.sem_ack_data);
|
|
|
41
|
- blc_loop_try_add_posting_semaphore(output.sem_new_data);
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
24
|
+
|
|
|
25
|
+ output1.create_or_open(output_name1, BLC_CHANNEL_WRITE, input.type, input.format, input.dims_nb, input.dims);
|
|
|
26
|
+
|
|
|
27
|
+ output2.create_or_open(output_name2, BLC_CHANNEL_WRITE, input.type, input.format, input.dims_nb, input.dims);
|
|
|
28
|
+
|
|
|
29
|
+
|
45
|
BLC_COMMAND_LOOP(0){
|
30
|
BLC_COMMAND_LOOP(0){
|
46
|
- FOR(j, out_height){
|
|
|
47
|
- FOR(i, out_width){
|
|
|
48
|
- output.uchars[i+j*out_width]=(IN(i, j)+IN(i+1, j)+IN(i+2,j)\
|
|
|
49
|
- + IN(i, j+1)+IN(i+1, j+1)+IN(i+2,j+1)\
|
|
|
50
|
- + IN(i, j+2)+IN(i+1, j+2)+IN(i+2,j+2))/9;
|
|
|
51
|
- }
|
|
|
52
|
- }
|
|
|
53
|
- }
|
31
|
+ if (output1.sem_ack_data) sem_wait(output1.sem_ack_data);
|
|
|
32
|
+ memcpy(output1.data, input.data, output1.size);
|
|
|
33
|
+ if (output1.sem_new_data) sem_post(output1.sem_new_data);
|
|
|
34
|
+
|
|
|
35
|
+
|
|
|
36
|
+ if (output2.sem_ack_data) sem_wait(output2.sem_ack_data);
|
|
|
37
|
+ memcpy(output2.data, input.data, output2.size);
|
|
|
38
|
+ if (output2.sem_new_data) sem_post(output2.sem_new_data);
|
|
|
39
|
+
|
|
|
40
|
+ }
|
54
|
return EXIT_SUCCESS;
|
41
|
return EXIT_SUCCESS;
|
55
|
} |
42
|
} |