public void BeginCapture(CaptureHeadbox headbox, string capture_dir, int max_frames, CaptureStatus status_interface, string to_prepend = "") { start_time_ = Time.realtimeSinceStartup; headbox_ = headbox; dynamic_range_ = headbox_.dynamic_range_; samples_per_face_ = (int)headbox_.samples_per_face_; capture_dir_ = capture_dir; capture_frame_ = 0; status_interface_ = status_interface; max_frames_ = max_frames; status_interface_.SendProgress(to_prepend + "Capturing Images...", 0.0f); List <Vector3> samples = new List <Vector3>(); // Use Hammersly point set to distribute samples. for (int position_sample_index = 0; position_sample_index < samples_per_face_; ++position_sample_index) { Vector3 headbox_position = new Vector3( (float)position_sample_index / (float)(samples_per_face_ - 1), RadicalInverse((ulong)position_sample_index, 2), RadicalInverse((ulong)position_sample_index, 3)); headbox_position.Scale(headbox.size_); headbox_position -= headbox.size_ * 0.5f; // Headbox samples are in camera space; transform to world space. headbox_position = headbox.transform.TransformPoint(headbox_position); samples.Add(headbox_position); } // Sort samples by distance from center of the headbox. samples.Sort(delegate(Vector3 a, Vector3 b) { float length_a = a.sqrMagnitude; float length_b = b.sqrMagnitude; return(length_a.CompareTo(length_b)); }); // Replace the sample closest to the center of the headbox with a sample at // exactly the center. This is important because Seurat requires // sampling information at the center of the headbox. samples[0] = headbox.transform.position; samples_ = samples; // Note this uses a modified version of Unity's standard internal depth // capture shader. See the shader in Assets/builtin_shaders/ // DefaultResourcesExtra/Internal-DepthNormalsTexture.shader. render_depth_shader_ = Shader.Find("GoogleVR/Seurat/CaptureEyeDepth"); capture_manifest_ = new JsonManifest.Capture(); // Setup cameras color_camera_ = headbox_.ColorCamera; depth_camera_object_ = new GameObject("Depth Camera"); depth_camera_ = depth_camera_object_.AddComponent <Camera>(); }
public void EndCapture() { if (capture_manifest_ != null) { string json_data = JsonUtility.ToJson(capture_manifest_, true); File.WriteAllText(PathCombine(export_path_, "manifest.json"), json_data); capture_manifest_ = null; GameObject.DestroyImmediate(depth_camera_object_); color_camera_ = null; Debug.Log("Total Capture time: " + (Time.realtimeSinceStartup - start_time_ + " seconds.")); DestroyRenderTargets(); } }