public void OnInitialized() { if (QCARRuntimeUtilities.IsQCAREnabled()) { foreach (string str in this.mDataSetsToLoad) { if (!DataSet.Exists(str)) { Debug.LogError("Data set " + str + " does not exist."); } else { ImageTracker tracker = TrackerManager.Instance.GetTracker <ImageTracker>(); DataSet dataSet = tracker.CreateDataSet(); if (!dataSet.Load(str)) { Debug.LogError("Failed to load data set " + str + "."); } else if (this.mDataSetsToActivate.Contains(str)) { tracker.ActivateDataSet(dataSet); } } } } }
void Awake() { if (!QCARRuntimeUtilities.IsQCAREnabled()) { return; } if (QCARRuntimeUtilities.IsPlayMode()) { // initialize QCAR QCARUnity.CheckInitializationError(); } if (TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER) == null) { TrackerManager.Instance.InitTracker(Tracker.Type.IMAGE_TRACKER); } if (mDataSetsToLoad.Count <= 0) { Debug.LogWarning("No data sets defined. Not loading any data sets."); return; } foreach (string dataSetName in mDataSetsToLoad) { if (!DataSet.Exists(dataSetName)) { Debug.LogError("Data set " + dataSetName + " does not exist."); continue; } ImageTracker imageTracker = (ImageTracker)TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER); DataSet dataSet = imageTracker.CreateDataSet(); if (!dataSet.Load(dataSetName)) { Debug.LogError("Failed to load data set " + dataSetName + "."); continue; } // Activate the data set if it is the one specified in the editor. if (mDataSetsToActivate.Contains(dataSetName)) { imageTracker.ActivateDataSet(dataSet); } } }
private void SwitchDatabase(string[] dataSetsToBeActivated) { if (Input.GetKeyDown(KeyCode.D)) { IEnumerable <DataSet> activeDataSets = objectTracker.GetActiveDataSets(); List <DataSet> activeDataSetsToBeRemoved = new List <DataSet>(); activeDataSetsToBeRemoved.AddRange(activeDataSets); foreach (DataSet set in activeDataSetsToBeRemoved) { objectTracker.DeactivateDataSet(set); } objectTracker.Stop(); DataSet dataSet = objectTracker.CreateDataSet(); if (DataSet.Exists(dataSetNames[dataSetCounter])) { dataSet.Load(dataSetNames[dataSetCounter]); objectTracker.ActivateDataSet(dataSet); if (dataSetCounter == dataSetNames.Length - 1) { dataSetCounter = 0; } else { dataSetCounter++; } } IEnumerable <TrackableBehaviour> trackableBehaviours = TrackerManager.Instance.GetStateManager().GetTrackableBehaviours(); foreach (TrackableBehaviour tb in trackableBehaviours) { if (tb is ModelTargetBehaviour && tb.isActiveAndEnabled) { Debug.Log("TrackableName: " + tb.TrackableName); (tb as ModelTargetBehaviour).GuideViewMode = ModelTargetBehaviour.GuideViewDisplayMode.GuideView2D; mModelTarget = tb.GetComponent <ModelTargetBehaviour>(); } } objectTracker.Start(); } }
private void LoadeDatabase(string setName) { ObjectTracker objectTracker = TrackerManager.Instance.GetTracker <objectTracker>(); objectTracker.Stop(); if (DataSet.Exists(setName)) { DataSet dataSet = objectTracker.CreateDataSet(); dataSet.Load(setName); objectTracker.ActivateDataSet(dataSet); } objectTracker.Start(); }
void Awake() { if (Application.isEditor) { return; } if (TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER) == null) { TrackerManager.Instance.InitTracker(Tracker.Type.IMAGE_TRACKER); } if (mDataSetsToLoad.Count <= 0) { Debug.LogWarning("No data sets defined. Not loading any data sets."); return; } foreach (string dataSetName in mDataSetsToLoad) { if (!DataSet.Exists(dataSetName)) { Debug.LogError("Data set " + dataSetName + " does not exist."); continue; } ImageTracker imageTracker = (ImageTracker)TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER); DataSet dataSet = imageTracker.CreateDataSet(); if (!dataSet.Load(dataSetName)) { Debug.LogError("Failed to load data set " + dataSetName + "."); continue; } // Activate the data set if it is the one specified in the editor. if (mDataSetToActivate == dataSetName) { imageTracker.ActivateDataSet(dataSet); } } }
void LoadDataSet(string datasetName) { if (DataSet.Exists(datasetName)) { DataSet dataset = this.objectTracker.CreateDataSet(); if (dataset.Load(datasetName)) { VLog.Log("yellow", "Loaded DataSet: " + datasetName); } else { Debug.LogError("Failed to load DataSet: " + datasetName); } } else { VLog.Log("yellow", "The following DataSet not found in 'StreamingAssets/Vuforia': " + datasetName); } }
//This function will load and activate the designated dataset. It will not de-activate //anything, so be sure no other Model Target datasets are active to avoid issues. public void ActivateTarget(string loadThisDataset) { TrackerManager trackerManager = (TrackerManager)TrackerManager.Instance; ObjectTracker objectTracker = TrackerManager.Instance.GetTracker <ObjectTracker>(); //Stop the tracker. objectTracker.Stop(); //Create a new dataset object. DataSet dataset = objectTracker.CreateDataSet(); //Load and activate the dataset if it exists. if (DataSet.Exists(loadThisDataset)) { dataset.Load(loadThisDataset); objectTracker.ActivateDataSet(dataset); } //Start the object tracker. objectTracker.Start(); }
/// <summary> /// 从外部路径加载dataset /// </summary> /// <param name="absolutePath"></param> public static void LoadDataSetFromPath(string absolutePath) { ObjectTracker objectTracker = TrackerManager.Instance.GetTracker <ObjectTracker>(); if (!DataSet.Exists(absolutePath, VuforiaUnity.StorageType.STORAGE_ABSOLUTE)) { AFLogger.d("load dataset Exists null:" + absolutePath); return; } else { objectTracker.Stop(); DataSet dataSet = objectTracker.CreateDataSet(); if (dataSet.Load(absolutePath, VuforiaUnity.StorageType.STORAGE_ABSOLUTE)) { //这里必须要停止跟踪才能激活DataSet objectTracker.ActivateDataSet(dataSet); } objectTracker.Start(); } }
public void LoadAndActivateDataset() { Debug.Log("activate database"); TrackerManager trackerManager = (TrackerManager)TrackerManager.Instance; ObjectTracker objectTracker = TrackerManager.Instance.GetTracker <ObjectTracker>(); //Stop the tracker. objectTracker.Stop(); //Create a new dataset object. DataSet dataset = objectTracker.CreateDataSet(); //Load and activate the dataset if it exists. if (DataSet.Exists("AkuuExpo")) { dataset.Load("AkuuExpo"); objectTracker.ActivateDataSet(dataset); } //Start the object tracker. objectTracker.Start(); }
// Load and activate a data set at the given path. private bool LoadDataSet(string dataSetPath, VuforiaUnity.StorageType storageType) { // Request an ImageTracker instance from the TrackerManager. ObjectTracker objectTracker = TrackerManager.Instance.GetTracker <ObjectTracker>(); objectTracker.Stop(); IEnumerable <DataSet> dataSetList = objectTracker.GetActiveDataSets(); foreach (DataSet set in dataSetList.ToList()) { objectTracker.DeactivateDataSet(set); } // Check if the data set exists at the given path. if (!DataSet.Exists(dataSetPath, storageType)) { Debug.LogError("Data set " + dataSetPath + " does not exist."); return(false); } // Create a new empty data set. DataSet dataSet = objectTracker.CreateDataSet(); // Load the data set from the given path. if (!dataSet.Load(dataSetPath, storageType)) { Debug.LogError("Failed to load data set " + dataSetPath + "."); return(false); } // (Optional) Activate the data set. objectTracker.ActivateDataSet(dataSet); objectTracker.Start(); AttachContentToTrackables(dataSet); return(true); }
IEnumerator Starter() { if (GameObject.Find("ObjLoaderHolder") == null) { var g = GameObject.Instantiate(Resources.Load("ObjLoaderHolder")); g.name = "ObjLoaderHolder"; } //////////////////////////////////////////////////////////////////////////////// // Load data set //////////////////////////////////////////////////////////////////////////////// int count = 0; while (!QCARRuntimeUtilities.IsQCAREnabled()) { yield return(new WaitForSeconds(0.5f)); count++; if (count > 10) { Debug.LogError("Timeout exception of waying QCARRuntimeUtilities.IsQCAREnabled"); yield break; } } Debug.Log("DataSetLoadBehaviour: IsQCAREnabled == true"); var path = Configuration.ConfigMaganer.Instance.Application.XmlPath; if (!path.StartsWith("/")) { path = System.IO.Path.Combine(Application.persistentDataPath, path); } if (QCARRuntimeUtilities.IsPlayMode()) { // initialize QCAR QCARUnity.CheckInitializationError(); } if (TrackerManager.Instance.GetTracker <ImageTracker>() == null) { TrackerManager.Instance.InitTracker <ImageTracker>(); } if (!DataSet.Exists(path, DataSet.StorageType.STORAGE_ABSOLUTE)) { Debug.LogError("Data set " + path + " does not exist."); Application.Quit(); } ImageTracker imageTracker = (ImageTracker)TrackerManager.Instance.GetTracker <ImageTracker>(); DataSet dataSet = imageTracker.CreateDataSet(); if (!dataSet.Load(path, DataSet.StorageType.STORAGE_ABSOLUTE)) { Debug.LogError("Failed to load data set " + path + "."); Application.Quit(); } imageTracker.ActivateDataSet(dataSet); Debug.Log("Dataset activated: " + path); //////////////////////////////////////////////////////////////////////////////// while (!QCARManager.Instance.Initialized) { yield return(new WaitForEndOfFrame()); } //////////////////////////////////////////////////////////////////////////////// QCARRenderer.Instance.DrawVideoBackground = Configuration.ConfigMaganer.Instance.Application.Debug; //////////////////////////////////////////////////////////////////////////////// if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_INFINITY)) { Debug.Log("Camera focus mode setted to FOCUS_MODE_INFINITY"); } else { Debug.Log("Camera can't focus to FOCUS_MODE_INFINITY"); } var markersLister = Camera.main.GetComponent <MarkersLister>(); DataSetTrackableBehaviour[] trackableBehaviours = (DataSetTrackableBehaviour[])GameObject.FindObjectsOfType(typeof(DataSetTrackableBehaviour)); var selectionObjectOriginal = (GameObject)Resources.Load("SelectionObject"); foreach (DataSetTrackableBehaviour trackableBehaviour in trackableBehaviours) { IEditorDataSetTrackableBehaviour editorTrackableBehaviour = trackableBehaviour; if (editorTrackableBehaviour.gameObject.transform.childCount == 0) { editorTrackableBehaviour.gameObject.name = "Marker[" + editorTrackableBehaviour.TrackableName + "]"; editorTrackableBehaviour.gameObject.AddComponent <TurnOffBehaviour>(); var markerName = editorTrackableBehaviour.TrackableName; var trackableEvent = editorTrackableBehaviour.gameObject.AddComponent <TrackableEventHandler>(); if (Configuration.ConfigMaganer.Instance.Application.Debug) { var obj = (GameObject)GameObject.Instantiate(selectionObjectOriginal); obj.transform.parent = editorTrackableBehaviour.gameObject.transform; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; } markersLister.AddMarker(markerName, trackableEvent); } } }
protected override void Execute() { try { WriteHtmlInformation("<br />"); WriteInformation(string.Format("Reading reference media file from {0}", DCMCompareForm.firstDCMFile)); WriteHtmlInformation("<br />"); // Read the DCM File DicomFile dcmFile = new DicomFile(); DataSet refDataset = new DataSet(); if ((DCMCompareForm.firstDCMFile.ToLower().IndexOf("dicomdir")) != -1) { // Read the DICOMDIR dataset refDataset.DvtkDataDataSet = Dvtk.DvtkDataHelper.ReadDataSetFromFile(DCMCompareForm.firstDCMFile); } else { dcmFile.Read(DCMCompareForm.firstDCMFile, this); refDataset = dcmFile.DataSet; } refDataset.UnVrDefinitionLookUpWhenReading = false; FileMetaInformation refFMI = dcmFile.FileMetaInformation; WriteInformation(string.Format("Reading source media file from {0}", DCMCompareForm.secondDCMFile)); WriteHtmlInformation("<br />"); DataSet srcDataset = new DataSet(); if ((DCMCompareForm.secondDCMFile.ToLower().IndexOf("dicomdir")) != -1) { // Read the DICOMDIR dataset srcDataset.DvtkDataDataSet = Dvtk.DvtkDataHelper.ReadDataSetFromFile(DCMCompareForm.secondDCMFile); } else { dcmFile.Read(DCMCompareForm.secondDCMFile, this); srcDataset = dcmFile.DataSet; } srcDataset.UnVrDefinitionLookUpWhenReading = false; FileMetaInformation srcFMI = dcmFile.FileMetaInformation; // Now get the list of filtered attribute if (DCMCompareForm.attributesTagList.Count != 0) { foreach (string filterAttr in DCMCompareForm.attributesTagList) { try { if (srcDataset.Exists(filterAttr)) { srcDataset.Delete(filterAttr); } if (refDataset.Exists(filterAttr)) { refDataset.Delete(filterAttr); } } catch (Exception exception) { MessageBox.Show(exception.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } DCMCompareForm.attributesTagList.Clear(); } WriteInformation(string.Format("Comparing the Media files - {0} and {1}", DCMCompareForm.firstDCMFile, DCMCompareForm.secondDCMFile)); WriteHtmlInformation("<br />"); StaticDicomCompare staticDicomCompare = new StaticDicomCompare(); //Determine the VR display based on Transfer syntax string srcTransferSyntax = ""; string refTransferSyntax = ""; if ((srcFMI != null) && srcFMI.Exists("0x00020010")) { // Get the Transfer syntax DvtkHighLevelInterface.Dicom.Other.Attribute tranferSyntaxAttr = srcFMI["0x00020010"]; srcTransferSyntax = tranferSyntaxAttr.Values[0]; } else { WriteHtmlInformation(string.Format("Couldn't retrieve the Transfer syntax from DCM File {0}", DCMCompareForm.secondDCMFile)); WriteHtmlInformation("<br />"); } if ((refFMI != null) && refFMI.Exists("0x00020010")) { // Get the Transfer syntax DvtkHighLevelInterface.Dicom.Other.Attribute tranferSyntaxAttr = refFMI["0x00020010"]; refTransferSyntax = tranferSyntaxAttr.Values[0]; } else { WriteHtmlInformation(string.Format("Couldn't retrieve the Transfer syntax from DCM File {0}", DCMCompareForm.firstDCMFile)); WriteHtmlInformation("<br />"); } FlagsDicomAttribute flags = FlagsDicomAttribute.Compare_values | FlagsDicomAttribute.Compare_present | FlagsDicomAttribute.Include_sequence_items; if ((srcTransferSyntax == "1.2.840.10008.1.2") || (refTransferSyntax == "1.2.840.10008.1.2")) { staticDicomCompare.DisplayAttributeVR = false; } else { flags |= FlagsDicomAttribute.Compare_VR; } //Check for group length attributes option if (DCMCompareForm.filterGroupLengthAttributes) { /*for( int i=0; i < srcDataset.Count; i++ ) * { * HLI.Attribute attribute = srcDataset[i]; * if(attribute.ElementNumber == 0x0000) * srcDataset.Delete(DCMCompareForm.TagString(attribute.GroupNumber,attribute.ElementNumber)); * } * * for( int i=0; i < refDataset.Count; i++ ) * { * HLI.Attribute attribute = refDataset[i]; * if(attribute.ElementNumber == 0x0000) * refDataset.Delete(DCMCompareForm.TagString(attribute.GroupNumber,attribute.ElementNumber)); * }*/ staticDicomCompare.DisplayGroupLength = false; } int differences = 0; if ((refFMI != null) && (srcFMI != null)) { AttributeCollections fmis = new AttributeCollections(); fmis.Add(refFMI); fmis.Add(srcFMI); StringCollection fmiDescriptions = new StringCollection(); fmiDescriptions.Add("Ref FMI"); fmiDescriptions.Add("Src FMI"); HLIStaticCompare.CompareResults fmiCompareResults = staticDicomCompare.CompareAttributeSets("FMI compare results", fmis, fmiDescriptions, flags); WriteHtmlInformation(fmiCompareResults.Table.ConvertToHtml()); differences += fmiCompareResults.DifferencesCount; NrOfValidationErrors += (uint)fmiCompareResults.DifferencesCount; } AttributeCollections datasets = new AttributeCollections(); datasets.Add(refDataset); datasets.Add(srcDataset); StringCollection dsDescriptions = new StringCollection(); dsDescriptions.Add("Ref Dataset"); dsDescriptions.Add("Src Dataset"); HLIStaticCompare.CompareResults dsCompareResults = staticDicomCompare.CompareAttributeSets("DataSet compare results", datasets, dsDescriptions, flags); WriteHtmlInformation(dsCompareResults.Table.ConvertToHtml()); differences += dsCompareResults.DifferencesCount; WriteHtmlInformation("<b>"); WriteInformation("Differences found: " + differences.ToString()); WriteHtmlInformation("</b><br />"); NrOfValidationErrors += (uint)dsCompareResults.DifferencesCount; } catch (Exception exception) { MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
// // - Methods - // public override bool Evaluate(DataSet dataSet) { return (dataSet.Exists(this.tagSequence)); }
protected override void Execute() { try { WriteHtmlInformation("<br />"); WriteInformation(string.Format("Reading reference media file from {0}",DCMCompareForm.firstDCMFile)); WriteHtmlInformation("<br />"); // Read the DCM File DicomFile dcmFile = new DicomFile(); DataSet refDataset = new DataSet(); if ((DCMCompareForm.firstDCMFile.ToLower().IndexOf("dicomdir")) != -1) { // Read the DICOMDIR dataset refDataset.DvtkDataDataSet = Dvtk.DvtkDataHelper.ReadDataSetFromFile(DCMCompareForm.firstDCMFile); } else { dcmFile.Read(DCMCompareForm.firstDCMFile, this); refDataset = dcmFile.DataSet; } refDataset.UnVrDefinitionLookUpWhenReading = false; FileMetaInformation refFMI = dcmFile.FileMetaInformation; WriteInformation(string.Format("Reading source media file from {0}",DCMCompareForm.secondDCMFile)); WriteHtmlInformation("<br />"); DataSet srcDataset = new DataSet(); if ((DCMCompareForm.secondDCMFile.ToLower().IndexOf("dicomdir")) != -1) { // Read the DICOMDIR dataset srcDataset.DvtkDataDataSet = Dvtk.DvtkDataHelper.ReadDataSetFromFile(DCMCompareForm.secondDCMFile); } else { dcmFile.Read(DCMCompareForm.secondDCMFile, this); srcDataset = dcmFile.DataSet; } srcDataset.UnVrDefinitionLookUpWhenReading = false; FileMetaInformation srcFMI = dcmFile.FileMetaInformation; // Now get the list of filtered attribute if(DCMCompareForm.attributesTagList.Count != 0) { foreach(string filterAttr in DCMCompareForm.attributesTagList) { try { if(srcDataset.Exists(filterAttr)) { srcDataset.Delete(filterAttr); } if(refDataset.Exists(filterAttr)) { refDataset.Delete(filterAttr); } } catch(Exception exception) { MessageBox.Show(exception.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } DCMCompareForm.attributesTagList.Clear(); } WriteInformation(string.Format("Comparing the Media files - {0} and {1}",DCMCompareForm.firstDCMFile,DCMCompareForm.secondDCMFile)); WriteHtmlInformation("<br />"); StaticDicomCompare staticDicomCompare = new StaticDicomCompare(); //Determine the VR display based on Transfer syntax string srcTransferSyntax = ""; string refTransferSyntax = ""; if((srcFMI != null) && srcFMI.Exists("0x00020010")) { // Get the Transfer syntax DvtkHighLevelInterface.Dicom.Other.Attribute tranferSyntaxAttr = srcFMI["0x00020010"]; srcTransferSyntax = tranferSyntaxAttr.Values[0]; } else { WriteHtmlInformation(string.Format("Couldn't retrieve the Transfer syntax from DCM File {0}",DCMCompareForm.secondDCMFile)); WriteHtmlInformation("<br />"); } if((refFMI != null) && refFMI.Exists("0x00020010")) { // Get the Transfer syntax DvtkHighLevelInterface.Dicom.Other.Attribute tranferSyntaxAttr = refFMI["0x00020010"]; refTransferSyntax = tranferSyntaxAttr.Values[0]; } else { WriteHtmlInformation(string.Format("Couldn't retrieve the Transfer syntax from DCM File {0}",DCMCompareForm.firstDCMFile)); WriteHtmlInformation("<br />"); } FlagsDicomAttribute flags = FlagsDicomAttribute.Compare_values | FlagsDicomAttribute.Compare_present | FlagsDicomAttribute.Include_sequence_items; if(( srcTransferSyntax == "1.2.840.10008.1.2") || ( refTransferSyntax == "1.2.840.10008.1.2")) { staticDicomCompare.DisplayAttributeVR = false; } else { flags |= FlagsDicomAttribute.Compare_VR; } //Check for group length attributes option if(DCMCompareForm.filterGroupLengthAttributes) { /*for( int i=0; i < srcDataset.Count; i++ ) { HLI.Attribute attribute = srcDataset[i]; if(attribute.ElementNumber == 0x0000) srcDataset.Delete(DCMCompareForm.TagString(attribute.GroupNumber,attribute.ElementNumber)); } for( int i=0; i < refDataset.Count; i++ ) { HLI.Attribute attribute = refDataset[i]; if(attribute.ElementNumber == 0x0000) refDataset.Delete(DCMCompareForm.TagString(attribute.GroupNumber,attribute.ElementNumber)); }*/ staticDicomCompare.DisplayGroupLength = false; } int differences = 0; if((refFMI != null) && (srcFMI != null)) { AttributeCollections fmis = new AttributeCollections(); fmis.Add(refFMI); fmis.Add(srcFMI); StringCollection fmiDescriptions = new StringCollection(); fmiDescriptions.Add("Ref FMI"); fmiDescriptions.Add("Src FMI"); HLIStaticCompare.CompareResults fmiCompareResults = staticDicomCompare.CompareAttributeSets("FMI compare results", fmis, fmiDescriptions, flags); WriteHtmlInformation(fmiCompareResults.Table.ConvertToHtml()); differences += fmiCompareResults.DifferencesCount; NrOfValidationErrors+= (uint)fmiCompareResults.DifferencesCount; } AttributeCollections datasets = new AttributeCollections(); datasets.Add(refDataset); datasets.Add(srcDataset); StringCollection dsDescriptions = new StringCollection(); dsDescriptions.Add("Ref Dataset"); dsDescriptions.Add("Src Dataset"); HLIStaticCompare.CompareResults dsCompareResults = staticDicomCompare.CompareAttributeSets("DataSet compare results", datasets, dsDescriptions, flags); WriteHtmlInformation(dsCompareResults.Table.ConvertToHtml()); differences += dsCompareResults.DifferencesCount; WriteHtmlInformation("<b>"); WriteInformation("Differences found: " + differences.ToString()); WriteHtmlInformation("</b><br />"); NrOfValidationErrors+= (uint)dsCompareResults.DifferencesCount; } catch(Exception exception) { MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }