Tutorial

Table Of Contents
90
import threading
import imutils
class CVThread(threading.Thread):
'''
This class is used to process OpenCV analysis of video frames in the background. For more basic usage principles of
the multi-threaded class, please refer to 14.2
'''
def __init__(self, *args, **kwargs):
self.CVThreading = 0
super(CVThread, self).__init__(*args, **kwargs)
self.__flag = threading.Event()
self.__flag.clear()
def mode(self, imgInput):
'''
This method is used for incoming video frames that need to be processed
'''
self.imgCV = imgInput
self.resume()
def elementDraw(self,imgInput):
'''
Draw elements in the picture
'''
return imgInput
def doOpenCV(self, frame_image):
'''
Add the content to be processed by OpenCV here
'''
self.pause()
def pause(self):
'''
Block the thread and wait for the next frame
'''
self.__flag.clear()