private void SetupCalibration() { leftCaptureDevice = new DirectShowCapture2(); leftCaptureDevice.InitVideoCapture(leftDeviceID, FrameRate._30Hz, Resolution._640x480, ImageFormat.R8G8B8_24, false); // Add left video capture device to the scene for rendering left eye image scene.AddVideoCaptureDevice(leftCaptureDevice); rightCaptureDevice = new DirectShowCapture2(); rightCaptureDevice.InitVideoCapture(rightDeviceID, FrameRate._30Hz, Resolution._640x480, ImageFormat.R8G8B8_24, false); // Add right video capture device to the scene for rendering right eye image scene.AddVideoCaptureDevice(rightCaptureDevice); // Create holders for retrieving the captured video images leftImagePtr = Marshal.AllocHGlobal(leftCaptureDevice.Width * leftCaptureDevice.Height * 3); rightImagePtr = Marshal.AllocHGlobal(rightCaptureDevice.Width * rightCaptureDevice.Height * 3); // Associate each video devices to each eye scene.LeftEyeVideoID = 0; scene.RightEyeVideoID = 1; scene.ShowCameraImage = true; float markerSize = 32.4f; // Initialize a marker tracker for tracking an marker array used for calibration markerTracker = new ALVARMarkerTracker(); markerTracker.MaxMarkerError = 0.02f; markerTracker.ZNearPlane = 0.1f; markerTracker.ZFarPlane = 1000; markerTracker.InitTracker(leftCaptureDevice.Width, leftCaptureDevice.Height, LEFT_CALIB, markerSize); ((StereoCamera)scene.CameraNode.Camera).LeftProjection = markerTracker.CameraProjection; // Add another marker detector for tracking right video capture device ALVARDllBridge.alvar_add_marker_detector(markerSize, 5, 2); ALVARDllBridge.alvar_add_camera(RIGHT_CALIB, rightCaptureDevice.Width, rightCaptureDevice.Height); double[] projMat = new double[16]; double cameraFovX = 0, cameraFovY = 0; ALVARDllBridge.alvar_get_camera_params(1, projMat, ref cameraFovX, ref cameraFovY, 1000, 0.1f); ((StereoCamera)scene.CameraNode.Camera).RightProjection = new Matrix( (float)projMat[0], (float)projMat[1], (float)projMat[2], (float)projMat[3], (float)projMat[4], (float)projMat[5], (float)projMat[6], (float)projMat[7], (float)projMat[8], (float)projMat[9], (float)projMat[10], (float)projMat[11], (float)projMat[12], (float)projMat[13], (float)projMat[14], (float)projMat[15]); // Add a marker array to be tracked markerID = markerTracker.AssociateMarker("ALVARGroundArray.xml"); relativeTransforms = new List <Matrix>(); }
private void SetupCalibration() { if (useImageSequence) { captureDevice = new NullCapture(); } else { captureDevice = new DirectShowCapture(); } captureDevice.InitVideoCapture(0, FrameRate._30Hz, Resolution._640x480, ImageFormat.R8G8B8_24, false); if (useImageSequence) { imageNames = Directory.GetFiles(imageDirectory); if (imageNames != null && imageNames.Length > 0) { ((NullCapture)captureDevice).StaticImageFile = imageNames[0]; } else { MessageBox.Show("No images are found in " + imageDirectory + " for static image calibration"); this.Exit(); } } // Add this video capture device to the scene so that it can be used for // the marker tracker scene.AddVideoCaptureDevice(captureDevice); imagePtr = Marshal.AllocHGlobal(captureDevice.Width * captureDevice.Height * 3); scene.ShowCameraImage = true; // Initializes ALVAR camera ALVARDllBridge.alvar_init(); ALVARDllBridge.alvar_add_camera(null, captureDevice.Width, captureDevice.Height); }
private void SetupCalibration() { leftCaptureDevice = new DirectShowCapture2(); leftCaptureDevice.InitVideoCapture(leftDeviceID, FrameRate._30Hz, Resolution._640x480, ImageFormat.R8G8B8_24, false); // Add left video capture device to the scene for rendering left eye image scene.AddVideoCaptureDevice(leftCaptureDevice); rightCaptureDevice = new DirectShowCapture2(); rightCaptureDevice.InitVideoCapture(rightDeviceID, FrameRate._30Hz, Resolution._640x480, ImageFormat.R8G8B8_24, false); // Add right video capture device to the scene for rendering right eye image scene.AddVideoCaptureDevice(rightCaptureDevice); // Create holders for retrieving the captured video images leftImagePtr = Marshal.AllocHGlobal(leftCaptureDevice.Width * leftCaptureDevice.Height * 3); rightImagePtr = Marshal.AllocHGlobal(rightCaptureDevice.Width * rightCaptureDevice.Height * 3); // Associate each video devices to each eye scene.LeftEyeVideoID = 0; scene.RightEyeVideoID = 1; scene.ShowCameraImage = true; float markerSize = 32.4f; // Initialize a marker tracker for tracking an marker array used for calibration markerTracker = new ALVARMarkerTracker(); markerTracker.MaxMarkerError = 0.02f; markerTracker.ZNearPlane = 0.1f; markerTracker.ZFarPlane = 1000; markerTracker.InitTracker(leftCaptureDevice.Width, leftCaptureDevice.Height, LEFT_CALIB, markerSize); ((StereoCamera)scene.CameraNode.Camera).LeftProjection = markerTracker.CameraProjection; // Add another marker detector for tracking right video capture device ALVARDllBridge.alvar_add_marker_detector(markerSize, 5, 2); ALVARDllBridge.alvar_add_camera(RIGHT_CALIB, rightCaptureDevice.Width, rightCaptureDevice.Height); double[] projMat = new double[16]; double cameraFovX = 0, cameraFovY = 0; ALVARDllBridge.alvar_get_camera_params(1, projMat, ref cameraFovX, ref cameraFovY, 1000, 0.1f); ((StereoCamera)scene.CameraNode.Camera).RightProjection = new Matrix( (float)projMat[0], (float)projMat[1], (float)projMat[2], (float)projMat[3], (float)projMat[4], (float)projMat[5], (float)projMat[6], (float)projMat[7], (float)projMat[8], (float)projMat[9], (float)projMat[10], (float)projMat[11], (float)projMat[12], (float)projMat[13], (float)projMat[14], (float)projMat[15]); // Add a marker array to be tracked markerID = markerTracker.AssociateMarker("ALVARGroundArray.xml"); relativeTransforms = new List<Matrix>(); }