Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #57 from robotpy/updates
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
virtuald committed Jan 12, 2019
2 parents 64dbe28 + efb1b91 commit 2590274
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gittrack
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
validation_root = cscore
exclude_commits_file = .gittrackexclude
upstream_root = ../allwpilib/cameraserver/src/main/java
upstream_commit = 6105873cbea6dadf3c7f6a3339a682d913a736dc
upstream_commit = 05d6660a6be0d37064a9fab44232b8379884ccab

16 changes: 11 additions & 5 deletions cscore/cameraserver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# validated: 2018-12-30 DS 0d7d880261b6 edu/wpi/first/cameraserver/CameraServer.java
# validated: 2019-01-12 DS fdf298b17243 edu/wpi/first/cameraserver/CameraServer.java
# ----------------------------------------------------------------------------
# Copyright (c) 2016-2018 FIRST. All Rights Reserved.
# Open Source Software - may be modified and shared by FRC teams. The code
Expand Down Expand Up @@ -389,7 +389,9 @@ def _onTableChange(self, event):
elif prop.isString():
self._nt.putString(key, prop.getString())

def startAutomaticCapture(self, *, dev=None, name=None, path=None, camera=None):
def startAutomaticCapture(
self, *, dev=None, name=None, path=None, camera=None, return_server=False
):
"""Start automatically capturing images to send to the dashboard.
You should call this method to see a camera feed on the dashboard.
Expand All @@ -400,9 +402,10 @@ def startAutomaticCapture(self, *, dev=None, name=None, path=None, camera=None):
:param name: If specified, the name to use for the camera (dev must be specified)
:param path: If specified, device path (e.g. "/dev/video0") of the camera
:param camera: If specified, an existing camera object to use
:param return_server: If specified, return the server instead of the camera
:returns: USB Camera object, or the camera argument
:rtype: :class:`cscore.VideoSource` object
:returns: USB Camera object, or the camera argument, or the created server
:rtype: :class:`cscore.VideoSource` or :class:`cscore.VideoSink`
The following argument combinations are accepted -- all argument must be specified
as keyword arguments:
Expand Down Expand Up @@ -451,7 +454,10 @@ def startAutomaticCapture(self, *, dev=None, name=None, path=None, camera=None):
server = self.addServer(name="serve_" + camera.getName())
server.setSource(camera)

return camera
if return_server:
return server
else:
return camera

def addAxisCamera(self, host, name="Axis Camera"):
"""Adds an Axis IP camera.
Expand Down
36 changes: 36 additions & 0 deletions docs/objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,14 @@ VideoSink
:returns: list of sinks.


.. py:method:: VideoSink.getConfigJson() -> str
:module: cscore

Get a JSON configuration string.

:returns: JSON configuration string


.. py:method:: VideoSink.getDescription() -> str
:module: cscore

Expand Down Expand Up @@ -952,6 +960,26 @@ VideoSink
:returns: Property (VideoSink.Kind.kNone if no property with the given name exists or no source connected)


.. py:method:: VideoSink.setConfigJson(config: str) -> bool
:module: cscore

Set properties from a JSON configuration string.

The format of the JSON input is::
{
"properties": [
{
"name": "property name",
"value": "property value"
}
]
}
:param config: configuration
:returns: True if set successfully


.. py:method:: VideoSink.setSource(source: cscore.VideoSource) -> None
:module: cscore

Expand Down Expand Up @@ -1197,6 +1225,10 @@ VideoSource
Utility functions
-----------------

.. py:function:: getHttpCameraUrls(arg0: int) -> List[str]
:module: cscore


.. py:function:: getNetworkInterfaces() -> List[str]
:module: cscore

Expand All @@ -1205,6 +1237,10 @@ Utility functions
:module: cscore


.. py:function:: getUsbCameraPath(arg0: int) -> str
:module: cscore


.. py:function:: setLogger(func: Callable[[int, str, int, str], None], min_level: int) -> None
:module: cscore

Expand Down
19 changes: 19 additions & 0 deletions src/_cscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,25 @@ PYBIND11_MODULE(_cscore, m) {
":returns: Property contents (VideoSource.Kind.kNone if no property with the given name exists)")
.def("enumerateProperties", &VideoSink::EnumerateProperties, release_gil(),
"Enumerate all properties of this sink")
.def("setConfigJson", [](VideoSink &__inst, wpi::StringRef config) {
py::gil_scoped_release __release;
return __inst.SetConfigJson(config);
}, py::arg("config"),
"Set properties from a JSON configuration string.\n\n"
"The format of the JSON input is::\n\n"
" {\n"
" \"properties\": [\n"
" {\n"
" \"name\": \"property name\",\n"
" \"value\": \"property value\"\n"
" }\n"
" ]\n"
" }\n\n"
":param config: configuration\n"
":returns: True if set successfully")
.def("getConfigJson", &VideoSink::GetConfigJson, release_gil(),
"Get a JSON configuration string.\n\n"
":returns: JSON configuration string\n")
.def("setSource", &VideoSink::SetSource, release_gil(),
py::arg("source"),
"Configure which source should provide frames to this sink. Each sink "
Expand Down

0 comments on commit 2590274

Please sign in to comment.