robotpy-cscore 2027.0.0a3__cp314-cp314-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.

Potentially problematic release.


This version of robotpy-cscore might be problematic. Click here for more details.

Files changed (42) hide show
  1. cscore/__init__.py +59 -0
  2. cscore/__main__.py +152 -0
  3. cscore/_cscore.cpython-314-darwin.so +0 -0
  4. cscore/_cscore.pyi +1615 -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 +19 -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-2027.0.0a3.dist-info/METADATA +11 -0
  39. robotpy_cscore-2027.0.0a3.dist-info/RECORD +42 -0
  40. robotpy_cscore-2027.0.0a3.dist-info/WHEEL +4 -0
  41. robotpy_cscore-2027.0.0a3.dist-info/entry_points.txt +3 -0
  42. robotpy_cscore-2027.0.0a3.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,152 @@
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-identity", default="cscore", help="NetworkTables identity"
87
+ )
88
+ parser.add_argument(
89
+ "vision_py",
90
+ nargs="?",
91
+ help="A string indicating the filename and object/function to call"
92
+ " (ex: vision.py:main)",
93
+ )
94
+
95
+ args = parser.parse_args()
96
+
97
+ # initialize logging first
98
+ log_level = logging.DEBUG if args.verbose else logging.INFO
99
+
100
+ logging.basicConfig(datefmt=log_datefmt, format=log_format, level=log_level)
101
+
102
+ # Enable cscore python logging
103
+ from ._logging import enableLogging
104
+
105
+ enableLogging(level=log_level)
106
+
107
+ # Initialize NetworkTables next
108
+ ntinst = NetworkTableInstance.getDefault()
109
+ if args.team:
110
+ ntinst.setServerTeam(args.team)
111
+ else:
112
+ ntinst.setServer(args.robot)
113
+
114
+ ntinst.startClient(args.nt_identity)
115
+
116
+ # If stdin is a pipe, then die when the pipe goes away
117
+ # -> this allows us to detect if a parent process exits
118
+ if stat.S_ISFIFO(os.fstat(0).st_mode):
119
+ t = threading.Thread(target=_parent_poll_thread, name="lifetime", daemon=True)
120
+ t.start()
121
+
122
+ # If no python file specified, then just start the automatic capture
123
+ if args.vision_py is None:
124
+ from ._cscore import CameraServer
125
+
126
+ CameraServer.startAutomaticCapture()
127
+ else:
128
+ s = args.vision_py.split(":", 1)
129
+ vision_py = abspath(s[0])
130
+ vision_fn = "main" if len(s) == 1 else s[1]
131
+
132
+ thread = threading.Thread(
133
+ target=_run_user_thread,
134
+ args=(vision_py, vision_fn),
135
+ name="vision",
136
+ daemon=True,
137
+ )
138
+ thread.start()
139
+
140
+ try:
141
+ from ._cscore import runMainRunLoopTimeout
142
+
143
+ SIGNALED = 2
144
+ while runMainRunLoopTimeout(1) != SIGNALED:
145
+ pass
146
+
147
+ finally:
148
+ logger.warning("cscore exiting")
149
+
150
+
151
+ if __name__ == "__main__":
152
+ main()
Binary file