# HTTP stream from camera delayed by a long time

Hi all,

I have a raspberry pi camera with "Motion" operating at localhost/8081 which I have got access to through my browser by simply including this html element in a page: <iframe src="my.pi.IP.add:8081" *params*></iframe>, and this works absolutely great.

After the fact, I decide I needed to get the "profile" across a frame for data processing reasons and, since I already have other data coming from a python server running tornado, I decided to include python-opencv and use that to analyse the frames.

I initialise the video with:

def init_video():
print("Opening video port")
# Set up video stream
video_port = "8081"
stream = "localhost:%s/frame.mjpeg" % video_port
capture = cv2.VideoCapture(stream)
return capture


Within the tornado ioloop I have a scheduled function which sends data to the client every 50ms or so, to update numeric indicators on a display, and again this works flawlessly. I also have the following function as part of the scheduler (which takes capture as an argument):

def intensity_profiles(capture):
# capture frame from stream and take profiles across it

And this works, but there is a BIG delay between the stream shown in the iframe (which updates close to real time) and the x_profile data which is coming out of this function. If I include a line in intensity_profiles() which prints the value of one pixel, covering the camera with my hand, I counted the seconds until I saw a difference in the output and it was between 10 and 30 seconds delay.