1 #include <VP_Api/vp_api.h>
2 #include <VP_Api/vp_api_error.h>
3 #include <VP_Stages/vp_stages_configs.h>
4 #include <VP_Stages/vp_stages_V4L2_i_camif.h>
5 #include <VP_Stages/vp_stages_io_com.h>
6 #include <VP_Os/vp_os_print.h>
7 #include <VP_Os/vp_os_malloc.h>
8 #include <VP_Os/vp_os_delay.h>
9 #include <VP_Api/vp_api_thread_helper.h>
10 #include <VP_Stages/vp_stages_io_file.h>
11 #include <VLIB/Stages/vlib_stage_encode.h>
12 #include <VP_Stages/blockline_to_buffer_stage.h>
15 #include "Video/ov7720.h"
16 #include "Video/cresyn.h"
22 //#define ACQ_WIDTH 176
23 //#define ACQ_HEIGHT 144
26 #define ACQ_HEIGHT 480
34 //#define ETHERNET_OUTPUT
38 #define NB_STAGES_MAX 10
41 static vp_stages_input_camif_config_t ivc;
42 static vlib_stage_encoding_config_t vec;
43 static vp_stages_output_file_config_t ofc;
44 static vp_stages_output_com_config_t occ;
45 static blockline_to_buffer_config_t bbc;
47 static PIPELINE_HANDLE pipeline_handle;
51 buffer_to_picture_close(int *cfg)
56 const vp_api_stage_funcs_t V4L2_funcs =
58 (vp_api_stage_handle_msg_t)vp_stages_input_camif_stage_handle_msg,
59 (vp_api_stage_open_t)vp_stages_input_camif_stage_open,
60 (vp_api_stage_transform_t)vp_stages_input_camif_stage_transform,
61 (vp_api_stage_close_t)vp_stages_input_camif_stage_close
65 vp_com_t* wired_com(void)
67 static vp_com_t com = {
91 vp_com_config_t* wired_config(void)
93 static vp_com_wired_config_t config = {
99 return (vp_com_config_t*) &config;
102 vp_com_connection_t* wired_connection(void)
104 static vp_com_wired_connection_t connection = {
108 return (vp_com_connection_t*) (void*) &connection;
114 int main(int argc, char **argv)
116 vp_api_picture_t video_picture;
117 vp_api_picture_t buffer_blockline;
119 vp_api_picture_t video_blockline;
121 vp_api_io_pipeline_t pipeline;
122 vp_api_io_data_t out;
123 vp_api_io_stage_t stages[NB_STAGES_MAX];
125 vp_os_memset(&ivc,0,sizeof(ivc));
126 vp_os_memset(&ofc,0,sizeof(ofc));
127 vp_os_memset(&occ,0,sizeof(occ));
131 ivc.camera = "/dev/video1";
132 ivc.i2c = "/dev/i2c-0";
134 ivc.camera_configure = &camera_configure_ov77xx;
137 ivc.camera_configure = &camera_configure_cresyn;
139 #error no cam selected
143 ivc.resolution = VGA;
145 ivc.format = V4L2_PIX_FMT_YUV420;
148 ivc.offset_delta = 0;
150 ivc.vp_api_blockline = &video_blockline;
152 ivc.vp_api_picture = &video_picture;
153 ivc.use_chrominances = 1;
158 bbc.picture = &video_blockline;
165 vec.block_mode_enable = TRUE;
167 vec.block_mode_enable = FALSE;
169 vec.picture = &video_picture;
171 // OUTPUT FILE config
172 ofc.name = "/tmp/out.yuv";
175 occ.com = wired_com();
176 occ.config = wired_config();
177 occ.connection = wired_connection();
178 occ.socket.type = VP_COM_SERVER;
179 occ.socket.protocol = VP_COM_TCP;
180 occ.socket.port = 5555;
181 occ.buffer_size = 640*480*3/2;
184 pipeline.nb_stages = 0;
186 stages[pipeline.nb_stages].type = VP_API_INPUT_CAMIF;
187 stages[pipeline.nb_stages].cfg = (void *)&ivc;
188 stages[pipeline.nb_stages++].funcs = V4L2_funcs;
192 stages[pipeline.nb_stages].type = VP_API_INPUT_CAMIF;
193 stages[pipeline.nb_stages].cfg = (void *)&bbc;
194 stages[pipeline.nb_stages++].funcs = blockline_to_buffer_funcs;
199 stages[pipeline.nb_stages].type = VP_API_FILTER_ENCODER;
200 stages[pipeline.nb_stages].cfg = (void*)&vec;
201 stages[pipeline.nb_stages++].funcs = vlib_encoding_funcs;
205 stages[pipeline.nb_stages].type = VP_API_OUTPUT_FILE;
206 stages[pipeline.nb_stages].cfg = (void *)&ofc;
207 stages[pipeline.nb_stages++].funcs = vp_stages_output_file_funcs;
210 #ifdef ETHERNET_OUTPUT
211 stages[pipeline.nb_stages].type = VP_API_OUTPUT_SOCKET;
212 stages[pipeline.nb_stages].cfg = (void *)&occ;
213 stages[pipeline.nb_stages++].funcs = vp_stages_output_com_funcs;
216 pipeline.stages = &stages[0];
219 vp_api_open(&pipeline, &pipeline_handle);
221 out.status = VP_API_STATUS_PROCESSING;
223 /////////////////////////////////////////////////////////////////////////////////////////
227 struct timeval time1,time2;
229 printf("Pipeline launched....\n");
230 gettimeofday(&time1,NULL);
231 while(SUCCEED(vp_api_run(&pipeline, &out)) && (out.status == VP_API_STATUS_PROCESSING))
234 //printf("image %d \n",i);
239 /////////////////////////////////////////////////////////////////////////////////////////
241 gettimeofday(&time2,NULL);
242 int seconde = time2.tv_sec-time1.tv_sec;
243 int ms = time2.tv_usec-time1.tv_usec;
250 float fps = ((float)i*1000)/(float)(seconde*1000+ms);
251 printf("temps ecoule : %d.%d / nombre image : %d average fps : %f\n",seconde,ms,i,fps);
252 vp_api_close(&pipeline, &pipeline_handle);