void CameraHandle::getSourceFormat() { VRmImageFormat sourceFormat; VRM_CHECK(VRmUsbCamGetSourceFormatEx(device, conf.portLeft, &sourceFormat)); const char* source_color_format_str; VRM_CHECK(VRmUsbCamGetStringFromColorFormat(sourceFormat.m_color_format, &source_color_format_str)); ROS_INFO("Selected source format: %d x %d (%s)", sourceFormat.m_width, sourceFormat.m_height, source_color_format_str); }
bool VRCam::init() { if (systemInited == true) return false; atexit(VRmUsbCamCleanup); //更新设备列表 if (!VRmUsbCamUpdateDeviceKeyList()){ sendMsg("update Device failed"); return false; } //检查连接的设备 VRmDWORD size = 0; if (!(VRmUsbCamGetDeviceKeyListSize(&size))){ sendMsg("Get Device Size failed"); return false; } if (size == 0){ sendMsg("0 Cam Connect"); return false; } sendMsg(tr("%1 Cam Find").arg(size)); //打开第一个可用的设备 VRmDeviceKey* p_device_key = 0; for (VRmDWORD i = 0; i < size; ++i) { VRMEXECANDCHECK(VRmUsbCamGetDeviceKeyListEntry(i, &p_device_key)); if (!p_device_key->m_busy) { if (!(VRmUsbCamOpenDevice(p_device_key, &device))) { sendMsg("Open Cam Failed"); } } else { sendMsg("Device is busy now"); } VRMEXECANDCHECK(VRmUsbCamFreeDeviceKey(&p_device_key)); } if (!device) { return false; } //now get the first sensor port VRMEXECANDCHECK(VRmUsbCamGetSensorPortListEntry(device, 0, &port)); // get the current source format VRmImageFormat source_format; VRMEXECANDCHECK(VRmUsbCamGetSourceFormatEx(device, port, &source_format)); const char *source_color_format_str; VRMEXECANDCHECK(VRmUsbCamGetStringFromColorFormat(source_format.m_color_format, &source_color_format_str)); VRmDWORD number_of_target_formats, i; VRMEXECANDCHECK(VRmUsbCamGetTargetFormatListSizeEx2(device, port, &number_of_target_formats)); for (i = 0; i < number_of_target_formats; ++i) { VRMEXECANDCHECK(VRmUsbCamGetTargetFormatListEntryEx2(device, port, i, &target_format)); if (target_format.m_color_format == VRM_ARGB_4X8) break; } systemInited = true; return true; }