-
Notifications
You must be signed in to change notification settings - Fork 1
/
artemishsc.i
executable file
·127 lines (97 loc) · 4.48 KB
/
artemishsc.i
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
%module artemishsc
%{
#include "ArtemisHscAPI.h"
#include <oleauto.h>
%}
%include "carrays.i"
%include "typemaps.i"
%include "cpointer.i"
%include "exception.i"
//
// General
//
%array_class(unsigned short, shortArray);
%array_class(VARIANT, variantArray);
//
// Misc
//
%apply int *OUTPUT { int *x, int *y, int *w, int *h, int *binx, int *biny };
int ArtemisGetImageData(ArtemisHandle hCam, int *x, int *y, int *w, int *h, int *binx, int *biny);
%clear int *x, int *y, int *w, int *h, int *binx, int *biny;
%apply int *OUTPUT { int *x, int *y, int *w, int *h };
int ArtemisGetSubframe(ArtemisHandle hCam, int *x, int *y, int *w, int *h);
%clear int *x, int *y, int *w, int *h;
%apply int *OUTPUT { int *x, int *y };
int ArtemisGetBin(ArtemisHandle hCam, int *x, int *y);
%clear int *x, int *y;
%apply int *OUTPUT { ARTEMISCOLOURTYPE *colourType, int *normalOffsetX, int *normalOffsetY, int *previewOffsetX, int *previewOffsetY };
int ArtemisColourProperties(ArtemisHandle hCam, ARTEMISCOLOURTYPE *colourType, int *normalOffsetX, int *normalOffsetY, int *previewOffsetX, int *previewOffsetY);
%clear ARTEMISCOLOURTYPE *colourType, int *normalOffsetX, int *normalOffsetY, int *previewOffsetX, int *previewOffsetY;
%apply int *OUTPUT { int *temperature };
int ArtemisTemperatureSensorInfo(ArtemisHandle hCam, int sensor, int *temperature);
%clear int *temperature;
%apply int *OUTPUT { int *flags, int *level, int *minlvl, int *maxlvl, int *setpoint };
int ArtemisCoolingInfo(ArtemisHandle hCam, int *flags, int *level, int *minlvl, int *maxlvl, int *setpoint);
%clear int *flags, int *level, int *minlvl, int *maxlvl, int *setpoint;
%apply int *OUTPUT { int *flags, int *serial };
int ArtemisCameraSerial(ArtemisHandle hCam, int *flags, int *serial);
%clear int *flags, int *serial;
%inline %{
PyObject *ArtemisDeviceName_pythonString(int device) {
char device_name[40];
ArtemisDeviceName(device, device_name);
return PyString_FromString(device_name);
}
PyObject *ArtemisDeviceSerial_pythonString(int device) {
char device_serial[40];
ArtemisDeviceSerial(device, device_serial);
return PyString_FromString(device_serial);
}
%}
//
// ArtemisProperties
//
%inline %{
PyObject *ArtemisProperties_pythonDictionary(ArtemisHandle hCam) {
struct ARTEMISPROPERTIES pProp;
int result = ArtemisProperties(hCam, &pProp);
if (result != ARTEMIS_OK) {
return NULL;
}
PyObject *dict = PyDict_New();
PyDict_SetItem(dict, PyString_FromString("protcol"), PyInt_FromLong((long) pProp.Protocol));
PyDict_SetItem(dict, PyString_FromString("pixel_count_x"), PyInt_FromLong((long) pProp.nPixelsX));
PyDict_SetItem(dict, PyString_FromString("pixel_count_y"), PyInt_FromLong((long) pProp.nPixelsY));
PyDict_SetItem(dict, PyString_FromString("pixel_microns_x"), PyFloat_FromDouble((double) pProp.PixelMicronsX));
PyDict_SetItem(dict, PyString_FromString("pixel_microns_y"), PyFloat_FromDouble((double) pProp.PixelMicronsY));
PyDict_SetItem(dict, PyString_FromString("ccd_flags"), PyInt_FromLong((long) pProp.ccdflags));
PyDict_SetItem(dict, PyString_FromString("camera_flags"), PyInt_FromLong((long) pProp.cameraflags));
PyDict_SetItem(dict, PyString_FromString("description"), PyString_FromString(pProp.Description));
PyDict_SetItem(dict, PyString_FromString("manufacturer"), PyString_FromString(pProp.Manufacturer));
return dict;
}
%}
//
// Image Data
//
%inline %{
PyObject *unsignedShortArrayToPythonList(unsigned short *array, int array_length) {
PyObject *list = PyList_New(array_length);
for (int i = 0; i < array_length; i++) {
PyObject *value = PyInt_FromLong((long) array[i]);
PyList_SetItem(list, i, value);
}
return list;
}
unsigned short *ArtemisImageBuffer_unsignedShort(ArtemisHandle hCam) {
return (unsigned short *) ArtemisImageBuffer(hCam);
}
PyObject *ArtemisImageBuffer_pythonList(ArtemisHandle hCam) {
int x, y, w, h, binx, biny;
ArtemisGetImageData(hCam, &x, &y, &w, &h, &binx, &biny);
int pixels = w * h;
printf("ArtemisGetImageArray_unsignedShort: pixel count = %d\n", pixels);
return unsignedShortArrayToPythonList(ArtemisImageBuffer_unsignedShort(hCam), pixels);
}
%}
%include "ArtemisHscAPI.h"