//parses cameras from COLMAP creates a list of cameras with poses public List <CameraItem> ParseCameras(string file, int numberOfCameras) { List <CameraItem> cameras = new List <CameraItem>(); byte[] byteArray = Encoding.UTF8.GetBytes(file); //byte[] byteArray = Encoding.ASCII.GetBytes(contents); MemoryStream stream = new MemoryStream(byteArray); int numberOfCams = 0; int index = 1; // convert stream to string StreamReader r = new StreamReader(stream); while (true) { string line = r.ReadLine(); if (line == null || line.Length == 0) { break; } if (line.StartsWith("# Number of images:")) { string[] v = line.Substring(0).Split(' '); string[] vv = v[4].Split(','); numberOfCams = Int32.Parse(vv[0]); if (numberOfCameras != numberOfCams) { Debug.Log("Number of cameras does not match " + numberOfCameras + " vs. " + numberOfCams); //return null; } //get image number } if (index > 4) { string[] v = line.Substring(0).Split(' '); Quaternion q = new Quaternion(float.Parse(v[2]), float.Parse(v[3]), float.Parse(v[4]), float.Parse(v[1])); Vector3 t = new Vector3(float.Parse(v[5]), float.Parse(v[6]), float.Parse(v[7])); string[] i = v[9].Substring(0).Split('_'); CameraItem cam = new CameraItem(t, q, 1, float.Parse(i[0] + "." + i[1])); cameras.Add(cam); r.ReadLine(); } index++; if (index > 4 + numberOfCams) { break; } } return(cameras); }
public CameraItem AddCameraToStack(LogicCamera camera, string cameraName) { Debug.Log("Adding Camera " + camera.name + " description:" + cameraName); var cameraHandle = new CameraItem(camera, cameraName); cameraStack.Add(cameraHandle); SwitchToCameraWithHighestPriority(); return(cameraHandle); }
public void RetrieveAdditionalInformationTest_withInvalidID(string value) { // Arrange CameraItem item = new CameraItem("_aa1", "Camera"); item.BaseTableName = value; // Act int count = item.RetrieveAdditionalInformation(); // Assert Assert.AreEqual(0, count); }
//handler for http request, draws cameras void HandleCameraDownload(AsyncOperation op) { UnityWebRequestAsyncOperation aop = (UnityWebRequestAsyncOperation)op; try { string result = aop.webRequest.downloadHandler.text; if (result.Length == 0) { Debug.Log("Empty file"); } else { Debug.Log("Cameras dowloaded"); // WriteCaptureCamsToFile(); List <CameraItem> reconstructionCams = new CameraItem().ParseCameras(result, photoCount); if (reconstructionCams != null) { /* reconstructionCams = reconstructionCams.OrderBy(o => o.imageID).ToList(); * * for (int i = 0; i < photoCount; i++) * { * * captureCameras[i].imageID = reconstructionCams[i].imageID; * }*/ WriteCaptureCamsToFile(); ProcessReconstructionView p = new ProcessReconstructionView(); p.DrawReconstructionView(reconstructionCams, captureCameras, cameraTransform); DownloadReconstruction(); } } } catch (ArgumentException e) { Debug.Log("Something wrong with cameras"); Debug.Log("Please restart"); } }
public void CameraItemTest_withID() { // Arrange CameraItem item = new CameraItem("_xx1", "Camera"); // Act // Assert Assert.IsNotNull(item); Assert.IsNotNull(item.Reader); Assert.AreEqual("", item.BaseTableName); Assert.AreEqual("Camera", item.TargetTableName); Assert.AreEqual("_xx1", item.ID); Assert.IsNull(item.Camera); Assert.IsNull(item.Details); Assert.IsNull(item.Status); Assert.IsNull(item.LastUpdated); }
public void RetrieveBasicInformationTest_withValidID_AdditionalInfo(string value) { // Arrange CameraItem item = new CameraItem("_xx1", "Camera"); item.BaseTableName = value; // Act int count = item.RetrieveBasicInformation(false); // Assert Assert.AreEqual(1, count); Assert.AreEqual("_xx1", item.ID); Assert.AreEqual("_xxx", item.Camera.ID); Assert.AreEqual($"{value} Camera Details X1", item.Details); Assert.AreEqual("_xxx", item.Status.ID); Assert.AreEqual($"{value} Camera LastUpdated X1", item.LastUpdated); }
public void RetrieveTest_withInvalidID_AdditionalInfo(string value) { // Arrange CameraItem item = new CameraItem("_aa1", "Camera"); item.BaseTableName = value; // Act int count = item.Retrieve(false); // Assert Assert.AreEqual(0, count); Assert.AreEqual("_aa1", item.ID); Assert.IsNull(item.Camera); Assert.IsNull(item.Details); Assert.IsNull(item.Status); Assert.IsNull(item.LastUpdated); }
public void RemoveCameraFromStack(CameraItem item) { Debug.Log("Removing Camera " + item.CameraName + " target:" + item.TargetCamera.name); cameraStack.Remove(item); SwitchToCameraWithHighestPriority(); }
/// <summary> /// Get camera info from database /// </summary> public void GetCameraData() { var en = new cctvEntities(); try { var ls = en.GetCameraByUser(Account.Username); Dictionary<String, List<CameraItem>> camgroupbyname = new Dictionary<string, List<CameraItem>>(); foreach (ComplexType1 complexType1 in ls) { ComplexType1 com = complexType1; var camItem = new CameraItem { Id = com.id, CameraUrl = com.cameraurl, Ip = com.ip, Type = com.type }; if (!camgroupbyname.ContainsKey(com.group_name)) { camgroupbyname.Add(com.group_name, new List<CameraItem> { camItem }); } else { camgroupbyname[com.group_name].Add(camItem); } } var highgroup = new ObservableCollection<CameraGroupViewModel>(); foreach (var cams in camgroupbyname) { highgroup.Add(new CameraGroupViewModel(new CameraGroup { GroupName = cams.Key, CameraList = cams.Value })); } _viewModel.SetCameraGroupViewModel(highgroup); } catch (Exception ex) { } }