robotpy-cscore 2025.2.1.2__cp313-cp313-manylinux_2_36_aarch64.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.

cscore/imagewriter.py ADDED
@@ -0,0 +1,146 @@
1
+ import os.path
2
+ import time
3
+ import threading
4
+
5
+ import cv2
6
+ import numpy as np
7
+
8
+ import logging
9
+
10
+ logger = logging.getLogger("cscore.storage")
11
+
12
+
13
+ class ImageWriter:
14
+ """
15
+ Creates a thread that periodically writes images to a specified
16
+ directory. Useful for looking at images after a match has
17
+ completed.
18
+
19
+ The default location is ``/media/sda1/camera``. The folder
20
+ ``/media/sda1`` is the default location that USB drives inserted into
21
+ the RoboRIO are mounted at. The USB drive must have a directory in it
22
+ named ``camera``.
23
+
24
+ .. note:: It is recommended to only write images when something useful
25
+ (such as targeting) is happening, otherwise you'll end up
26
+ with a lot of images written to disk that you probably aren't
27
+ interested in.
28
+
29
+ Intended usage is::
30
+
31
+ self.image_writer = ImageWriter()
32
+
33
+ ..
34
+
35
+ while True:
36
+
37
+ img = ..
38
+
39
+ if self.logging_enabled:
40
+ self.image_writer.setImage(img)
41
+
42
+ """
43
+
44
+ def __init__(
45
+ self,
46
+ *,
47
+ location_root="/media/sda1/camera",
48
+ capture_period=0.5,
49
+ image_format="jpg"
50
+ ):
51
+ """
52
+ :param location_root: Directory to write images to. A subdirectory
53
+ with the current time will be created, and
54
+ timestamped images will be written to the
55
+ subdirectory.
56
+ :param capture_period: How often to write images to disk
57
+ :param image_format: File extension of files to write
58
+ """
59
+
60
+ self.location_root = os.path.abspath(location_root)
61
+ self.capture_period = capture_period
62
+ self.image_format = image_format
63
+
64
+ self.active = True
65
+ self._location = None
66
+ self.has_image = False
67
+ self.size = None
68
+
69
+ self.lock = threading.Condition()
70
+ self._thread = threading.Thread(target=self._run, daemon=True)
71
+ self._thread.start()
72
+
73
+ def setImage(self, img):
74
+ """
75
+ Call this function when you wish to write the image to disk. Not
76
+ every image is written to disk. Makes a copy of the image.
77
+
78
+ :param img: A numpy array representing an OpenCV image
79
+ """
80
+
81
+ if not self.active:
82
+ return
83
+
84
+ if (
85
+ self.size is None
86
+ or self.size[0] != img.shape[0]
87
+ or self.size[1] != img.shape[1]
88
+ ):
89
+ h, w = img.shape[:2]
90
+ self.size = (h, w)
91
+
92
+ self.out1 = np.empty((h, w, 3), dtype=np.uint8)
93
+ self.out2 = np.empty((h, w, 3), dtype=np.uint8)
94
+
95
+ with self.lock:
96
+ cv2.copyMakeBorder(
97
+ img, 0, 0, 0, 0, cv2.BORDER_CONSTANT, value=(0, 0, 255), dst=self.out1
98
+ )
99
+ self.has_image = True
100
+ self.lock.notify()
101
+
102
+ @property
103
+ def location(self):
104
+ if self._location is None:
105
+ # This assures that we only log when a USB memory stick is plugged in
106
+ if not os.path.exists(self.location_root):
107
+ raise IOError(
108
+ "Logging disabled, %s does not exist" % self.location_root
109
+ )
110
+
111
+ # Can't do this when program starts, time might be wrong. Ideally by now the DS
112
+ # has connected, so the time will be correct
113
+ self._location = self.location_root + "/%s" % time.strftime(
114
+ "%Y-%m-%d %H.%M.%S"
115
+ )
116
+ logger.info("Logging to %s", self._location)
117
+ os.makedirs(self._location, exist_ok=True)
118
+
119
+ return self._location
120
+
121
+ def _run(self):
122
+ last = time.time()
123
+
124
+ logger.info("Storage thread started")
125
+
126
+ try:
127
+ while True:
128
+ with self.lock:
129
+ now = time.time()
130
+ while (not self.has_image) or (now - last) < self.capture_period:
131
+ self.lock.wait()
132
+ now = time.time()
133
+
134
+ self.out2, self.out1 = self.out1, self.out2
135
+ self.has_image = False
136
+
137
+ fname = "%s/%.2f.%s" % (self.location, now, self.image_format)
138
+ cv2.imwrite(fname, self.out2)
139
+
140
+ last = now
141
+
142
+ except IOError as e:
143
+ logger.error("Error logging images: %s", e)
144
+
145
+ logger.warn("Storage thread exited")
146
+ self.active = False
cscore/pkgcfg.py ADDED
@@ -0,0 +1,34 @@
1
+ # fmt: off
2
+ # This file is automatically generated, DO NOT EDIT
3
+
4
+ from os.path import abspath, join, dirname
5
+ _root = abspath(dirname(__file__))
6
+
7
+ libinit_import = "cscore._init_cscore"
8
+ depends = ['wpiutil', 'wpinet', 'ntcore']
9
+ pypi_package = 'robotpy-cscore'
10
+
11
+ def get_include_dirs():
12
+ return [join(_root, "include"), join(_root, "rpy-include")]
13
+
14
+ def get_library_dirs():
15
+ return []
16
+
17
+ def get_library_dirs_rel():
18
+ return []
19
+
20
+ def get_library_names():
21
+ return []
22
+
23
+ def get_library_full_names():
24
+ return []
25
+
26
+ def get_type_casters_cfg(casters):
27
+ casters.update({'cv::Mat': {'hdr': 'cvnp/cvnp.h'}})
28
+
29
+ def get_type_casters(casters):
30
+ t = {}
31
+ get_type_casters_cfg(t)
32
+ for k, v in t.items():
33
+ if "hdr" in v:
34
+ casters[k] = v["hdr"]
cscore/py.typed ADDED
File without changes
cscore/src/main.cpp ADDED
@@ -0,0 +1,29 @@
1
+
2
+ #include <rpygen_wrapper.hpp>
3
+
4
+ #include "cscore_cpp.h"
5
+
6
+ #ifdef __FRC_ROBORIO__
7
+ extern "C" {
8
+ void WPI_Impl_SetupNowUseDefaultOnRio(void);
9
+ }
10
+ #endif
11
+
12
+ RPYBUILD_PYBIND11_MODULE(m) {
13
+ initWrapper(m);
14
+
15
+ static int unused; // the capsule needs something to reference
16
+ py::capsule cleanup(&unused, [](void *) {
17
+ // don't release gil until after calling this
18
+ cs::SetDefaultLogger(20 /* WPI_LOG_INFO */);
19
+
20
+ // but this MUST release the gil, or deadlock may occur
21
+ py::gil_scoped_release __release;
22
+ CS_Shutdown();
23
+ });
24
+ m.add_object("_cleanup", cleanup);
25
+
26
+ #ifdef __FRC_ROBORIO__
27
+ m.def("_setupWpiNow", WPI_Impl_SetupNowUseDefaultOnRio);
28
+ #endif
29
+ }
cscore/version.py ADDED
@@ -0,0 +1,4 @@
1
+ # file generated by setuptools_scm
2
+ # don't change, don't track in version control
3
+ __version__ = version = '2025.2.1.2'
4
+ __version_tuple__ = version_tuple = (2025, 2, 1, 2)
@@ -0,0 +1,51 @@
1
+
2
+ Copyright (c) 2017 Dustin Spicuzza
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ * Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ * Neither the name of RobotPy nor the
12
+ names of its contributors may be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY ROBOTPY AND CONTRIBUTORS``AS IS'' AND ANY
16
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR
18
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ROBOTPY OR CONTRIBUTORS BE LIABLE FOR
19
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ Code for for cscore and other FIRST libraries use the following license:
27
+
28
+ * Copyright (c) 2016 FIRST
29
+ * All rights reserved.
30
+ *
31
+ * Redistribution and use in source and binary forms, with or without
32
+ * modification, are permitted provided that the following conditions are met:
33
+ * * Redistributions of source code must retain the above copyright
34
+ * notice, this list of conditions and the following disclaimer.
35
+ * * Redistributions in binary form must reproduce the above copyright
36
+ * notice, this list of conditions and the following disclaimer in the
37
+ * documentation and/or other materials provided with the distribution.
38
+ * * Neither the name of the FIRST nor the
39
+ * names of its contributors may be used to endorse or promote products
40
+ * derived from this software without specific prior written permission.
41
+ *
42
+ * THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' AND ANY
43
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
44
+ * WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR
45
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR
46
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
47
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
51
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.2
2
+ Name: robotpy-cscore
3
+ Version: 2025.2.1.2
4
+ Summary: RobotPy bindings for cscore image processing library
5
+ Home-page: https://github.com/robotpy/robotpy-cscore
6
+ Author: RobotPy Development Team
7
+ Author-email: robotpy@googlegroups.com
8
+ License: BSD-3-Clause
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/x-rst
11
+ License-File: LICENSE
12
+ Requires-Dist: robotpy-wpiutil==2025.2.1.2
13
+ Requires-Dist: robotpy-wpinet==2025.2.1.2
14
+ Requires-Dist: pyntcore==2025.2.1.2
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: license
21
+ Dynamic: requires-dist
22
+ Dynamic: requires-python
23
+ Dynamic: summary
24
+
25
+ robotpy-cscore
26
+ ==============
27
+
28
+ These are python bindings for the cscore library, which is a high performance
29
+ library used in the FIRST Robotics competition to serve video to/from robots.
30
+ However, the core library is suitable for use in other applications, and is
31
+ comparable to something like mjpg-streamer.
32
+
33
+ This library requires python 3.6+
34
+
35
+ Documentation
36
+ =============
37
+
38
+ * `Installation <http://robotpy.readthedocs.io/en/stable/install/cscore.html>`_
39
+ * `Usage <http://robotpy.readthedocs.io/en/stable/vision/index.html>`_
40
+
41
+ Author
42
+ ======
43
+
44
+ Dustin Spicuzza (dustin@virtualroadside.com)
@@ -0,0 +1,27 @@
1
+ cscore/__init__.py,sha256=tqWBUurlnxvpu_lkDI-E1_or6ylJmcXtwKLkMv9jt6Y,1060
2
+ cscore/__main__.py,sha256=QHhVqR_n-tLu_FX4Gy8eic5cwxyaAS3v0yCDQkcoOAQ,4418
3
+ cscore/_cscore.cpython-313-aarch64-linux-gnu.so,sha256=ABGolrCb7SiddEidOyhqnXZ6YAF2CJ9YsPpNpKS3O2E,23102920
4
+ cscore/_cscore.pyi,sha256=setYtaknMo2U1tYA4_JO0zTbmZR_0V5PRtDS7MyRsdc,57612
5
+ cscore/_init_cscore.py,sha256=lCGwXmghwSNK5TZwOSgJlqSDthxu6TIpUrpqc0xlpvs,257
6
+ cscore/_logging.py,sha256=FBz3zqXozXiMVB27nXH_65gN9eziUyrhso9pQhcIBdw,321
7
+ cscore/grip.py,sha256=CG4yAHNzAn1JbXoChKO_wblbnNoAuDDaLA9ipp0Tclo,1001
8
+ cscore/imagewriter.py,sha256=ClQvVMXiAVPSz_xh26KwkBzhsM3TpZWi8ZJy5ZbtYhM,4391
9
+ cscore/pkgcfg.py,sha256=ogl4qspR8kqCP6pwd1Bt9b-VoNO-XhkzDrk9ltgm3IM,758
10
+ cscore/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ cscore/version.py,sha256=bfIC59YG8V1ONDlwdzTBhR3MmYCOcKOkrhFetI7YP5Y,171
12
+ cscore/__pycache__/__init__.cpython-313.pyc,sha256=pxfWnj5m0A6-lm2BZCtJ_jq7N2HZ8XaeSLUA81w4fAU,1030
13
+ cscore/__pycache__/_init_cscore.cpython-313.pyc,sha256=1WcUoRsqCuBZodLtyyUItOjARJ4e4xIu_CBCE_1E_8c,493
14
+ cscore/__pycache__/_logging.cpython-313.pyc,sha256=23wlhxQV1bYbiCOwCfIJ56XFyrSnMTwmw_Iy0X5Y0QU,903
15
+ cscore/__pycache__/version.cpython-313.pyc,sha256=IDO5DxEbNqu9WTtcxJ6MCk4Q0IdLHOYLBCatI43Q5EU,332
16
+ cscore/cvnp/README.md,sha256=tjM2hm7INpdQZRPHRmpxTPj23-k4vkGbTlbaBTunN1Q,1164
17
+ cscore/cvnp/cvnp.cpp,sha256=9q5YWv53QyG5pRcOyJCOMEFQJSsUeYRklfgLi9amELU,8974
18
+ cscore/cvnp/cvnp.h,sha256=YgTLCL73KZU3kNUBDUxxYie_kP9nMniMPkNnBrTgPwU,14503
19
+ cscore/cvnp/cvnp_synonyms.cpp,sha256=CdsCtg3Vpl7-kpjpPONhPvsa_9giTvns_xTgtnby4WQ,2350
20
+ cscore/cvnp/cvnp_synonyms.h,sha256=g1oNmv1OTA3TXgg_54JqAwCg43slzenrAet3M-ipEv4,565
21
+ cscore/src/main.cpp,sha256=oHhDGPhuktjHGjCLMalqYWiRXmwwtXG9mXS5pq4NTC8,709
22
+ robotpy_cscore-2025.2.1.2.dist-info/LICENSE,sha256=sH4JB8OjTOdUoAPcybggUhhjphTHQWR9M8uoT3v8u5w,3087
23
+ robotpy_cscore-2025.2.1.2.dist-info/METADATA,sha256=xBtd5xvCa1KuqZWJK_A3unQoQD5V_OMLWGpFC-7cHxI,1255
24
+ robotpy_cscore-2025.2.1.2.dist-info/WHEEL,sha256=5fO2GCWuspngZ9FJWukgP4rtx2QqAWw9fydknItou34,105
25
+ robotpy_cscore-2025.2.1.2.dist-info/entry_points.txt,sha256=ZOi1FKkpTmx8xBqUtdp6Z4IzoCKfwDOKJoVDAF9qjhE,38
26
+ robotpy_cscore-2025.2.1.2.dist-info/top_level.txt,sha256=yKRnfRQe07G2XO6XXYgsj9CN2obAQX3D3gsGvcewpVw,7
27
+ robotpy_cscore-2025.2.1.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.8.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-linux_aarch64
5
+
@@ -0,0 +1,2 @@
1
+ [robotpybuild]
2
+ cscore = cscore.pkgcfg
@@ -0,0 +1 @@
1
+ cscore