24 #include "ofxNetwork.h" 45 virtual void onReceive(uint32_t label) = 0;
62 virtual void onReceive(vector<double>) = 0;
87 : key_mapping_(key_mapping) {
101 va_start(args, count);
102 for (uint32_t i = 1; i <= count; i++) {
103 key_mapping_[i] = va_arg(args,
int);
110 if (getChar(label) !=
'\0') {
111 sendKey(getChar(label));
117 void sendKey(
char c);
119 void sendString(
const std::string& str);
121 char getChar(uint32_t label) {
122 return key_mapping_[label];
125 uint64_t elapsed_time_ = 0;
126 std::map<uint32_t, char> key_mapping_;
152 : mouse_mapping_(mouse_mapping) {
168 va_start(args, count);
169 for (uint32_t i = 1; i <= count; i++) {
170 mouse_mapping_[i] = make_pair(va_arg(args, uint32_t),
171 va_arg(args, uint32_t));
179 pair<uint32_t, uint32_t> mouse = getMousePosition(label);
180 if (mouse.first > 0 & mouse.second > 0) {
187 void clickMouse(pair<uint32_t, uint32_t> mouse);
188 void doubleClick(pair<uint32_t, uint32_t> mouse,
int clickCount = 2);
190 pair<uint32_t, uint32_t> getMousePosition(uint32_t label) {
191 return mouse_mapping_[label];
194 uint64_t elapsed_time_ = 0;
195 std::map<uint32_t, pair<uint32_t, uint32_t>> mouse_mapping_;
220 : server_(server), port_(port),
221 use_tcp_stream_mapping_(false), is_in_retry_(false) {}
235 std::map<uint32_t, string> tcp_stream_mapping)
236 : server_(server), port_(port),
237 use_tcp_stream_mapping_(true),
238 tcp_stream_mapping_(tcp_stream_mapping),
239 is_in_retry_(false) {
255 : server_(server), port_(port), use_tcp_stream_mapping_(true),
256 is_in_retry_(false) {
258 va_start(args, count);
259 for (uint32_t i = 1; i <= count; i++) {
260 char* s = va_arg(args,
char *);
261 tcp_stream_mapping_[i] = std::string(s);
268 string to_send = getStreamString(label);
269 if (!to_send.empty()) {
277 for (
int i = 0; i < data.size(); i++) {
278 if (i > 0) s +=
"\t";
279 s += to_string(data[i]);
282 if (!s.empty()) sendString(s);
288 void sendString(
const string& tosend);
290 string getStreamString(uint32_t label) {
291 if (use_tcp_stream_mapping_)
return tcp_stream_mapping_[label];
292 else return std::to_string(label) +
"\n";
297 ofxTCPClient *client_;
299 uint64_t elapsed_time_ = 0;
300 std::map<uint32_t, string> tcp_stream_mapping_;
301 bool use_tcp_stream_mapping_;
virtual void onReceive(uint32_t label)=0
MacOSMouseOStream(uint32_t count,...)
Create a MacOSMouseOStream instance, specifying the location at which to double-click the mouse for e...
Definition: ostream.h:166
virtual void onReceive(uint32_t label)
Definition: ostream.h:108
virtual void onReceive(vector< double > data)
Definition: ostream.h:275
Emulate keyboard key presses corresponding to prediction results.
Definition: ostream.h:76
virtual void onReceive(uint32_t label)
Definition: ostream.h:177
Base class for output streams that forward ESP prediction results to other systems.
Definition: ostream.h:43
MacOSKeyboardOStream(uint32_t count,...)
Create a MacOSKeyboardOStream instance, specifying the key presses to emulate for each predicted clas...
Definition: ostream.h:99
std::atomic_bool has_started_
Definition: stream.h:24
MacOSKeyboardOStream(std::map< uint32_t, char > key_mapping)
Create a MacOSKeyboardOStream instance, specifying the key presses to emulate for each predicted clas...
Definition: ostream.h:86
virtual bool start()
Definition: stream.h:13
Emulate mouse double-clicks at locations corresponding to prediction results.
Definition: ostream.h:141
Base class for output streams that forward ESP pipeline output to other systems.
Definition: ostream.h:60
const uint64_t kGracePeriod
Definition: ostream.h:27
virtual void onReceive(uint32_t label)
Definition: ostream.h:266
MacOSMouseOStream(std::map< uint32_t, pair< uint32_t, uint32_t > > mouse_mapping)
Create a MacOSMouseOStream instance, specifying the locations at which to double-click the mouse for ...
Definition: ostream.h:151
TcpOStream(string server, int port)
Definition: ostream.h:219
TcpOStream(string server, int port, std::map< uint32_t, string > tcp_stream_mapping)
Definition: ostream.h:234
TcpOStream(string server, int port, uint32_t count,...)
Definition: ostream.h:254
Send strings over a TCP socket based on pipeline predictions.
Definition: ostream.h:209