private async Task LoadCameraAsync() { try { IsLoading = true; CameraCollection.Clear(); var cameras = await _cameraManager.GetCameraListAsync(); int i = 0; foreach (var camera in cameras) { var cam = Mapper.Map <CameraViewModel>(camera); cam.RowNumber = ++i; CameraCollection.Add(cam); } } catch (Exception ex) { _dialogService.ShowMessage(ex.Message, "Error"); } finally { IsLoading = false; } }
protected override void BindCommands() { SearchCameraCommand = new RelayCommand(() => { Status = ViewModelStatus.Loading; CameraCollection.Clear(); Model.SearchCameras(SearchCameraText, SearchCamerasCallback); }); RefreshCameraCommand = new RelayCommand(() => { SearchCameraText = string.Empty; Refresh(); }); PublishCameraCommand = new RelayCommand(() => { if (SelectedCamera == null) { Messenger.Default.Send(new ViewModelMessageBoxMessage(this, LanguageString.Find("PublishMedia_CameraListView_PublishCameraNull"), ViewModelMessageBoxType.Error)); return; } Messenger.Default.Send(new NotificationMessage <Camera>(UIMessageType.PublishMedia_CameraSelectedEvent, SelectedCamera)); }); CancelCommand = new RelayCommand(() => { Messenger.Default.Send(new NotificationMessage(UIMessageType.PublishMedia_CancelSelectCameraEvent)); }); }
public int Open() { string strName; Vimba sys = new Vimba(); CameraCollection cameras = null; try { sys.Startup(); cameras = sys.Cameras; Console.WriteLine("Cameras found: " + cameras.Count); Console.WriteLine(); foreach (Camera camera in cameras) { try { strName = camera.Name; } catch (VimbaException ve) { strName = ve.Message; } Console.WriteLine("/// Camera Name: " + strName); } } catch (Exception e) { //sys.Shutdown(); } StartCamera(cameras[1]); return(0); }
internal Scene3D( Game game, InputMessageBuffer inputMessageBuffer, Func <Viewport> getViewport, ICameraController cameraController, WorldLighting lighting, int randomSeed, bool isDiagnosticScene = false) : this(game, getViewport, inputMessageBuffer, randomSeed, isDiagnosticScene, null, null) { _players = new List <Player>(); _teams = new List <Team>(); // TODO: This is completely wrong. LocalPlayer = _players.FirstOrDefault(); WaterAreas = AddDisposable(new WaterAreaCollection()); Lighting = lighting; Roads = AddDisposable(new RoadCollection()); Bridges = Array.Empty <Bridge>(); Waypoints = new WaypointCollection(); Cameras = new CameraCollection(); CameraController = cameraController; }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); mp_aureus = AureusEdge.CreateAndInitializeAureus(msg); checkLicense(); settingsContent = readFromFile(Settings); //Declare all of the new global variables from above CAMS = new CameraCollection(); defaultAOI = new AOISettings(); email = new EmailSettings(); //Call the function to load everything loadAll(); TempCAMs = CAMS.clone(true); getLicenseNumber(); CM = new CameraMonitor(); camMonitorThread = new System.Threading.Thread(new System.Threading.ThreadStart(CM.monitor)); camMonitorThread.Start(); CF = new CameraForm(); Application.Run(CF); }
public override void Refresh() { base.Refresh(); CameraCollection.Clear(); Status = ViewModelStatus.Initializing; Model.GetCameras(GetCamerasCallback); }
internal Scene3D( Game game, MapFile mapFile, string mapPath, int randomSeed, Data.Map.Player[] mapPlayers, Data.Map.Team[] mapTeams, ScriptList[] mapScriptLists, GameType gameType) : this(game, () => game.Viewport, game.InputMessageBuffer, randomSeed, false, mapFile, mapPath) { var contentManager = game.ContentManager; PlayerManager.OnNewGame(mapPlayers, game, gameType); TeamFactory = new TeamFactory(); TeamFactory.Initialize(mapTeams, PlayerManager); Audio = game.Audio; AssetLoadContext = game.AssetStore.LoadContext; Lighting = new WorldLighting( mapFile.GlobalLighting.LightingConfigurations.ToLightSettingsDictionary(), mapFile.GlobalLighting.Time); LoadObjects( game.AssetStore.LoadContext, Terrain.HeightMap, mapFile.ObjectsList.Objects, MapFile.NamedCameras, out var waypoints, out var roads, out var bridges, out var cameras); Roads = roads; Bridges = bridges; Waypoints = waypoints; Cameras = cameras; PlayerScripts = new PlayerScriptsList { ScriptLists = mapScriptLists }; CameraController = new RtsCameraController(game.AssetStore.GameData.Current, Camera, Terrain.HeightMap) { TerrainPosition = Terrain.HeightMap.GetPosition( Terrain.HeightMap.Width / 2, Terrain.HeightMap.Height / 2) }; contentManager.GraphicsDevice.WaitForIdle(); }
internal Scene3D(Game game, MapFile mapFile, int randomSeed) : this(game, () => game.Viewport, game.InputMessageBuffer, randomSeed, false, mapFile) { var contentManager = game.ContentManager; _players = Player.FromMapData(mapFile.SidesList.Players, game.AssetStore).ToList(); // TODO: This is completely wrong. LocalPlayer = _players.FirstOrDefault(); _teams = (mapFile.SidesList.Teams ?? mapFile.Teams.Items) .Select(team => Team.FromMapData(team, _players)) .ToList(); Audio = game.Audio; AssetLoadContext = game.AssetStore.LoadContext; Lighting = new WorldLighting( mapFile.GlobalLighting.LightingConfigurations.ToLightSettingsDictionary(), mapFile.GlobalLighting.Time); LoadObjects( game.AssetStore.LoadContext, Terrain.HeightMap, mapFile.ObjectsList.Objects, MapFile.NamedCameras, _teams, out var waypoints, out var roads, out var bridges, out var cameras); Roads = roads; Bridges = bridges; Waypoints = waypoints; Cameras = cameras; PlayerScripts = mapFile .GetPlayerScriptsList() .ScriptLists .Select(s => new MapScriptCollection(s)) .ToArray(); KeyBindingController = new KeyBindingController(contentManager); CameraController = new RtsCameraController(game.AssetStore.GameData.Current, KeyBindingController) { TerrainPosition = Terrain.HeightMap.GetPosition( Terrain.HeightMap.Width / 2, Terrain.HeightMap.Height / 2) }; contentManager.GraphicsDevice.WaitForIdle(); }
public MainPage() { InitializeComponent(); //handler.ServerCertificateCustomValidationCallback = (message, certificate, chain, sslPolicyErrors) => true; //httpClient = new HttpClient(handler); ObservableCollection <Camera> output = CameraCollection.CameraList(); CameraList.ItemsSource = output; // GetCameras(); }
void Start() { _reference = FirebaseDatabase.DefaultInstance.GetReference(DatabaseConstants.PLAYERS); _sessionId = Random.Range(0, 1000000).ToString(); _collection = FindObjectOfType <CameraCollection>(); _collection.SetSessionID(_sessionId); NickNameSetter ns = FindObjectOfType <NickNameSetter>(); if (ns != null) { _sesionNick = ns.GetNickName(); } }
private void GetCamerasCallback(object sender, AsyncWorkerCallbackEventArgs <IList <Camera> > args) { bool result = CheckAsyncWorkerCallback <IList <Camera> >(sender, args, true, LanguageString.Find("DeviceConfiguration_CameraManagementView_GetCamerasFailed")); CameraCollection.Clear(); Status = ViewModelStatus.Loaded; if (result) { foreach (var item in (args.Data as IList <Camera>)) { CameraCollection.Add(item); } } }
private void SearchCamerasCallback(object sender, AsyncWorkerCallbackEventArgs <IList <Camera> > args) { bool result = CheckAsyncWorkerCallback <IList <Camera> >(sender, args, true, LanguageString.Find("PublishMedia_CameraListView_SearchError")); CameraCollection.Clear(); if (result) { foreach (var item in (args.Data as IList <Camera>)) { CameraCollection.Add(item); } } Status = ViewModelStatus.Loaded; }
public static Scene bundleAdjustSceneMultiCollection() { //scene bevat SObject. dit kunnen eender welke elementen zijn die hier van overerven var s = new Scene(); //calibratieruimte 8x4x10m elke 1m een marker, returns List<CalibratieForms::Marker> var ptn3d = createBox(8, 4, 10, 0.2); s.objects.AddRange(ptn3d); //markers toevoegen aan scene Random rnd = new Random(); int index = rnd.Next(ptn3d.Count); var cameras = new List <PinholeCamera>(); for (int i = 0; i < 6; i++) //7 foto's met Huawei camera { var c = PinholeCamera.getTestCameraHuawei(); //Huawei bepaald via Zhang c.Name = "huaweip9"; var pos = new Matrix <double>(new double [] { rnd.Next(2, 6), 2, rnd.Next(3, 7) }); //camera staat op x: 2-6m, y=2m, z=3-7m random gekozen var target = ptn3d[rnd.Next(ptn3d.Count)]; //camera richt naar een random gekozen marker var worldtocamera = MatrixExt.LookAt(pos, target.Pos, MatrixExt.UnitVectorY <double>()); //berekend de wereld->cameracoordinaten c.WorldMat = worldtocamera.Inverted(); //camera->wereldcoordinaten. //Deze matrix bevat dus op kolom3 de Positie van de camera in wereldcoordinten, //hiernaast de rotatie in 3x3 ([R t]) cameras.Add(c); } CameraCollection coll = new CameraCollection(cameras); CameraCollection coll2 = new CameraCollection(cameras); //coll.SetCollectionCenter_MidCameras(); /*for (int i = 0; i < 5; i++) { //5 foto's met Casio camera * var c = PinholeCamera.getTestCamera();//Casio bepaald via zhang * c.Name = "casio"; * var Pos = new Vector3d(rnd.Next(2, 6), 2, rnd.Next(3, 7)); * var target = ptn3d[rnd.Next(ptn3d.Count)]; * var worldtocamera = Matrix4d.LookAt(Pos, target.Pos, Vector3d.UnitY); * c.worldMat = worldtocamera.Inverted(); * cameras.Add(c); * }*/ //s.objects.AddRange(cameras); s.objects.Add(coll); s.objects.Add(coll2); return(s); }
private void Form1_Load(object sender, EventArgs e) { try { Vimba vimba = new Vimba(); vimba.Startup(); m_Vimba = vimba; cameras = m_Vimba.Cameras; // Fetch all cameras known to Vimba Init_Camera(); updateControls(); updateControls2(); } catch (Exception exception) { // LogError("Could not startup Vimba API. Reason: " + exception.Message); System.Diagnostics.Trace.WriteLine("Could not startup Vimba API. Reason: " + exception.Message); } }
private void CameraListChanged(VmbUpdateTriggerType reason) { List <Camera> cameraList = new List <Camera>(); cameras = vimba.Cameras; foreach (Camera camera in cameras) { cameraList.Add(camera); } if (cameraList.Count == 0) { cameraOnline = false; } else { cameraOnline = true; } }
internal Scene3D( Game game, InputMessageBuffer inputMessageBuffer, Func <Viewport> getViewport, ICameraController cameraController, WorldLighting lighting, int randomSeed, bool isDiagnosticScene = false) : this(game, getViewport, inputMessageBuffer, randomSeed, isDiagnosticScene, null, null) { WaterAreas = AddDisposable(new WaterAreaCollection()); Lighting = lighting; Roads = AddDisposable(new RoadCollection()); Bridges = Array.Empty <Bridge>(); Waypoints = new WaypointCollection(); Cameras = new CameraCollection(); CameraController = cameraController; }
private void openCamera(CameraModel camera) { Vimba sys = new Vimba(); try { sys.Startup(); CameraCollection cameras = sys.Cameras; foreach (Camera c in cameras) { if (c.Id.Equals(camera.cameraID)) { sc = c; break; } } if (sc != null) { try { sys.OpenCameraByID(camera.cameraID, VmbAccessModeType.VmbAccessModeFull); } catch (VimbaException ve) { MessageBox.Show("Error opening camera: " + ve.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } Console.WriteLine("Camera opened: " + camera.cameraID); // Read camera features readFeatures(); } } finally { sys.Shutdown(); } }
GlobalData() { Cameras = new CameraCollection(); }
public SceneManager(Settings settings, GraphicsDevice graphicsDevice) { if (settings == null) { throw new ArgumentNullException("settings"); } if (graphicsDevice == null) { throw new ArgumentNullException("graphicsDevice"); } this.settings = settings; GraphicsDevice = graphicsDevice; spriteBatch = new SpriteBatch(GraphicsDevice); Cameras = new CameraCollection(InitialCameraCapacity); DirectionalLights = new DirectionalLightCollection(InitialDirectionalLightCapacity); ParticleSystems = new ParticleSystemCollection(InitialParticleSystemCapacity); PostProcessors = new PostProcessorCollection(InitialPostProcessorCapacity); opaqueObjects = new List <SceneObject>(InitialSceneObjectCapacity); translucentObjects = new List <SceneObject>(InitialSceneObjectCapacity); shadowCasters = new List <ShadowCaster>(InitialShadowCasterCapacity); collectObjectsAction = new Action <Octree>(CollectObjects); //---------------------------------------------------------------- // シーン描画のためのレンダ ターゲット var pp = GraphicsDevice.PresentationParameters; var width = pp.BackBufferWidth; var height = pp.BackBufferHeight; var format = pp.BackBufferFormat; var depthFormat = pp.DepthStencilFormat; var multiSampleCount = pp.MultiSampleCount; RenderTarget = new RenderTarget2D(GraphicsDevice, width, height, false, format, depthFormat, multiSampleCount, RenderTargetUsage.PreserveContents); //---------------------------------------------------------------- // ポストプロセッサ コンテキスト postProcessorContext = new PostProcessorContext(this); //---------------------------------------------------------------- // ポスト プロセスのためのレンダ ターゲット postProcessRenderTarget = new RenderTarget2D(GraphicsDevice, width, height, false, format, depthFormat, multiSampleCount, RenderTargetUsage.PreserveContents); // TODO octreeManager = new OctreeManager(new Vector3(256), 3); // TODO RootNode = new SceneNode(this, "Root"); #if DEBUG || TRACE debugBoxEffect = new BasicEffect(GraphicsDevice); debugBoxEffect.AmbientLightColor = Vector3.One; debugBoxEffect.VertexColorEnabled = true; debugBoxDrawer = new BoundingBoxDrawer(GraphicsDevice); #endif }
private void LoadObjects( AssetLoadContext loadContext, HeightMap heightMap, MapObject[] mapObjects, NamedCameras namedCameras, List <Team> teams, out WaypointCollection waypointCollection, out RoadCollection roads, out Bridge[] bridges, out CameraCollection cameras) { var waypoints = new List <Waypoint>(); var bridgesList = new List <Bridge>(); var roadTopology = new RoadTopology(); for (var i = 0; i < mapObjects.Length; i++) { var mapObject = mapObjects[i]; switch (mapObject.RoadType & RoadType.PrimaryType) { case RoadType.None: switch (mapObject.TypeName) { case Waypoint.ObjectTypeName: waypoints.Add(new Waypoint(mapObject)); break; default: GameObject.FromMapObject(mapObject, loadContext.AssetStore, GameObjects, heightMap, null, teams); break; } break; case RoadType.BridgeStart: case RoadType.BridgeEnd: // Multiple invalid bridges can be found in e.g GLA01. if ((i + 1) >= mapObjects.Length || !mapObjects[i + 1].RoadType.HasFlag(RoadType.BridgeEnd)) { Logger.Warn($"Invalid bridge: {mapObject.ToString()}, skipping..."); continue; } var bridgeEnd = mapObjects[++i]; bridgesList.Add(AddDisposable(new Bridge( loadContext, heightMap, mapObject, mapObject.Position, bridgeEnd.Position, GameObjects))); break; case RoadType.Start: case RoadType.End: var roadEnd = mapObjects[++i]; // Some maps have roads with invalid start- or endpoints. // We'll skip processing them altogether. if (mapObject.TypeName == "" || roadEnd.TypeName == "") { Logger.Warn($"Road {mapObject.ToString()} has invalid start- or endpoint, skipping..."); continue; } if (!mapObject.RoadType.HasFlag(RoadType.Start) || !roadEnd.RoadType.HasFlag(RoadType.End)) { throw new InvalidDataException(); } // Note that we're searching with the type of either end. // This is because of weirdly corrupted roads with unmatched ends in USA04, which work fine in WB and SAGE. var roadTemplate = loadContext.AssetStore.RoadTemplates.GetByName(mapObject.TypeName) ?? loadContext.AssetStore.RoadTemplates.GetByName(roadEnd.TypeName); if (roadTemplate == null) { throw new InvalidDataException($"Missing road template: {mapObject.TypeName}"); } roadTopology.AddSegment(roadTemplate, mapObject, roadEnd); break; } loadContext.GraphicsDevice.WaitForIdle(); } cameras = new CameraCollection(namedCameras?.Cameras); roads = AddDisposable(new RoadCollection(roadTopology, loadContext, heightMap)); waypointCollection = new WaypointCollection(waypoints, MapFile.WaypointsList.WaypointPaths); bridges = bridgesList.ToArray(); }
public VimbaCapture() { if (RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully) { source = Observable.Create <VimbaDataFrame>((observer, cancellationToken) => { return(Task.Factory.StartNew(() => { lock (captureLock) { global_observer = observer; // Start the Vimba API vimba = new Vimba(); vimba.Startup(); // Register the on camera list change handler for when cameras go offline vimba.OnCameraListChanged += new Vimba.OnCameraListChangeHandler(CameraListChanged); // Get a list of the connected cameras cameras = vimba.Cameras; // Get the ID of the camera at index given by the Index parameter string id = cameras[Index].Id; // Open the camera camera = vimba.OpenCameraByID(id, VmbAccessModeType.VmbAccessModeFull); // Get the camera's features FeatureCollection features = camera.Features; // Checks whether to reset the camera if (ResetDevice) { // Sets the camera online variable to false cameraOnline = false; // Reset camera features["DeviceReset"].RunCommand(); // Checks if the camera's are still offline while (cameraOnline == false) { // Do nothing } // Open the camera again camera = vimba.OpenCameraByID(id, VmbAccessModeType.VmbAccessModeFull); // Get the camera's features again features = camera.Features; } // Set the callback function for when a frame is received camera.OnFrameReceived += new Camera.OnFrameReceivedHandler(OnFrameReceived); // Set the acquisition mode features["AcquisitionFrameRateMode"].EnumValue = "Basic"; // Calculate the camera's maximum possible fps double cameraFrameRateLimit = getCameraFrameRateLimit(features); // Set exposure time to camera's current exposure time variable if (ExposureTime == 0) { // Set exposure time variable to current value on the camera (convert from us to ms) ExposureTime = features["ExposureTime"].FloatValue / 1000.0; // Get the theoretical maximum framerate for this exposure time maxFrameRate = Math.Min(1000.0 / ExposureTime, cameraFrameRateLimit); // Set the fps variable to the real maximum realMaxFrameRate = getRealMaxFrameRate(features, maxFrameRate); FrameRate = realMaxFrameRate; } // Set black level parameter to the camera's current black level setting if (BlackLevel == 0) { BlackLevel = features["BlackLevel"].FloatValue; } // Set gain parameter to the camera's current gain setting if (Gain == 0) { Gain = features["Gain"].FloatValue; } // Set gamma parameter to the camera's current gamma setting if (Gamma == 0) { Gamma = features["Gamma"].FloatValue; } // Set exposure time to exposure time before camera reset if (ExposureTime != features["ExposureTime"].FloatValue) { features["ExposureTime"].FloatValue = ExposureTime * 1000.0; } // Set frame rate to frame rate before camera reset if (FrameRate != features["AcquisitionFrameRate"].FloatValue) { features["AcquisitionFrameRate"].FloatValue = FrameRate; } // Set black level to black level before camera reset if (BlackLevel != features["BlackLevel"].FloatValue) { features["BlackLevel"].FloatValue = BlackLevel; } // Set gain to gain before camera reset if (Gain != features["Gain"].FloatValue) { features["Gain"].FloatValue = Gain; } // Set gamma to gamma before camera reset if (Gamma != features["Gamma"].FloatValue) { features["Gamma"].FloatValue = Gamma; } try { // Start capturing frames camera.StartContinuousImageAcquisition(3); while (!cancellationToken.IsCancellationRequested) { // Check the parameters of the camera CheckCameraParameters(features, cameraFrameRateLimit); } // Stop camera acquisition camera.StopContinuousImageAcquisition(); } finally { // Shutdown everything camera.Close(); vimba.Shutdown(); } } }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default)); }) .PublishReconnectable() .RefCount(); } }
public SceneManager( string name ) : base() { this.cameraList = new CameraCollection(); this.sceneNodeList = new SceneNodeCollection(); this.animationList = new AnimationCollection(); this.animationStateList = new AnimationStateSet(); this.regionList = new List<StaticGeometry.Region>(); this.shadowCasterQueryListener = new ShadowCasterSceneQueryListener( this ); // create the root scene node this.rootSceneNode = new SceneNode( this, "Root" ); this.rootSceneNode.SetAsRootNode(); this.defaultRootNode = this.rootSceneNode; this.name = name; // default to no fog this.fogMode = FogMode.None; // no shadows by default this.shadowTechnique = ShadowTechnique.None; // setup default shadow camera setup this._defaultShadowCameraSetup = new DefaultShadowCameraSetup(); this.illuminationStage = IlluminationRenderStage.None; this.renderingNoShadowQueue = false; this.renderingMainGroup = false; this.shadowColor.a = this.shadowColor.r = this.shadowColor.g = this.shadowColor.b = 0.25f; this.shadowDirLightExtrudeDist = 10000; this.shadowIndexBufferSize = 51200; this.shadowTextureOffset = 0.6f; this.shadowTextureFadeStart = 0.7f; this.shadowTextureFadeEnd = 0.9f; this.shadowTextureSize = 512; this.shadowTextureCount = 1; this.findVisibleObjects = true; this.suppressRenderStateChanges = false; this.suppressShadows = false; this.shadowUseInfiniteFarPlane = true; }
static void Main(string[] args) { LoadUserSettings(); //Hook Ctrl+C and Ctrl+Break to be able to gracefully shut down laser Console.CancelKeyPress += Console_CancelKeyPress; //Obtain information on connected cameras Vimba camsession = new Vimba(); CameraCollection cameras = null; camsession.Startup(); cameras = camsession.Cameras; //Write camera information to console for (int i = 0; i < cameras.Count; i++) { Console.WriteLine("Camera {0} is : {1}", i, cameras[i]); } //Write default camera and paradigm structure to console Console.WriteLine("############################################################"); Console.WriteLine("Paradigm defaults:"); Console.WriteLine("Assuming that camera {0} is the main camera", _cam_id_default); Console.WriteLine("Pre/post stimulus = {0} seconds.", _laserPrePostSeconds); Console.WriteLine("Stimulus ON = {0} seconds.", _laserOnSeconds); Console.WriteLine("Laser stimulus current = {0} mA.", _laserCurrentmA); Console.WriteLine("Number of stimulus trials = {0}.", _n_stim); Console.WriteLine("############################################################"); string answer = ""; while (answer != "a" && answer != "e") { Console.Write("accept defaults or edit? [a/e]"); answer = Console.ReadLine(); } if (answer == "e") { AskParadigmInput(); } Console.WriteLine("Please enter the experiment name and press return:"); string exp_name = Console.ReadLine(); Camera av_cam = cameras[_cam_id_default]; Console.WriteLine("Starting laser tasks"); StartLaserTasks(); Console.WriteLine("Opening camera"); av_cam.Open(VmbAccessModeType.VmbAccessModeFull); try { av_cam.LoadCameraSettings("CaSettings.xml"); } catch { Console.WriteLine("Could not find camera configuration file CaSettings.xml"); Console.WriteLine("Reverting to whatever defaults are currently set..."); } string today_folder = string.Format("{0}_{1}_{2}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); _imageWriter = new TiffWriter("F://PatchCommander_Data//" + today_folder + "//" + exp_name, true); av_cam.OnFrameReceived += FrameReceived; double total_seconds = _n_stim * (2 * _laserPrePostSeconds + _laserOnSeconds); //Allocate enough frames for a 4Hz acquisition. TODO: Get/set true framerate based on exposure av_cam.StartContinuousImageAcquisition((int)(total_seconds * 4)); Console.WriteLine("Started continuous capture. Total length: {0} seconds", total_seconds); while (total_seconds > 0) { Thread.Sleep(2000); total_seconds -= 2; Console.WriteLine("{0} seconds remaining.", total_seconds); } camsession.Shutdown(); _imageWriter.Dispose(); StopLaserTasks(); SaveUserSettings(); Console.WriteLine("Finished successfully."); Thread.Sleep(1000); }
public void LevelLoadedStart() { _reference = FirebaseDatabase.DefaultInstance.GetReference(DatabaseConstants.PLAYERS); _camCollection = FindObjectOfType <CameraCollection>(); Enable(); }
public void SolveMultiCollection() { SetUniqueValues(); var collections = scene.get <CameraCollection>(); var markers3d = scene.get <Marker>(); var cameras = scene.get <PinholeCamera>(); var collec = new CameraCollection(cameras); collections = new[] { collec }; var ccoll = new CeresCameraCollection(); ccoll.Cameras = new List <CeresCamera>(); ccoll.Cameras.AddRange(cameras.Select(x => { var cc = x.toCeresCamera(); return(cc); })); // ccoll.CreateSecondPositionCopy(); var bundler = new ceresdotnet.CeresCameraMultiCollectionBundler(); Dictionary <CeresCameraCollection, Dictionary <CeresCamera, List <CeresMarker> > > observations = new Dictionary <CeresCameraCollection, Dictionary <CeresCamera, List <CeresMarker> > >(); List <CeresCamera> cerescameras = new List <CeresCamera>(); List <CeresCameraCollection> cerescameracollections = new List <CeresCameraCollection>(); int cameraID = -1; var collectionobservations2 = new Dictionary <CeresCamera, List <CeresMarker> >(); foreach (var camera in UniqueCameras) { //voor ruis kopie maken var cameracopy = new PinholeCamera(); var cc = camera.toCeresCamera(); cameracopy.toCeresCamera(); cameracopy.updateFromCeres(cc.Internal); cameracopy.updateFromCeres(cc.External); this.OriginalValues.Add(camera, cameracopy); } int totaalfotos = 0; foreach (var collection in collections) { var cerescollection = new CeresCameraCollection(); var collectionobservations = new Dictionary <CeresCamera, List <CeresMarker> >(); foreach (var camera in collection) { totaalfotos++; List <CeresMarker> ceresmarkers = new List <CeresMarker>(); cameraID++; var puntenCv = markers3d.ToDictionary(m => new MCvPoint3D32f((float)m.X, (float)m.Y, (float)m.Z)); var cc = camera.toCeresCamera(); ceresdotnet.CeresTestFunctions.ProjectPoint(cc.Internal, cc.External, markers3d[0].Pos); var visible_proj = camera.ProjectPointd2D_Manually(markers3d, out Marker[] visible3d); GemFeaturesPerFoto += visible_proj.Length; //Pixel ruis for (int i = 0; i < visible_proj.Length; i++) { PixelRuisProvider?.Apply(ref visible_proj[i]); } //in een cerescamera worden interne parameters opgeslaan volgens array v doubles //Per interne parameters kan men bepalen wat dient gebundeld te worden //ook combinatie zijn mogelijk //3D ruis foreach (var marker in markers3d) { //WorldRuisProvider?.Apply(marker); } for (int i = 0; i < visible3d.Length; i++) { var proj = visible_proj[i]; ceresmarkers.Add(new CeresMarker() { id = visible3d[i].ID, Location = visible3d[i].toCeresParameter(), x = proj.X, y = proj.Y }); } cerescameras.Add(cc); collectionobservations.Add(cc, ceresmarkers); //gesimuleerde foto weergeven /*var window2 = new CameraSimulationFrm(string.Format("Camera {0}: {1}", cameraID, camera.Name)) { * Camera = camera * }; * window2.Show(); * window2.drawChessboard(visible_proj);*/ } observations.Add(cerescollection, collectionobservations); collectionobservations2 = collectionobservations; } GemFeaturesPerFoto /= totaalfotos; foreach (var intr in UniqueIntr) { //Camera ruis/modifier CameraModifier?.Apply(intr); intr.toCeresParameter(); } foreach (var marker in markers3d) { WorldRuisProvider?.Apply(marker); marker.toCeresParameter(); } CeresCameraMultiCollectionBundler.MarkersFromCameraDelegate findObservationsFunc = (camera, coll) => { var r = collectionobservations2[camera]; double Allreproj = 0; double totalmrkrcout = 0; //foreach (var ceresCamera in bundler.StandaloneCameraList) { double reprojections = 0; foreach (var ceresMarker in r) { var reproj = CeresTestFunctions.ReprojectPoint(camera.Internal, camera.External, ceresMarker.toPointF(), ceresMarker.Location.toMatrix()); reprojections += Math.Sqrt(reproj.X * reproj.X + reproj.Y * reproj.Y); } Allreproj += reprojections; totalmrkrcout += r.Count; reprojections /= r.Count; //} return(r); }; bundler.MarkersFromCamera = findObservationsFunc; bundler.CollectionList = cerescameracollections; bundler.StandaloneCameraList = cerescameras; bundler.bundleCollections(iterationCallbackHandler); CeresCameraMultiCollectionBundler b = bundler; double AllReprojections = 0; double totalmarkercount = 0; double meanPosX = 0; double meanPosY = 0; double meanPosZ = 0; foreach (var ceresCamera in b.StandaloneCameraList) { double reprojections = 0; var markerlist = b.MarkersFromCamera(ceresCamera, null); foreach (var ceresMarker in markerlist) { var reproj = CeresTestFunctions.ReprojectPoint(ceresCamera.Internal, ceresCamera.External, ceresMarker.toPointF(), ceresMarker.Location.toMatrix()); reprojections += Math.Sqrt(reproj.X * reproj.X + reproj.Y * reproj.Y); } AllReprojections += reprojections; totalmarkercount += markerlist.Count; reprojections /= markerlist.Count; //mean cam pos; var pos = ceresCamera.External.t; meanPosX += pos[0]; meanPosY += pos[1]; meanPosZ += pos[2]; } meanPosX /= b.StandaloneCameraList.Count; meanPosY /= b.StandaloneCameraList.Count; meanPosZ /= b.StandaloneCameraList.Count; AllReprojections /= totalmarkercount; reporjectionsstring += String.Format("({0}) Error: {1}", "final", AllReprojections) + Environment.NewLine; meancamereapos += String.Format("({0}) pos: {1} {2} {3}", "final", AllReprojections, meanPosX, meanPosY, meanPosZ) + Environment.NewLine; Console.WriteLine("({0}) reprojerror: {1} mean cam pos: x({2}) y({3}) z({4})", "final", AllReprojections, meanPosX, meanPosY, meanPosZ); lastReproj = AllReprojections; foreach (var collection in collections) { foreach (var camera in collection) { camera.updateFromCeres(); } } }
GlobalData() { Cameras = new CameraCollection(); }
public override void Cleanup() { base.Cleanup(); CameraCollection.Clear(); Model = null; }