Skip to content

Commit 67dc2b1

Browse files
authored
Convert AxisCamera example to generic HTTP camera
1 parent 192811c commit 67dc2b1

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

AxisCamera/robot.py renamed to HttpCamera/robot.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111

1212

1313
class MyRobot(wpilib.TimedRobot):
14-
"""
15-
This is a demo program showing the use of OpenCV to do vision processing. The image is acquired
16-
from the Axis camera, then a rectangle is put on the image and sent to the dashboard. OpenCV has
17-
many methods for different types of processing.
18-
"""
19-
2014
def robotInit(self):
2115
# Your image processing code will be launched via a stub that will set up logging and initialize NetworkTables
2216
# to talk to your robot code.

AxisCamera/vision.py renamed to HttpCamera/vision.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44
# the WPILib BSD license file in the root directory of this project.
55
#
66

7+
"""
8+
This is a demo program showing the use of OpenCV to do vision processing. The image is acquired
9+
from an HTTP camera, then a rectangle is put on the image and sent to the dashboard. OpenCV has
10+
many methods for different types of processing.
11+
"""
712

813
import ntcore
914
import numpy
15+
import cscore
1016
from cscore import CameraServer
1117
import cv2
1218

@@ -19,9 +25,11 @@
1925

2026

2127
def main():
22-
# Get the Axis camera from CameraServer
23-
camera = CameraServer.addAxisCamera("axis-camera.local")
24-
28+
# Create an HTTP camera. The address will need to be modified to have the
29+
# correct team number. The exact path will depend on the source.
30+
camera = cscore.HttpCamera("HTTP Camera", "http://10.x.y.11/video/stream.mjpg")
31+
# Start capturing images
32+
CameraServer.startAutomaticCapture(camera)
2533
# Set the resolution
2634
camera.setResolution(640, 480)
2735

run_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ BASE_TESTS="
1111
ArmBot
1212
ArmBotOffboard
1313
ArmSimulation
14-
AxisCamera
1514
CANPDP
1615
DifferentialDriveBot
1716
DigitalCommunication
@@ -32,6 +31,7 @@ BASE_TESTS="
3231
HatchbotInlined
3332
HatchbotTraditional
3433
HidRumble
34+
HttpCamera
3535
I2CCommunication
3636
IntermediateVision
3737
MagicbotSimple

0 commit comments

Comments
 (0)