Setting up Axis Camera on Raspberry Pi

I have an axis camera that I want to set up with the raspberry pi using the frc linux image. Does anyone know how to do that?

It’s not built into the webdash, but you can do it in your code the same way you use it with the RoboRIO. Use CameraServer.addAxisCamera(), and then use getVideo() to get OpenCV access to the stream if desired.

Is that an IP camera or USB webcam?

Axis cameras are IP cameras.

1 Like

I am using python code and i have the method to get the frame in opencv.
The exact error message I’m getting is this:
cv2.error: OpenCV(3.4.4) /__w/1/s/deps/02-extract/opencv/modules/core/src/matrix.cpp:757: error: (-215:Assertion failed) dims <= 2 && step[0] > 0 in function ‘locateROI’

Are you checking the return value of getFrame()? If it returns 0 it has timed out waiting for the frame (eg it’s still connecting to the camera) and you shouldn’t try to process it.

I can connect to the camera through its ip address and it gives frames perfectly. How do I fix this?

I am getting this frame in the python code. How do I fix this error?

Can you share the snippet of your code that is actually reading and starting to process the frame? The error you are getting is from OpenCV trying to process the image. It can have one of two causes (1) getFrame is returning 0, but you aren’t checking it and trying to process an invalid image (2) you’re getting a valid frame and something else is going wrong with your OpenCV code

!/usr/bin/env python3

import cv2

import numpy as np

import time

import threading

from networktables import NetworkTables

import sys

import logging


ntinst = NetworkTables.getDefault()

sd = ntinst.getTable(‘SmartDashboard’)

def connectionListener(connected, info):
print(info, “; Connected=%s” % connected)
NetworkTables.addConnectionListener(connectionListener, immediateNotify=True)
cap = cv2.VideoCapture(“”)

while True:
ret, frame =
#Apply required filters to the frame
blurred_frame = cv2.GaussianBlur(frame, (5, 5), 0)
hsv = cv2.cvtColor(blurred_frame, cv2.COLOR_BGR2HSV)

Oh, you’re not using CameraServer to read the camera, you’re using OpenCV. I’m afraid I can’t help you much with that method. See for an example using CameraServer, just change startAutomaticCapture() to addAxisCamera("").

I used this code for getting the camera feed:
camera = cs.addAxisCamera(“”)
I keep getting the error “could not resolve http address”

You should give it just the IP address, not the full URL. It knows where to find the stream on Axis cameras.

How do you get the robotpy-cscore module. I tried “pip install robotpy-cscore” but it is saying that “ModuleNotFoundError: No module named ‘cv2’” and I do have cv2 installed.

It’s already installed. You need to be using python3, not python.

When we enter the ip address it shoots the error:
AttributeError: ‘cscore._cscore.VideoSource’ object has no attribute ‘getUrls’

Looks like you ran into a bug in robotpy-cscore. I’m talking with @virtuald to resolve it.

Do you know of any alternatives to this?

Here are the relevant changes:

The file that needs fixing is /usr/local/lib/python3.5/dist-packages/cscore/

Will the raspberry pi automatically update though?