What argument types (explicit, not interfaces) does solvePnPRansac from EmguCV expect?
1) Context
I'm using EmguCV's plugin for Unity, in order to call openCV functions from within my C# code. More precisely I need to call the SolvePnPRansac method.
Here is the documentation for the method SolvePnPRansac and the expected arguments:
http://www.emgu.com/wiki/files/3.1.0/document/html/36ff5d6b-498a-0587-5350-370bdecf64d7.htm
2) Problem:
The method call crashes the unity editor itself, leaving no exceptions, no stack trace, because the plugin crashes internally and unity doesn't seem to be able to handle it, despite my try-catch block.
from the logs that unity stores persistently, this is what I get, which clearly suggests a type mismatch:
Stacktrace:
at (wrapper managed-to-native) Emgu.CV.CvInvoke.cveSolvePnPRansac (intptr,intptr,intptr,intptr,intptr,intptr,bool,int,single,double,intptr,Emgu.CV.CvEnum.SolvePnpMethod)
at (wrapper managed-to-native) Emgu.CV.CvInvoke.cveSolvePnPRansac (intptr,intptr,intptr,intptr,intptr,intptr,bool,int,single,double,intptr,Emgu.CV.CvEnum.SolvePnpMethod)
at Emgu.CV.CvInvoke.SolvePnPRansac (Emgu.CV.IInputArray,Emgu.CV.IInputArray,Emgu.CV.IInputArray,Emgu.CV.IInputArray,Emgu.CV.IOutputArray,Emgu.CV.IOutputArray,bool,int,single,double,Emgu.CV.IOutputArray,Emgu.CV.CvEnum.SolvePnpMethod) [0x00090] in /Users/user/Documents/dgunity-v2/Assets/Emgu.CV/Emgu.CV/PInvoke/CvInvokeCalib3d.cs:659
at ObjectLocalization.LocalToCameraMatrixFromPnP ...
3) What I tried :
I can successfully run:
CvInvoke.SolvePnP(objectPoints, imagePoints, cameraMatrix, distortionCoeffs, rvec, tvec, useIntrinsicGuess);
where
- objectPoints is of type Emgu.CV.Util.VectorOfPoint3D32F
- imagePoints is of type Emgu.CV.Util.VectorOfPointF
- cameraMatrix is 3X3 of type Emgu.CV.Matrix
- distortionCoeffs is 1X4 of type Emgu.CV.Util.VectorOfFloat
- rvec and tvec are of type Emgu.CV.Util.VectorOfFloat
- and useIntrinsicGuess is type bool
4) What doesn't work
now I try:
CvInvoke.SolvePnPRansac(ransacObjPoints, ransacImgPoints, cameraMatrix, distortionCoeffs, rvec, tvec, useIntrinsicGuess, iterationsCount, reprojectionError, confident, inliers, Emgu.CV.CvEnum.SolvePnpMethod.Iterative);
where
- iterationsCount is 100 of type int
- reprojectionError is 8f of type float
- confident is 0.99 of type double
- inliers is empty of type Emgu.CV.Util.VectorOfInt
It just crashes the unity editor.
What am I doing wrong?
c# opencv unity3d emgucv
add a comment |
1) Context
I'm using EmguCV's plugin for Unity, in order to call openCV functions from within my C# code. More precisely I need to call the SolvePnPRansac method.
Here is the documentation for the method SolvePnPRansac and the expected arguments:
http://www.emgu.com/wiki/files/3.1.0/document/html/36ff5d6b-498a-0587-5350-370bdecf64d7.htm
2) Problem:
The method call crashes the unity editor itself, leaving no exceptions, no stack trace, because the plugin crashes internally and unity doesn't seem to be able to handle it, despite my try-catch block.
from the logs that unity stores persistently, this is what I get, which clearly suggests a type mismatch:
Stacktrace:
at (wrapper managed-to-native) Emgu.CV.CvInvoke.cveSolvePnPRansac (intptr,intptr,intptr,intptr,intptr,intptr,bool,int,single,double,intptr,Emgu.CV.CvEnum.SolvePnpMethod)
at (wrapper managed-to-native) Emgu.CV.CvInvoke.cveSolvePnPRansac (intptr,intptr,intptr,intptr,intptr,intptr,bool,int,single,double,intptr,Emgu.CV.CvEnum.SolvePnpMethod)
at Emgu.CV.CvInvoke.SolvePnPRansac (Emgu.CV.IInputArray,Emgu.CV.IInputArray,Emgu.CV.IInputArray,Emgu.CV.IInputArray,Emgu.CV.IOutputArray,Emgu.CV.IOutputArray,bool,int,single,double,Emgu.CV.IOutputArray,Emgu.CV.CvEnum.SolvePnpMethod) [0x00090] in /Users/user/Documents/dgunity-v2/Assets/Emgu.CV/Emgu.CV/PInvoke/CvInvokeCalib3d.cs:659
at ObjectLocalization.LocalToCameraMatrixFromPnP ...
3) What I tried :
I can successfully run:
CvInvoke.SolvePnP(objectPoints, imagePoints, cameraMatrix, distortionCoeffs, rvec, tvec, useIntrinsicGuess);
where
- objectPoints is of type Emgu.CV.Util.VectorOfPoint3D32F
- imagePoints is of type Emgu.CV.Util.VectorOfPointF
- cameraMatrix is 3X3 of type Emgu.CV.Matrix
- distortionCoeffs is 1X4 of type Emgu.CV.Util.VectorOfFloat
- rvec and tvec are of type Emgu.CV.Util.VectorOfFloat
- and useIntrinsicGuess is type bool
4) What doesn't work
now I try:
CvInvoke.SolvePnPRansac(ransacObjPoints, ransacImgPoints, cameraMatrix, distortionCoeffs, rvec, tvec, useIntrinsicGuess, iterationsCount, reprojectionError, confident, inliers, Emgu.CV.CvEnum.SolvePnpMethod.Iterative);
where
- iterationsCount is 100 of type int
- reprojectionError is 8f of type float
- confident is 0.99 of type double
- inliers is empty of type Emgu.CV.Util.VectorOfInt
It just crashes the unity editor.
What am I doing wrong?
c# opencv unity3d emgucv
add a comment |
1) Context
I'm using EmguCV's plugin for Unity, in order to call openCV functions from within my C# code. More precisely I need to call the SolvePnPRansac method.
Here is the documentation for the method SolvePnPRansac and the expected arguments:
http://www.emgu.com/wiki/files/3.1.0/document/html/36ff5d6b-498a-0587-5350-370bdecf64d7.htm
2) Problem:
The method call crashes the unity editor itself, leaving no exceptions, no stack trace, because the plugin crashes internally and unity doesn't seem to be able to handle it, despite my try-catch block.
from the logs that unity stores persistently, this is what I get, which clearly suggests a type mismatch:
Stacktrace:
at (wrapper managed-to-native) Emgu.CV.CvInvoke.cveSolvePnPRansac (intptr,intptr,intptr,intptr,intptr,intptr,bool,int,single,double,intptr,Emgu.CV.CvEnum.SolvePnpMethod)
at (wrapper managed-to-native) Emgu.CV.CvInvoke.cveSolvePnPRansac (intptr,intptr,intptr,intptr,intptr,intptr,bool,int,single,double,intptr,Emgu.CV.CvEnum.SolvePnpMethod)
at Emgu.CV.CvInvoke.SolvePnPRansac (Emgu.CV.IInputArray,Emgu.CV.IInputArray,Emgu.CV.IInputArray,Emgu.CV.IInputArray,Emgu.CV.IOutputArray,Emgu.CV.IOutputArray,bool,int,single,double,Emgu.CV.IOutputArray,Emgu.CV.CvEnum.SolvePnpMethod) [0x00090] in /Users/user/Documents/dgunity-v2/Assets/Emgu.CV/Emgu.CV/PInvoke/CvInvokeCalib3d.cs:659
at ObjectLocalization.LocalToCameraMatrixFromPnP ...
3) What I tried :
I can successfully run:
CvInvoke.SolvePnP(objectPoints, imagePoints, cameraMatrix, distortionCoeffs, rvec, tvec, useIntrinsicGuess);
where
- objectPoints is of type Emgu.CV.Util.VectorOfPoint3D32F
- imagePoints is of type Emgu.CV.Util.VectorOfPointF
- cameraMatrix is 3X3 of type Emgu.CV.Matrix
- distortionCoeffs is 1X4 of type Emgu.CV.Util.VectorOfFloat
- rvec and tvec are of type Emgu.CV.Util.VectorOfFloat
- and useIntrinsicGuess is type bool
4) What doesn't work
now I try:
CvInvoke.SolvePnPRansac(ransacObjPoints, ransacImgPoints, cameraMatrix, distortionCoeffs, rvec, tvec, useIntrinsicGuess, iterationsCount, reprojectionError, confident, inliers, Emgu.CV.CvEnum.SolvePnpMethod.Iterative);
where
- iterationsCount is 100 of type int
- reprojectionError is 8f of type float
- confident is 0.99 of type double
- inliers is empty of type Emgu.CV.Util.VectorOfInt
It just crashes the unity editor.
What am I doing wrong?
c# opencv unity3d emgucv
1) Context
I'm using EmguCV's plugin for Unity, in order to call openCV functions from within my C# code. More precisely I need to call the SolvePnPRansac method.
Here is the documentation for the method SolvePnPRansac and the expected arguments:
http://www.emgu.com/wiki/files/3.1.0/document/html/36ff5d6b-498a-0587-5350-370bdecf64d7.htm
2) Problem:
The method call crashes the unity editor itself, leaving no exceptions, no stack trace, because the plugin crashes internally and unity doesn't seem to be able to handle it, despite my try-catch block.
from the logs that unity stores persistently, this is what I get, which clearly suggests a type mismatch:
Stacktrace:
at (wrapper managed-to-native) Emgu.CV.CvInvoke.cveSolvePnPRansac (intptr,intptr,intptr,intptr,intptr,intptr,bool,int,single,double,intptr,Emgu.CV.CvEnum.SolvePnpMethod)
at (wrapper managed-to-native) Emgu.CV.CvInvoke.cveSolvePnPRansac (intptr,intptr,intptr,intptr,intptr,intptr,bool,int,single,double,intptr,Emgu.CV.CvEnum.SolvePnpMethod)
at Emgu.CV.CvInvoke.SolvePnPRansac (Emgu.CV.IInputArray,Emgu.CV.IInputArray,Emgu.CV.IInputArray,Emgu.CV.IInputArray,Emgu.CV.IOutputArray,Emgu.CV.IOutputArray,bool,int,single,double,Emgu.CV.IOutputArray,Emgu.CV.CvEnum.SolvePnpMethod) [0x00090] in /Users/user/Documents/dgunity-v2/Assets/Emgu.CV/Emgu.CV/PInvoke/CvInvokeCalib3d.cs:659
at ObjectLocalization.LocalToCameraMatrixFromPnP ...
3) What I tried :
I can successfully run:
CvInvoke.SolvePnP(objectPoints, imagePoints, cameraMatrix, distortionCoeffs, rvec, tvec, useIntrinsicGuess);
where
- objectPoints is of type Emgu.CV.Util.VectorOfPoint3D32F
- imagePoints is of type Emgu.CV.Util.VectorOfPointF
- cameraMatrix is 3X3 of type Emgu.CV.Matrix
- distortionCoeffs is 1X4 of type Emgu.CV.Util.VectorOfFloat
- rvec and tvec are of type Emgu.CV.Util.VectorOfFloat
- and useIntrinsicGuess is type bool
4) What doesn't work
now I try:
CvInvoke.SolvePnPRansac(ransacObjPoints, ransacImgPoints, cameraMatrix, distortionCoeffs, rvec, tvec, useIntrinsicGuess, iterationsCount, reprojectionError, confident, inliers, Emgu.CV.CvEnum.SolvePnpMethod.Iterative);
where
- iterationsCount is 100 of type int
- reprojectionError is 8f of type float
- confident is 0.99 of type double
- inliers is empty of type Emgu.CV.Util.VectorOfInt
It just crashes the unity editor.
What am I doing wrong?
c# opencv unity3d emgucv
c# opencv unity3d emgucv
edited Dec 11 '18 at 8:14
Daveloper
asked Nov 14 '18 at 13:47
DaveloperDaveloper
2789
2789
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Answering my own question here after countless hours of frustration : EmguCV expects arguments of type Mat. Period.
It exposes method arguments of interface types iInputArray and iOutputArray, but some of the classes implementing those interfaces can really only be handled in some combinations in some methods.
So the safe way is just to forget about other classes implementing the stated interface and just go for type Mat; so use
- objectPoints of type Emgu.CV.Util.VectorOfPoint3D32F
- imagePoints of type Emgu.CV.Util.VectorOfPointF
- cameraMatrix 3X3 of type MAT
- distortionCoeffs 1X 5 of type MAT
- rvec and tvec of type MAT
- and useIntrinsicGuess type bool
- iterationsCount 100 of type int
- reprojectionError 8f of type float
- confident 0.99 of type double
- inliers of type MAT
To get or set values in in your instances of type mat, you have to either transform them into images or matrices. I used methods CopyTo and SetTo to get values out of the Mat and into the Mat through instances of type Cv.Matrix. Be aware only the SetTo(double) worked for me. From a InputArray did not get handled properly (if you give it a MAT maybe it will, but not those implementations of iInputArray i tried using)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301731%2fwhat-argument-types-explicit-not-interfaces-does-solvepnpransac-from-emgucv-e%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Answering my own question here after countless hours of frustration : EmguCV expects arguments of type Mat. Period.
It exposes method arguments of interface types iInputArray and iOutputArray, but some of the classes implementing those interfaces can really only be handled in some combinations in some methods.
So the safe way is just to forget about other classes implementing the stated interface and just go for type Mat; so use
- objectPoints of type Emgu.CV.Util.VectorOfPoint3D32F
- imagePoints of type Emgu.CV.Util.VectorOfPointF
- cameraMatrix 3X3 of type MAT
- distortionCoeffs 1X 5 of type MAT
- rvec and tvec of type MAT
- and useIntrinsicGuess type bool
- iterationsCount 100 of type int
- reprojectionError 8f of type float
- confident 0.99 of type double
- inliers of type MAT
To get or set values in in your instances of type mat, you have to either transform them into images or matrices. I used methods CopyTo and SetTo to get values out of the Mat and into the Mat through instances of type Cv.Matrix. Be aware only the SetTo(double) worked for me. From a InputArray did not get handled properly (if you give it a MAT maybe it will, but not those implementations of iInputArray i tried using)
add a comment |
Answering my own question here after countless hours of frustration : EmguCV expects arguments of type Mat. Period.
It exposes method arguments of interface types iInputArray and iOutputArray, but some of the classes implementing those interfaces can really only be handled in some combinations in some methods.
So the safe way is just to forget about other classes implementing the stated interface and just go for type Mat; so use
- objectPoints of type Emgu.CV.Util.VectorOfPoint3D32F
- imagePoints of type Emgu.CV.Util.VectorOfPointF
- cameraMatrix 3X3 of type MAT
- distortionCoeffs 1X 5 of type MAT
- rvec and tvec of type MAT
- and useIntrinsicGuess type bool
- iterationsCount 100 of type int
- reprojectionError 8f of type float
- confident 0.99 of type double
- inliers of type MAT
To get or set values in in your instances of type mat, you have to either transform them into images or matrices. I used methods CopyTo and SetTo to get values out of the Mat and into the Mat through instances of type Cv.Matrix. Be aware only the SetTo(double) worked for me. From a InputArray did not get handled properly (if you give it a MAT maybe it will, but not those implementations of iInputArray i tried using)
add a comment |
Answering my own question here after countless hours of frustration : EmguCV expects arguments of type Mat. Period.
It exposes method arguments of interface types iInputArray and iOutputArray, but some of the classes implementing those interfaces can really only be handled in some combinations in some methods.
So the safe way is just to forget about other classes implementing the stated interface and just go for type Mat; so use
- objectPoints of type Emgu.CV.Util.VectorOfPoint3D32F
- imagePoints of type Emgu.CV.Util.VectorOfPointF
- cameraMatrix 3X3 of type MAT
- distortionCoeffs 1X 5 of type MAT
- rvec and tvec of type MAT
- and useIntrinsicGuess type bool
- iterationsCount 100 of type int
- reprojectionError 8f of type float
- confident 0.99 of type double
- inliers of type MAT
To get or set values in in your instances of type mat, you have to either transform them into images or matrices. I used methods CopyTo and SetTo to get values out of the Mat and into the Mat through instances of type Cv.Matrix. Be aware only the SetTo(double) worked for me. From a InputArray did not get handled properly (if you give it a MAT maybe it will, but not those implementations of iInputArray i tried using)
Answering my own question here after countless hours of frustration : EmguCV expects arguments of type Mat. Period.
It exposes method arguments of interface types iInputArray and iOutputArray, but some of the classes implementing those interfaces can really only be handled in some combinations in some methods.
So the safe way is just to forget about other classes implementing the stated interface and just go for type Mat; so use
- objectPoints of type Emgu.CV.Util.VectorOfPoint3D32F
- imagePoints of type Emgu.CV.Util.VectorOfPointF
- cameraMatrix 3X3 of type MAT
- distortionCoeffs 1X 5 of type MAT
- rvec and tvec of type MAT
- and useIntrinsicGuess type bool
- iterationsCount 100 of type int
- reprojectionError 8f of type float
- confident 0.99 of type double
- inliers of type MAT
To get or set values in in your instances of type mat, you have to either transform them into images or matrices. I used methods CopyTo and SetTo to get values out of the Mat and into the Mat through instances of type Cv.Matrix. Be aware only the SetTo(double) worked for me. From a InputArray did not get handled properly (if you give it a MAT maybe it will, but not those implementations of iInputArray i tried using)
edited Dec 11 '18 at 8:20
answered Dec 11 '18 at 8:13
DaveloperDaveloper
2789
2789
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301731%2fwhat-argument-types-explicit-not-interfaces-does-solvepnpransac-from-emgucv-e%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown