-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkleption.hh
More file actions
163 lines (131 loc) · 3.4 KB
/
kleption.hh
File metadata and controls
163 lines (131 loc) · 3.4 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#ifndef __MAKEMORE_KLEPTION_HH__
#define __MAKEMORE_KLEPTION_HH__ 1
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string>
#include <vector>
#include <map>
#include <random>
namespace makemore {
struct Kleption {
static std::string picreader_cmd;
static void set_picreader_cmd(const std::string &cmd) {
picreader_cmd = cmd;
}
static std::string picwriter_cmd;
static void set_picwriter_cmd(const std::string &cmd) {
picwriter_cmd = cmd;
}
static std::string vidreader_cmd;
static void set_vidreader_cmd(const std::string &cmd) {
vidreader_cmd = cmd;
}
static std::string vidwriter_cmd;
static void set_vidwriter_cmd(const std::string &cmd) {
vidwriter_cmd = cmd;
}
enum Kind {
KIND_ANY = 0,
KIND_DIR,
KIND_PIC,
KIND_CAM,
KIND_VID,
KIND_SDL,
KIND_REF,
KIND_RVG,
KIND_RND,
KIND_F64LE,
KIND_U8,
KIND_UNK = -1,
};
static Kind get_kind(const std::string &kindstr) {
if (kindstr == "") return KIND_ANY;
if (kindstr == "dir") return KIND_DIR;
if (kindstr == "pic") return KIND_PIC;
if (kindstr == "cam") return KIND_CAM;
if (kindstr == "vid") return KIND_VID;
if (kindstr == "sdl") return KIND_SDL;
if (kindstr == "ref") return KIND_REF;
if (kindstr == "rvg") return KIND_RVG;
if (kindstr == "rnd") return KIND_RND;
if (kindstr == "rgb") return KIND_U8;
if (kindstr == "u8") return KIND_U8;
if (kindstr == "f64le") return KIND_F64LE;
if (kindstr == "dat") return KIND_F64LE;
return KIND_UNK;
}
typedef uint32_t Flags;
const static Flags FLAG_LOWMEM = (1 << 0);
// const static Flags FLAG_ADDGEO = (1 << 1);
const static Flags FLAG_REPEAT = (1 << 2);
const static Flags FLAG_WRITER = (1 << 4);
const static Flags FLAG_CENTER = (1 << 5);
const static Flags FLAG_APPEND = (1 << 6);
typedef enum {
TRAV_NONE = 0,
TRAV_RAND,
TRAV_SCAN,
TRAV_REFS
} Trav;
static Trav get_trav(const std::string &travstr) {
if (travstr == "rand") return TRAV_RAND;
if (travstr == "scan") return TRAV_SCAN;
if (travstr == "refs") return TRAV_REFS;
return TRAV_NONE;
}
std::string fn;
Kind kind;
Flags flags;
Trav trav;
unsigned int pw, ph, pc;
unsigned int sw, sh, sc;
bool loaded;
double trim;
// pic, dat
uint8_t *dat;
size_t datn;
unsigned int b;
FILE *datreader;
FILE *datwriter;
// ref
FILE *refwriter;
FILE *refreader;
// cam
class Camera *cam;
unsigned int frames;
// vid
class Picreader *vidreader;
class Picwriter *vidwriter;
// dir
std::vector<std::string> ids;
std::map<std::string, Kleption *> id_sub;
unsigned int idi;
// sdl
class Display *dsp;
// rvg
class Rando *rvg;
double evolve;
double rvgmul;
Kleption(
const std::string &_fn,
unsigned int _pw, unsigned int _ph, unsigned int _pc,
Flags _flags = 0, Trav _trav = TRAV_RAND, Kind _kind = KIND_UNK,
unsigned int _sw = 0, unsigned int _sh = 0, unsigned int _sc = 0,
const char *refsfn = NULL, double _evolve = 0, double _rvgmul = 1.0,
double trim = 0.0
);
~Kleption();
void load();
void unload();
void reset();
bool pick(double *kdat, std::string *idp = NULL);
void find(const std::string &id, double *kdat);
static std::string pick_pair(
Kleption *kl0, double *kdat0,
Kleption *kl1, double *kdat1
);
bool place(const std::string &id, const double *kdat);
};
}
#endif