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

rotate intrinsics #11414

Closed
Allius27 opened this issue Feb 8, 2023 · 3 comments
Closed

rotate intrinsics #11414

Allius27 opened this issue Feb 8, 2023 · 3 comments

Comments

@Allius27
Copy link
Contributor

Allius27 commented Feb 8, 2023

Hi there

Please, help me with correct function for rotating intrinsics
Camera is D415/D435

There is no need to calibrate camera, and for that reason there is no need to take into account the distortion coefficients
Is that code correct?

Code ( with opencv rotate flags )
    rs2_intrinsics intr = depth.get_profile().as<rs2::video_stream_profile>().get_intrinsics();

    int width  = intr.width;
    int height = intr.height;

    float angle;

    switch (getRotateCode()) {
    case ROTATE_90_CLOCKWISE:
            angle = -90;
            std::swap(width, height);
        break;
    case ROTATE_90_COUNTERCLOCKWISE:
            angle = 90;
            std::swap(width, height);
        break;
    case ROTATE_180:
            angle = 180;
        break;
    }

    float radians = angle*M_PI/180;

    ppx = cos(radians) * (intr.ppx - intr.width/2) - sin(radians) * (intr.ppy - intr.height/2) + width/2;
    ppy = sin(radians) * (intr.ppx - intr.width/2) + cos(radians) * (intr.ppy - intr.height/2) + height/2;
    fx  = cos(radians) * (intr.fx - intr.width/2)  - sin(radians) * (intr.fy - intr.height/2)  + width/2;
    fy  = sin(radians) * (intr.fx - intr.width/2)  + cos(radians) * (intr.fy - intr.height/2)  + height/2;
@MartyG-RealSense
Copy link
Collaborator

Hi @Allius27 If you are simply rotating the camera then it is not necessary to update the intrinsics. The calibration information and other camera parameters would only need to be updated if the camera was rotated and then the image was counter-rotated so that it was displayed the 'right way up'. This subject is discussed at #6023

Whilst there is an official Intel feature request to add a function to rotate the camera image, there is unfortunately not a time estimate available for the implementation of that feature.

Some RealSense users have used the workaround of rotating the image in OpenCV, like the method described at #6023 (comment)

Another approach to image rotation is described at #4395

@MartyG-RealSense
Copy link
Collaborator

Hi @Allius27 Do you require further assistance with this case, please? Thanks!

@MartyG-RealSense
Copy link
Collaborator

Case closed due to no further comments received.

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

No branches or pull requests

2 participants