static int ids_core_Camera_init(ids_core_Camera *self, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"handle", "color", NULL}; int ret; self->handle = 0; self->bitdepth = 0; self->color = IS_CM_RGB8_PACKED; self->autofeatures = 0; self->ready = NOT_READY; LIST_INIT(&self->mem_list); /* * This means the definition is: * def __init__(self, handle=0, color=ids_core.COLOR_RGB8): */ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwlist, &self->handle, &self->color)) { return -1; } ret = is_InitCamera(&self->handle, NULL); switch (ret) { case IS_SUCCESS: break; case IS_CANT_OPEN_DEVICE: PyErr_SetString(PyExc_IOError, "Unable to open camera. Camera not connected."); return -1; case IS_INVALID_HANDLE: PyErr_SetString(PyExc_IOError, "Unable to open camera. Invalid camera handle."); return -1; default: PyErr_Format(PyExc_IOError, "Unable to open camera (Error %d).", ret); return -1; } self->ready = CONNECTED; if (!set_color_mode(self, self->color)) { return -1; } /* Initialize image queue so we can WaitForNextImage */ if (is_InitImageQueue(self->handle, 0) != IS_SUCCESS) { PyErr_SetString(PyExc_IOError, "Unable to start image queue."); return -1; } /* Lookup maximum width, height, and name */ ret = init_cam_info(self); if (ret) { return -1; } self->ready = READY; return 0; }
static int ids_core_Camera_setcolor_mode(ids_core_Camera *self, PyObject *value, void *closure) { int color; PyObject *exception; if (value == NULL) { PyErr_SetString(PyExc_TypeError, "Cannot delete attribute 'color'"); return -1; } color = (int) PyLong_AsLong(value); exception = PyErr_Occurred(); if (exception) { PyErr_SetString(exception, "Color mode must be an int or long"); return -1; } if (!set_color_mode(self, color)) { return -1; } return 0; }
static void change_color_mode( GtkComboBox * combo, CPUGraph * base ) { set_color_mode( base, gtk_combo_box_get_active( combo ) ); select_active_colors( base ); }