Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is it possible to get function and method documentation programmatically?

Is it possible to have python return a list or dictionary of method arguments and their type?

For instance take cv2.threshold function. If I go to the docs webpage I can see all of the info I want, but is it possible to get this information in code? I would like to query the function cv2.threshold and have something tell me it takes the arguments [src,thresh,maxval,type[,dst]). It would be ideal if it also told me what type or class the values are:

e.g. the docs say: Python: cv2.threshold(src, thresh, maxval, type[, dst]) → retval, dst

so I want to be able to do something like:

foo.getMethods(cv2.threshold) -> {src:mat, thresh:int, maxval:int, type:built-in/[cv2. THRESH_BINARY_INV,cv2. THRESH_BINARY)]}

All of this info is in the documentation on the web page, I just want to access it to dynamically setup a codebase I am working on for a GUI.

Python: cv2.threshold(src, thresh, maxval, type[, dst]) → retval, dst Parameters:
src – input array (single-channel, 8-bit or 32-bit floating point). dst – output array of the same size and type as src. thresh – threshold value. maxval – maximum value to use with the THRESH_BINARY and THRESH_BINARY_INV thresholding types. type – thresholding type

Can I access this info without having to setup a web-scraper to pull it directly from the website?

Is it possible to get function and method documentation programmatically?

Is it possible to have python return a list or dictionary of method arguments and their type?

For instance take cv2.threshold function. If I go to the docs webpage I can see all of the info I want, but is it possible to get this information in code? I would like to query the function cv2.threshold and have something tell me it takes the arguments [src,thresh,maxval,type[,dst]). It would be ideal if it also told me what type or class the values are:

e.g. the docs say: Python: cv2.threshold(src, thresh, maxval, type[, dst]) → retval, dst

so I want to be able to do something like:

foo.getMethods(cv2.threshold) -> {src:mat, thresh:int, maxval:int, type:built-in/[cv2. THRESH_BINARY_INV,cv2. THRESH_BINARY)]}

All of this info is in the documentation on the web page, I just want to access it to dynamically setup a codebase I am working on for a GUI.

Python: cv2.threshold(src, thresh, maxval, type[, dst]) → retval, dst Parameters:
src – input array (single-channel, 8-bit or 32-bit floating point). dst – output array of the same size and type as src. thresh – threshold value. maxval – maximum value to use with the THRESH_BINARY and THRESH_BINARY_INV thresholding types. type – thresholding type

Can I access this info without having to setup a web-scraper to pull it directly from the website?

Is it possible to get function and method documentation programmatically?

Is it possible to have python return a list or dictionary of method arguments and their type?

For instance take cv2.threshold function. If I go to the docs webpage I can see all of the info I want, but is it possible to get this information in code? I would like to query the function cv2.threshold and have something tell me it takes the arguments [src,thresh,maxval,type[,dst]). It would be ideal if it also told me what type or class the values are:

e.g. the docs say: Python: cv2.threshold(src, thresh, maxval, type[, dst]) → retval, dst

so I want to be able to do something like:

foo.getMethods(cv2.threshold) -> {src:mat, thresh:int, maxval:int, type:built-in/[cv2. THRESH_BINARY_INV,cv2. THRESH_BINARY)]}

All of this info is in the documentation on the web page, I just want to access it to dynamically setup a codebase I am working on for a GUI.

Can I access this info without having to setup a web-scraper to pull it directly from the website?

Is it possible to get function and method documentation programmatically?

Is it possible to have python return a list or dictionary of method arguments and their type?

For instance take cv2.threshold function. If I go to the docs webpage I can see all of the info I want, but is it possible to get this information in code? I would like to query the function cv2.threshold and have something tell me it takes the arguments [src,thresh,maxval,type[,dst]). It would be ideal if it also told me what type or class the values are:

e.g. the docs say: Python: cv2.threshold(src, thresh, maxval, type[, dst]) → retval, dst

so I want to be able to do something like:

foo.getMethods(cv2.threshold) -> {src:mat, thresh:int, maxval:int, type:built-in/[cv2. THRESH_BINARY_INV,cv2. THRESH_BINARY)]}

All of this info is in the documentation on the web page, I just want to access it to dynamically setup a codebase I am working on for a GUI.

Can I access this info without having to setup a web-scraper to pull it directly from the website?

Edit: I've uploaded a video to show exactly what I want to do.

Up to now for each function I have to manually enter its parameters which look like this:

    def guiParams(self):
    thresh = {'type':'int',
              'name':'threshold value',
              'min':0,
              'max' : 255,
              'default': 127}
    maxval = {'type':'int',
            'name':'max threshold value',
            'min':0,  
            'max' : 255,
          'default': 255}
    threshtype ={'type':'builtin',
            'name':'thresholding type',
            'options':{'THRESH_BINARY':cv2.THRESH_BINARY,
                       'THRESH_BINARY_INV':cv2.THRESH_BINARY_INV,
                       'THRESH_TRUNC':cv2.THRESH_TRUNC,
                       'THRESH_TOZERO':cv2.THRESH_TOZERO,
                       'THRESH_TOZERO_INV':cv2.THRESH_TOZERO_INV},
            'default':'THRESH_BINARY'
            }
    return [thresh,maxval,threshtype]

This question is trying to figure out how I can get the information in these dictionaries (primarily the attribute name and type, default/typical values would be a bonus) grammatically so I can ensure the gui will work with every image processing method in the opencv Library

Is it possible to get function and method documentation programmatically?

Is it possible to have python return a list or dictionary of method arguments and their type?

For instance take cv2.threshold function. If I go to the docs webpage I can see all of the info I want, but is it possible to get this information in code? I would like to query the function cv2.threshold and have something tell me it takes the arguments [src,thresh,maxval,type[,dst]). It would be ideal if it also told me what type or class the values are:

e.g. the docs say: Python: cv2.threshold(src, thresh, maxval, type[, dst]) → retval, dst

so I want to be able to do something like:

foo.getMethods(cv2.threshold) -> {src:mat, thresh:int, maxval:int, type:built-in/[cv2. THRESH_BINARY_INV,cv2. THRESH_BINARY)]}

All of this info is in the documentation on the web page, I just want to access it to dynamically setup a codebase I am working on for a GUI.

Can I access this info without having to setup a web-scraper to pull it directly from the website?

Edit: I've uploaded a video to show exactly what I want to do.

Up to now for each function I have to manually enter its parameters which look like this:this (for cv2.threshold or Binary Threshold in the video):

    def guiParams(self):
    thresh = {'type':'int',
              'name':'threshold value',
              'min':0,
              'max' : 255,
              'default': 127}
    maxval = {'type':'int',
            'name':'max threshold value',
            'min':0,  
            'max' : 255,
          'default': 255}
    threshtype ={'type':'builtin',
            'name':'thresholding type',
            'options':{'THRESH_BINARY':cv2.THRESH_BINARY,
                       'THRESH_BINARY_INV':cv2.THRESH_BINARY_INV,
                       'THRESH_TRUNC':cv2.THRESH_TRUNC,
                       'THRESH_TOZERO':cv2.THRESH_TOZERO,
                       'THRESH_TOZERO_INV':cv2.THRESH_TOZERO_INV},
            'default':'THRESH_BINARY'
            }
    return [thresh,maxval,threshtype]

This question is trying to figure out how I can get the information in these dictionaries (primarily the attribute name and type, default/typical values would be a bonus) grammatically so I can ensure the gui will work with every image processing method in the opencv Library