|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
How to get image from Axis camera to a Python program?
Hello, I would like to be able to get the stream of from the axis camera plugged into the router into a Python program so I can perform some image processing on it with OpenCv.
How would I got about doing this? And is there any example code? |
|
#2
|
||||
|
||||
|
Re: How to get image from Axis camera to a Python program?
I'm not sure this is a full answer but...
You can use a lot of OpenCV image manipulation features by way of the recently-released GRIP. I've been playing with this and it's really slick. Powerful, easy to use, and written in Java so it will run on a DS, RoboRio, or other onboard processor. It can output to NetworkTables, which puts the data in easy reach of any Python program. Another similar option is RoboRealm. Every team gets a code for a free license (see your TIMS). It's also easy and powerful, writes to NetworkTables and even lets you run Python code right inside the app. We did exactly that with an Axis in the 2014 game to identify the hot goal during autonomous. The only downside is it's a PC-only app, so you'll need to do processing on your DS or similar onboard computer. Hope that helps. |
|
#3
|
||||
|
||||
|
Re: How to get image from Axis camera to a Python program?
This is the code from a demo I did with my team a while back.
https://github.com/dawonn/HelloPythonOpenCV I highly recommend that you record videos of interest and then develop your algorithm with the videos. It will save you a lot of time and effort. Then once you think the vision system is working, link it to your robot and let it rip. ![]() |
|
#4
|
||||
|
||||
|
Re: How to get image from Axis camera to a Python program?
Quote:
|
|
#5
|
||||
|
||||
|
Re: How to get image from Axis camera to a Python program?
Our OpenCV code from last year running on the RoboRIO: https://github.com/frc1418/2015-vision
You will need to install OpenCV to use it, see https://github.com/robotpy/roborio-opencv |
|
#6
|
||||
|
||||
|
Re: How to get image from Axis camera to a Python program?
Okay I got some code to work that I found someplace else. Here's what I have.
Code:
import cv2
import urllib
import numpy as np
stream=urllib.urlopen('http://10.58.54.108/mjpg/video.mjpg')
bytes=''
while True:
bytes+=stream.read(1024)
a = bytes.find('\xff\xd8')
b = bytes.find('\xff\xd9')
if a!=-1 and b!=-1:
jpg = bytes[a:b+2]
bytes= bytes[b+2:]
i = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8),cv2.CV_LOAD_IMAGE_COLOR)
i = cv2.cvtColor(i, cv2.COLOR_BGR2HSV)
cv2.imshow('i',i)
if cv2.waitKey(1) == 27:
exit(0)
|
|
#7
|
||||
|
||||
|
Re: How to get image from Axis camera to a Python program?
Yes, you would put your code in that loop. But... I wouldn't use that code, it's not going to be particularly efficient.
You might want to try this instead: https://github.com/frc1418/2015-visi...mjpg_client.py |
|
#8
|
||||
|
||||
|
Re: How to get image from Axis camera to a Python program?
Quote:
|
|
#9
|
||||
|
||||
|
Re: How to get image from Axis camera to a Python program?
Look at the files next to it?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|