robotpy-cscore 2026.1.1__cp312-cp312-macosx_13_0_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. cscore/__init__.py +59 -0
  2. cscore/__main__.py +170 -0
  3. cscore/_cscore.cpython-312-darwin.so +0 -0
  4. cscore/_cscore.pyi +1657 -0
  5. cscore/_init__cscore.py +6 -0
  6. cscore/_logging.py +12 -0
  7. cscore/cscore-casters.pc +8 -0
  8. cscore/cscore-casters.pybind11.json +1 -0
  9. cscore/cscore.pc +10 -0
  10. cscore/cvnp/README.md +11 -0
  11. cscore/cvnp/cvnp.cpp +242 -0
  12. cscore/cvnp/cvnp.h +434 -0
  13. cscore/cvnp/cvnp_synonyms.cpp +70 -0
  14. cscore/cvnp/cvnp_synonyms.h +25 -0
  15. cscore/grip.py +41 -0
  16. cscore/imagewriter.py +146 -0
  17. cscore/py.typed +0 -0
  18. cscore/src/main.cpp +29 -0
  19. cscore/trampolines/cs__AxisCamera.hpp +9 -0
  20. cscore/trampolines/cs__CvSink.hpp +13 -0
  21. cscore/trampolines/cs__CvSource.hpp +13 -0
  22. cscore/trampolines/cs__HttpCamera.hpp +9 -0
  23. cscore/trampolines/cs__ImageSink.hpp +9 -0
  24. cscore/trampolines/cs__ImageSource.hpp +9 -0
  25. cscore/trampolines/cs__MjpegServer.hpp +9 -0
  26. cscore/trampolines/cs__RawEvent.hpp +9 -0
  27. cscore/trampolines/cs__UsbCamera.hpp +9 -0
  28. cscore/trampolines/cs__UsbCameraInfo.hpp +9 -0
  29. cscore/trampolines/cs__VideoCamera.hpp +9 -0
  30. cscore/trampolines/cs__VideoEvent.hpp +9 -0
  31. cscore/trampolines/cs__VideoListener.hpp +9 -0
  32. cscore/trampolines/cs__VideoMode.hpp +9 -0
  33. cscore/trampolines/cs__VideoProperty.hpp +9 -0
  34. cscore/trampolines/cs__VideoSink.hpp +9 -0
  35. cscore/trampolines/cs__VideoSource.hpp +9 -0
  36. cscore/trampolines/frc__CameraServer.hpp +12 -0
  37. cscore/version.py +3 -0
  38. robotpy_cscore-2026.1.1.dist-info/METADATA +11 -0
  39. robotpy_cscore-2026.1.1.dist-info/RECORD +42 -0
  40. robotpy_cscore-2026.1.1.dist-info/WHEEL +4 -0
  41. robotpy_cscore-2026.1.1.dist-info/entry_points.txt +3 -0
  42. robotpy_cscore-2026.1.1.dist-info/licenses/LICENSE +51 -0
cscore/__init__.py ADDED
@@ -0,0 +1,59 @@
1
+ from . import _init__cscore
2
+
3
+ # autogenerated by 'semiwrap create-imports cscore cscore._cscore'
4
+ from ._cscore import (
5
+ AxisCamera,
6
+ CameraServer,
7
+ CvSink,
8
+ CvSource,
9
+ HttpCamera,
10
+ ImageSink,
11
+ ImageSource,
12
+ MjpegServer,
13
+ RawEvent,
14
+ UsbCamera,
15
+ UsbCameraInfo,
16
+ VideoCamera,
17
+ VideoEvent,
18
+ VideoListener,
19
+ VideoMode,
20
+ VideoProperty,
21
+ VideoSink,
22
+ VideoSource,
23
+ runMainRunLoop,
24
+ runMainRunLoopTimeout,
25
+ stopMainRunLoop,
26
+ )
27
+
28
+ __all__ = [
29
+ "AxisCamera",
30
+ "CameraServer",
31
+ "CvSink",
32
+ "CvSource",
33
+ "HttpCamera",
34
+ "ImageSink",
35
+ "ImageSource",
36
+ "MjpegServer",
37
+ "RawEvent",
38
+ "UsbCamera",
39
+ "UsbCameraInfo",
40
+ "VideoCamera",
41
+ "VideoEvent",
42
+ "VideoListener",
43
+ "VideoMode",
44
+ "VideoProperty",
45
+ "VideoSink",
46
+ "VideoSource",
47
+ "runMainRunLoop",
48
+ "runMainRunLoopTimeout",
49
+ "stopMainRunLoop",
50
+ ]
51
+
52
+ from ._logging import enableLogging
53
+
54
+ __all__.append("enableLogging")
55
+
56
+ try:
57
+ from .version import __version__
58
+ except ImportError:
59
+ __version__ = "master"
cscore/__main__.py ADDED
@@ -0,0 +1,170 @@
1
+ import argparse
2
+ import importlib.machinery
3
+ import os
4
+ import logging
5
+ from os.path import abspath, basename, dirname, splitext
6
+ import stat
7
+ import sys
8
+ import threading
9
+
10
+ from ntcore import NetworkTableInstance
11
+
12
+ log_datefmt = "%H:%M:%S"
13
+ log_format = "%(asctime)s:%(msecs)03d %(levelname)-8s: %(name)-20s: %(message)s"
14
+
15
+ logger = logging.getLogger("cscore")
16
+
17
+
18
+ def _parent_poll_thread() -> None:
19
+ """Kills process if input disappears"""
20
+ from ._cscore import stopMainRunLoop
21
+
22
+ try:
23
+ while True:
24
+ if not sys.stdin.read():
25
+ break
26
+ except Exception:
27
+ pass
28
+
29
+ stopMainRunLoop()
30
+
31
+
32
+ def _run_user_thread(vision_py: str, vision_fn: str) -> None:
33
+ vision_pymod = splitext(basename(vision_py))[0]
34
+
35
+ logger.info("Loading %s (%s)", vision_py, vision_fn)
36
+
37
+ sys.path.insert(0, dirname(vision_py))
38
+
39
+ loader = importlib.machinery.SourceFileLoader(vision_pymod, vision_py)
40
+ vision_module = loader.load_module(vision_pymod)
41
+
42
+ try:
43
+ obj = getattr(vision_module, vision_fn)
44
+
45
+ # If the object has a 'process' function, then we assume
46
+ # that it is a GRIP-generated pipeline, so launch it via the
47
+ # GRIP shim
48
+ if hasattr(obj, "process"):
49
+ logger.info("-> Detected GRIP-compatible object")
50
+
51
+ from . import grip
52
+
53
+ grip.run(obj)
54
+ else:
55
+ # otherwise just call it
56
+ obj()
57
+
58
+ except Exception:
59
+ logger.exception("%s exited unexpectedly", vision_py)
60
+ finally:
61
+ logger.warning("%s exited", vision_py)
62
+
63
+ from ._cscore import stopMainRunLoop
64
+
65
+ stopMainRunLoop()
66
+
67
+
68
+ def main():
69
+ parser = argparse.ArgumentParser()
70
+
71
+ parser.add_argument(
72
+ "-v",
73
+ "--verbose",
74
+ action="store_true",
75
+ default=False,
76
+ help="Enable debug logging",
77
+ )
78
+ nt_server_group = parser.add_mutually_exclusive_group()
79
+ nt_server_group.add_argument(
80
+ "--robot", help="Robot's IP address", default="127.0.0.1"
81
+ )
82
+ nt_server_group.add_argument(
83
+ "--team", help="Team number to specify robot", type=int
84
+ )
85
+ parser.add_argument(
86
+ "--nt-protocol",
87
+ choices=[3, 4],
88
+ type=int,
89
+ help="NetworkTables protocol",
90
+ default=4,
91
+ )
92
+ parser.add_argument(
93
+ "--nt-identity", default="cscore", help="NetworkTables identity"
94
+ )
95
+ parser.add_argument(
96
+ "vision_py",
97
+ nargs="?",
98
+ help="A string indicating the filename and object/function to call"
99
+ " (ex: vision.py:main)",
100
+ )
101
+
102
+ args = parser.parse_args()
103
+
104
+ # initialize logging first
105
+ log_level = logging.DEBUG if args.verbose else logging.INFO
106
+
107
+ logging.basicConfig(datefmt=log_datefmt, format=log_format, level=log_level)
108
+
109
+ # Enable cscore python logging
110
+ from ._logging import enableLogging
111
+
112
+ enableLogging(level=log_level)
113
+
114
+ # Initialize NetworkTables next
115
+ ntinst = NetworkTableInstance.getDefault()
116
+ if args.team:
117
+ ntinst.setServerTeam(args.team)
118
+ else:
119
+ ntinst.setServer(args.robot)
120
+
121
+ if args.nt_protocol == 3:
122
+ ntinst.startClient3(args.nt_identity)
123
+ else:
124
+ ntinst.startClient4(args.nt_identity)
125
+
126
+ # If stdin is a pipe, then die when the pipe goes away
127
+ # -> this allows us to detect if a parent process exits
128
+ if stat.S_ISFIFO(os.fstat(0).st_mode):
129
+ t = threading.Thread(target=_parent_poll_thread, name="lifetime", daemon=True)
130
+ t.start()
131
+
132
+ # If no python file specified, then just start the automatic capture
133
+ if args.vision_py is None:
134
+ from ._cscore import CameraServer
135
+
136
+ CameraServer.startAutomaticCapture()
137
+ else:
138
+ s = args.vision_py.split(":", 1)
139
+ vision_py = abspath(s[0])
140
+ vision_fn = "main" if len(s) == 1 else s[1]
141
+
142
+ thread = threading.Thread(
143
+ target=_run_user_thread,
144
+ args=(vision_py, vision_fn),
145
+ name="vision",
146
+ daemon=True,
147
+ )
148
+ thread.start()
149
+
150
+ try:
151
+ from ._cscore import runMainRunLoopTimeout
152
+
153
+ SIGNALED = 2
154
+ while runMainRunLoopTimeout(1) != SIGNALED:
155
+ pass
156
+
157
+ finally:
158
+ logger.warning("cscore exiting")
159
+
160
+
161
+ if __name__ == "__main__":
162
+ # Setup wpi::now on roborio when executed as __main__
163
+ try:
164
+ from ._cscore import _setupWpiNow # type: ignore
165
+
166
+ _setupWpiNow()
167
+ except ImportError:
168
+ pass
169
+
170
+ main()
Binary file