Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade vitrivr-VR Cineast API. #10

Merged
merged 1 commit into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public async void ToggleTagList()
var listContent = _tagList.content;

// TODO: Preload or cache for all results
var tagIds = await CineastWrapper.MetadataApi.FindTagsByIdAsync(Segment.Id);
var tagIds = await CineastWrapper.MetadataApi.FindTagInformationByIdAsync(Segment.Id);

var tags = await CineastWrapper.TagApi.FindTagsByIdAsync(new IdList(tagIds.TagIDs));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public async void ToggleTagList()

// TODO: Preload or cache for all results
var segment = await GetCurrentSegment(_videoPlayerController.ClockTime);
var tagIds = await CineastWrapper.MetadataApi.FindTagsByIdAsync(segment.Id);
var tagIds = await CineastWrapper.MetadataApi.FindTagInformationByIdAsync(segment.Id);

var tags = await CineastWrapper.TagApi.FindTagsByIdAsync(new IdList(tagIds.TagIDs));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public override (string attribute, RelationalOperator op, string[] values) GetTe
var options = selection
.Zip(_options, (use, option) => (use, option))
.Where(value => value.use)
.Select(value => value.option)
.Select(value => "\"" + value.option + "\"")
.ToArray();

return options.Length == 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ public class CanvasOptionSelection : CanvasBooleanTerm
private List<string> _options;

private bool _enabled;
private bool _numeric;

public void Initialize(string optionTitle, string entity, List<RelationalOperator> operators, List<string> options)
public void Initialize(string optionTitle, string entity, List<RelationalOperator> operators, List<string> options,
bool numeric)
{
_entity = entity;
_operators = operators;
_options = options;
// If numeric, do not add quotes around value for query term
_numeric = numeric;

optionName.text = optionTitle;
operatorDropdown.AddOptions(_operators.Select(op => op.ToString()).ToList());
Expand All @@ -32,7 +36,13 @@ public void Initialize(string optionTitle, string entity, List<RelationalOperato

public override (string attribute, RelationalOperator op, string[] values) GetTerm()
{
return (_entity, _operators[operatorDropdown.value], new[] { _options[valueDropdown.value] });
var value = _options[valueDropdown.value];
if (!_numeric)
{
value = "\"" + value + "\"";
}

return (_entity, _operators[operatorDropdown.value], new[] { value });
}

public override bool IsEnabled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,21 @@ private async void Start()
case BooleanTermTypes.DynamicOptions:
var dynamicOptions = Instantiate(optionSelection, transform);
var dynOpt = await CineastWrapper.GetDistinctTableValues(category.table, category.column);
var numeric = false;
if (category.options != null)
{
// TODO: Handle empty options array
dynOpt = SortOptions(dynOpt, category.options.First());
var sortOrder = category.options.First();
dynOpt = SortOptions(dynOpt, sortOrder);
numeric = Enum.TryParse<SortOrder>(sortOrder, out var order) && order == SortOrder.Numeric;
}

dynamicOptions.Initialize(category.name, entity,
new List<RelationalOperator>
{
RelationalOperator.Eq,
RelationalOperator.NEq
}, dynOpt);
}, dynOpt, numeric);
_termProviders.Add(dynamicOptions);
break;
default:
Expand Down
18 changes: 9 additions & 9 deletions Assets/Scripts/VitrivrVR/Submission/DresClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace VitrivrVR.Submission
{
public class DresClientManager : MonoBehaviour
{
public static DresClient instance;
public static DresClient Instance;

private static readonly List<QueryEvent> InteractionEvents = new List<QueryEvent>();
private static float _interactionEventTimer;
Expand All @@ -37,12 +37,12 @@ private async void Start()
(sender, certificate, chain, sslPolicyErrors) => true;
}

instance = new DresClient();
await instance.Login();
Instance = new DresClient();
await Instance.Login();
var logDir = ConfigManager.Config.logFileLocation;
var startTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
var username = instance.UserDetails.Username;
var session = instance.UserDetails.SessionId;
var username = Instance.UserDetails.Username;
var session = Instance.UserDetails.SessionId;
_interactionLogPath = Path.Combine(logDir, $"{startTime}_{username}_{session}_interaction.txt");
_resultsLogPath = Path.Combine(logDir, $"{startTime}_{username}_{session}_results.txt");
_submissionLogPath = Path.Combine(logDir, $"{startTime}_{username}_{session}_submission.txt");
Expand Down Expand Up @@ -80,7 +80,7 @@ public static async void SubmitResult(string mediaObjectId, int? frame = null)

try
{
var result = await instance.SubmitResult(mediaObjectId, frame);
var result = await Instance.SubmitResult(mediaObjectId, frame);
NotificationController.Notify($"Submission: {result.Submission}");
}
catch (Exception e)
Expand Down Expand Up @@ -165,7 +165,7 @@ public static async void LogResults(string sortType, List<ScoredSegment> results
return new QueryResult(objectId, sequenceNumber, frame, result.score, i);
}));

var queryEvents = query.Containers.First().Terms.Select(term =>
var queryEvents = query.Terms.Select(term =>
{
// Convert term type to Dres category
var category = term.Type switch
Expand Down Expand Up @@ -194,7 +194,7 @@ public static async void LogResults(string sortType, List<ScoredSegment> results
var queryEventsList = queryEvents.ToList();
try
{
var success = await instance.LogResults(timestamp, sortType, "top", queryResultsList, queryEventsList);
var success = await Instance.LogResults(timestamp, sortType, "top", queryResultsList, queryEventsList);

if (!success.Status)
{
Expand Down Expand Up @@ -232,7 +232,7 @@ private static async void LogInteraction()
// Submit to DRES
try
{
var success = await instance.LogQueryEvents(timestamp, InteractionEvents);
var success = await Instance.LogQueryEvents(timestamp, InteractionEvents);

if (!success.Status)
{
Expand Down
9 changes: 3 additions & 6 deletions Assets/Scripts/VitrivrVR/UI/QueryListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,9 @@ private void SelectQuery(int index)
private static string QueryToString(SimilarityQuery query)
{
var stringBuilder = new StringBuilder();
foreach (var component in query.Containers)
{
stringBuilder.Append("{");
stringBuilder.Append(string.Join(", ", component.Terms.Select(TermToString)));
stringBuilder.Append("}");
}
stringBuilder.Append("{");
stringBuilder.Append(string.Join(", ", query.Terms.Select(TermToString)));
stringBuilder.Append("}");

return stringBuilder.ToString();
}
Expand Down
2 changes: 1 addition & 1 deletion Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"com.unity.xr.management": "4.2.1",
"com.unity.xr.openxr": "1.3.1",
"deepspeech": "https://github.com/Spiess/deep-speech-upm.git",
"org.vitrivr.unityinterface.cineastapi": "https://github.com/vitrivr/CineastUnityInterface.git#v0.0.1",
"org.vitrivr.unityinterface.cineastapi": "https://github.com/vitrivr/CineastUnityInterface.git#v0.0.2",
"org.vitrivr.unityinterface.dresapi": "https://github.com/dres-dev/UnityClient.git#v1.0.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
Expand Down
6 changes: 3 additions & 3 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
}
},
"com.unity.xr.legacyinputhelpers": {
"version": "2.1.8",
"version": "2.1.9",
"depth": 1,
"source": "registry",
"dependencies": {
Expand Down Expand Up @@ -142,11 +142,11 @@
"hash": "b5c2335720146358ae35a3ca25807140da33713d"
},
"org.vitrivr.unityinterface.cineastapi": {
"version": "https://github.com/vitrivr/CineastUnityInterface.git#v0.0.1",
"version": "https://github.com/vitrivr/CineastUnityInterface.git#v0.0.2",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "a9ad36fa3c828830a1fe7e4c7afa0fb0757e0e54"
"hash": "a1ef472aa70f55ddb15a8b2701d965d046470ef7"
},
"org.vitrivr.unityinterface.dresapi": {
"version": "https://github.com/dres-dev/UnityClient.git#v1.0.0",
Expand Down
109 changes: 103 additions & 6 deletions ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
--- !u!129 &1
PlayerSettings:
m_ObjectHideFlags: 0
serializedVersion: 22
serializedVersion: 23
productGUID: 5b60c2f25b164401eb960119cf625050
AndroidProfiler: 0
AndroidFilterTouchesWhenObscured: 0
Expand Down Expand Up @@ -163,7 +163,7 @@ PlayerSettings:
tvOS: 0
overrideDefaultApplicationIdentifier: 0
AndroidBundleVersionCode: 1
AndroidMinSdkVersion: 19
AndroidMinSdkVersion: 22
AndroidTargetSdkVersion: 0
AndroidPreferredInstallLocation: 1
aotOptions:
Expand Down Expand Up @@ -219,6 +219,7 @@ PlayerSettings:
iOSLaunchScreeniPadCustomStoryboardPath:
iOSDeviceRequirements: []
iOSURLSchemes: []
macOSURLSchemes: []
iOSBackgroundModes: 0
iOSMetalForceHardShadows: 0
metalEditorSupport: 1
Expand Down Expand Up @@ -270,7 +271,99 @@ PlayerSettings:
AndroidValidateAppBundleSize: 1
AndroidAppBundleSizeToValidate: 150
m_BuildTargetIcons: []
m_BuildTargetPlatformIcons: []
m_BuildTargetPlatformIcons:
- m_BuildTarget: Android
m_Icons:
- m_Textures: []
m_Width: 432
m_Height: 432
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 324
m_Height: 324
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 216
m_Height: 216
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 162
m_Height: 162
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 108
m_Height: 108
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 81
m_Height: 81
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 192
m_Height: 192
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 144
m_Height: 144
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 96
m_Height: 96
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 72
m_Height: 72
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 48
m_Height: 48
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 36
m_Height: 36
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 192
m_Height: 192
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 144
m_Height: 144
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 96
m_Height: 96
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 72
m_Height: 72
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 48
m_Height: 48
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 36
m_Height: 36
m_Kind: 0
m_SubKind:
m_BuildTargetBatching:
- m_BuildTarget: Standalone
m_StaticBatching: 1
Expand Down Expand Up @@ -322,7 +415,7 @@ PlayerSettings:
m_BuildTargetGraphicsAPIs:
- m_BuildTarget: AndroidPlayer
m_APIs: 150000000b000000
m_Automatic: 0
m_Automatic: 1
- m_BuildTarget: iOSSupport
m_APIs: 10000000
m_Automatic: 1
Expand All @@ -348,6 +441,7 @@ PlayerSettings:
m_BuildTargetGroupLightmapEncodingQuality: []
m_BuildTargetGroupLightmapSettings: []
m_BuildTargetNormalMapEncoding: []
m_BuildTargetDefaultTextureCompressionFormat: []
playModeTestRunnerEnabled: 0
runPlayModeTestAsEditModeTest: 0
actionOnDotNetUnhandledException: 1
Expand All @@ -366,6 +460,7 @@ PlayerSettings:
switchScreenResolutionBehavior: 2
switchUseCPUProfiler: 0
switchUseGOLDLinker: 0
switchLTOSetting: 0
switchApplicationID: 0x01004b9000490000
switchNSODependencies:
switchTitleNames_0:
Expand Down Expand Up @@ -496,7 +591,9 @@ PlayerSettings:
switchPlayerConnectionEnabled: 1
switchUseNewStyleFilepaths: 0
switchUseMicroSleepForYield: 1
switchEnableRamDiskSupport: 0
switchMicroSleepForYieldTime: 25
switchRamDiskSpaceSize: 12
ps4NPAgeRating: 12
ps4NPTitleSecret:
ps4NPTrophyPackPath:
Expand Down Expand Up @@ -567,7 +664,6 @@ PlayerSettings:
ps4videoRecordingFeaturesUsed: 0
ps4contentSearchFeaturesUsed: 0
ps4CompatibilityPS5: 0
ps4AllowPS5Detection: 0
ps4GPU800MHz: 1
ps4attribEyeToEyeDistanceSettingVR: 0
ps4IncludedModules: []
Expand Down Expand Up @@ -602,7 +698,6 @@ PlayerSettings:
suppressCommonWarnings: 1
allowUnsafeCode: 0
useDeterministicCompilation: 1
useReferenceAssemblies: 1
enableRoslynAnalyzers: 1
additionalIl2CppArgs:
scriptingRuntimeVersion: 1
Expand Down Expand Up @@ -690,4 +785,6 @@ PlayerSettings:
organizationId:
cloudEnabled: 0
legacyClampBlendShapeWeights: 0
playerDataPath:
forceSRGBBlit: 1
virtualTexturingSupportEnabled: 0
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2021.2.11f1
m_EditorVersionWithRevision: 2021.2.11f1 (e50cafbb4399)
m_EditorVersion: 2021.2.17f1
m_EditorVersionWithRevision: 2021.2.17f1 (efb8f635e7b1)