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; }
bool FlosIDSAdaptor::openDevice() { if(isOpen()) { return true; } INT nRet = is_InitCamera(&m_deviceID, NULL); if(nRet != IS_SUCCESS) { if(nRet == IS_STARTER_FW_UPLOAD_NEEDED) { return false; } } else { IS_SIZE_2D imageSize; INT lMemoryId; char *pcImageMemory; is_AOI(m_deviceID, IS_AOI_IMAGE_GET_SIZE, (void *)&imageSize, sizeof(imageSize)); for(unsigned int i = 0; i < 25; i++) { is_AllocImageMem(m_deviceID, imageSize.s32Width, imageSize.s32Height, 24, &pcImageMemory, &lMemoryId); is_AddToSequence(m_deviceID, pcImageMemory, lMemoryId); is_SetImageMem(m_deviceID, pcImageMemory, lMemoryId); } if(is_InitImageQueue(m_deviceID, 0) != IS_SUCCESS) { imaqkit::adaptorWarn("FlosIDSAdaptor:openDevice","Something went wrong while allocating memory."); return false; } } m_acquireThread = CreateThread(NULL, 0, acquireThread, this, 0, &m_acquireThreadID); if(m_acquireThread == NULL) { closeDevice(); return false; } while(PostThreadMessage(m_acquireThreadID, WM_USER + 1, 0, 0) == 0) { Sleep(10); } return true; }