View Single Post
  #6   Spotlight this post!  
Unread 14-01-2016, 23:05
JohnM's Avatar
JohnM JohnM is offline
Registered User
FRC #5854 (Glitch)
Team Role: Programmer
 
Join Date: Mar 2014
Rookie Year: 2013
Location: North Carolina
Posts: 53
JohnM has a spectacular aura aboutJohnM has a spectacular aura about
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)
My question I have now is that does the rest of my code for my program go in that while loop? I don't think I clarified in my other post that this program will be running on the driver station.
Reply With Quote