private void DeployData(NRTrackingImageDatabase database) { string deploy_path = database.TrackingImageDataOutPutPath; NRDebugger.Log("[TrackingImageDatabase] DeployData to path :" + deploy_path); ZipUtility.UnzipFile(database.RawData, deploy_path, NativeConstants.ZipKey); }
private void DeployData() { if (NRSessionBehaviour.SessionConfig == null) { return; } var database = NRSessionBehaviour.SessionConfig.TrackingImageDatabase; if (database == null) { NRDebugger.Log("augmented image data base is null!"); return; } string deploy_path = database.TrackingImageDataOutPutPath; NRDebugger.Log("[TrackingImageDatabase] DeployData to path :" + deploy_path); ZipUtility.UnzipFile(database.RawData, deploy_path, NativeConstants.ZipKey); }
/// @endcond /// @cond EXCLUDE_FROM_DOXYGEN /// <summary> /// Rebuilds the database asset, if needed. /// </summary> public void BuildIfNeeded() { if (!m_IsRawDataDirty) { return; } m_IsRawDataDirty = false; string directory = NRTools.GetTrackingImageDataGenPath() + GUID; if (!Directory.Exists(directory)) { ZipUtility.UnzipFile(RawData, NRTools.GetTrackingImageDataGenPath(), NativeConstants.ZipKey); } //Generate marker data by json file var result_json = TrackingImageDataPath + "markers.json"; if (File.Exists(result_json)) { var json_data = File.ReadAllText(result_json); StringBuilder str = new StringBuilder(); str.AppendLine("# Number of markers"); str.AppendLine(Count.ToString()); DirectoryInfo dir = new DirectoryInfo(directory); var fsinfos = dir.GetDirectories(); string dataPathName = "Data"; if (fsinfos != null && fsinfos.Length > 0) { Array.Sort(fsinfos, (dir1, dir2) => dir1.CreationTime.CompareTo(dir2.CreationTime)); dataPathName = fsinfos[0].Name; } for (int i = 0; i < Count; i++) { var image_info = JsonMapper.ToObject(json_data)[this[i].Name]; str.AppendLine(); str.AppendLine(string.Format("./{0}/{1}", dataPathName, this[i].Name)); str.AppendLine("NFT"); str.AppendLine(string.Format("FILTER {0}", image_info["filter"])); str.AppendLine(string.Format("MARKER_WIDTH {0}", image_info["physical_width"])); str.AppendLine(string.Format("MARKER_HEIGHT {0}", image_info["physical_height"])); } File.WriteAllText(TrackingImageDataPath + "markers.dat", str.ToString()); } string file_path = directory + "_zipFile"; // Generate zip file ZipUtility.Zip(new string[1] { directory }, file_path, NativeConstants.ZipKey, new ZipUtility.ZipCallback(_result => { m_IsRawDataDirty = _result ? false : true; if (!string.IsNullOrEmpty(file_path) && File.Exists(file_path)) { // Read the zip bytes m_RawData = File.ReadAllBytes(file_path); //Debug.Log("Generate raw data success!" + file_path); //m_IsNeedLoadRawData = false; EditorUtility.SetDirty(this); // Force a save to make certain build process will get updated asset. AssetDatabase.SaveAssets(); } })); UpdateClipVersion(); }