forked from zougloub/libseek
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseek-test.cpp
78 lines (64 loc) · 1.34 KB
/
seek-test.cpp
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
#include <thread>
#include <chrono>
#include <fstream>
#include <sstream>
#include <vector>
#include "seek.hpp"
using namespace std;
using namespace LibSeek;
inline void sleep(float secs) {
chrono::milliseconds dura(int(1000*secs));
this_thread::sleep_for(dura);
}
int main() {
setbuf(stdout, NULL);
Imager iface;
iface.init();
Frame frame;
iface.frame_init(frame);
for (int i = 0; i < 71370537; i++) {
//break;
iface.frame_acquire(frame);
int h = frame.height();
int w = frame.width();
vector<uint16_t> img(w*h);
{
int _max = 0;
int _min = 0xffff;
#if 0
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
uint16_t v = frame.data()[y*w+x];
if (v > _max) _max = v;
if (v < _min) _min = v;
}
}
#elif 0
_max = 0x8200;
_min = 0x7e00;
#else
_max = 0xffff;
_min = 0x0;
#endif
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
#if 1
float v = float(frame.data()[y*w+x] - _min) / (_max - _min);
if (v < 0.0) { v = 0; }
if (v > 1.0) { v = 1; }
uint16_t o = 0xffff * v;
#else
uint16_t o = frame.data()[y*w+x];
#endif
//fprintf(stderr, " %4x", o);
img[y*w+x] = o;
}
//fprintf(stderr, "\n");
}
//fprintf(stderr, "\n");
fwrite((uint8_t*)img.data(), sizeof(uint16_t), w*h, stdout);
}
}
iface.frame_exit(frame);
iface.exit();
}