forked from thecaptury/RemoteCaptury
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RemoteCapturyPython.cpp
131 lines (113 loc) · 3.95 KB
/
RemoteCapturyPython.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
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
#include <Python.h>
#include "RemoteCaptury.h"
static PyObject* connect(PyObject *self, PyObject *args)
{
const char* host;
int port = 2101;
if (PyArg_ParseTuple(args, "s|i:connect", &host, &port)) {
if (Captury_connect(host, port))
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
}
static PyObject* startStreamingImages(PyObject *self, PyObject *args, PyObject* kwargs)
{
static char *kwlist[] = {(char *)"what", (char*)"cameraNumber", NULL};
int cameraNumber;
int what;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:startStreamingImages", kwlist, &what, &cameraNumber)) {
PyErr_SetString(PyExc_TypeError, "startStreamingImages expects an integer arguments. startStreamingImages(what: int, cameraNumber:int)->bool");
Py_RETURN_FALSE;
}
// todo : check numberNumber is in range of available cameras.
// the method captury_startStreamingImages accepts int cameraNumber, that number is what ? 0 to totalCameras-1 ?
if (Captury_startStreamingImages(what, cameraNumber))
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
static PyObject* startStreaming(PyObject *self, PyObject *args, PyObject* kwargs)
{
static char *kwlist[] = {(char *)"what", NULL};
int cameraNumber;
int what;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:startStreaming", kwlist, &what, &cameraNumber)) {
PyErr_SetString(PyExc_TypeError, "startStreaming expects an integer arguments. startStreaming(what: int)->bool");
Py_RETURN_FALSE;
}
// todo : check numberNumber is in range of available cameras.
if (Captury_startStreaming(what))
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
static PyObject* stopStreaming(PyObject *self, PyObject *args)
{
if (Captury_stopStreaming())
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
static PyObject* synchronizeTime(PyObject *self, PyObject *args)
{
return PyLong_FromLong(Captury_synchronizeTime());
}
static PyObject* getTime(PyObject *self, PyObject *args)
{
return PyLong_FromLong(Captury_getTime());
}
static PyObject* getTimeOffset(PyObject *self, PyObject *args)
{
return PyLong_FromLong(Captury_getTimeOffset());
}
static PyObject* snapActor(PyObject *self, PyObject *args)
{
float x, y;
float heading = 370;
if (PyArg_ParseTuple(args, "ff|f:snapActor", &x, &y, &heading)) {
if (Captury_snapActor(x, y, heading))
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
}
static PyObject* startRecording(PyObject *self, PyObject *args)
{
if (Captury_startRecording())
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
static PyObject* stopRecording(PyObject *self, PyObject *args)
{
if (Captury_stopRecording())
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
static PyObject* setShotName(PyObject *self, PyObject *args)
{
const char* name;
if (PyArg_ParseTuple(args, "s:setShotName", &name)) {
if (Captury_setShotName(name))
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
}
static PyMethodDef pythonVisibleMethods[] = {
{"connect", connect, METH_VARARGS, "Connect to host[, port=2101]"},
// {"getActors", getActors, METH_VARARGS, "Returns an array of actors"},
{"startStreaming", (PyCFunction)startStreaming, METH_VARARGS | METH_KEYWORDS, "starts streaming "},
{"startStreamingImages", (PyCFunction)startStreamingImages, METH_VARARGS | METH_KEYWORDS, "Starts streaming data and images"},
{"stopStreaming", stopStreaming, METH_NOARGS, "Stops streaming"},
{"synchronizeTime", synchronizeTime, METH_NOARGS, "Stops streaming"},
{"getTime", getTime, METH_NOARGS, "Stops streaming"},
{"getTimeOffset", getTimeOffset, METH_NOARGS, "Stops streaming"},
{"snapActor", snapActor, METH_NOARGS, "Tries to track a person at the given location."},
{"setShotName", setShotName, METH_VARARGS, "Select the shot with the name (or create new one if it doesn't exist)."},
{"startRecording", startRecording, METH_NOARGS, "Start recording."},
{"stopRecording", stopRecording, METH_NOARGS, "Stop recording."},
{NULL, NULL, 0, NULL}
};
static PyModuleDef rcModule = {
PyModuleDef_HEAD_INIT, "remotecaptury", "communicate with CapturyLive", -1, pythonVisibleMethods
};
PyMODINIT_FUNC
PyInit_remotecaptury(void)
{
return PyModule_Create(&rcModule);
}