GithubHelp home page GithubHelp logo

ros-drivers / axis_camera Goto Github PK

View Code? Open in Web Editor NEW
51.0 26.0 72.0 678 KB

Contains basic Python drivers for accessing an Axis camera's MJPG stream. Also provides control for PTZ cameras.

License: BSD 3-Clause "New" or "Revised" License

CMake 1.48% Python 98.52%

axis_camera's Introduction

axis_camera Build Status

Overview

This ROS package provides an Axis network camera driver, written in Python.

ROS wiki documentation: axis_camera

This driver is under active development. Its ROS interfaces are relatively stable, but may still change.

There is no released code API.

⚠️Warning

The master branch normally contains code being tested for the next ROS release. It does not always work with previous ROS distributions. Sometimes, it may not work at all.

Each official release is tagged in the repository. The change history describes every version.

Supported Cameras

The following is a list of cameras that have been tested with this driver and are known to work. Other cameras may also be usable, but have not been tested by the developers/maintainers of this package.

If you have used this driver with a specific model of camera not listed below, please submit a PR so we can keep this list up-to-date.

Camera Preparation

Before using the ROS driver you should ensure your camera is properly connected to the PC and powered as-per the manufacturer's specifications.

We recommend configuring the camera to use a static IP address on your robot's internal wired LAN, rather than DHCP. Because the driver addresses the camera by hostname or IP address it's easier if the address is constant.

HTTP Authentication and Anonymous Control

By default most Axis cameras require HTTP authentication to view the camera data & to send PTZ (or other) commands.

There are two solutions to this:

  1. Log into the camera's web GUI and enable Anomymous Viewers and Anonymous PTZ Operators. These options can usually be found under settings > Users
  2. Configure the launch file to use a valid Axis user's username and password. This is done with the username and password arguments to axis.launch. Some cameras require HTTP Digest authentication instead of basic authentication. If this is the case for your camera, make sure to also set the encrypt_password argument im axis.launch. (The Q62 series cameras are known to require digest authentication.)

Usage Examples

Once the camera is configured, simply launch the driver:

roslaunch axis_camera axis.launch hostname:=192.168.0.90 username:=root password:=password

If your camera requires digest authentication instead of basic authentication, set the encrypt_password argument:

roslaunch axis_camera axis.launch hostname:=192.168.0.90 username:=root password:=password encrypted:=true

If your camera supports PTZ control, you can enable it with

roslaunch axis_camera axis.launch hostname:=192.168.0.90 username:=root password:=password enable_ptz:=true

In the case of the F Series cameras, multiple cameras can be connected to a single controller box. In this case, launch the driver once for each physical camera, specifying the camera name & ID number. The ID number corresponds to the physical port in the e.g. F34 controller (1-4).

roslaunch axis_camera axis.launch hostname:=192.168.0.90 username:=root password:=password camera_name:=front_camera camera:=1

roslaunch axis_camera axis.launch hostname:=192.168.0.90 username:=root password:=password camera_name:=rear_camera camera:=2

The Q62 Series cameras also feature a night-vision mode (adds and IR illuminator and disables the IR filter), a lens wiper, and a defogger in addition to the normal PTZ control. To enable all of this camera's supported features, use

roslaunch axis_camera axis.launch hostname:=192.168.0.90 username:=root password:=password encrypt_password:=true enable_ptz:=true enable_ir:=true enable_defog:=true enable_wiper:=true

Topics and Services

The camera's main image data is published on /camera_name/image_raw/compressed as a sensor_msgs/CompressedImage.

If the enable_theora argument is true then additional image topics are available in the /camera_name/image_raw_out namespace, including /camera_name/image_raw_out/theora as theora_image_transport/Packet messages.

PTZ control (if enabled) uses the axis_camera/Axis.msg type:

float32 pan
float32 tilt
float32 zoom
float32 focus
float32 brightness
float32 iris
bool autofocus
bool autoiris

To write to the camera, use

rostopic pub /camera_name/cmd axis_camera/Axis "{pan: 45.0, tilt: 20.0, zoom: 1000.0, focus: 0.0, brightness: 1.0, iris: 1.0, autofocus: true, autoiris: true}" -1

All writable camera properties are set simultaneously. It is recommended to read the camera's current state from /camera_name/state, copy the focus, autofocus, brightness, and iris parameters, and then set the pan, tilt and zoom fields as desired. Failure to set the brightness field may result in a very dark image.

pan and tilt are expressed in degrees (for ease of use with Axis' REST API) with positive tilt being upwards and positive pan being clockwise.

zoom is a value from 1 to 10000, with higher numbers indicating a narrower field of view.

The Q62 Series' IR mode can be toggled by running

rosservice call /camera_name/set_ir_on "data: true"  # or "data: false"

When IR mode is on the IR illuminator will be turned on and the IR filter turned off. The current state of the IR mode can be read from /camera_name/ir_on as a std_msgs/Bool.

To enable the defogger, run

rosservice call /camera_name/set_defog_on "data: true"  # or "data: false"

The current state of the defogger can be read from /camera_name/defog_on as a std_msgs/Bool.

To start the lens wiper, run

rosservice call /camera_name/set_wiper_on "data: true"

The wiper will run for 10s and stop automatically. You can stop the wiper early by running

rosservice call /camera_name/set_wiper_on "data: false"

The current state of the wiper can be read from /camera_name/wiper_on as a std_msgs/Bool.

axis_camera's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

axis_camera's Issues

Provide username and password automatically, when available

The current driver always prompts for the username and password, even when they were specified as parameters.

I think that is happening under the covers inside urllib.urlopen(). There seem to be ways to provide the authentication information automatically, either by overloading the prompt_user_passwd() method, or by migrating to urllib2.

"Corrupt JPEG Data" warnings when used with Axis M5525 PTZ camera

The Axis M5525 appears to be Axis' replacement for the P-series PTZ cameras. While the driver is able to stream MJPEG data from the camera just fine, a continuous stream of warning messages are also generated while the image stream is accessed. The message is as follows, with the number of bytes varying somewhat between messages:

Corrupt JPEG data: 651 extraneous bytes before marker 0xd9

These messages are a nuisance!

Need diagnostics

The driver should provide ROS diagnostic information on the status and availability of the camera.

Add parameter for choosing camera

Would it be possible to add a parameter for choosing camera or maybe a parameter for a string to append to the URL parameters?

Now I did in axis.py:

def formURL(self):
    self.url = 'http://%s/mjpg/video.mjpg' % self.axis.hostname
    self.url += "?fps=0&resolultion=%dx%d" % (self.axis.width, 
                                                        self.axis.height)
    self.url += "&camera=2"
    rospy.logdebug('opening ' + str(self.axis))

PTZ Processing Speed

Is there a way to force the PTZ operation to happen more smoothly? I wrote my own teleop procedure for the camera, and currently it seems to execute a pan or tilt operation once every second to a few seconds. It also is buffering commands a bit even though the subscribed queue size is 1 (from axis_ptz.py), so I'm guessing the camera is imposing some buffer. Is this slow delay a function of the camera hardware or the web interface used to send commands?

Thanks!

convert to catkin for Groovy and Hydro

Since axis_camera has not yet been released to either of those ROS distributions, we might as well convert it to catkin, first. The main dependency, camera_info_manager_py, is already converted and available on both Groovy and Hydro.

High latency due to python implementation

Just for information, because python is sometimes introducing huge delay (like 4-5 seconds!), I was investigating another option to get the camera video stream.

Using gstreamer and gscam seems to work but uses a lot of CPU if it does the decoding itself. The patch below to gscam allows publishing the jpeg stream, same as the axis_driver.
ros-drivers/gscam#11

This looks like a good alternative on the kingfisher, although I haven't found yet how to tell gstreamer to use additional parameter in the get request (like resolution, fps, image size).

"Error opening URL...Looping until camera appears" when viewing image in image_view

Hello,

I am running into an issue where I cannot view the published Axis camera images using the image_view package. I run rosrun axis_camera axis.py where the default host name is 192.168.0.90 and I get the warning that the publisher should be created with an explicit keyword argument 'queue_size'. When I run image_view to view the raw image stream, the axis camera node prints out the warning

[WARN] [WallTime: 1456299554.224392] Error opening URL http://192.168.0.90/mjpg/video.mjpg?fps=0&resolution=640x480Possible timeout. Looping until camera appears

which doesn't make sense because I can go to my web browser and type in 192.168.0.90 and I'm able to view the live stream and command the PTZ.

I've even tried removing the axis_camera package and using the latest tagged release version and I still get the same error.

Any help would be appreciated!

Authentication with encrypted password

The authentication doesn't work when the axis camera only accept authentication with encrypted password. It would be nice to handle this kind of authentication.

publisher should be created with an explicity keyword argument 'queue_size'

I'm having trouble viewing images from the axis driver, and I'm just trying to cover all issues.

When I launch:

roslaunch axis_camera axis.launch hostname:=axis_camera_hostname

I get the error:

/home/cholloway/workspace/axis_camera/src/axis_camera/nodes/axis.py:156: SyntaxWarning: The publisher should be created with an explicit keyword argument 'queue_size'. Please see http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers for more information.
  self.pub = rospy.Publisher("image_raw/compressed", CompressedImage, self)

add basic unit tests

The default tests should verify that the scripts can all be loaded and invoked, even when there is no actual device attached. These tests can run on the build farm.

Under CMake variable control: enable conditional tests that verify basic device function with various real cameras attached.

Handle loss of access to the camera.

If the camera is unavailable on the network when the driver starts, it should initiate a slow poll waiting for it to respond.

Similarly, if the device stops sending images, the driver should wait in a slow poll loop until access is recovered and the camera reconnected.

Please add a LICENSE file

According to http://wiki.ros.org/axis_camera, axis_camera is under the BSD license, which says

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Alas, there are multiple variants of the BSD license out there and it's not obvious to me which one applies. Could you add a copy of the license with copyright notice on top to the axis_camera repo to save distributors from having to figure it out?

Even better if individual source files have a short notice [1] so the license information is easy to track down even out of context.

Thanks,
Jonathan

[1] like this one: https://go.googlesource.com/go/+/master/src/go/ast/ast.go
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

Control ptz camera

Hi.
If I want to control ptz, what should I do after executing the command below?
rosrun axis_camera axis_ptz.py _hostname:=IP_ADDRESS_OF_YOUR_CAMERA
Thanks!

atkin _make fails with following message in hydro - ubuntu

CMake Error at /opt/ros/hydro/share/catkin/cmake/catkinConfig.cmake:72 (find_package):
Could not find a package configuration file provided by
"camera_info_manager_py" with any of the following names:

camera_info_manager_pyConfig.cmake
camera_info_manager_py-config.cmake

Add the installation prefix of "camera_info_manager_py" to
CMAKE_PREFIX_PATH or set "camera_info_manager_py_DIR" to a directory
containing one of the above files. If "camera_info_manager_py" provides a
separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
axis_camera/CMakeLists.txt:4 (find_package)

-- Configuring incomplete, errors occurred!
Invoking "cmake" failed

ImportError: No module named camera_info_manager

My camera is camera Axis M10XX, not a ptz type .
I meet a error like follwing.
File "/home/robot/axisM10/src/axis_camera/nodes/axis.py", line 13, in
import camera_info_manager
ImportError: No module named camera_info_manager

my ros version is indigo, I have installed camera-info-manager pkg use apt tool,
but this error still exist.

can you tell me how to solve this problem?
Thank you sincerely

Compressed Depth Image Transport Error

When launched the axis_camera node fills the row.log file with this error:

[[31m[ERROR] [1423596401.252559513]: Compressed Depth Image Transport - Compression requires single-channel 32bit-floating point or 16bit raw depth images (input format is: bgr8)

The test conditions are an Axis M1013 camera set to 640x480, with enable_theora=1. The node doesn't crash and I do get an image, so this is more of a question about whether this is a problem (aside from filling the log file with junk).

Publish CameraInfo, when available.

I am thinking of writing a Python camera_info_manager module, with a subset of the full C++ implementation.

With that, the camera driver would use a standard camera_info_url parameter to access calibration information for the appropriate device.

Unexpected crash

Not sure if this is related to the driver itself. Axis node stops publishing, however it's still running.

Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
File "/home/devex/catkin_ws/src/axis_camera/nodes/axis.py", line 24, in run
self.stream()
File "/home/devex/catkin_ws/src/axis_camera/nodes/axis.py", line 30, in stream
if self.openURL():
File "/home/devex/catkin_ws/src/axis_camera/nodes/axis.py", line 62, in openURL
self.fp = urllib2.urlopen(self.url, timeout=self.timeoutSeconds)
File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 406, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 519, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 438, in error
result = self._call_chain(_args)
File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
result = func(_args)
File "/usr/lib/python2.7/urllib2.py", line 890, in http_error_401
url, req, headers)
File "/usr/lib/python2.7/urllib2.py", line 865, in http_error_auth_reqed
response = self.retry_http_basic_auth(host, req, realm)
File "/usr/lib/python2.7/urllib2.py", line 878, in retry_http_basic_auth
return self.parent.open(req, timeout=req.timeout)
File "/usr/lib/python2.7/urllib2.py", line 400, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 418, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1180, in do_open
r = h.getresponse(buffering=True)
File "/usr/lib/python2.7/httplib.py", line 1038, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 415, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 371, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/usr/lib/python2.7/socket.py", line 476, in readline
data = self._sock.recv(self._rbufsize)
timeout: timed out

My launch file:

<node pkg="axis_camera" type="axis.py" name="axis">
  <param name="username" value="$(arg username)" />
  <param name="password" value="$(arg password)" />
</node>

<node pkg="image_transport" type="republish" name="republish" args="compressed in:=image_raw/ raw out:=image_raw" />
 <!-- Rectifying the image_raw -->  
<node pkg="image_proc" type="image_proc" name="image_proc" />

AXIS PTZ M5525-e tested and it is working

Greetings,

Thanks for the ros pkg guys! I have tested the noetic devel branch with the M5525-E model and it is working fine after all the fixes with the python3 rosdep and the recomendation of this guy: NVlabs/Deep_Object_Pose#167 (comment)

Also in order to get the image from the camera you must set the ecrypted_password=true

Thanks again you can add this axis model to the tested list as well.

How to use the driver on several cameras AXIS F10**

Hi everyone,
I'm currently working on a complete acquisition of several AXIS cameras linked to a F44 switch unit.
I managed to run the driver and publish successfully the raw images in the topic /axis/image_raw/compressed and now I'd like to retrieve the images of each camera in different topics simultaneosly to save it into rosbag afterwards.
Do you know I could achieve that ? I know that i have to use the url but it seems like the attributes of the axis object are not updated which means the 'camera' attribute remains at 0...

Add frame_id parameter.

When using multiple cameras, we need to define different TF frame identifiers for each device.

I propose to do that by adding a frame_id parameter, with a default value of "axis_camera". I don't think the published frame identifier is supposed to include the "_optical" suffix.

Proposal: Change Axis.msg to use radians instead of degrees

I'm writing this as the maintainer of the package. When I inherited this project, the package was already released using degree for the pan and tilt positions in the Axis messages. Obviously the ROS standard is to use radians.

I'm hesitant to change the units used by the package simply because it's been released and used in its current state for years. But the fact that the message uses non-standard units makes interoperability with other ROS packages less convenient.

My initial proposal is to add a new rosparam option to the PTZ node to specify the units:

<node pkg="axis_camera" type="teleop.py" name="teleop" if="$(arg enable_ptz_teleop)">
  <param name="use_degrees" value="1" />
  <param name="enable_button" value="1" />
  <param name="scale_pan_deg" value="25" />
  <param name="scale_tilt_deg" value="25" />
  <remap from="joy" to="/joy" />
</node>

I'd like to use radians by default, as this is the ROS standard. But initially the default may remain degrees so as not to break anything that depends on this package.

Before I implement any of this work, I'm going to leave this issue open to solicit feedback from the wider community. If you have opinions on this proposal, please leave them below!

When executing roslaunch axis_camera axis.launch, no error is reported, but at the same time, I can’t see the camera image even when I use rviz

Hello, I would like to know whether the related drivers of axis camera support work under ubuntu 20.04+ros noetic or ubuntu20.04+ros2 foxy version? I try to run under ubuntu20.04+ros noetic, but when I execute roslaunch axis_camera axis.launch, no error is reported, but at the same time I can't see the camera image using rviz, but I can see it clearly using rostopic list The topic to the camera is indeed released, but there is no data, I don’t know why, I hope you can help me, thank you~

Noetic release

The apt version of axis_camera is at 0.3.2 but it's broken for python3 due to the urllib2 issue.

Can we get a new release for the buildfarm of the noetic-devel branch?

Brightness now received

Hi guys,

I am using an AXIS M5525-E PTZ Dome camera and I am trying to connect it with ROS. I am able to get the image stream and control pan/tilt and zoom. However, I am not able to control the brightness. I can publish the desired brightness value, but it doesn't change in the system status and also the image brightness is not changing. Since it remains set to 0, the images suddenly become dark.

Do you have any hint?

launch file problems

  • The launch files use image_view, which ought not be a dependency of the driver, itself.
  • The axis.launch is not compatible with the current driver parameters and topic names.
  • The axis_ptz.launch seems to have similar issues.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.