Skip to content

Commit 717be0d

Browse files
IanKirwanbarcharcraz
authored andcommitted
Down sample depth map if buf > window (#31)
* 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
1 parent d6f8be9 commit 717be0d

File tree

5 files changed

+282
-45
lines changed

5 files changed

+282
-45
lines changed

database_schema.sql

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
create type detection_type AS ENUM ('background', 'person', 'car', 'bicycle');
2+
3+
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');
4+
5+
create type weather AS ENUM ('Unknown', 'ExtraSunny', 'Clear', 'Clouds', 'Smog', 'Foggy', 'Overcast', 'Raining', 'ThunderStorm', 'Clearing', 'Neutral', 'Snowing', 'Blizzard', 'Snowlight', 'Christmas', 'Halloween');
6+
7+
create table detections
8+
(
9+
detection_id serial not null
10+
constraint detections_pkey
11+
primary key,
12+
snapshot_id integer,
13+
type detection_type,
14+
pos geometry(PointZ),
15+
bbox box,
16+
class detection_class default 'Unknown'::detection_class,
17+
handle integer default '-1'::integer,
18+
best_bbox box,
19+
best_bbox_old box,
20+
bbox3d box3d,
21+
rot geometry,
22+
coverage real default 0.0,
23+
created timestamp without time zone default (now() at time zone 'utc')
24+
)
25+
;
26+
27+
28+
create table runs
29+
(
30+
run_id serial not null
31+
constraint runs_pkey
32+
primary key,
33+
runguid uuid,
34+
archivepath text,
35+
localpath text,
36+
session_id integer default 1,
37+
instance_id integer default 0,
38+
created timestamp without time zone default (now() at time zone 'utc')
39+
)
40+
;
41+
42+
43+
create table sessions
44+
(
45+
session_id serial not null
46+
constraint sessions_pkey
47+
primary key,
48+
name text
49+
constraint sessions_name_key
50+
unique,
51+
start timestamp with time zone,
52+
"end" timestamp with time zone,
53+
created timestamp without time zone default (now() at time zone 'utc')
54+
)
55+
;
56+
57+
alter table runs
58+
add constraint runs_session_fkey
59+
foreign key (session_id) references sessions
60+
on delete cascade
61+
;
62+
63+
create table snapshots
64+
(
65+
snapshot_id serial not null
66+
constraint snapshots_pkey
67+
primary key,
68+
run_id integer
69+
constraint snapshots_run_fkey
70+
references runs
71+
on delete cascade,
72+
version integer,
73+
imagepath text,
74+
timestamp timestamp with time zone,
75+
timeofday time,
76+
currentweather weather,
77+
camera_pos geometry(PointZ),
78+
camera_direction geometry,
79+
camera_fov real,
80+
view_matrix double precision[],
81+
proj_matrix double precision[],
82+
processed boolean default false not null,
83+
width integer,
84+
height integer
85+
)
86+
;
87+
88+
89+
alter table detections
90+
add constraint detections_snapshot_fkey
91+
foreign key (snapshot_id) references snapshots
92+
on delete cascade
93+
;
94+
95+
create table instances
96+
(
97+
instance_id serial not null
98+
constraint isntances_pkey
99+
primary key,
100+
hostname text,
101+
instanceid text
102+
constraint instanceid_uniq
103+
unique,
104+
instancetype text,
105+
publichostname text,
106+
amiid text,
107+
created timestamp without time zone default (now() at time zone 'utc'),
108+
constraint instance_info_uniq
109+
unique (hostname, instanceid, instancetype, publichostname, amiid)
110+
)
111+
;
112+
113+
alter table runs
114+
add constraint runs_instance_fkey
115+
foreign key (instance_id) references instances
116+
;
117+
118+
create table snapshot_weathers
119+
(
120+
weather_id serial not null
121+
constraint snapshot_weathers_pkey
122+
primary key,
123+
snapshot_id integer
124+
constraint snapshot_weathers_snapshot_id_fkey
125+
references snapshots
126+
on delete cascade,
127+
weather_type weather,
128+
snapshot_page integer,
129+
created timestamp without time zone default (now() at time zone 'utc')
130+
)
131+
;
132+
133+
create table uploads
134+
(
135+
id serial not null
136+
constraint uploads_pkey
137+
primary key,
138+
bucket text,
139+
key text,
140+
uploadid text,
141+
created timestamp without time zone default (now() at time zone 'utc')
142+
)
143+
;
144+
145+
create table datasets
146+
(
147+
dataset_id serial not null
148+
constraint datasets_pkey
149+
primary key,
150+
dataset_name text,
151+
view_name text,
152+
created timestamp without time zone default (now() at time zone 'utc')
153+
)
154+
;
155+
156+
create table systems
157+
(
158+
system_uuid uuid not null
159+
constraint systems_pkey
160+
primary key,
161+
vendor text,
162+
dnshostname text,
163+
username text,
164+
systemtype text,
165+
totalmem bigint,
166+
created timestamp without time zone default (now() at time zone 'utc')
167+
)
168+
;
169+
170+
create table system_graphics
171+
(
172+
system_graphic_id serial not null
173+
constraint system_graphics_pkey
174+
primary key,
175+
deviceid text,
176+
adaptercompatibility text,
177+
adapterdactype text,
178+
adapterram integer,
179+
availability integer,
180+
caption text,
181+
description text,
182+
driverdate timestamp with time zone,
183+
driverversion text,
184+
pnpdeviceid text,
185+
name text,
186+
videoarch integer,
187+
memtype integer,
188+
videoprocessor text,
189+
bpp integer,
190+
hrez integer,
191+
vrez integer,
192+
num_colors integer,
193+
cols integer,
194+
rows integer,
195+
refresh integer,
196+
scanmode integer,
197+
videomodedesc text,
198+
created timestamp without time zone default (now() at time zone 'utc')
199+
)
200+
;

managed/GTAVisionExport/GTAVisionExport.csproj

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,16 @@
7474
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
7575
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.1.1.0\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
7676
</Reference>
77-
<Reference Include="NativeUI, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
78-
<SpecificVersion>False</SpecificVersion>
79-
<HintPath>G:\games\SteamLibrary\steamapps\common\Grand Theft Auto V\scripts\NativeUI.dll</HintPath>
77+
<Reference Include="NativeUI">
78+
<HintPath>C:\Program Files\Rockstar Games\Grand Theft Auto V\Scripts\NativeUI.dll</HintPath>
8079
</Reference>
8180
<Reference Include="Npgsql, Version=3.2.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL">
8281
<HintPath>..\packages\Npgsql.3.2.1\lib\net451\Npgsql.dll</HintPath>
8382
</Reference>
8483
<Reference Include="PresentationCore" />
8584
<Reference Include="PresentationFramework" />
8685
<Reference Include="ScriptHookVDotNet2">
87-
<HintPath>..\..\..\..\..\Program Files (x86)\SteamLibrary\steamapps\common\Grand Theft Auto V\ScriptHookVDotNet2.dll</HintPath>
88-
</Reference>
89-
<Reference Include="ScriptHookVDotNet2, Version=2.10.3.0, Culture=neutral, PublicKeyToken=null">
90-
<HintPath>D:\Program Files (x86)\SteamLibrary\steamapps\common\Grand Theft Auto V\ScriptHookVDotNet2.dll</HintPath>
86+
<HintPath>C:\Program Files\Rockstar Games\Grand Theft Auto V\ScriptHookVDotNet2.dll</HintPath>
9187
</Reference>
9288
<Reference Include="System" />
9389
<Reference Include="System.ComponentModel.Composition" />
@@ -113,10 +109,10 @@
113109
<Reference Include="System.Net.Http" />
114110
<Reference Include="System.Xml" />
115111
<Reference Include="VAutodrive">
116-
<HintPath>G:\games\SteamLibrary\steamapps\common\Grand Theft Auto V\scripts\VAutodrive.dll</HintPath>
112+
<HintPath>C:\Program Files\Rockstar Games\Grand Theft Auto V\Scripts\VAutodrive.dll</HintPath>
117113
</Reference>
118114
<Reference Include="VCommonFunctions">
119-
<HintPath>G:\games\SteamLibrary\steamapps\common\Grand Theft Auto V\scripts\VCommonFunctions.dll</HintPath>
115+
<HintPath>C:\Program Files\Rockstar Games\Grand Theft Auto V\Scripts\VCommonFunctions.dll</HintPath>
120116
</Reference>
121117
<Reference Include="WindowsBase" />
122118
<Reference Include="YamlDotNet, Version=4.1.0.0, Culture=neutral, processorArchitecture=MSIL">

managed/GTAVisionExport/VisionExport.cs

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class VisionExport : Script
6767
private speedAndTime lowSpeedTime = new speedAndTime();
6868
private bool IsGamePaused = false;
6969
private StereoCamera cams;
70+
private bool notificationsEnabled = true;
7071
public VisionExport()
7172
{
7273
// loading ini file
@@ -105,9 +106,9 @@ public VisionExport()
105106
private void handlePipeInput()
106107
{
107108
System.IO.File.AppendAllText(logFilePath, "VisionExport handlePipeInput called.\n");
108-
UI.Notify("handlePipeInput called");
109-
UI.Notify("server connected:" + server.Connected.ToString());
110-
UI.Notify(connection == null ? "connection is null" : "connection:" + connection.ToString());
109+
if(notificationsEnabled) UI.Notify("handlePipeInput called");
110+
if (notificationsEnabled) UI.Notify("server connected:" + server.Connected.ToString());
111+
if (notificationsEnabled) UI.Notify(connection == null ? "connection is null" : "connection:" + connection.ToString());
111112
if (connection == null) return;
112113

113114
byte[] inBuffer = new byte[1024];
@@ -133,7 +134,7 @@ private void handlePipeInput()
133134
connection = null;
134135
return;
135136
}
136-
UI.Notify(str.Length.ToString());
137+
if (notificationsEnabled) UI.Notify(str.Length.ToString());
137138
switch (str)
138139
{
139140
case "START_SESSION":
@@ -150,7 +151,7 @@ private void handlePipeInput()
150151
ToggleNavigation();
151152
break;
152153
case "ENTER_VEHICLE":
153-
UI.Notify("Trying to enter vehicle");
154+
if (notificationsEnabled) UI.Notify("Trying to enter vehicle");
154155
EnterVehicle();
155156
break;
156157
case "AUTOSTART":
@@ -219,7 +220,7 @@ public void OnTick(object o, EventArgs e)
219220
if (server.Poll(10, SelectMode.SelectRead) && connection == null)
220221
{
221222
connection = server.Accept();
222-
UI.Notify("CONNECTED");
223+
if (notificationsEnabled) UI.Notify("CONNECTED");
223224
connection.Blocking = false;
224225
}
225226
handlePipeInput();
@@ -234,9 +235,9 @@ public void OnTick(object o, EventArgs e)
234235
StopRun();
235236
runTask?.Wait();
236237
runTask = StartRun();
237-
//StopSession();
238-
//Autostart();
239-
UI.Notify("need reload game");
238+
//StopSession();
239+
//Autostart();
240+
if (notificationsEnabled) UI.Notify("need reload game");
240241
Script.Wait(100);
241242
ReloadGame();
242243
break;
@@ -284,11 +285,11 @@ public void OnTick(object o, EventArgs e)
284285
var colorframe = VisionNative.GetLastColorTime();
285286
var depthframe = VisionNative.GetLastConstantTime();
286287
var constantframe = VisionNative.GetLastConstantTime();
287-
//UI.Notify("DIFF: " + (colorframe - depthframe) + " FRAMETIME: " + (1 / Game.FPS) * 1000);
288-
UI.Notify(colors[0].Length.ToString());
288+
//UI.Notify("DIFF: " + (colorframe - depthframe) + " FRAMETIME: " + (1 / Game.FPS) * 1000);
289+
if (notificationsEnabled) UI.Notify(colors[0].Length.ToString());
289290
if (depth == null || stencil == null)
290291
{
291-
UI.Notify("No DEPTH");
292+
if (notificationsEnabled) UI.Notify("No DEPTH");
292293
return;
293294
}
294295

@@ -499,24 +500,39 @@ public void TraverseWeather()
499500
public void OnKeyDown(object o, KeyEventArgs k)
500501
{
501502
System.IO.File.AppendAllText(logFilePath, "VisionExport OnKeyDown called.\n");
503+
504+
if (k.KeyCode == Keys.Z)
505+
{
506+
if (notificationsEnabled)
507+
{
508+
UI.Notify("Notifications Disabled");
509+
notificationsEnabled = false;
510+
}
511+
else
512+
{
513+
UI.Notify("Notifications Enabled");
514+
notificationsEnabled = true;
515+
516+
}
517+
}
502518
if (k.KeyCode == Keys.PageUp)
503519
{
504520
postgresTask?.Wait();
505521
postgresTask = StartSession();
506522
runTask?.Wait();
507523
runTask = StartRun();
508-
UI.Notify("GTA Vision Enabled");
524+
if (notificationsEnabled) UI.Notify("GTA Vision Enabled");
509525
}
510526
if (k.KeyCode == Keys.PageDown)
511527
{
512528
StopRun();
513529
StopSession();
514-
UI.Notify("GTA Vision Disabled");
530+
if (notificationsEnabled) UI.Notify("GTA Vision Disabled");
515531
}
516532
if (k.KeyCode == Keys.H) // temp modification
517533
{
518534
EnterVehicle();
519-
UI.Notify("Trying to enter vehicle");
535+
if (notificationsEnabled) UI.Notify("Trying to enter vehicle");
520536
ToggleNavigation();
521537
}
522538
if (k.KeyCode == Keys.Y) // temp modification
@@ -530,7 +546,7 @@ public void OnKeyDown(object o, KeyEventArgs k)
530546

531547
//UI.Notify(ConfigurationManager.AppSettings["database_connection"]);
532548
var str = settings.GetValue("", "ConnectionString");
533-
UI.Notify(loc);
549+
if (notificationsEnabled) UI.Notify(loc);
534550

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

640656

@@ -681,8 +697,8 @@ public void OnKeyDown(object o, KeyEventArgs k)
681697
if (k.KeyCode == Keys.I)
682698
{
683699
var info = new GTAVisionUtils.InstanceData();
684-
UI.Notify(info.type);
685-
UI.Notify(info.publichostname);
700+
if (notificationsEnabled) UI.Notify(info.type);
701+
if (notificationsEnabled) UI.Notify(info.publichostname);
686702
}
687703
}
688704
}

0 commit comments

Comments
 (0)