Skip to content

Commit

Permalink
[Pythonclient] Fix hello_car.py print, reshape statements
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat2004 committed May 10, 2020
1 parent 961456c commit d029cfc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions PythonClient/car/hello_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
client = airsim.CarClient()
client.confirmConnection()
client.enableApiControl(True)
print("API Control enabled: %s" % (client.isApiControlEnabled()))
car_controls = airsim.CarControls()

for idx in range(3):
Expand Down Expand Up @@ -54,7 +55,7 @@
airsim.ImageRequest("1", airsim.ImageType.DepthPerspective, True), #depth in perspective projection
airsim.ImageRequest("1", airsim.ImageType.Scene), #scene vision image in png format
airsim.ImageRequest("1", airsim.ImageType.Scene, False, False)]) #scene vision image in uncompressed RGB array
print('Retrieved images: %d', len(responses))
print('Retrieved images: %d' % (len(responses)) )

for response in responses:
filename = 'c:/temp/py' + str(idx)
Expand All @@ -69,7 +70,7 @@
else: #uncompressed array
print("Type %d, size %d" % (response.image_type, len(response.image_data_uint8)))
img1d = np.fromstring(response.image_data_uint8, dtype=np.uint8) # get numpy array
img_rgb = img1d.reshape(response.height, response.width, 3) # reshape array to 3 channel image array H X W X 3
img_rgb = img1d.reshape(response.height, response.width, -1) # reshape array to 3 channel image array H X W X 3
cv2.imwrite(os.path.normpath(filename + '.png'), img_rgb) # write to png

#restore to original state
Expand Down

0 comments on commit d029cfc

Please sign in to comment.