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

broken python wrappers for face module #184

Closed
berak opened this issue Mar 7, 2015 · 4 comments
Closed

broken python wrappers for face module #184

berak opened this issue Mar 7, 2015 · 4 comments
Assignees

Comments

@berak
Copy link
Contributor

berak commented Mar 7, 2015

no methods are exposed:

>>> model = cv2.face.createLBPHFaceRecognizer()
>>> model
<face_LBPHFaceRecognizer 00ADB100>
>>> help(model)
Help on face_LBPHFaceRecognizer object:

class face_LBPHFaceRecognizer(__builtin__.object)
 |  Methods defined here:
 |
 |  __repr__(...)
 |      x.__repr__() <==> repr(x)
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  __new__ = <built-in method __new__ of type object>
 |      T.__new__(S, ...) -> a new object with type S, a subtype of T

>>> model2 = cv2.face.createFisherFaceRecognizer()
>>> help(model2)
Help on face_BasicFaceRecognizer object:

class face_BasicFaceRecognizer(__builtin__.object)
 |  Methods defined here:
 |
 |  __repr__(...)
 |      x.__repr__() <==> repr(x)
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  __new__ = <built-in method __new__ of type object>
 |      T.__new__(S, ...) -> a new object with type S, a subtype of T

code in pyopencv_generated_types.h has this:


static void pyopencv_face_BasicFaceRecognizer_specials(void)
{
    pyopencv_face_BasicFaceRecognizer_Type.tp_base = NULL; // should be: &pyopencv_face_FaceRecognizer_Type;

@berak
Copy link
Contributor Author

berak commented Mar 7, 2015

due to the Algorithm removal, a new BasicFaceRecognizer class was introduced there, but it seems, the python wrappers can't handle more than one level of inheritance.

(btw, the java wrappers (currently not enabled) work fine !)

@mshabunin
Copy link
Contributor

Looks like this problem only exists for modules inside nested namespaces. I've checked cv::StereoBM -> cv::StereoMatcher -> cv::Algorithm, and it works as expected, i.e. creates full inheritance chain and all parent methods.

class StereoBM(StereoMatcher)
 |  Method resolution order:
 |      StereoBM
 |      StereoMatcher
 |      Algorithm
 |      __builtin__.object

Nested modules members (I've checked ml and face) are shown like first level objects:

class ml_Boost(__builtin__.object)

I'll take a look into generator script to see how it can be fixed.

@mshabunin
Copy link
Contributor

@berak, can you, please, check if the issue has been fixed for you with the latest master version (opencv + contrib)?

@berak
Copy link
Contributor Author

berak commented Mar 26, 2015

yes, excellent, works now, thanks a lot !


>>> help(cv2.face)
Help on module cv2.face in cv2:

NAME
    cv2.face

FILE
    (built-in)

FUNCTIONS
    createEigenFaceRecognizer(...)
        createEigenFaceRecognizer([, num_components[, threshold]]) -> retval

    createFisherFaceRecognizer(...)
        createFisherFaceRecognizer([, num_components[, threshold]]) -> retval

    createLBPHFaceRecognizer(...)
        createLBPHFaceRecognizer([, radius[, neighbors[, grid_x[, grid_y[, thres
hold]]]]]) -> retval


>>> fr = createEigenFaceRecognizer()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'createEigenFaceRecognizer' is not defined
>>> fr = cv2.face.createEigenFaceRecognizer()
>>> help(fr)
Help on face_BasicFaceRecognizer object:

class face_BasicFaceRecognizer(face_FaceRecognizer)
 |  Method resolution order:
 |      face_BasicFaceRecognizer
 |      face_FaceRecognizer
 |      Algorithm
 |      __builtin__.object
 |
 |  Methods defined here:
 |
 |  __repr__(...)
 |      x.__repr__() <==> repr(x)
 |
 |  getEigenValues(...)
 |      getEigenValues() -> retval
 |
 |  getEigenVectors(...)
 |      getEigenVectors() -> retval
 |
 |  getLabels(...)
 |      getLabels() -> retval
 |
 |  getMean(...)
 |      getMean() -> retval
 |
 |  getNumComponents(...)
 |      getNumComponents() -> retval
 |
 |  getProjections(...)
 |      getProjections() -> retval
 |
 |  getThreshold(...)
 |      getThreshold() -> retval
 |
 |  setNumComponents(...)
 |      setNumComponents(val) -> None
 |
 |  setThreshold(...)
 |      setThreshold(val) -> None
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  __new__ = <built-in method __new__ of type object>
 |      T.__new__(S, ...) -> a new object with type S, a subtype of T
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from face_FaceRecognizer:
 |
 |  getLabelInfo(...)
 |      getLabelInfo(label) -> retval
 |
 |  getLabelsByString(...)
 |      getLabelsByString(str) -> retval
 |
 |  load(...)
 |      load(filename) -> None
 |
 |  predict(...)
 |      predict(src) -> label, confidence
 |
 |  save(...)
 |      save(filename) -> None
 |
 |  setLabelInfo(...)
 |      setLabelInfo(label, strInfo) -> None
 |
 |  train(...)
 |      train(src, labels) -> None
 |
 |  update(...)
 |      update(src, labels) -> None

trying on vs2008 (!) i encountered another tiny issue:
it tried to wrap e:\code\opencv\modules\objdetect\include\opencv2\objdetect\detection_based_tracker.hpp , and the class is #idef'ed out (because no threading available).

the wrapper ofc. is not able to see the #ifdefs there, and it failed to compile/link.

adding the header to the blacklist in opencv\modules\python\common.cmake( ~line 31), like:

 ocv_list_filterout(opencv_hdrs "detection_based")

fixed this locally.

@berak berak closed this as completed Mar 27, 2015
allnes pushed a commit to allnes/opencv_contrib that referenced this issue Jun 9, 2024
* Align mvn SLTs with MVN1 api.

* Remove redundant variable.

* Update test case name.
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