Skip to content

Commit

Permalink
doc: Update RST for CV
Browse files Browse the repository at this point in the history
  • Loading branch information
e10harvey committed Nov 27, 2024
1 parent ca03e12 commit 90bd352
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,4 @@ These are the book keeping classes that enable the spot analysis pipeline.
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: bysource

.. automodule:: opencsp.common.lib.cv.CacheableImage
:members:
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: groupwise
:member-order: bysource
95 changes: 95 additions & 0 deletions doc/source/library_reference/common/lib/cv/config.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
Base Classes
============

.. currentmodule:: opencsp.common.lib.cv.CacheableImage

.. automodule:: opencsp.common.lib.cv.CacheableImage
:members:
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: groupwise

.. currentmodule:: opencsp.common.lib.cv.OpticalFlow

.. automodule:: opencsp.common.lib.cv.OpticalFlow
:members:
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: groupwise

Utility Functions
=================

.. currentmodule:: opencsp.common.lib.cv.image_filters

.. automodule:: opencsp.common.lib.cv.image_filters
:members:
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: groupwise

.. currentmodule:: opencsp.common.lib.cv.image_reshapers

.. automodule:: opencsp.common.lib.cv.image_reshapers
:members:
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: groupwise

Annotations
===========

.. currentmodule:: opencsp.common.lib.cv.annotations.AbstractAnnotations

.. automodule:: opencsp.common.lib.cv.annotations.AbstractAnnotations
:members:
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: groupwise

.. currentmodule:: opencsp.common.lib.cv.annotations.HotspotAnnotation

.. automodule:: opencsp.common.lib.cv.annotations.HotspotAnnotation
:members:
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: groupwise

.. currentmodule:: opencsp.common.lib.cv.annotations.PointAnnotations

.. automodule:: opencsp.common.lib.cv.annotations.PointAnnotations
:members:
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: groupwise

Fiducials
=========

.. automodule:: opencsp.common.lib.cv.fiducials.AbstractFiducials
:members:
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: groupwise

.. automodule:: opencsp.common.lib.cv.fiducials.BcsFiducial
:members:
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: groupwise

.. automodule:: opencsp.common.lib.cv.fiducials.PointFiducials
:members:
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: groupwise
10 changes: 10 additions & 0 deletions doc/source/library_reference/common/lib/cv/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Computer Vision (CV)
====================

This is a collection of computer vision utilities for OpenCSP.

.. toctree::
:maxdepth: 1

config.rst
SpotAnalysis/index.rst
2 changes: 1 addition & 1 deletion doc/source/library_reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ This section describes the OpenCSP classes and interfaces.
app/target/index.rst
app/camera_calibration/index.rst
app/scene_reconstruction/index.rst
common/lib/cv/SpotAnalysis/index.rst
common/lib/cv/index.rst
22 changes: 8 additions & 14 deletions opencsp/common/lib/cv/OpticalFlow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ class OpticalFlow:
This class wraps around OpenCV's optical flow functions, providing functionality
to compute dense optical flow and manage caching of results.
Attributes
----------
mag : np.ndarray, optional
OpenCSP version of the magnitude matrix.
ang : np.ndarray, optional
OpenCSP version of the angle matrix.
"""

# "ChatGPT 4o-mini" assisted with generating this docstring.
Expand Down Expand Up @@ -98,15 +91,16 @@ def __init__(
Notes
-----
Wrapper class around cv::calcOpticalFlowFarneback (and also cv::calcOpticalFlowPyrLK, eventually).
Wrapper class around cv::calcOpticalFlowFarneback (and also cv::calcOpticalFlowPyrLK, eventually).
opencsp is not compatible with the multiprocessing library on linux. Typical error message::
"global /io/opencv/modules/core/src/parallel_impl.cpp (240) WorkerThread 6: Can't spawn new thread: res = 11"
opencsp is not compatible with the multiprocessing library on linux. Typical error message:
"global /io/opencv/modules/core/src/parallel_impl.cpp (240) WorkerThread 6: Can't spawn new thread: res = 11"
This is due to some sort of bug with how multiprocessing processes and opencv threads interact.
Possible solutions:
- use concurrent.futures.ThreadPoolExecutor
- Loky multiprocessing https://github.com/joblib/loky (I (BGB) couldn't make this one work)
- use concurrent.futures.ThreadPoolExecutor
- Loky multiprocessing https://github.com/joblib/loky (I (BGB) couldn't make this one work)
"""
# "ChatGPT 4o-mini" assisted with generating this docstring.
self._frame1_dir = frame1_dir
Expand All @@ -126,9 +120,9 @@ def __init__(
self._cache = cache

self._mag: np.ndarray = None
""" XY Matrix. The raw magnitude values returned by opencv, one value per pixel in frame1 """
# XY Matrix. The raw magnitude values returned by opencv, one value per pixel in frame1
self._ang: np.ndarray = None
""" XY Matrix. The raw angle values returned by opencv, one value per pixel in frame1 """
# XY Matrix. The raw angle values returned by opencv, one value per pixel in frame1
self.mag: np.ndarray = None
""" XY Matrix. The OpenCSP version of the magnitude matrix, where each value corresponds to a pixel in frame1 and
represents the number of pixels that pixel has moved by frame2. """
Expand Down
1 change: 1 addition & 0 deletions opencsp/common/lib/cv/annotations/AbstractAnnotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class AbstractAnnotations(af.AbstractFiducials):
"""
Annotations are applied to images to mark specific points of interest. Some
examples of annotations might include:
- The hotspot in a beam where light is the brightest
- The power envelope for 90% of the light of a beam
- Distances between two pixels
Expand Down
18 changes: 11 additions & 7 deletions opencsp/common/lib/cv/fiducials/AbstractFiducials.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AbstractFiducials(ABC):
"""
A collection of markers (such as an ArUco board) that is used to orient the camera relative to observed objects
in the scene. It is suggested that each implementing class be paired with a complementary locator method or
SpotAnalysisImageProcessor.
:class:`opencsp.common.lib.cv.spot_analysis.image_processor.AbstractSpotAnalysisImageProcessor`.
"""

def __init__(self, style: rcps.RenderControlPointSeq = None, pixels_to_meters: Callable[[p2.Pxy], v3.Vxyz] = None):
Expand Down Expand Up @@ -88,15 +88,19 @@ def rotation(self) -> scipy.spatial.transform.Rotation:
marker whose origin is in the center of the image and is facing towards the camera could have the rotation
defined as:
Rotation.from_euler('y', np.pi)
.. code-block:: python
Rotation.from_euler('y', np.pi)
If that same ArUco marker was also placed upside down, then its rotation could be defined as:
Rotation.from_euler(
'yz',
[[np.pi, 0],
[0, np.pi]]
)
.. code-block:: python
Rotation.from_euler(
'yz',
[[np.pi, 0],
[0, np.pi]]
)
Note that this just describes rotation, and not the translation. We call the rotation and translation together
the orientation.
Expand Down

0 comments on commit 90bd352

Please sign in to comment.