This README details how python and Arma 3 script(s) are used to generate data for a Neural Network using the editor from the game Arma 3. It also gives system requirements and many other changes that must be made by the user in order for the python script to run.
The intention of this script is to create images to further develop a neural network. The script generates roughly 20,000+ images in different environment settings and locations, from multiple different angles. Some examples of different environments are fog, sun, rain, etc.
The Python script starts by writing the Arma 3 script. This script will get stored in a separate file for later use. It then opens the game on the system and navigates through the menu to the editor using an autoclick function. After getting to the editor, an Arma 3 "mission" is then run. This mission will be the Arma 3 script that was created at the start of the python script. This Arma 3 script will generate the object that the neural network needs pictures of, and start taking screenshots of it. Then, the Python script will run in the background, and manage the screenshots created by putting them in an appropriate folder. Once all of the pictures have been taken, Python then closes the game and exits.
Example usage
python Data_Generation_Main.py [[6258.016,5474.695,0],[5998.337,4960.8,0]] ['B_CTRG_LSV_01_light_F','B_GEN_Van_02_transport_F'] 120 361 3 50 0.5 12 50
Arguments
In order for the script to work correctly:
The script moves the screenshots to this folder:
%HOMEDIRECTORY%\Users\%MainUser%\Documents\SyntheticDataGen
Ensure before running the script that this directory is either empty or non-existent. IMPORTANT: The user should move all data out of this folder when done to avoid having data overwritten by a future execution.
Use these commands in the Windows terminal to install required packages:
python -m pip install pyautogui
python -m pip install pypiwin32
It is recommended to run this command before you install these two packages:
python -m pip install --upgrade pip
Note: depending on where your python is installed or what exact version you have, you may need to use the command "py" instead of "python."
If you have the python terminal open instead, use these commands:
install pyautogui
install pypiwin32
Follow these steps if you would like to use custom vehicles with this script instead of default vehicles:
Open Steam and click on Library
Click Tools in the drop down menu
Scroll to the top (if necessary) and install "Arma 3 Tools" and "Arma 3 Samples" by double clicking on them.
Run "Arma 3 Tools" by double clicking on it. Choose the option "Play Arma 3 Tools."
When the Arma 3 Tools Window Opens click on "Project Drive Management."
In the window that opens, first click "Install Buldozer" then "Run," and accept any windows that pop up.
Once this is finished, click "Extract Game Data" then run, and accept any windows that pop up.
While the game data is extracting, click on "Mount the work drive (P)" and then run, accepting any appearing text boxes.
In the newly created P: drive, make a directory called "\Custom_Mods\Custom_Cars", or whatever you would like to call it. Just make sure there is a directory to place your custom file in.
Take the .obj file that you would like to use and place it in this directory, creating sub-directories for each as you see fit.
Go back to the Arma 3 Tools application (see steps 1-4) and click on "Object Builder."
Once in Object Builder, go to File->Import->OBJ File. Locate your file in the directory that you chose and import it.
Once imported, Object Builder will next ask you to scale the object file. The number you put in here will depend on the size of the object in the file. Start with 1, and play around with different numbers until you get a sensible result. The resulting object in the application should be no larger than 5x5x5 units on the graph the app provides.
Go to File->Options and ensure that next to External Viewer, this path and command is listed: P:\buldozer.exe -buldozer -name=Buldozer -window -noLand -exThreads=0 -noLogs -noAsserts -cfg=p:\buldozer.cfg. Hit ok once this is confirmed.
Now this is where some knowledge of 3D modeling is helpful. There should be a red square in the toolbar; this is Buldozer. When clicked, it should show a Start/Restart option. Click this, and the 3d Modeler Buldozer will run. This will show you what the model will look like in Arma.
Now, in Object Builder, save the object as a .p3d file, and put it in the same directory where you placed the .obj file.
Next, a config file needs to be created so Arma can read it as a car. Details about creating a config file can be found in this video: https://youtu.be/jJ7E-Eov5mo. This file has quite a lot in it, but for this purpose, a lot of it is unnecessary. However, the video details every part of the file, and what is needed to make it run.
Once the config file is created, go back to Steam->Library-> Tools->Arma 3 Tools. From here click "Launch Addon Builder."
In the source directory, choose the car directory you created in step 9. In the destination directory, create a seperate folder to place the packed data. Name this however you wish.
Once the data is packed, everything should be set! Go into the Arma editor and choose any map you prefer. On the right hand side of the window, search the name of your vehicle. If it is not there, something may have gone wrong with the textures or config of the vehicle. If it is there, click and drag it onto the world. As long as everything went as it should have, the vehicle should appear!
Troubleshooting for this process can be found in this Youtube playlist: https://www.youtube.com/playlist?list=PL64QY_ftN4sHB86nnFJ866tmZj6BQFv_1
This is a very complicated process, so it may take time to create and verify all of the necessary data.
Here are some examples of the data that this script creates:
Here is one example of the image processing the script does to generate the location of the vehicle. It first takes a regular image, and then makes a copy of it without the vehicle. It then compares the two to find the spot where the vehicle is: