-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera_downsampler_test.c
More file actions
109 lines (85 loc) · 2.43 KB
/
Copy pathcamera_downsampler_test.c
File metadata and controls
109 lines (85 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* Test for camera_reader and downsampling integration
*/
#include <stdio.h>
#include <pthread.h>
#include "../include/camera_reader.h"
#include "../include/downsampler.h"
#include "../include/globals.h"
#include <sys/time.h>
#include "../include/frame_encoder.h"
void *downsampling_task();
int ratio_height_YUV;
int ratio_width_YUV;
int pppyUV;
int pppxUV;
int main(int argc, char* argv[])
{
//ProfilerStart("LHE_Pi_profiling.prof");
CAMERA_OPTIONS options;
MMAL_COMPONENT_T *camera;
int status;
pthread_t downsampling_thread;
options.width = 1280;
options.height = 720;
options.framerate = 30;
options.cameraNum = 0;
options.sensor_mode = 6;
DEBUG = false;
yuv_model = 2; // 4:2:0
pppx = 2;
pppy = 2;
camera = init_camera(&options);
ratio_height_YUV=height_orig_Y/height_orig_UV;
ratio_width_YUV=width_orig_Y/width_orig_UV;
pppyUV=2*pppy/ratio_height_YUV;
pppxUV=2*pppx/ratio_width_YUV;
init_downsampler();
status = pthread_create(&downsampling_thread, NULL, downsampling_task, (void *)0);
if (status)
{
printf("Error creating thread %d", status);
}
sleep(5);
status = pthread_cancel(downsampling_thread);
if (status)
{
printf("Error cancelling thread %d", status);
}
status = close_camera(camera);
if (status)
{
printf("Error closing camera %d", status);
}
//ProfilerStop();
return 0;
}
void *downsampling_task(void *argument)
{
while(1)
{
pthread_mutex_lock (&cam_down_mutex);
pthread_cond_wait (&cam_down_cv,&cam_down_mutex);
// prueba de tiempos
struct timeval t_ini, t_fin;
double secs;
gettimeofday(&t_ini, NULL);
for (int i = 0; i < 100; i++){
for(int y =0 ; y <height_orig_Y; y+=pppy)
{
down_avg_horiz(orig_Y,width_orig_Y, orig_down_Y, y,pppx, pppy);
}
for(int y =0 ; y <height_orig_UV; y+=pppyUV)
{
down_avg_horiz(orig_U,width_orig_UV, orig_down_U, y,pppxUV, pppyUV);
down_avg_horiz(orig_V,width_orig_UV, orig_down_V, y,pppxUV, pppyUV);
}
}
gettimeofday(&t_fin, NULL);
secs = timeval_diff(&t_fin, &t_ini);
printf("%.16g ms\n", secs * 10);
//save_frame("../LHE_Pi/img/orig_down_Y.bmp", width_down_Y, height_down_Y, 1, orig_down_Y,orig_down_U,orig_down_V);
exit(0);
pthread_mutex_unlock (&cam_down_mutex);
}
}