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

Scene image and Depth image not synchronized? #275

Closed
ShukuiZhang opened this issue Jun 13, 2017 · 2 comments
Closed

Scene image and Depth image not synchronized? #275

ShukuiZhang opened this issue Jun 13, 2017 · 2 comments

Comments

@ShukuiZhang
Copy link

ShukuiZhang commented Jun 13, 2017

I obtain the scene image and the depth image using python API, with the following code (modified from camera.py):

while True:
    result2 = client.getImageForCamera(0, AirSimImageType.Depth)
    result1 = client.getImageForCamera(0, AirSimImageType.Scene)
    if (result1 == "\0" or result2 == "\0"):
        if (not help):
            help = True
            print("Please press '1' in the AirSim view to enable the Depth camera view")
    else:
        rawImage = np.fromstring(result1, np.int8)
        png = cv2.imdecode(rawImage, cv2.IMREAD_UNCHANGED)
        
        depthImage = np.fromstring(result2, np.int8)
        depthpng = cv2.imdecode(depthImage, cv2.IMREAD_UNCHANGED)
        
        cv2.imshow("Depth", png)
        cv2.imshow("Raw", depthpng)
        cv2.imwrite(os.path.join(DATA_PATH ,"img_" + str(frameCount) + ".png"), png)
        cv2.imwrite(os.path.join(DATA_PATH, "depth_" + str(frameCount) + ".png"), depthpng)

However, the recorded scene image and the depth image seems not synchronized. As shown in the following:
depth_34
img_34
Is there any solution to reduce the drift besides slowing down the drone? I mean, is there a way to improve synchronization performance by tuning the code? Thanks.

@lovettchris
Copy link
Member

Right they are rendered when you ask for them, which means they will not be perfectly synchronized, Sai Vemprala wrote a handy script that captures the images via screen capture so they are in sync. See his post on issue#244.

@ShukuiZhang
Copy link
Author

Thanks. I will close this one and switch to that thread.

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

No branches or pull requests

2 participants