Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why all the data in .pfm array are 1? #1187

Open
husha1993 opened this issue Jun 22, 2018 · 2 comments
Open

why all the data in .pfm array are 1? #1187

husha1993 opened this issue Jun 22, 2018 · 2 comments
Labels

Comments

@husha1993
Copy link

the .pfm file is required by the following codes

responses = client.simGetImages([airsim.ImageRequest("0", airsim.ImageType.DepthPerspective, True)])
for idx, response in enumerate(responses):
filename = os.path.join(tmp_dir, str(idx) + '_' + str(response.image_type))
if response.pixels_as_float:
print("1, Type %d, size %d" % (response.image_type, len(response.image_data_float)))
airsim.write_pfm(os.path.normpath(filename + '.pfm'), airsim.get_pfm_array(response))

then read the .pfm file

airsim.read_pfm(r'C:\temp\airsim_drone\1_2.pfm')
(array([[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
...,
[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.]], dtype=float32), 1.0)

@husha1993
Copy link
Author

when I set the pixels_as_float as default, then the depth data is not always '1'

responses = client.simGetImages([airsim.ImageRequest("0", airsim.ImageType.DepthPerspective)])
res= response[0]

np.frombuffer(res.image_data_uint8, np.uint8)
array([137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73,
72, 68, 82, 0, 0, 1, 0, 0, 0, 0, 144, 8, 6,
0, 0, 0, 231, 99, 181, 145, 0, 0, 3, 152, 73, 68,
65, 84, 120, 1, 237, 212, 1, 17, 0, 32, 12, 3, 49,
192, 191, 231, 193, 97, 227, 51, 7, 77, 119, 221, 243, 110,
57, 2, 4, 146, 2, 39, 153, 90, 104, 2, 4, 190, 128,
1, 240, 8, 4, 194, 2, 6, 32, 92, 190, 232, 4, 12,
128, 31, 32, 16, 22, 48, 0, 225, 242, 69, 39, 96, 0,
252, 0, 129, 176, 128, 1, 8, 151, 47, 58, 1, 3, 224,
7, 8, 132, 5, 12, 64, 184, 124, 209, 9, 24, 0, 63,
64, 32, 44, 96, 0, 194, 229, 139, 78, 192, 0, 248, 1,
2, 97, 1, 3, 16, 46, 95, 116, 2, 6, 192, 15, 16,
8, 11, 24, 128, 112, 249, 162, 19, 48, 0, 126, 128, 64,
88, 192, 0, 132, 203, 23, 157, 128, 1, 240, 3, 4, 194,
2, 6, 32, 92, 190, 232, 4, 12, 128, 31, 32, 16, 22,
48, 0, 225, 242, 69, 39, 96, 0, 252, 0, 129, 176, 128,
1, 8, 151, 47, 58, 1, 3, 224, 7, 8, 132, 5, 12,
64, 184, 124, 209, 9, 24, 0, 63, 64, 32, 44, 96, 0,
194, 229, 139, 78, 192, 0, 248, 1, 2, 97, 1, 3, 16,
46, 95, 116, 2, 6, 192, 15, 16, 8, 11, 24, 128, 112,
249, 162, 19, 48, 0, 126, 128, 64, 88, 192, 0, 132, 203,
23, 157, 128, 1, 240, 3, 4, 194, 2, 6, 32, 92, 190,
232, 4, 12, 128, 31, 32, 16, 22, 48, 0, 225, 242, 69,
39, 96, 0, 252, 0, 129, 176, 128, 1, 8, 151, 47, 58,
1, 3, 224, 7, 8, 132, 5, 12, 64, 184, 124, 209, 9,
24, 0, 63, 64, 32, 44, 96, 0, 194, 229, 139, 78, 192,
0, 248, 1, 2, 97, 1, 3, 16, 46, 95, 116, 2, 6,
192, 15, 16, 8, 11, 24, 128, 112, 249, 162, 19, 48, 0,
126, 128, 64, 88, 192, 0, 132, 203, 23, 157, 128, 1, 240,
3, 4, 194, 2, 6, 32, 92, 190, 232, 4, 12, 128, 31,
32, 16, 22, 48, 0, 225, 242, 69, 39, 96, 0, 252, 0,
129, 176, 128, 1, 8, 151, 47, 58, 1, 3, 224, 7, 8,
132, 5, 12, 64, 184, 124, 209, 9, 24, 0, 63, 64, 32,
44, 96, 0, 194, 229, 139, 78, 192, 0, 248, 1, 2, 97,
1, 3, 16, 46, 95, 116, 2, 6, 192, 15, 16, 8, 11,
24, 128, 112, 249, 162, 19, 48, 0, 126, 128, 64, 88, 192,
0, 132, 203, 23, 157, 128, 1, 240, 3, 4, 194, 2, 6,
32, 92, 190, 232, 4, 12, 128, 31, 32, 16, 22, 48, 0,
225, 242, 69, 39, 96, 0, 252, 0, 129, 176, 128, 1, 8,
151, 47, 58, 1, 3, 224, 7, 8, 132, 5, 12, 64, 184,
124, 209, 9, 24, 0, 63, 64, 32, 44, 96, 0, 194, 229,
139, 78, 192, 0, 248, 1, 2, 97, 1, 3, 16, 46, 95,
116, 2, 6, 192, 15, 16, 8, 11, 24, 128, 112, 249, 162,
19, 48, 0, 126, 128, 64, 88, 192, 0, 132, 203, 23, 157,
128, 1, 240, 3, 4, 194, 2, 6, 32, 92, 190, 232, 4,
12, 128, 31, 32, 16, 22, 48, 0, 225, 242, 69, 39, 96,
0, 252, 0, 129, 176, 128, 1, 8, 151, 47, 58, 1, 3,
224, 7, 8, 132, 5, 12, 64, 184, 124, 209, 9, 24, 0,
63, 64, 32, 44, 96, 0, 194, 229, 139, 78, 192, 0, 248,
1, 2, 97, 1, 3, 16, 46, 95, 116, 2, 6, 192, 15,
16, 8, 11, 24, 128, 112, 249, 162, 19, 48, 0, 126, 128,
64, 88, 192, 0, 132, 203, 23, 157, 128, 1, 240, 3, 4,
194, 2, 6, 32, 92, 190, 232, 4, 12, 128, 31, 32, 16,
22, 48, 0, 225, 242, 69, 39, 96, 0, 252, 0, 129, 176,
128, 1, 8, 151, 47, 58, 1, 3, 224, 7, 8, 132, 5,
12, 64, 184, 124, 209, 9, 24, 0, 63, 64, 32, 44, 96,
0, 194, 229, 139, 78, 192, 0, 248, 1, 2, 97, 1, 3,
16, 46, 95, 116, 2, 6, 192, 15, 16, 8, 11, 24, 128,
112, 249, 162, 19, 48, 0, 126, 128, 64, 88, 192, 0, 132,
203, 23, 157, 128, 1, 240, 3, 4, 194, 2, 6, 32, 92,
190, 232, 4, 12, 128, 31, 32, 16, 22, 48, 0, 225, 242,
69, 39, 96, 0, 252, 0, 129, 176, 128, 1, 8, 151, 47,
58, 1, 3, 224, 7, 8, 132, 5, 12, 64, 184, 124, 209,
9, 24, 0, 63, 64, 32, 44, 96, 0, 194, 229, 139, 78,
192, 0, 248, 1, 2, 97, 1, 3, 16, 46, 95, 116, 2,
6, 192, 15, 16, 8, 11, 24, 128, 112, 249, 162, 19, 48,
0, 126, 128, 64, 88, 192, 0, 132, 203, 23, 157, 128, 1,
240, 3, 4, 194, 2, 6, 32, 92, 190, 232, 4, 12, 128,
31, 32, 16, 22, 48, 0, 225, 242, 69, 39, 96, 0, 252,
0, 129, 176, 128, 1, 8, 151, 47, 58, 1, 3, 224, 7,
8, 132, 5, 12, 64, 184, 124, 209, 9, 24, 0, 63, 64,
32, 44, 96, 0, 194, 229, 139, 78, 192, 0, 248, 1, 2,
97, 1, 3, 16, 46, 95, 116, 2, 6, 192, 15, 16, 8,
11, 24, 128, 112, 249, 162, 19, 184, 95, 26, 5, 28, 126,
113, 254, 208, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66,
96, 130], dtype=uint8)

maybe it relates to the decoding of buffer data as floats in simGetImages()

@husha1993
Copy link
Author

np.frombuffer(response.image_data_uint8, np.uint8).shape
(977,)

it should be 144*256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants