Skip to content

Commit 30d8b1d

Browse files
authored
Update python cscore/cameraserver documentation to be clearer about install (#2625)
- Fixes #2624
1 parent d5db5cb commit 30d8b1d

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

source/docs/software/vision-processing/roborio/using-multiple-cameras.rst

+26
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ If you're interested in just switching what the driver sees, and are using Smart
6868
.. tab-item:: PYTHON
6969
:sync: tabcode-python
7070

71+
.. note:: Python requires you to place your image processing code in a separate file from your robot code. You can create ``robot.py`` and ``vision.py`` in the same directory.
72+
7173
``robot.py`` contents:
7274

7375
.. code-block:: python
@@ -103,6 +105,17 @@ If you're interested in just switching what the driver sees, and are using Smart
103105
104106
CameraServer.waitForever()
105107
108+
``pyproject.toml`` contents (this only shows the portions you need to update):
109+
110+
.. code-block:: toml
111+
112+
[tool.robotpy]
113+
114+
...
115+
116+
# Add cscore to the robotpy-extras list
117+
robotpy_extras = ["cscore"]
118+
106119
If you're using some other dashboard, you can change the camera used by the camera server dynamically. If you open a stream viewer nominally to camera1, the robot code will change the stream contents to either camera1 or camera2 based on the joystick trigger.
107120

108121
.. tab-set-code::
@@ -232,6 +245,8 @@ By default, the cscore library is pretty aggressive in turning off cameras not i
232245
.. tab-item:: PYTHON
233246
:sync: tabcode-python
234247

248+
.. note:: Python requires you to place your image processing code in a separate file from your robot code. You can create ``robot.py`` and ``vision.py`` in the same directory.
249+
235250
``robot.py`` contents:
236251

237252
.. code-block:: python
@@ -270,6 +285,17 @@ By default, the cscore library is pretty aggressive in turning off cameras not i
270285
271286
CameraServer.waitForever()
272287
288+
``pyproject.toml`` contents (this only shows the portions you need to update):
289+
290+
.. code-block:: toml
291+
292+
[tool.robotpy]
293+
294+
...
295+
296+
# Add cscore to the robotpy-extras list
297+
robotpy_extras = ["cscore"]
298+
273299
.. note::
274300
If both cameras are USB, you may run into USB bandwidth limitations with higher resolutions, as in all of these cases the roboRIO is going to be streaming data from both cameras to the roboRIO simultaneously (for a short period in options 1 and 2, and continuously in option 3). It is theoretically possible for the library to avoid this simultaneity in the option 2 case (only), but this is not currently implemented.
275301

source/docs/software/vision-processing/roborio/using-the-cameraserver-on-the-roborio.rst

+13-1
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ In the following example a thread created in robotInit() gets the Camera Server
6464

6565
This introduces a number of rules that your image processing code must follow to efficiently and safely run on the RoboRIO:
6666

67-
* Your image processing code must be in its own file
67+
* Your image processing code must be in its own file. It's easiest to just place it next to your ``robot.py``
6868
* Never import the ``cscore`` package from your robot code, it will just waste memory
6969
* Never import the ``wpilib`` or ``hal`` packages from your image processing file
7070
* The camera code will be killed when the ``robot.py`` program exits. If you wish to perform cleanup, you should register an atexit handler.
71+
* ``robotpy-cscore`` is not installed on the roboRIO by default, you need to update your ``pyproject.toml`` file to install it
7172

7273
.. warning:: ``wpilib`` may not be imported from two programs on the RoboRIO. If this happens, the second program will attempt to kill the first program.
7374

@@ -85,4 +86,15 @@ In the following example a thread created in robotInit() gets the Camera Server
8586
:lines: 12-55
8687
:linenos:
8788

89+
You need to update ``pyproject.toml`` contents to include cscore in the robotpy-extras key (this only shows the portions you need to update):
90+
91+
.. code-block:: toml
92+
93+
[tool.robotpy]
94+
95+
...
96+
97+
# Add cscore to the robotpy-extras list
98+
robotpy_extras = ["cscore"]
99+
88100
Notice that in these examples, the ``PutVideo()`` method writes the video to a named stream. To view that stream on SmartDashboard or Shuffleboard, select that named stream. In this case that is "Rectangle".

source/docs/yearly-overview/known-issues.rst

+13
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,19 @@ Issues with WPILib Dashboards and Simulation on Windows N Editions
155155

156156
**Solution:** Install the `Media Feature Pack <https://www.microsoft.com/en-us/software-download/mediafeaturepack>`__
157157

158+
Python - CameraServer/cscore runs out of memory on roboRIO 1
159+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
160+
161+
**Issue:** When using CameraServer on a roboRIO 1, the image processing program will sometimes exit with a ``SIGABRT`` or "Error code 6" or a ``MemoryError``.
162+
163+
**Solution:** You may be able to workaround this issue by disabling the NI webserver using the following robotpy-installer command:
164+
165+
.. code-block:: shell
166+
167+
python -m robotpy installer niweb disable
168+
169+
.. seealso:: `Github issue <https://github.com/robotpy/mostrobotpy/issues/61>`__
170+
158171
Fixed in WPILib 2024.2.1
159172
------------------------
160173

0 commit comments

Comments
 (0)