* Fixed cross-referencing in reference manual (except C++ operator() ).
authorAndrey Kamaev <no@email>
Fri, 12 Aug 2011 22:18:04 +0000 (22:18 +0000)
committerAndrey Kamaev <no@email>
Fri, 12 Aug 2011 22:18:04 +0000 (22:18 +0000)
* Fixed display of struct and class definitions (except classes with base class specified).
* Fixed formatting and referencing errors in several documentation files.

doc/ocv.py
modules/core/doc/dynamic_structures.rst
modules/imgproc/doc/filtering.rst
modules/video/doc/motion_analysis_and_object_tracking.rst

index a2f0266..7f29f79 100644 (file)
@@ -1149,6 +1149,8 @@ class OCVObject(ObjectDescription):
                 #(self.env.docname, self.objtype, theid))
             self.env.domaindata['ocv']['objects'].setdefault(theid,
                 (self.env.docname, self.objtype, theid))
+            self.env.domaindata['ocv']['objects2'].setdefault(name,
+                (self.env.docname, self.objtype, theid))
 
         indextext = self.get_index_text(name)
         if indextext:
@@ -1192,33 +1194,32 @@ class OCVObject(ObjectDescription):
 
 
 class OCVClassObject(OCVObject):
+    object_annotation = "class "
+    object_long_name = "class"
 
-    def get_index_text(self, name):
-        return _('%s (C++ class)') % name
-
-    def parse_definition(self, parser):
-        return parser.parse_class()
-
-    def describe_signature(self, signode, cls):
-        #self.attach_modifiers(signode, cls)
-        #signode += addnodes.desc_annotation('class ', 'class ')
-        #self.attach_name(signode, cls.name)
-        pass
-
-class OCVStructObject(OCVObject):
+    def attach_modifiers(self, node, obj):
+        if obj.visibility != 'public':
+            node += addnodes.desc_annotation(obj.visibility,
+                                             obj.visibility)
+            node += nodes.Text(' ')
+        if obj.static:
+            node += addnodes.desc_annotation('static', 'static')
+            node += nodes.Text(' ')
 
     def get_index_text(self, name):
-        return _('%s (C structure)') % name
+        return _('%s (C++ %s)') % (name, self.__class__.object_long_name)
 
     def parse_definition(self, parser):
         return parser.parse_class()
 
     def describe_signature(self, signode, cls):
-        #self.attach_modifiers(signode, cls)
-        #signode += addnodes.desc_annotation('class ', 'class ')
-        #self.attach_name(signode, cls.name)
-        pass
+        self.attach_modifiers(signode, cls)
+        signode += addnodes.desc_annotation(self.__class__.object_annotation, self.__class__.object_annotation)
+        self.attach_name(signode, cls.name)
 
+class OCVStructObject(OCVClassObject):
+    object_annotation = "struct "
+    object_long_name = "structure"
 
 class OCVTypeObject(OCVObject):
 
@@ -1238,9 +1239,7 @@ class OCVTypeObject(OCVObject):
             signode += nodes.Text(' ')
         self.attach_name(signode, obj.name)
 
-
 class OCVMemberObject(OCVObject):
-
     ismember = True
 
     def get_index_text(self, name):
@@ -1259,7 +1258,6 @@ class OCVMemberObject(OCVObject):
         if obj.value is not None:
             signode += nodes.Text(u' = ' + obj.value)
 
-
 class OCVFunctionObject(OCVObject):
 
     def attach_function(self, node, func):
@@ -1417,6 +1415,10 @@ class OCVDomain(Domain):
     initial_data = {
         'objects': {},  # fullname -> docname, objtype
     }
+    
+    def __init__(self, env):
+        Domain.__init__(self, env)
+        self.data['objects2'] = {}
 
     def clear_doc(self, docname):
         for fullname, (fn, _, _) in self.data['objects'].items():
@@ -1427,9 +1429,19 @@ class OCVDomain(Domain):
                      typ, target, node, contnode):
         def _create_refnode(expr):
             name = unicode(expr)
-            if name not in self.data['objects']:
+            if "type" in self.objtypes_for_role(typ):
+                return None
+            if "cfunction" in self.objtypes_for_role(typ):
+                if not name.lower().startswith(u'cv'):
+                    name = u'cv' + name
+            dict = self.data['objects']
+            if name not in dict:
+                dict = self.data['objects2']
+            if name not in dict:
+                refdoc = node.get('refdoc', fromdocname)
+                env.warn(refdoc, 'unresolved reference: %r - %r' % (target, typ), node.line)
                 return None
-            obj = self.data['objects'][name]
+            obj = dict[name]
             if obj[1] not in self.objtypes_for_role(typ):
                 return None
             return make_refnode(builder, fromdocname, obj[0], obj[2],
@@ -1443,7 +1455,7 @@ class OCVDomain(Domain):
                 raise DefinitionError('')
         except DefinitionError:
             refdoc = node.get('refdoc', fromdocname)
-            env.warn(refdoc, 'unparseable1 C++ definition: %r' % target,
+            env.warn(refdoc, 'unparseable C++ definition: %r' % target,
                      node.line)
             return None
 
index de4f19b..379e794 100644 (file)
@@ -1,5 +1,5 @@
 Dynamic Structures
-==================
+================== 
 
 .. highlight:: c
 
@@ -452,17 +452,17 @@ Finds an edge in a graph.
 
 .. ocv:cfunction:: CvGraphEdge* cvFindGraphEdge( const CvGraph* graph, int start_idx, int end_idx )
 
-::
-
-    #define cvGraphFindEdge cvFindGraphEdge
-
-..
-
     :param graph: Graph
 
     :param start_idx: Index of the starting vertex of the edge
 
     :param end_idx: Index of the ending vertex of the edge. For an unoriented graph, the order of the vertex parameters does not matter.
+       
+::
+
+    #define cvGraphFindEdge cvFindGraphEdge
+
+..
 
 The function finds the graph edge connecting two specified vertices and returns a pointer to it or NULL if the edge does not exist.
 
@@ -472,17 +472,17 @@ Finds an edge in a graph by using its pointer.
 
 .. ocv:cfunction:: CvGraphEdge* cvFindGraphEdgeByPtr(  const CvGraph* graph, const CvGraphVtx* startVtx, const CvGraphVtx* endVtx )
 
-::
-
-    #define cvGraphFindEdgeByPtr cvFindGraphEdgeByPtr
-
-..
-
     :param graph: Graph
 
     :param startVtx: Pointer to the starting vertex of the edge
 
     :param endVtx: Pointer to the ending vertex of the edge. For an unoriented graph, the order of the vertex parameters does not matter.
+       
+::
+
+    #define cvGraphFindEdgeByPtr cvFindGraphEdgeByPtr
+
+..
 
 The function finds the graph edge connecting two specified vertices and returns pointer to it or NULL if the edge does not exists.
 
@@ -521,15 +521,16 @@ Returns a pointer to a sequence element according to its index.
 
 .. ocv:cfunction:: char* cvGetSeqElem( const CvSeq* seq, int index )
 
+    :param seq: Sequence
+
+    :param index: Index of element
+       
 ::
 
     #define CV_GET_SEQ_ELEM( TYPE, seq, index )  (TYPE*)cvGetSeqElem( (CvSeq*)(seq), (index) )
 
 ..
 
-    :param seq: Sequence
-
-    :param index: Index of element
 
 The function finds the element with the given
 index in the sequence and returns the pointer to it. If the element
@@ -841,6 +842,12 @@ Allocates a text string in a storage block.
 
 .. ocv:cfunction:: CvString cvMemStorageAllocString(CvMemStorage* storage, const char* ptr, int len=-1)
 
+    :param storage: Memory storage
+
+    :param ptr: The string
+
+    :param len: Length of the string (not counting the ending  ``NUL`` ) . If the parameter is negative, the function computes the length.
+       
 ::
 
     typedef struct CvString
@@ -852,12 +859,6 @@ Allocates a text string in a storage block.
 
 ..
 
-    :param storage: Memory storage
-
-    :param ptr: The string
-
-    :param len: Length of the string (not counting the ending  ``NUL`` ) . If the parameter is negative, the function computes the length.
-
 The function creates copy of the string
 in memory storage. It returns the structure that contains user-passed
 or computed length of the string and pointer to the copied string.
@@ -1256,6 +1257,12 @@ Sorts sequence element using the specified comparison function.
 
 .. ocv:cfunction:: void cvSeqSort( CvSeq* seq, CvCmpFunc func, void* userdata=NULL )
 
+    :param seq: The sequence to sort
+
+    :param func: The comparison function that returns a negative, zero, or positive value depending on the relationships among the elements (see the above declaration and the example below) - a similar function is used by  ``qsort``  from C runline except that in the latter,  ``userdata``  is not used
+
+    :param userdata: The user parameter passed to the compasion function; helps to avoid global variables in some cases
+       
 ::
 
     /* a < b ? -1 : a > b ? 1 : 0 */
@@ -1263,12 +1270,6 @@ Sorts sequence element using the specified comparison function.
 
 ..
 
-    :param seq: The sequence to sort
-
-    :param func: The comparison function that returns a negative, zero, or positive value depending on the relationships among the elements (see the above declaration and the example below) - a similar function is used by  ``qsort``  from C runline except that in the latter,  ``userdata``  is not used
-
-    :param userdata: The user parameter passed to the compasion function; helps to avoid global variables in some cases
-
 The function sorts the sequence in-place using the specified criteria. Below is an example of using this function:
 
 ::
index ec50c6d..c0b4dbe 100644 (file)
@@ -51,13 +51,13 @@ The class ``BaseColumnFilter`` is a base class for filtering data using single-c
 
 where
 :math:`F` is a filtering function but, as it is represented as a class, it can produce any side effects, memorize previously processed data, and so on. The class only defines an interface and is not used directly. Instead, there are several functions in OpenCV (and you can add more) that return pointers to the derived classes that implement specific filtering operations. Those pointers are then passed to the
-:ocv:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
+:ocv:class:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
 
 .. seealso::
 
-   :ocv:func:`BaseRowFilter`,
-   :ocv:func:`BaseFilter`,
-   :ocv:func:`FilterEngine`,
+   :ocv:class:`BaseRowFilter`,
+   :ocv:class:`BaseFilter`,
+   :ocv:class:`FilterEngine`,
    :ocv:func:`getColumnSumFilter`,
    :ocv:func:`getLinearColumnFilter`,
    :ocv:func:`getMorphologyColumnFilter`
@@ -101,13 +101,13 @@ The class ``BaseFilter`` is a base class for filtering data using 2D kernels. Fi
 
 where
 :math:`F` is a filtering function. The class only defines an interface and is not used directly. Instead, there are several functions in OpenCV (and you can add more) that return pointers to the derived classes that implement specific filtering operations. Those pointers are then passed to the
-:ocv:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
+:ocv:class:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
 
 .. seealso::
 
-    :ocv:func:`BaseColumnFilter`,
-    :ocv:func:`BaseRowFilter`,
-    :ocv:func:`FilterEngine`,
+    :ocv:class:`BaseColumnFilter`,
+    :ocv:class:`BaseRowFilter`,
+    :ocv:class:`FilterEngine`,
     :ocv:func:`getLinearFilter`,
     :ocv:func:`getMorphologyFilter`
 
@@ -143,13 +143,13 @@ The class ``BaseRowFilter`` is a base class for filtering data using single-row
 
 where
 :math:`F` is a filtering function. The class only defines an interface and is not used directly. Instead, there are several functions in OpenCV (and you can add more) that return pointers to the derived classes that implement specific filtering operations. Those pointers are then passed to the
-:ocv:func:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
+:ocv:class:`FilterEngine` constructor. While the filtering operation interface uses the ``uchar`` type, a particular implementation is not limited to 8-bit data.
 
 .. seealso::
 
-    :ocv:func:`BaseColumnFilter`,
+    :ocv:class:`BaseColumnFilter`,
     :ocv:func:`Filter`,
-    :ocv:func:`FilterEngine`,
+    :ocv:class:`FilterEngine`,
     :ocv:func:`getLinearRowFilter`,
     :ocv:func:`getMorphologyRowFilter`,
     :ocv:func:`getRowSumFilter`
@@ -347,7 +347,7 @@ Unlike the earlier versions of OpenCV, now the filtering operations fully suppor
 
 
 Explore the data types. As it was mentioned in the
-:ocv:func:`BaseFilter` description, the specific filters can process data of any type, despite that ``Base*Filter::operator()`` only takes ``uchar`` pointers and no information about the actual types. To make it all work, the following rules are used:
+:ocv:class:`BaseFilter` description, the specific filters can process data of any type, despite that ``Base*Filter::operator()`` only takes ``uchar`` pointers and no information about the actual types. To make it all work, the following rules are used:
 
 *
     In case of separable filtering, ``FilterEngine::rowFilter``   is  applied first. It transforms the input image data (of type ``srcType``  ) to the intermediate results stored in the internal buffers (of type ``bufType``   ). Then, these intermediate results are processed as
@@ -359,9 +359,9 @@ Explore the data types. As it was mentioned in the
 
 .. seealso::
 
-   :ocv:func:`BaseColumnFilter`,
-   :ocv:func:`BaseFilter`,
-   :ocv:func:`BaseRowFilter`,
+   :ocv:class:`BaseColumnFilter`,
+   :ocv:class:`BaseFilter`,
+   :ocv:class:`BaseRowFilter`,
    :ocv:func:`createBoxFilter`,
    :ocv:func:`createDerivFilter`,
    :ocv:func:`createGaussianFilter`,
@@ -457,12 +457,12 @@ The function computes and returns the coordinate of a donor pixel corresponding
 
 
 Normally, the function is not called directly. It is used inside
-:ocv:func:`FilterEngine` and
+:ocv:class:`FilterEngine` and
 :ocv:func:`copyMakeBorder` to compute tables for quick extrapolation.
 
 .. seealso::
 
-    :ocv:func:`FilterEngine`,
+    :ocv:class:`FilterEngine`,
     :ocv:func:`copyMakeBorder`
 
 
@@ -558,7 +558,7 @@ Forms a border around an image.
     :param value: Border value if  ``borderType==BORDER_CONSTANT`` .
     
 The function copies the source image into the middle of the destination image. The areas to the left, to the right, above and below the copied source image will be filled with extrapolated pixels. This is not what
-:ocv:func:`FilterEngine` or filtering functions based on it do (they extrapolate pixels on-fly), but what other more complex functions, including your own, may do to simplify image boundary handling.
+:ocv:class:`FilterEngine` or filtering functions based on it do (they extrapolate pixels on-fly), but what other more complex functions, including your own, may do to simplify image boundary handling.
 
 The function supports the mode when ``src`` is already in the middle of ``dst`` . In this case, the function does not copy ``src`` itself but simply constructs the border, for example: ::
 
@@ -611,7 +611,7 @@ Returns a box filter engine.
 The function is a convenience function that retrieves the horizontal sum primitive filter with
 :ocv:func:`getRowSumFilter` , vertical sum filter with
 :ocv:func:`getColumnSumFilter` , constructs new
-:ocv:func:`FilterEngine` , and passes both of the primitive filters there. The constructed filter engine can be used for image filtering with normalized or unnormalized box filter.
+:ocv:class:`FilterEngine` , and passes both of the primitive filters there. The constructed filter engine can be used for image filtering with normalized or unnormalized box filter.
 
 The function itself is used by
 :ocv:func:`blur` and
@@ -619,7 +619,7 @@ The function itself is used by
 
 .. seealso::
 
-    :ocv:func:`FilterEngine`,
+    :ocv:class:`FilterEngine`,
     :ocv:func:`blur`,
     :ocv:func:`boxFilter` 
 
@@ -714,12 +714,12 @@ Creates a non-separable linear filter engine.
     :param borderValue: Border vaule used in case of a constant border.
 
 The function returns a pointer to a 2D linear filter for the specified kernel, the source array type, and the destination array type. The function is a higher-level function that calls ``getLinearFilter`` and passes the retrieved 2D filter to the
-:ocv:func:`FilterEngine` constructor.
+:ocv:class:`FilterEngine` constructor.
 
 .. seealso::
 
     :ocv:func:`createSeparableLinearFilter`,
-    :ocv:func:`FilterEngine`,
+    :ocv:class:`FilterEngine`,
     :ocv:func:`filter2D`
 
 
@@ -766,7 +766,7 @@ Note that
     :ocv:func:`erode`,
     :ocv:func:`dilate`,
     :ocv:func:`morphologyEx`,
-    :ocv:func:`FilterEngine`
+    :ocv:class:`FilterEngine`
 
 
 createSeparableLinearFilter
@@ -807,13 +807,13 @@ The functions construct primitive separable linear filtering operations or a fil
 :ocv:func:`createSeparableLinearFilter` or even higher-level
 :ocv:func:`sepFilter2D` . The function
 :ocv:func:`createMorphologyFilter` is smart enough to figure out the ``symmetryType`` for each of the two kernels, the intermediate ``bufType``  and, if filtering can be done in integer arithmetics, the number of ``bits`` to encode the filter coefficients. If it does not work for you, it is possible to call ``getLinearColumnFilter``,``getLinearRowFilter`` directly and then pass them to the
-:ocv:func:`FilterEngine` constructor.
+:ocv:class:`FilterEngine` constructor.
 
 .. seealso::
 
     :ocv:func:`sepFilter2D`,
     :ocv:func:`createLinearFilter`,
-    :ocv:func:`FilterEngine`,
+    :ocv:class:`FilterEngine`,
     :ocv:func:`getKernelType`
 
 
index 13cd9bb..8d85ab8 100644 (file)
@@ -573,39 +573,39 @@ Gaussian Mixture-based Backbround/Foreground Segmentation Algorithm.
 
     Here are important members of the class that control the algorithm, which you can set after constructing the class instance:
 
-    :ocv:member:: nmixtures
+    .. ocv:member:: int nmixtures
     
         Maximum allowed number of mixture comonents. Actual number is determined dynamically per pixel.
 
-    :ocv:member:: backgroundRatio
+    .. ocv:member:: float backgroundRatio
     
         Threshold defining whether the component is significant enough to be included into the background model ( corresponds to ``TB=1-cf`` from the paper??which paper??). ``cf=0.1 => TB=0.9`` is default. For ``alpha=0.001``, it means that the mode should exist for approximately 105 frames before it is considered foreground.
 
-    :ocv:member:: varThresholdGen
+    .. ocv:member:: float varThresholdGen
     
         Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the existing components (corresponds to ``Tg``). If it is not close to any component, a new component is generated. ``3 sigma => Tg=3*3=9`` is default. A smaller ``Tg`` value generates more components. A higher ``Tg`` value may result in a small number of components but they can grow too large.
 
-    :ocv:member:: fVarInit
+    .. ocv:member:: float fVarInit
     
         Initial variance for the newly generated components. It affects the speed of adaptation. The parameter value is based on your estimate of the typical standard deviation from the images. OpenCV uses 15 as a reasonable value.
 
-    :ocv:member::
+    .. ocv:member:: float fVarMin 
     
-        fVarMin Parameter used to further control the variance.
+        Parameter used to further control the variance.
 
-    :ocv:member::
+    .. ocv:member:: float fVarMax
     
-        fVarMax Parameter used to further control the variance.
+        Parameter used to further control the variance.
 
-    :ocv:member:: fCT
+    .. ocv:member:: float fCT
         
         Complexity reduction parameter. This parameter defines the number of samples needed to accept to prove the component exists. ``CT=0.05`` is a default value for all the samples. By setting ``CT=0`` you get an algorithm very similar to the standard Stauffer&Grimson algorithm.
 
-    :param nShadowDetection
+    .. ocv:member:: uchar nShadowDetection
     
         The value for marking shadow pixels in the output foreground mask. Default value is 127.
 
-    :param fTau
+    .. ocv:member:: float fTau
         
         Shadow threshold. The shadow is detected if the pixel is a darker version of the background. ``Tau`` is a threshold defining how much darker the shadow can be. ``Tau= 0.5`` means that if a pixel is more than twice darker then it is not shadow. See Prati,Mikic,Trivedi,Cucchiarra, *Detecting Moving Shadows...*, IEEE PAMI,2003.