-
Notifications
You must be signed in to change notification settings - Fork 8.7k
/
testraw.cc
57 lines (43 loc) · 1.15 KB
/
testraw.cc
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
#include <cstdio>
#include <cstdlib>
#include <unistd.h>
#include <zmq.h>
#include "common/visionipc.h"
#include "common/timing.h"
#include "RawLogger.h"
int main() {
int err;
VisionStream stream;
VisionStreamBufs buf_info;
while (true) {
err = visionstream_init(&stream, VISION_STREAM_YUV, false, &buf_info);
if (err != 0) {
printf("visionstream fail\n");
usleep(100000);
}
break;
}
RawLogger vidlogger("prcamera", buf_info.width, buf_info.height, 20);
vidlogger.Open("o1");
for (int cnt=0; cnt<200; cnt++) {
VIPCBufExtra extra;
VIPSBuf* buf = visionstream_get(&stream, &extra);
if (buf == NULL) {
printf("visionstream get failed\n");
break;
}
if (cnt == 100) {
vidlogger.Rotate("o2", 2);
}
uint8_t *y = (uint8_t*)buf->addr;
uint8_t *u = y + (buf_info.width*buf_info.height);
uint8_t *v = u + (buf_info.width/2)*(buf_info.height/2);
double t1 = millis_since_boot();
vidlogger.LogFrame(cnt, y, u, v, NULL);
double t2 = millis_since_boot();
printf("%d %.2f\n", cnt, (t2-t1));
}
vidlogger.Close();
visionstream_destroy(&stream);
return 0;
}