Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Gaining high frame rate from ELP camera (python)

I'm using an ELP USB camera that is supposedly rated at 100fps at VGA quality but I don't seem to be getting anywhere near that frame rate. I was wondering if anyone has used an ELP camera with openCV and managed to achieve a frame rate close to 100 fps? Or if anyone has any advice to help increase the frame rate?

I have already tested that the output is MJPEG at 640x420 and I am running cv2.VideoCapture in one thread and placing the frame on a queue. From the main thread I repeatedly ask for frames but only return when the results is not None. This gives a frame rate hovering around 30fps.

import cv2
import time
import numpy as np
from datetime import datetime
from threading import Thread, Lock, Condition
import time
from Queue import Queue

class WebcamVideoStream:

def __init__(self, src=0):
    # initialize the video camera stream 
    self.stream = cv2.VideoCapture(src)
    # initialize the variable used to indicate if the thread should
    # be stopped
    self.stopped = False
    self.frame = None

def start(self):
    global qt
    self.stopped = False
    qt = Queue(10)
    # start the thread to read frames from the video stream
    thread1 = Thread(target=self.update, args=())
    thread1.start()
    return self

def update(self):
    global qt
    # keep looping infinitely until the thread is stopped
    while True:
        if self.stopped:
            return
        _, self.frame = self.stream.read()
        qt.put(self.frame)

def read(self):
    global qt
    if(not qt.empty()):
        self.CurrFrame=qt.get()
        if self.CurrFrame is not None:
            return self.CurrFrame
    if self.stopped:
        return

def stop(self):
    print('Stop')
    # indicate that the thread should be stopped
    self.stopped = True
    return self

vs = WebcamVideoStream(src=-1).start()
time.sleep(1)

i = 0
t0 = time.time()
while i < 100:
frame = vs.read()
while frame is None:
    frame = vs.read()
date_string = datetime.now().strftime("%Y-%m-%d-%H:%M:%S:%f")
i = i + 1

rate = 100/(time.time()-t0)
print(rate)

cv2.destroyAllWindows()
vs.stop()

Thanks in advance

Gaining high frame rate from ELP camera (python)

I'm using an ELP USB camera that is supposedly rated at 100fps at VGA quality but I don't seem to be getting anywhere near that frame rate. I was wondering if anyone has used an ELP camera with openCV and managed to achieve a frame rate close to 100 fps? Or if anyone has any advice to help increase the frame rate?

I have already tested that the output is MJPEG at 640x420 and I am running cv2.VideoCapture in one thread and placing the frame on a queue. From the main thread I repeatedly ask for frames but only return when the results is not None. This gives a frame rate hovering around 30fps.

import cv2
import time
import numpy as np
from datetime import datetime
from threading import Thread, Lock, Condition
import time
from Queue import Queue

class WebcamVideoStream:

def __init__(self, src=0):
    # initialize the video camera stream 
    self.stream = cv2.VideoCapture(src)
    # initialize the variable used to indicate if the thread should
    # be stopped
    self.stopped = False
    self.frame = None

def start(self):
    global qt
    self.stopped = False
    qt = Queue(10)
    # start the thread to read frames from the video stream
    thread1 = Thread(target=self.update, args=())
    thread1.start()
    return self

def update(self):
    global qt
    # keep looping infinitely until the thread is stopped
    while True:
        if self.stopped:
            return
        _, self.frame = self.stream.read()
        qt.put(self.frame)

def read(self):
    global qt
    if(not qt.empty()):
        self.CurrFrame=qt.get()
        if self.CurrFrame is not None:
            return self.CurrFrame
    if self.stopped:
        return

def stop(self):
    print('Stop')
    # indicate that the thread should be stopped
    self.stopped = True
    return self

vs = WebcamVideoStream(src=-1).start()
time.sleep(1)

i = 0
t0 = time.time()
while i < 100:
frame = vs.read()
while frame is None:
    frame = vs.read()
date_string = datetime.now().strftime("%Y-%m-%d-%H:%M:%S:%f")
i = i + 1

rate = 100/(time.time()-t0)
print(rate)

cv2.destroyAllWindows()
vs.stop()

Thanks in advance

Gaining high frame rate from ELP camera (python)

I'm using an ELP USB camera that is supposedly rated at 100fps at VGA 640x480 quality but I don't seem to be getting anywhere near that frame rate. I was wondering if anyone has used an ELP camera with openCV and managed to achieve a frame rate close to 100 fps? Or if anyone has any advice to help increase the frame rate?

I have already tested that the output is MJPEG at 640x420 and I am running cv2.VideoCapture in one thread and placing the frame on a queue. From the main thread I repeatedly ask for frames but only return when the results is not None. This gives a frame rate hovering around 30fps.

import cv2
import time
import numpy as np
from datetime import datetime
from threading import Thread, Lock, Condition
import time
from Queue import Queue

class WebcamVideoStream:

def __init__(self, src=0):
    # initialize the video camera stream 
    self.stream = cv2.VideoCapture(src)
    # initialize the variable used to indicate if the thread should
    # be stopped
    self.stopped = False
    self.frame = None

def start(self):
    global qt
    self.stopped = False
    qt = Queue(10)
    # start the thread to read frames from the video stream
    thread1 = Thread(target=self.update, args=())
    thread1.start()
    return self

def update(self):
    global qt
    # keep looping infinitely until the thread is stopped
    while True:
        if self.stopped:
            return
        _, self.frame = self.stream.read()
        qt.put(self.frame)

def read(self):
    global qt
    if(not qt.empty()):
        self.CurrFrame=qt.get()
        if self.CurrFrame is not None:
            return self.CurrFrame
    if self.stopped:
        return

def stop(self):
    print('Stop')
    # indicate that the thread should be stopped
    self.stopped = True
    return self

vs = WebcamVideoStream(src=-1).start()
time.sleep(1)

i = 0
t0 = time.time()
while i < 100:
frame = vs.read()
while frame is None:
    frame = vs.read()
i = i + 1

rate = 100/(time.time()-t0)
print(rate)

cv2.destroyAllWindows()
vs.stop()

Thanks in advance

Gaining high frame rate from ELP camera (python)

I'm using an ELP USB camera that is supposedly rated at 100fps at 640x480 quality but I don't seem to be getting anywhere near that frame rate. I was wondering if anyone has used an ELP camera with openCV and managed to achieve a frame rate close to 100 fps? Or if anyone has any advice to help increase the frame rate?rate? I am using Ubuntu 14.04 with openCV version 2.4.8.

I have already tested that the output is MJPEG at 640x420 and I am running cv2.VideoCapture in one thread and placing the frame on a queue. From the main thread I repeatedly ask for frames but only return when the results is not None. This gives a frame rate hovering around 30fps. One I have the image I am performing contour detection but essentially I would like to get the frame rate up as high as possible. Below is the code I'm using just to test the frame rate.

import cv2
import time
import numpy as np
from datetime import datetime
from threading import Thread, Lock, Condition
import time
from Queue import Queue

class WebcamVideoStream:

def __init__(self, src=0):
    # initialize the video camera stream 
    self.stream = cv2.VideoCapture(src)
    # initialize the variable used to indicate if the thread should
    # be stopped
    self.stopped = False
    self.frame = None

def start(self):
    global qt
    self.stopped = False
    qt = Queue(10)
    # start the thread to read frames from the video stream
    thread1 = Thread(target=self.update, args=())
    thread1.start()
    return self

def update(self):
    global qt
    # keep looping infinitely until the thread is stopped
    while True:
        if self.stopped:
            return
        _, self.frame = self.stream.read()
        qt.put(self.frame)

def read(self):
    global qt
    if(not qt.empty()):
        self.CurrFrame=qt.get()
        if self.CurrFrame is not None:
            return self.CurrFrame
    if self.stopped:
        return

def stop(self):
    print('Stop')
    # indicate that the thread should be stopped
    self.stopped = True
    return self

vs = WebcamVideoStream(src=-1).start()
time.sleep(1)

i = 0
t0 = time.time()
while i < 100:
frame = vs.read()
while frame is None:
    frame = vs.read()
i = i + 1

rate = 100/(time.time()-t0)
print(rate)

cv2.destroyAllWindows()
vs.stop()

Thanks in advance

click to hide/show revision 5
No.5 Revision

updated 2017-07-05 04:42:08 -0500

berak gravatar image

Gaining high frame rate from ELP camera (python)

I'm using an ELP USB camera that is supposedly rated at 100fps at 640x480 quality but I don't seem to be getting anywhere near that frame rate. I was wondering if anyone has used an ELP camera with openCV and managed to achieve a frame rate close to 100 fps? Or if anyone has any advice to help increase the frame rate? I am using Ubuntu 14.04 with openCV version 2.4.8.rate?

I have already tested that the output is MJPEG at 640x420 and I am running cv2.VideoCapture in one thread and placing the frame on a queue. From the main thread I repeatedly ask for frames but only return when the results is not None. This gives a frame rate hovering around 30fps. One I have the image I am performing contour detection but essentially I would like to get the frame rate up as high as possible. Below is the code I'm using just to test the frame rate.

import cv2
import time
import numpy as np
from datetime import datetime
from threading import Thread, Lock, Condition
import time
from Queue import Queue

class WebcamVideoStream:

 def __init__(self, src=0):
     # initialize the video camera stream 
     self.stream = cv2.VideoCapture(src)
     # initialize the variable used to indicate if the thread should
     # be stopped
     self.stopped = False
     self.frame = None

 def start(self):
     global qt
     self.stopped = False
     qt = Queue(10)
     # start the thread to read frames from the video stream
     thread1 = Thread(target=self.update, args=())
     thread1.start()
     return self

 def update(self):
     global qt
     # keep looping infinitely until the thread is stopped
     while True:
         if self.stopped:
             return
         _, self.frame = self.stream.read()
         qt.put(self.frame)

 def read(self):
     global qt
     if(not qt.empty()):
         self.CurrFrame=qt.get()
         if self.CurrFrame is not None:
             return self.CurrFrame
     if self.stopped:
         return

 def stop(self):
     print('Stop')
     # indicate that the thread should be stopped
     self.stopped = True
     return self

vs = WebcamVideoStream(src=-1).start()
time.sleep(1)

i = 0
t0 = time.time()
while i < 100:
 frame = vs.read()
 while frame is None:
     frame = vs.read()
 i = i + 1

rate = 100/(time.time()-t0)
print(rate)

cv2.destroyAllWindows()
vs.stop()

Thanks in advance

Gaining high frame rate from ELP camera (python)

I'm using an ELP USB camera that is supposedly rated at 100fps at 640x480 quality but I don't seem to be getting anywhere near that frame rate. I was wondering if anyone has used an ELP camera with openCV and managed to achieve a frame rate close to 100 fps? Or if anyone has any advice to help increase the frame rate?rate? I am using Ubuntu 14.04 with openCV version 2.4.8.

I have already tested that the output is MJPEG at 640x420 and I am running cv2.VideoCapture in one thread and placing the frame on a queue. From the main thread I repeatedly ask for frames but only return when the results is not None. This gives a frame rate hovering around 30fps. One I have the image I am performing contour detection but essentially I would like to get the frame rate up as high as possible. Below is the code I'm using just to test the frame rate.

import cv2
import time
import numpy as np
from datetime import datetime
from threading import Thread, Lock, Condition
import time
from Queue import Queue

class WebcamVideoStream:

 def __init__(self, src=0):
     # initialize the video camera stream 
     self.stream = cv2.VideoCapture(src)
     # initialize the variable used to indicate if the thread should
     # be stopped
     self.stopped = False
     self.frame = None

 def start(self):
     global qt
     self.stopped = False
     qt = Queue(10)
     # start the thread to read frames from the video stream
     thread1 = Thread(target=self.update, args=())
     thread1.start()
     return self

 def update(self):
     global qt
     # keep looping infinitely until the thread is stopped
     while True:
         if self.stopped:
             return
         _, self.frame = self.stream.read()
         qt.put(self.frame)

 def read(self):
     global qt
     if(not qt.empty()):
         self.CurrFrame=qt.get()
         if self.CurrFrame is not None:
             return self.CurrFrame
     if self.stopped:
         return

 def stop(self):
     print('Stop')
     # indicate that the thread should be stopped
     self.stopped = True
     return self

vs = WebcamVideoStream(src=-1).start()
time.sleep(1)

i = 0
t0 = time.time()
while i < 100:
 frame = vs.read()
 while frame is None:
     frame = vs.read()
 i = i + 1

rate = 100/(time.time()-t0)
print(rate)

cv2.destroyAllWindows()
vs.stop()

Thanks in advance