private void InitializeAR(int captureWidth, int captureHeight) { arDetector = new GrayBufferMarkerDetector(); // Load the marker pattern. It has 16x16 segments and a width of 80 millimeters var markers = new List<Marker>(); string[] markerNames = config.GetStringArray("MarkerNames", "Names"); foreach (string markerName in markerNames) { string markerPatternPath = config.GetString("MarkerPatternPaths", markerName); markers.Add(Marker.LoadFromResource(markerPatternPath, 16, 16, 80, markerName)); } // The perspective projection has the near plane at 1 and the far plane at 4000 arDetector.Initialize(captureWidth, captureHeight, 1, 4000, markers); arDetector.Threshold = 150; isInitialized = true; }
/// <summary> /// Handle successful camera initialization /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="Microsoft.Devices.CameraOperationCompletedEventArgs"/> instance containing the event data.</param> private void CameraInitialized(object sender, CameraOperationCompletedEventArgs e) { if (this.cam != null) { Deployment.Current.Dispatcher.BeginInvoke(delegate { // Set the orientation of the viewfinder. this.viewfinderBrushTransform.Angle = this.cam.Orientation; }); if (this.detectColors) { // Start the background worker thread that processes the camera preview buffer frames. this.cdtPleaseExit = false; this.colorDetectThread = new Thread(this.ColorDetectWorker); this.colorDetectThread.Start(); } if (this.detectImages) { this.markerDetector = new GrayBufferMarkerDetector(); // TODO: add more markers var marker = Marker.LoadFromResource("markers/wp8.pat", 16, 16, 80, "WP8"); // The perspective projection has the near plane at 1 and the far plane at 4000 this.markerDetector.Initialize((int)this.cam.PreviewResolution.Width, (int)this.cam.PreviewResolution.Height, 1, 4000, marker); Deployment.Current.Dispatcher.BeginInvoke( () => { imageDetectTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(100) }; imageDetectTimer.Tick += (s, args) => this.DetectImages(); imageDetectTimer.Start(); }); } } }
void PhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e) { // Initialize the Detector arDetector = new GrayBufferMarkerDetector(); // Load the marker pattern. It has 16x16 segments and a width of 80 millimeters var marker = Marker.LoadFromResource("data/Marker_SLAR_16x16segments_80width.pat", 16, 16, 80); // The perspective projection has the near plane at 1 and the far plane at 4000 arDetector.Initialize((int)photoCamera.PreviewResolution.Width, (int)photoCamera.PreviewResolution.Height, 1, 4000, marker); isInitialized = true; }
void photoCamera_Initialized(object sender, CameraOperationCompletedEventArgs e) { // Initialize the Detector //This need to be done AFTER the camera is initialized arDetector = new GrayBufferMarkerDetector(); // Setup both markers Marker[] markers = GameState.getInstance().getMarkers(); arDetector.Initialize(System.Convert.ToInt32(photoCamera.PreviewResolution.Width), System.Convert.ToInt32(photoCamera.PreviewResolution.Height), 1, 4000, markers); isInitialized = true; }