How do I increase the fps in output
<p>I am trying to do face detection on a video file. I am using openCV HAAR Face Detector. I also resize the image by a suitable factor to enable faster processing. I have also used multiple threading but the threads are sequential. The output video lags a lot.
I want the output to be as fast as the input frames. Any suggestions as to how I can increase the frame rate in the o/p video.
Also can the threads be used in parallel? If yes, how?</p>

<p>The Face detection module in written in the file faceDetector.py</p>

<p>The sample gives 25 fps. </p>

<p>The program works fine with webCam.</p>

<p>My code:</p>

<pre><code>import cv2

from threading import Thread

from faceDetector import Face

cap = cv2.VideoCapture("sample2.mp4")

class T1(Thread):

    def  __init__(self, frame):
        Thread.__init__(self)
        self.frame = frame
        self.imgResized = None

    def run(self):
        self.imgResized, self.faces = FaceDetection(self.frame)



class  T2(Thread):

    def __init__(self, img, faces):
        Thread.__init__(self)
        self.img = img
        self.faces = faces

    def run(self):
        Faceobj.RectAroundFace(self.faces, self.img)
        # cv2.imshow("faces in video", self.img)

class T3(Thread):

    def __init__(self, img):
        Thread.__init__(self)
        self.img = img

    def run(self):
        cv2.imshow("faces in video", self.img)


def FaceDetection(img):

    imgPreProcessed, imgResized = Faceobj.preprocessing(img)
    faces = Faceobj.detectFace(imgPreProcessed)
    return imgResized, faces

Faceobj = Face()

while (cap.isOpened):

    ret, frame = cap.read()
    # print cap.get(cv2.cv.CV_CAP_PROP_FPS)
    # cap.set(cv2.cv.CV_CAP_PROP_FPS, 60)

    if not ret :
        break

    thread_1 = T1(frame)
    thread_1.start()
    thread_1.join()
    thread_2 = T2(thread_1.imgResized, thread_1.faces)
    thread_2.start()
    thread_3 = T3(thread_2.img)
    thread_3.start()
    thread_3.join()

    if (cv2.waitKey(1) &amp; 0xFF == 27):
        break
</code></pre>