void Update() { LabeledDataUtil.Snapshot(agentCamera, cameraRenderTexture, readerTexture, trainingFilePath, captureFilePrefix, labelFileName, recordCategoryTags, nDirectionSensors, wallTag, counter, wallHitMultiplier: 0.4f, storeImages: storeImages); if (agentRandomControl != null) { FileUtils.AppendStringToFile(trainingFilePath + actionFileName, agentRandomControl.currentAction.ToString() + '\n'); } counter++; if (counter % 1000 == 0) { Debug.LogFormat("counter: {0}", counter); } // if (periodicResetter.HasBeenReset()) { // Debug.Log ("Reset!"); // } }
// Update is called once per frame void Update() { if (Time.time > nextRecordingTime) { nextRecordingTime += recordingPeriod; FileUtils.AppendStringToFile(progressFileName, Time.time + "," + rewardManager.GetRewardRate() + "\n"); } }
/** Render camera, save snapshot and label */ public static void Snapshot(Camera agentCamera, RenderTexture cameraRenderTexture, Texture2D readerTexture, string trainingFilePath, string captureFilePrefix, string labelFileName, string[] recordCategoryTags, int nDirectionSensors, string wallTag, int counter, float wallHitMultiplier, bool storeImages) { float[] sensorData = GetSensorInfo(agentCamera, recordCategoryTags, nDirectionSensors, wallTag, wallHitMultiplier); string labelVector = ""; foreach (float a in sensorData) { labelVector += a.ToString(); labelVector += ","; } //Debug.Log(labelVector); if (storeImages) { agentCamera.Render(); Color32[] currentImage = MiscUtils.getCurrentCameraImage(cameraRenderTexture, readerTexture); int downsampleFactor = 2; currentImage = MathUtils.downSampleImg(currentImage, downsampleFactor); Texture2D tex = new Texture2D(cameraRenderTexture.width / downsampleFactor, cameraRenderTexture.height / downsampleFactor); tex.SetPixels32(currentImage); FileUtils.SaveTextureToFile(tex, trainingFilePath + captureFilePrefix + counter.ToString("D6") + ".png"); } string trainingLine = labelVector + "\n"; FileUtils.AppendStringToFile(trainingFilePath + labelFileName, trainingLine); }