зеркало из https://github.com/microsoft/AirSim.git
add doc about the subview performance impact..
This commit is contained in:
Родитель
7d16c4f6b7
Коммит
a680c06b31
|
@ -5,6 +5,27 @@ import cv2
|
|||
import time
|
||||
import sys
|
||||
|
||||
def printUsage():
|
||||
print("Usage: python camera.py [depth|segmentation|scene]")
|
||||
|
||||
cameraType = "depth"
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
cameraType = arg.lower()
|
||||
|
||||
cameraTypeMap = {
|
||||
"depth": AirSimImageType.Depth,
|
||||
"segmentation": AirSimImageType.Segmentation,
|
||||
"seg": AirSimImageType.Segmentation,
|
||||
"scene": AirSimImageType.Scene,
|
||||
}
|
||||
|
||||
if (not cameraType in cameraTypeMap):
|
||||
printUsage()
|
||||
sys.exit(0)
|
||||
|
||||
print cameraTypeMap[cameraType]
|
||||
|
||||
client = AirSimClient('127.0.0.1')
|
||||
|
||||
help = False
|
||||
|
@ -21,11 +42,10 @@ fps = 0
|
|||
|
||||
while True:
|
||||
# because this method returns std::vector<uint8>, msgpack decides to encode it as a string unfortunately.
|
||||
result = client.getImageForCamera(0, AirSimImageType.Depth)
|
||||
result = client.getImageForCamera(0, cameraTypeMap[cameraType])
|
||||
if (result == "\0"):
|
||||
if (not help):
|
||||
help = True
|
||||
print("Please press '1' in the AirSim view to enable the Depth camera view")
|
||||
print("Camera is not returning image, please check airsim for error messages")
|
||||
sys.exit(0)
|
||||
else:
|
||||
rawImage = np.fromstring(result, np.int8)
|
||||
png = cv2.imdecode(rawImage, cv2.IMREAD_UNCHANGED)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# Camera Views
|
||||
|
||||
The camera views that are shown on screen are the camera views you can fetch via the DroneControllerBase::getImageTypeForCamera API.
|
||||
Note that getImageTypeForCamera returns .png compressed images.
|
||||
Note that getImageForCamera returns .png compressed images.
|
||||
|
||||
![Cameras](images/cameras.png)
|
||||
|
||||
From left to right is the depth view, segmentation view and the FPV view. These views must be visible in order for
|
||||
getImageTypeForCamera to work.
|
||||
getImageForCamera to work. In fact getImageForCamera will make them visible if they are not already.
|
||||
|
||||
## Depth View
|
||||
|
||||
|
@ -27,3 +27,23 @@ assignment that is happening in AFlyingPawn::setStencilIDs.
|
|||
|
||||
This view is simulating a fixed forward pointing camera on the drone. Note however, that this camera switchs places with the
|
||||
main game view if the user presses '[' or ']'.
|
||||
|
||||
## Performance
|
||||
|
||||
Now rendering these views does impact the FPS performance of the game, since this is additional work for the GPU. The following shows the impact on FPS when you open these views. The impact is higher when fetching the images via python calling getImageForCamera because this is an additional render request for each frame.
|
||||
|
||||
![fps](images/fps_views.png)
|
||||
|
||||
This is measured on Intel core i7 computer with 32 gb RAM and a GeForce GTX 1080
|
||||
graphics card running the Modular Neighborhood map, using cooked debug bits, no debugger or GameEditor open. The normal state with no subviews open is measuring around 16 ms per frame, which means it is keeping a nice steady 60 FPS (which is the target FPS). As it climbs up to 35ms the FPS drops to around 28 frames per second, spiking to 40ms means a few drops to 25 fps.
|
||||
|
||||
The simulator can still function and fly correctly when all this is going on even in the worse case because the physics is decoupled from the rendering. However if the delay gets too high such that the communication with PX4 hardware is interrupted due to overly busy CPU then the flight can stall due to timeout in the offboard control messages.
|
||||
|
||||
On the computer where this was measured the drone could fly the path.py program
|
||||
without any problems with all views open, and with 3 python scripts running
|
||||
to capture each view type. But there was one stall during this flight, but it
|
||||
recovered gracefully and completed the path. So it was right on the limit.
|
||||
|
||||
The following shows the impact on CPU, perhaps a bit surprizingly, the CPU impact is also non trivial.
|
||||
|
||||
![fps](images/cpu_views.png)
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 45 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 28 KiB |
|
@ -81,7 +81,7 @@ The drone should now be flying fast along the specified path.
|
|||
|
||||
### Camera
|
||||
|
||||
While the drone if flying you might want to capture some camera images.
|
||||
While the drone is flying you might want to capture some camera images.
|
||||
See [camera.py](https://github.com/Microsoft/AirSim/blob/master/PythonClient/camera.py) in the PythonClient folder.
|
||||
This program is capturing the Depth camera view from AirSim and displaying it in an OpenCV window.
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче