Created
December 4, 2019 18:37
-
-
Save berak/7dd8a872b5bc9cf9893f8a1bec9aa201 to your computer and use it in GitHub Desktop.
pyopencv_cv_solvePnPGeneric
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static PyObject* pyopencv_cv_solvePnPGeneric(PyObject* , PyObject* args, PyObject* kw) | |
{ | |
using namespace cv; | |
{ | |
PyObject* pyobj_objectPoints = NULL; | |
Mat objectPoints; | |
PyObject* pyobj_imagePoints = NULL; | |
Mat imagePoints; | |
PyObject* pyobj_cameraMatrix = NULL; | |
Mat cameraMatrix; | |
PyObject* pyobj_distCoeffs = NULL; | |
Mat distCoeffs; | |
PyObject* pyobj_rvecs = NULL; | |
vector_Mat rvecs; | |
PyObject* pyobj_tvecs = NULL; | |
vector_Mat tvecs; | |
bool useExtrinsicGuess=false; | |
PyObject* pyobj_flags = NULL; | |
SolvePnPMethod flags=SOLVEPNP_ITERATIVE; | |
PyObject* pyobj_rvec = NULL; | |
Mat rvec; | |
PyObject* pyobj_tvec = NULL; | |
Mat tvec; | |
PyObject* pyobj_reprojectionError = NULL; | |
Mat reprojectionError; | |
int retval; | |
const char* keywords[] = { "objectPoints", "imagePoints", "cameraMatrix", "distCoeffs", "rvecs", "tvecs", "useExtrinsicGuess", "flags", "rvec", "tvec", "reprojectionError", NULL }; | |
if( PyArg_ParseTupleAndKeywords(args, kw, "OOOO|OObOOOO:solvePnPGeneric", (char**)keywords, &pyobj_objectPoints, &pyobj_imagePoints, &pyobj_cameraMatrix, &pyobj_distCoeffs, &pyobj_rvecs, &pyobj_tvecs, &useExtrinsicGuess, &pyobj_flags, &pyobj_rvec, &pyobj_tvec, &pyobj_reprojectionError) && | |
pyopencv_to(pyobj_objectPoints, objectPoints, ArgInfo("objectPoints", 0)) && | |
pyopencv_to(pyobj_imagePoints, imagePoints, ArgInfo("imagePoints", 0)) && | |
pyopencv_to(pyobj_cameraMatrix, cameraMatrix, ArgInfo("cameraMatrix", 0)) && | |
pyopencv_to(pyobj_distCoeffs, distCoeffs, ArgInfo("distCoeffs", 0)) && | |
pyopencv_to(pyobj_rvecs, rvecs, ArgInfo("rvecs", 1)) && | |
pyopencv_to(pyobj_tvecs, tvecs, ArgInfo("tvecs", 1)) && | |
pyopencv_to(pyobj_flags, flags, ArgInfo("flags", 0)) && | |
pyopencv_to(pyobj_rvec, rvec, ArgInfo("rvec", 0)) && | |
pyopencv_to(pyobj_tvec, tvec, ArgInfo("tvec", 0)) && | |
pyopencv_to(pyobj_reprojectionError, reprojectionError, ArgInfo("reprojectionError", 1)) ) | |
{ | |
ERRWRAP2(retval = cv::solvePnPGeneric(objectPoints, imagePoints, cameraMatrix, distCoeffs, rvecs, tvecs, useExtrinsicGuess, flags, rvec, tvec, reprojectionError)); | |
return Py_BuildValue("(NNNN)", pyopencv_from(retval), pyopencv_from(rvecs), pyopencv_from(tvecs), pyopencv_from(reprojectionError)); | |
} | |
} | |
PyErr_Clear(); | |
{ | |
PyObject* pyobj_objectPoints = NULL; | |
UMat objectPoints; | |
PyObject* pyobj_imagePoints = NULL; | |
UMat imagePoints; | |
PyObject* pyobj_cameraMatrix = NULL; | |
UMat cameraMatrix; | |
PyObject* pyobj_distCoeffs = NULL; | |
UMat distCoeffs; | |
PyObject* pyobj_rvecs = NULL; | |
vector_Mat rvecs; | |
PyObject* pyobj_tvecs = NULL; | |
vector_Mat tvecs; | |
bool useExtrinsicGuess=false; | |
PyObject* pyobj_flags = NULL; | |
SolvePnPMethod flags=SOLVEPNP_ITERATIVE; | |
PyObject* pyobj_rvec = NULL; | |
UMat rvec; | |
PyObject* pyobj_tvec = NULL; | |
UMat tvec; | |
PyObject* pyobj_reprojectionError = NULL; | |
UMat reprojectionError; | |
int retval; | |
const char* keywords[] = { "objectPoints", "imagePoints", "cameraMatrix", "distCoeffs", "rvecs", "tvecs", "useExtrinsicGuess", "flags", "rvec", "tvec", "reprojectionError", NULL }; | |
if( PyArg_ParseTupleAndKeywords(args, kw, "OOOO|OObOOOO:solvePnPGeneric", (char**)keywords, &pyobj_objectPoints, &pyobj_imagePoints, &pyobj_cameraMatrix, &pyobj_distCoeffs, &pyobj_rvecs, &pyobj_tvecs, &useExtrinsicGuess, &pyobj_flags, &pyobj_rvec, &pyobj_tvec, &pyobj_reprojectionError) && | |
pyopencv_to(pyobj_objectPoints, objectPoints, ArgInfo("objectPoints", 0)) && | |
pyopencv_to(pyobj_imagePoints, imagePoints, ArgInfo("imagePoints", 0)) && | |
pyopencv_to(pyobj_cameraMatrix, cameraMatrix, ArgInfo("cameraMatrix", 0)) && | |
pyopencv_to(pyobj_distCoeffs, distCoeffs, ArgInfo("distCoeffs", 0)) && | |
pyopencv_to(pyobj_rvecs, rvecs, ArgInfo("rvecs", 1)) && | |
pyopencv_to(pyobj_tvecs, tvecs, ArgInfo("tvecs", 1)) && | |
pyopencv_to(pyobj_flags, flags, ArgInfo("flags", 0)) && | |
pyopencv_to(pyobj_rvec, rvec, ArgInfo("rvec", 0)) && | |
pyopencv_to(pyobj_tvec, tvec, ArgInfo("tvec", 0)) && | |
pyopencv_to(pyobj_reprojectionError, reprojectionError, ArgInfo("reprojectionError", 1)) ) | |
{ | |
ERRWRAP2(retval = cv::solvePnPGeneric(objectPoints, imagePoints, cameraMatrix, distCoeffs, rvecs, tvecs, useExtrinsicGuess, flags, rvec, tvec, reprojectionError)); | |
return Py_BuildValue("(NNNN)", pyopencv_from(retval), pyopencv_from(rvecs), pyopencv_from(tvecs), pyopencv_from(reprojectionError)); | |
} | |
} | |
return NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment