Skip to content

Commit

Permalink
Down sample depth map if buf > window (#31)
Browse files Browse the repository at this point in the history
* Add files via upload

Mods to allow toggling notifications and enable/disable invocation of VAutodrive in case user wants to use other software to drive while capturing data e.g. DeepGTAV

* Revert "Add files via upload"

This reverts commit 6e58036.

* Conditionally resample depth to fit GTAV window

Resamples (down samples) the depth and stencil maps to the same size as the GTAV window image capture if the depth map has larger dimensions than the GTAV window resolution.

* Moved scaled x and y declarations/definitions outside of sample loops.

Moved scaled x and y declarations/definitions outside of sample loops to improve code efficiency.

* Moved scaled values back into context.

scaledX and Y needed to have for loop context.

* Revert "Add files via upload"

This reverts commit 6e58036.

* Z key toggles notifications

Mod to toggle notifications using the Z key. Gets rid of notifications during capture.

* Added call to get screen size

Added call to get screen size
  • Loading branch information
IanKirwan authored and barcharcraz committed May 23, 2018
1 parent d6f8be9 commit 717be0d
Show file tree
Hide file tree
Showing 5 changed files with 282 additions and 45 deletions.
200 changes: 200 additions & 0 deletions database_schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
create type detection_type AS ENUM ('background', 'person', 'car', 'bicycle');

create type detection_class AS ENUM ('Unknown', 'Compacts', 'Sedans', 'SUVs', 'Coupes', 'Muscle', 'SportsClassics', 'Sports', 'Super', 'Motorcycles', 'OffRoad', 'Industrial', 'Utility', 'Vans', 'Cycles', 'Boats', 'Helicopters', 'Planes', 'Service', 'Emergency', 'Military', 'Commercial', 'Trains');

create type weather AS ENUM ('Unknown', 'ExtraSunny', 'Clear', 'Clouds', 'Smog', 'Foggy', 'Overcast', 'Raining', 'ThunderStorm', 'Clearing', 'Neutral', 'Snowing', 'Blizzard', 'Snowlight', 'Christmas', 'Halloween');

create table detections
(
detection_id serial not null
constraint detections_pkey
primary key,
snapshot_id integer,
type detection_type,
pos geometry(PointZ),
bbox box,
class detection_class default 'Unknown'::detection_class,
handle integer default '-1'::integer,
best_bbox box,
best_bbox_old box,
bbox3d box3d,
rot geometry,
coverage real default 0.0,
created timestamp without time zone default (now() at time zone 'utc')
)
;


create table runs
(
run_id serial not null
constraint runs_pkey
primary key,
runguid uuid,
archivepath text,
localpath text,
session_id integer default 1,
instance_id integer default 0,
created timestamp without time zone default (now() at time zone 'utc')
)
;


create table sessions
(
session_id serial not null
constraint sessions_pkey
primary key,
name text
constraint sessions_name_key
unique,
start timestamp with time zone,
"end" timestamp with time zone,
created timestamp without time zone default (now() at time zone 'utc')
)
;

alter table runs
add constraint runs_session_fkey
foreign key (session_id) references sessions
on delete cascade
;

create table snapshots
(
snapshot_id serial not null
constraint snapshots_pkey
primary key,
run_id integer
constraint snapshots_run_fkey
references runs
on delete cascade,
version integer,
imagepath text,
timestamp timestamp with time zone,
timeofday time,
currentweather weather,
camera_pos geometry(PointZ),
camera_direction geometry,
camera_fov real,
view_matrix double precision[],
proj_matrix double precision[],
processed boolean default false not null,
width integer,
height integer
)
;


alter table detections
add constraint detections_snapshot_fkey
foreign key (snapshot_id) references snapshots
on delete cascade
;

create table instances
(
instance_id serial not null
constraint isntances_pkey
primary key,
hostname text,
instanceid text
constraint instanceid_uniq
unique,
instancetype text,
publichostname text,
amiid text,
created timestamp without time zone default (now() at time zone 'utc'),
constraint instance_info_uniq
unique (hostname, instanceid, instancetype, publichostname, amiid)
)
;

alter table runs
add constraint runs_instance_fkey
foreign key (instance_id) references instances
;

create table snapshot_weathers
(
weather_id serial not null
constraint snapshot_weathers_pkey
primary key,
snapshot_id integer
constraint snapshot_weathers_snapshot_id_fkey
references snapshots
on delete cascade,
weather_type weather,
snapshot_page integer,
created timestamp without time zone default (now() at time zone 'utc')
)
;

create table uploads
(
id serial not null
constraint uploads_pkey
primary key,
bucket text,
key text,
uploadid text,
created timestamp without time zone default (now() at time zone 'utc')
)
;

create table datasets
(
dataset_id serial not null
constraint datasets_pkey
primary key,
dataset_name text,
view_name text,
created timestamp without time zone default (now() at time zone 'utc')
)
;

create table systems
(
system_uuid uuid not null
constraint systems_pkey
primary key,
vendor text,
dnshostname text,
username text,
systemtype text,
totalmem bigint,
created timestamp without time zone default (now() at time zone 'utc')
)
;

create table system_graphics
(
system_graphic_id serial not null
constraint system_graphics_pkey
primary key,
deviceid text,
adaptercompatibility text,
adapterdactype text,
adapterram integer,
availability integer,
caption text,
description text,
driverdate timestamp with time zone,
driverversion text,
pnpdeviceid text,
name text,
videoarch integer,
memtype integer,
videoprocessor text,
bpp integer,
hrez integer,
vrez integer,
num_colors integer,
cols integer,
rows integer,
refresh integer,
scanmode integer,
videomodedesc text,
created timestamp without time zone default (now() at time zone 'utc')
)
;
14 changes: 5 additions & 9 deletions managed/GTAVisionExport/GTAVisionExport.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,16 @@
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.1.1.0\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="NativeUI, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>G:\games\SteamLibrary\steamapps\common\Grand Theft Auto V\scripts\NativeUI.dll</HintPath>
<Reference Include="NativeUI">
<HintPath>C:\Program Files\Rockstar Games\Grand Theft Auto V\Scripts\NativeUI.dll</HintPath>
</Reference>
<Reference Include="Npgsql, Version=3.2.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL">
<HintPath>..\packages\Npgsql.3.2.1\lib\net451\Npgsql.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="ScriptHookVDotNet2">
<HintPath>..\..\..\..\..\Program Files (x86)\SteamLibrary\steamapps\common\Grand Theft Auto V\ScriptHookVDotNet2.dll</HintPath>
</Reference>
<Reference Include="ScriptHookVDotNet2, Version=2.10.3.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\Program Files (x86)\SteamLibrary\steamapps\common\Grand Theft Auto V\ScriptHookVDotNet2.dll</HintPath>
<HintPath>C:\Program Files\Rockstar Games\Grand Theft Auto V\ScriptHookVDotNet2.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
Expand All @@ -113,10 +109,10 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="VAutodrive">
<HintPath>G:\games\SteamLibrary\steamapps\common\Grand Theft Auto V\scripts\VAutodrive.dll</HintPath>
<HintPath>C:\Program Files\Rockstar Games\Grand Theft Auto V\Scripts\VAutodrive.dll</HintPath>
</Reference>
<Reference Include="VCommonFunctions">
<HintPath>G:\games\SteamLibrary\steamapps\common\Grand Theft Auto V\scripts\VCommonFunctions.dll</HintPath>
<HintPath>C:\Program Files\Rockstar Games\Grand Theft Auto V\Scripts\VCommonFunctions.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="YamlDotNet, Version=4.1.0.0, Culture=neutral, processorArchitecture=MSIL">
Expand Down
56 changes: 36 additions & 20 deletions managed/GTAVisionExport/VisionExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class VisionExport : Script
private speedAndTime lowSpeedTime = new speedAndTime();
private bool IsGamePaused = false;
private StereoCamera cams;
private bool notificationsEnabled = true;
public VisionExport()
{
// loading ini file
Expand Down Expand Up @@ -105,9 +106,9 @@ public VisionExport()
private void handlePipeInput()
{
System.IO.File.AppendAllText(logFilePath, "VisionExport handlePipeInput called.\n");
UI.Notify("handlePipeInput called");
UI.Notify("server connected:" + server.Connected.ToString());
UI.Notify(connection == null ? "connection is null" : "connection:" + connection.ToString());
if(notificationsEnabled) UI.Notify("handlePipeInput called");
if (notificationsEnabled) UI.Notify("server connected:" + server.Connected.ToString());
if (notificationsEnabled) UI.Notify(connection == null ? "connection is null" : "connection:" + connection.ToString());
if (connection == null) return;

byte[] inBuffer = new byte[1024];
Expand All @@ -133,7 +134,7 @@ private void handlePipeInput()
connection = null;
return;
}
UI.Notify(str.Length.ToString());
if (notificationsEnabled) UI.Notify(str.Length.ToString());
switch (str)
{
case "START_SESSION":
Expand All @@ -150,7 +151,7 @@ private void handlePipeInput()
ToggleNavigation();
break;
case "ENTER_VEHICLE":
UI.Notify("Trying to enter vehicle");
if (notificationsEnabled) UI.Notify("Trying to enter vehicle");
EnterVehicle();
break;
case "AUTOSTART":
Expand Down Expand Up @@ -219,7 +220,7 @@ public void OnTick(object o, EventArgs e)
if (server.Poll(10, SelectMode.SelectRead) && connection == null)
{
connection = server.Accept();
UI.Notify("CONNECTED");
if (notificationsEnabled) UI.Notify("CONNECTED");
connection.Blocking = false;
}
handlePipeInput();
Expand All @@ -234,9 +235,9 @@ public void OnTick(object o, EventArgs e)
StopRun();
runTask?.Wait();
runTask = StartRun();
//StopSession();
//Autostart();
UI.Notify("need reload game");
//StopSession();
//Autostart();
if (notificationsEnabled) UI.Notify("need reload game");
Script.Wait(100);
ReloadGame();
break;
Expand Down Expand Up @@ -284,11 +285,11 @@ public void OnTick(object o, EventArgs e)
var colorframe = VisionNative.GetLastColorTime();
var depthframe = VisionNative.GetLastConstantTime();
var constantframe = VisionNative.GetLastConstantTime();
//UI.Notify("DIFF: " + (colorframe - depthframe) + " FRAMETIME: " + (1 / Game.FPS) * 1000);
UI.Notify(colors[0].Length.ToString());
//UI.Notify("DIFF: " + (colorframe - depthframe) + " FRAMETIME: " + (1 / Game.FPS) * 1000);
if (notificationsEnabled) UI.Notify(colors[0].Length.ToString());
if (depth == null || stencil == null)
{
UI.Notify("No DEPTH");
if (notificationsEnabled) UI.Notify("No DEPTH");
return;
}

Expand Down Expand Up @@ -499,24 +500,39 @@ public void TraverseWeather()
public void OnKeyDown(object o, KeyEventArgs k)
{
System.IO.File.AppendAllText(logFilePath, "VisionExport OnKeyDown called.\n");

if (k.KeyCode == Keys.Z)
{
if (notificationsEnabled)
{
UI.Notify("Notifications Disabled");
notificationsEnabled = false;
}
else
{
UI.Notify("Notifications Enabled");
notificationsEnabled = true;

}
}
if (k.KeyCode == Keys.PageUp)
{
postgresTask?.Wait();
postgresTask = StartSession();
runTask?.Wait();
runTask = StartRun();
UI.Notify("GTA Vision Enabled");
if (notificationsEnabled) UI.Notify("GTA Vision Enabled");
}
if (k.KeyCode == Keys.PageDown)
{
StopRun();
StopSession();
UI.Notify("GTA Vision Disabled");
if (notificationsEnabled) UI.Notify("GTA Vision Disabled");
}
if (k.KeyCode == Keys.H) // temp modification
{
EnterVehicle();
UI.Notify("Trying to enter vehicle");
if (notificationsEnabled) UI.Notify("Trying to enter vehicle");
ToggleNavigation();
}
if (k.KeyCode == Keys.Y) // temp modification
Expand All @@ -530,7 +546,7 @@ public void OnKeyDown(object o, KeyEventArgs k)

//UI.Notify(ConfigurationManager.AppSettings["database_connection"]);
var str = settings.GetValue("", "ConnectionString");
UI.Notify(loc);
if (notificationsEnabled) UI.Notify(loc);

}
if (k.KeyCode == Keys.G) // temp modification
Expand Down Expand Up @@ -580,7 +596,7 @@ public void OnKeyDown(object o, KeyEventArgs k)
/* set it between 0 = stop, 1 = heavy rain. set it too high will lead to sloppy ground */
Function.Call(GTA.Native.Hash._SET_RAIN_FX_INTENSITY, 0.5f);
var test = Function.Call<float>(GTA.Native.Hash.GET_RAIN_LEVEL);
UI.Notify("" + test);
if (notificationsEnabled) UI.Notify("" + test);
World.CurrentDayTime = new TimeSpan(12, 0, 0);
//Script.Wait(5000);
}
Expand Down Expand Up @@ -634,7 +650,7 @@ public void OnKeyDown(object o, KeyEventArgs k)
var t = Tiff.Open(Path.Combine(dataPath, "info" + i.ToString() + ".tiff"), "w");
ImageUtils.WriteToTiff(t, res.Width, res.Height, colors, depth, stencil);
t.Close();
UI.Notify(GameplayCamera.FieldOfView.ToString());
if (notificationsEnabled) UI.Notify(GameplayCamera.FieldOfView.ToString());
//UI.Notify((connection != null && connection.Connected).ToString());


Expand Down Expand Up @@ -681,8 +697,8 @@ public void OnKeyDown(object o, KeyEventArgs k)
if (k.KeyCode == Keys.I)
{
var info = new GTAVisionUtils.InstanceData();
UI.Notify(info.type);
UI.Notify(info.publichostname);
if (notificationsEnabled) UI.Notify(info.type);
if (notificationsEnabled) UI.Notify(info.publichostname);
}
}
}
Expand Down
Loading

0 comments on commit 717be0d

Please sign in to comment.