This is the first post of my series of survey posts on synthesis ways to produce datasets for computer vision or virtual environment for DL/RL. Today we will have a look at a pretty neat tool -- unrealcv to acquire data from the Unreal4 world. In this post, you will discover:
- how to install
unrealcv
to your computer - how to use the command interactively in RealisticRendering map
- how to use python code to fetch data
Note: The official website is pretty nice organized and you're encouraged to read their document there or a richer official version. I record these things here just to make my series thorough and organized.
Intro
UnrealCV is a project to help computer vision researchers build virtual worlds using Unreal Engine 4 (UE4)
-- Gitbub of unrealcv
Features
Before all, let us think what data we really need, for computer vision applications, we need:
- at least one camera
- the camera can be adjusted by providing the \(\mathbf{R}\) and \(\mathbf{t}\)
- the original image data, the normal, the mask, better if can get depth image
- the objects number, name, color
The unrealcv
meets all these common requirements and even more, see figure 1.
Let us have a try!
You are also encouraged to see official getting_started.
- Download the extended version of RealisticRendering for your platform
- Unzip and run the binary.
- Use the mouse to look around and use keys
wasd
to navigate, useqe
to level the camera up and down, use←↑→↓
to control the rotation of the camera. (Seem that←→
do theyaw
rotation well but↑↓
is somewhat wired -- notpitch
norroll
, but it's OK) - Type ` (the key on top of the tab) to release the mouse and thus enter command line environment, type it twice to show enlarged command graphical interface.
- Type
vget /camera/0/lit
and navigate to the folderRealisticRendering\Binaries\Win64
, we can see the00000001.png
we just captured. You should get something like figure 2 - Type
vget /unrealcv/help
will get something like our first figure. - TRY COMMANDS LISTED IN HELP
Note: In Windows, chances are that you will encounter DirectX Runtime
problem when trying to run the binary file, just download something like DirectX Repair V2.1
and repair the lacked files.
Show me the code, please!
We want to get tons of thousands of images from the virtual environment and then use them in various ways. So, we need codes to do that, and TES, we can do that! To use code fetch images via unrealcv is unreally easy:). See code snippet below (or just wget https://raw.githubusercontent.com/unrealcv/unrealcv/master/client/python/demo.py . --no-check-certificate
):
1 | from unrealcv import client |
The code is pretty straightforward, we will get these files in a very short time. (Still in RealisticRendering\Binaries\Win64
folder)
Note: The python version is version 2.x.x, and pip install unrealcv
before typing python demo.py
, and remember to launch the binary file first to start the game!
Could it be better
For me, It would be better if we can get:
- distance of the specific object from the camera or between objects (calculate from the depth image can lose accuracy (intuitive feeling) and not easy as a function call)
Conclusion
Today, we tried to install the unrealcv
and use it both in the interactive mode and programming mode (python).
What we did not cover is setting the camera position and rotation in the code, move the camera and fetch new images there, which is essential when getting images dataset.
And, we are using the RealisticRendering virtual environment all the time, in practical usage, we need to create our own world and thus need to do some programming with Unreal Engine. Will talk about later (hopefully won't be too long). And you can see unrealcv/playground before my coming post covering that.