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

I can not use solvePnP in Calib3d #150

Open
kyaohoh opened this issue Sep 6, 2022 · 2 comments
Open

I can not use solvePnP in Calib3d #150

kyaohoh opened this issue Sep 6, 2022 · 2 comments

Comments

@kyaohoh
Copy link

kyaohoh commented Sep 6, 2022

Hi there,

I've been trying to use the below function.

public static bool solvePnP(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, bool useExtrinsicGuess, int flags)

I thought that it would work, but I keep getting rvec, tvec only as 0, 0, 0.

I tried adding the "ref" keyword in front of rvec and tvec but it didn't work.

Could you tell me how to get the values?

Thank you,
Kyaohoh.

@EnoxSoftware
Copy link
Owner

Perhaps there is some error on the opencv side.
Enclose the point where the error occurs in Utils.setDebugMode() method, and the error on the C++ side will be displayed on the console.

Utils.setDebugMode (true);

solvePnP(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, bool useExtrinsicGuess, int flags)

Utils.setDebugMode (false);

@kyaohoh
Copy link
Author

kyaohoh commented Sep 19, 2022

Thank you for sharing debugging info.
I found that I made a mistake when setting cameraMatrix.

I have one more question.
Now solvePnP function is working, but not well.
It looks like the axis settings are wrong.
To fix it, I'm going to do a multiplication operation of the below matrix. (similar to invertYM 4x4 mat you used in sample unity code)
1 0 0 0
0 0 1 0
0 1 0 0
0 0 0 0

Do you think it will work?

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