Skip to content

Commit 1686bcc

Browse files
authored
Fix Python CameraServer example code errors (#3113)
- Change cs.getVideo() to CameraServer.getVideo() - Change cs.putVideo() to CameraServer.putVideo() - Change cvSink.grabFrame() to sink.grabFrame() - Add input_img initialization before use in both examples - Fix indentation in second example Fixes #2754
1 parent e5ee272 commit 1686bcc

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

source/docs/software/vision-processing/wpilibpi/using-cameraserver.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ The WPILibPi image comes with all the necessary libraries to make your own visio
1313
CameraServer.enableLogging()
1414
camera = CameraServer.startAutomaticCapture()
1515
camera.setResolution(width, height)
16-
sink = cs.getVideo()
16+
sink = CameraServer.getVideo()
17+
input_img = np.zeros(shape=(height, width, 3), dtype=np.uint8)
1718
while True:
18-
time, input_img = cvSink.grabFrame(input_img)
19+
time, input_img = sink.grabFrame(input_img)
1920
if time == 0: # There is an error
2021
continue
2122
```
@@ -37,12 +38,13 @@ Sometimes, you may want to send processed video frames back to the CameraServer
3738
#
3839
# CameraServer initialization code here
3940
#
40-
output = cs.putVideo("Name", width, height)
41+
output = CameraServer.putVideo("Name", width, height)
42+
input_img = np.zeros(shape=(height, width, 3), dtype=np.uint8)
4143
while True:
42-
time, input_img = cvSink.grabFrame(input_img)
43-
if time == 0: # There is an error
44-
output.notifyError(sink.getError())
45-
continue
44+
time, input_img = sink.grabFrame(input_img)
45+
if time == 0: # There is an error
46+
output.notifyError(sink.getError())
47+
continue
4648
#
4749
# Insert processing code here
4850
#

0 commit comments

Comments
 (0)