void CAddDevice::GetCameraObj(ec_Camera& camObj) { USES_CONVERSION; CString strAddress, strPort, str; GetKeyinAddress(strAddress, strPort); camObj.camera_idx = m_pbk->GetEmptyCameraIdx(); camObj.ipaddress = strAddress; camObj.httpport = _ttoi(strPort); camObj.username = m_strUserName; camObj.password = m_strPassword; camObj.active_ = _T("Y"); m_mapJason[_T("network")].GetValuebyKey(_T("gateway"), camObj.gateway); m_mapJason[_T("network")].GetValuebyKey(_T("dns1"), camObj.name_server); m_mapJason[_T("info")].GetValuebyKey(_T("macaddr"), camObj.mac_address); camObj.mac_address.Replace(_T(":"),_T("")); m_mapJason[_T("rs485")].GetValuebyKey(_T("proto"),camObj.ptz_protocol); m_mapJason[_T("info")].GetValuebyKey(_T("model"),camObj.model_code); GetCameraName(camObj.cameraname); GetConnectTypeCode(camObj.connect_type_code); GetBrandCode(camObj.brand_code); GetDigitalStatus(m_mapJason[_T("io")], _T("in1"), camObj.digital_in1); GetDigitalStatus(m_mapJason[_T("io")], _T("in2"), camObj.digital_in2); GetDigitalStatus(m_mapJason[_T("io")], _T("out1"), camObj.digital_out); GetVideoFormat(m_mapJason[_T("mcp")], camObj.video_format); GetNetMask(m_mapJason[_T("network")], camObj); GetPTZSupport(camObj.ptz_support); GetStreamUrl(camObj.stream_url); if (m_isONVIF) { DWORD dwVideoFormat = m_pbk->PackVideoFormat(0,0,ONVIF,0); NODEITEM node = m_vcNodes[0]; m_pbk->TransMac2String(node.mac,camObj.mac_address); camObj.stream_url.Format(_T("%s"),node.stream_url); camObj.video_format.Format(_T("%d"),dwVideoFormat); camObj.model_code = A2W(node.modelname); } }
void NVScene::UpdateHUD() { if(1) // no longer care about HUDSwitch -- we don't work that way anymore { if(1) { osg::Vec3 Eye, Center, Up; PartialVertexDEM CamLoc; GetGlobalViewer()->getSceneHandlerList()[0]->getSceneView()->getViewMatrixAsLookAt(Eye, Center, Up); CamLoc.XYZ[0] = Eye.x(); CamLoc.XYZ[1] = Eye.y(); CamLoc.XYZ[2] = Eye.z(); CartToDeg(CamLoc); if(Overlay.GetOverlayTextTemplate().empty()) { std::ostringstream NewOverlayText; if(ThreadDebugMsg[0]) { NewOverlayText << ThreadDebugMsg; } // if else { double ElevAGL = -FLT_MAX; NewOverlayText.precision(8); if(GetNumCameras()) // prevent null pointers when no cameras defined { NewOverlayText << "Camera: " << GetCameraName(GetCurCameraNum()) << "\n"; } // if else { NewOverlayText << "\n"; // no camera info, insert blank line } // else if(fabs(CamLoc.Lat) < 0.00000001) CamLoc.Lat = 0; // truncate silly scientific notation epsilons... if(fabs(CamLoc.Lon) < 0.00000001) CamLoc.Lon = 0; // truncate silly scientific notation epsilons... if(fabs(CamLoc.Elev) < 0.00000001) CamLoc.Elev = 0; // truncate silly scientific notation epsilons... NewOverlayText << " Latitude: "; NewOverlayText << (CamLoc.Lat < 0 ? "S" : "N"); NewOverlayText << fabs(CamLoc.Lat); NewOverlayText << "\n Longitude: "; NewOverlayText << (CamLoc.Lon < 0 ? "E" : "W"); NewOverlayText << fabs(CamLoc.Lon); NewOverlayText.precision(6); NewOverlayText << "\n Elevation: " << CamLoc.Elev; if(FetchTerrainHeight(NULL, CamLoc.Lon, CamLoc.Lat, ElevAGL)) { NewOverlayText << " (" << (CamLoc.Elev - ElevAGL) << " AGL)"; } // if //NewOverlayText << "\nDX: " << DXG << " DY: " << DYG << " V: " << MiscReadout; //NewOverlayText << "\nDebug: " << MiscReadout << ", " << MiscReadoutTwo; //NewOverlayText << "\nDebug: " << MiscReadout; } // else // handle appending framerate info if(MasterScene.SceneLOD.GetShowFramerate()) { if(1) // to preserve indent { double AvgTime = 0.01f; // not 0 to prevent divide by zero char FormatStr[200]; if(FrameStatisticsCounter.QueryAdequateSamples()) { AvgTime = FrameStatisticsCounter.FetchAverageTime(); } // if FormatStr[0] = NULL; // can't get the cout formatter to do what I want, here goes sprintf! //sprintf(FormatStr, "%#04.1f", (1.0f / TimeDelta)); NewOverlayText << "\nF:" << FormatStr; if(AvgTime > 0.0) { sprintf(FormatStr, "%#04.1f", (1.0f / AvgTime)); NewOverlayText << " A:" << FormatStr; } // if //sprintf(FormatStr, "%d", (long int)TargetFramerate); //NewOverlayText << " T:" << FormatStr; // <<<>>> Debug: CurrentInstantFrameRate sprintf(FormatStr, "%#04.1f", CurrentInstantFrameRate); NewOverlayText << " C:" << FormatStr; sprintf(FormatStr, "%#4.2f", MasterScene.SceneLOD.GetLODAutoFactor()); NewOverlayText << " D:" << FormatStr; unsigned long int TotPoly; TotPoly = GetTotalNumTriangles(); if(TotPoly != 0) { sprintf(FormatStr, "%d", TotPoly); NewOverlayText << " P:" << FormatStr; } // if bool NewLineSent = false; // append pager info osgDB::DatabasePager* dp = osgDB::Registry::instance()->getDatabasePager(); if(dp) { if(dp->getFileRequestListSize() > 0 || dp->getDataToCompileListSize() > 0) { if(!NewLineSent) { NewOverlayText << "\n"; NewLineSent = true; } // if NewOverlayText << "L: " << dp->getFileRequestListSize(); NewOverlayText << " C: " << dp->getDataToCompileListSize() << " "; } // if } // if if(ThreadLoadMsg[0]) { if(!NewLineSent) { NewOverlayText << "\n"; //NewLineSent = true; // who cares at this point? } // if NewOverlayText << "[" << ThreadLoadMsg << "] "; } // if } // if } // if Overlay.SetOverlayText(NewOverlayText.str()); } // if else { Overlay.SetOverlayText(Overlay.GetProcessedText()); } // else if(Overlay.GetMapOn()) { float Heading = 0; GetCurCameraCurHeadingRadians(Heading); Overlay.UpdateMapPoint(CamLoc.Lon, CamLoc.Lat, Heading); // Heading is in radians } // if } // if } // if } // NVScene::UpdateHUD
/************************************ * 设备初始化 *************************************/ bool CCommon::InitialDevice(CComboBox &m_cbDevice, LONG * width, LONG * height) { LONG w = 0, h = 0; bool m_bCameraOpen = false; int cam_count = GetCameraCount();//仅仅获取摄像头数目 m_cbDevice.SetDroppedWidth(cam_count); //获取所有摄像头的名称 for(int i=0; i < cam_count; i++) { char camera_name[1024]; int retval = GetCameraName(i, camera_name, sizeof(camera_name)); if(retval >0) { CString str,str_camera_name; str_camera_name = CCommon::Char2CString(camera_name); //防止摄像头名称太长,超出显示区域 int spaceNum = str_camera_name.Find(" "); CString strTemp = str_camera_name.Mid(0,spaceNum); str.Format("[%d] %s",i,strTemp); m_cbDevice.InsertString(i,str.GetBuffer(0)); } } if(cam_count > 0) { CString camera = CCommon::GetReg("Camera"); int m_iCameraIndex = atoi(CCommon::CString2Char(camera));//注册表获取摄像头id if(m_iCameraIndex < 0 || m_iCameraIndex > cam_count - 1) m_iCameraIndex = 0; m_cbDevice.SetCurSel(m_iCameraIndex);//设置默认选中第一个摄像头,现在从配置文件读取 //打开第一个摄像头 if(OpenCameraCB(m_iCameraIndex, false, &w,&h)) //不弹出属性选择窗口,用代码制定图像宽和高 { m_bCameraOpen = TRUE; } if(m_bCameraOpen == false) { for(int k = 0; k < cam_count; k++) { //打开第一个摄像头 if(OpenCameraCB(k, false, &w, &h)) //不弹出属性选择窗口,用代码制定图像宽和高 { m_bCameraOpen = TRUE; break; } } if(m_bCameraOpen == false && cam_count> 0) { //AfxMessageBox("摄像头初始化失败", MB_OK, MB_ICONINFORMATION); //OnOK(); *width = w; *width = h; return false; } } } *width = w; *height = h; return true; }