////////////////////////////////////////////////////////////////////////////////// // OpenCamera -------------------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////////// BOOL ofxUeye::OpenCamera(int id){ int nRet; m_hCam = (HCAM)id; nRet = InitCamera (&m_hCam, m_hwndDisp); // init camera if( nRet == IS_SUCCESS ) { is_GetCameraInfo( m_hCam, &m_ci); // retrieve original image size is_GetSensorInfo( m_hCam, &m_si); GetMaxImageSize(&m_nSizeX, &m_nSizeY); // setup the bitmap or directdraw display mode nRet = InitDisplayMode(); if(nRet == IS_SUCCESS) { // Enable Messages nRet = is_EnableMessage( m_hCam, IS_DEVICE_REMOVED, m_hwndDisp ); nRet = is_EnableMessage( m_hCam, IS_DEVICE_RECONNECTED, m_hwndDisp ); nRet = is_EnableMessage( m_hCam, IS_FRAME, m_hwndDisp ); } // end if( nRet == IS_SUCCESS ) } // end if( nRet == IS_SUCCESS ) return (nRet == IS_SUCCESS); }
PyObject *ids_core_Camera_getinfo(ids_core_Camera *self, void *closure) { CAMINFO cam_info; SENSORINFO sensor_info; int ret = is_GetCameraInfo(self->handle, &cam_info); if (ret != IS_SUCCESS) { raise_general_error(self, ret); return NULL; } ret = is_GetSensorInfo(self->handle, &sensor_info); if (ret != IS_SUCCESS) { raise_general_error(self, ret); return NULL; } PyObject *dict = PyDict_New(); PyObject *serial_num = PyBytes_FromString(cam_info.SerNo); PyObject *manufacturer = PyBytes_FromString(cam_info.ID); PyObject *hw_version = PyBytes_FromString(cam_info.Version); PyObject *manufacture_date = PyBytes_FromString(cam_info.Date); PyObject *id = Py_BuildValue("B", cam_info.Select); PyObject *sensor_id = Py_BuildValue("H", sensor_info.SensorID); PyObject *sensor_name = PyBytes_FromString(sensor_info.strSensorName); PyObject *max_width = Py_BuildValue("I", sensor_info.nMaxWidth); PyObject *max_height = Py_BuildValue("I", sensor_info.nMaxHeight); PyObject *pixel_size = Py_BuildValue("d", sensor_info.wPixelSize/100.0); PyObject *type; switch (cam_info.Type) { case IS_CAMERA_TYPE_UEYE_USB_SE: type = PyBytes_FromString("USB uEye SE or RE"); break; case IS_CAMERA_TYPE_UEYE_USB_ME: type = PyBytes_FromString("USB uEye ME"); break; case IS_CAMERA_TYPE_UEYE_USB_LE: type = PyBytes_FromString("USB uEye LE"); break; case IS_CAMERA_TYPE_UEYE_USB3_CP: type = PyBytes_FromString("USB 3 uEye CP"); break; case IS_CAMERA_TYPE_UEYE_ETH_HE: type = PyBytes_FromString("GigE uEye HE"); break; case IS_CAMERA_TYPE_UEYE_ETH_SE: type = PyBytes_FromString("GigE uEye SE or RE"); break; case IS_CAMERA_TYPE_UEYE_ETH_LE: type = PyBytes_FromString("GigE uEye LE"); break; case IS_CAMERA_TYPE_UEYE_ETH_CP: type = PyBytes_FromString("GigE uEye CP"); break; default: type = PyBytes_FromString("Unknown"); } PyObject *color_mode; switch (sensor_info.nColorMode) { case IS_COLORMODE_BAYER: color_mode = PyBytes_FromString("Bayer"); break; case IS_COLORMODE_MONOCHROME: color_mode = PyBytes_FromString("Monochrome"); break; case IS_COLORMODE_CBYCRY: color_mode = PyBytes_FromString("CBYCRY"); break; default: color_mode = PyBytes_FromString("Unknown"); } PyDict_SetItemString(dict, "serial_num", serial_num); PyDict_SetItemString(dict, "manufacturer", manufacturer); PyDict_SetItemString(dict, "hw_version", hw_version); PyDict_SetItemString(dict, "manufacture_date", manufacture_date); PyDict_SetItemString(dict, "id", id); PyDict_SetItemString(dict, "sensor_id", sensor_id); PyDict_SetItemString(dict, "sensor_name", sensor_name); PyDict_SetItemString(dict, "max_width", max_width); PyDict_SetItemString(dict, "max_height", max_height); PyDict_SetItemString(dict, "type", type); PyDict_SetItemString(dict, "color_mode", color_mode); PyDict_SetItemString(dict, "pixel_size", pixel_size); /* in um */ /* Gains */ if (sensor_info.bMasterGain) { PyDict_SetItemString(dict, "master_gain", Py_True); } else { PyDict_SetItemString(dict, "master_gain", Py_False); } if (sensor_info.bRGain) { PyDict_SetItemString(dict, "red_gain", Py_True); } else { PyDict_SetItemString(dict, "red_gain", Py_False); } if (sensor_info.bGGain) { PyDict_SetItemString(dict, "green_gain", Py_True); } else { PyDict_SetItemString(dict, "green_gain", Py_False); } if (sensor_info.bBGain) { PyDict_SetItemString(dict, "blue_gain", Py_True); } else { PyDict_SetItemString(dict, "blue_gain", Py_False); } /* Global shutter, rolling if false */ if (sensor_info.bGlobShutter) { PyDict_SetItemString(dict, "global_shutter", Py_True); } else { PyDict_SetItemString(dict, "global_shutter", Py_False); } Py_DECREF(serial_num); Py_DECREF(manufacturer); Py_DECREF(hw_version); Py_DECREF(manufacture_date); Py_DECREF(id); Py_DECREF(sensor_id); Py_DECREF(sensor_name); Py_DECREF(max_width); Py_DECREF(max_height); Py_DECREF(type); Py_DECREF(color_mode); Py_DECREF(pixel_size); return dict; }