private void Capture(int num) { string imageName = _camera.name + "_" + num; Dictionary <string, int> labelInstances = new Dictionary <string, int>(); // Call Screen Capture var screen = CaptureCamera.Capture(_camera, request => { string path = screenCapturePath + "/" + imageName + ".jpg"; // Convert the screen capture to a byte array Array image = CaptureImageEncoder.Encode(request.data.colorBuffer as Array, 640, 480, GraphicsFormat.R8G8B8A8_UNorm, CaptureImageEncoder.ImageFormat.Jpg, true); // Write the screen capture to a file var result = FileProducer.Write(path, image); // Wait for Async screen capture request to return and then log data point if (result) { labelInstances.Add("Cube", 100); labelInstances.Add("Sphere", 111); labelInstances.Add("Cylinder", 131); string temp = JsonConvert.SerializeObject(labelInstances); InstanceCount instanceCount = new InstanceCount(imageName, temp); // Log data point to file dataLogger.Log(instanceCount); return(AsyncRequest.Result.Completed); } return(AsyncRequest.Result.Error); }); }
private void Capture(int num) { string imageName = _camera.name + "_" + num; // Define Data point object outside async call DataPoint dataPoint = new DataPoint(_cube.name, _cube.transform.rotation, simElapsed, imageName); // Call Screen Capture var screen = CaptureCamera.Capture(_camera, request => { string path = screenCapturePath + "/" + imageName + ".jpg"; // Convert the screen capture to a byte array Array image = CaptureImageEncoder.Encode(request.data.colorBuffer as Array, 640, 480, GraphicsFormat.R8G8B8A8_UNorm, CaptureImageEncoder.ImageFormat.Jpg, true); // Write the screen capture to a file var result = DXFile.Write(path, image); // Wait for Async screen capture request to return and then log data point if (result) { // Log data point to file dataLogger.Log(dataPoint); return(AsyncRequest.Result.Completed); } return(AsyncRequest.Result.Error); }); }