__init__.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:service_vision 作者: JarbasAI 项目源码 文件源码
def init_vision(self):
        self.set_default_context()
        # read cascades
        self.log.info("reading haar cascades")
        self.face_cascade = cv2.CascadeClassifier(dirname(__file__) + '/cascades/haarcascade_frontalface_alt2.xml')
        self.smile_cascade = cv2.CascadeClassifier(dirname(__file__) + '/cascades/haarcascade_smile.xml')
        self.leye_cascade = cv2.CascadeClassifier(dirname(__file__) + '/cascades/haarcascade_lefteye.xml')
        self.reye_cascade = cv2.CascadeClassifier(dirname(__file__) + '/cascades/haarcascade_righteye.xml')
        self.profileface_cascade = cv2.CascadeClassifier(dirname(__file__) + '/cascades/lbpcascade_profileface.xml')

        #######video streaming and fps ###########33
        self.log.info("initializing videostream")
        self.vs = eye(src=0).start()
        self.fps = FPS().start()

        # TODO distance from cam
        self.rect = (161, 79, 150, 150)  # random initial guess for foreground/face position for background extraction
        self.distance = 0
        # initialize the known distance from the camera to the reference eye pic, which
        # in this case is 50cm from computer screen
        self.KNOWN_DISTANCE = 50.0
        # initialize the known object width, which in this case, the human eye is 24mm width average
        self.KNOWN_WIDTH = 2.4
        # initialize the reference eye image that we'll be using
        self.REF_IMAGE_PATH = dirname(__file__) + "/ref/eye.jpg"
        # load the image that contains an eye that is KNOWN TO BE 50cm
        # from our camera, then find the eye marker in the image, and initialize
        # the focal length
        image = cv2.imread(self.REF_IMAGE_PATH)
        self.radius = 24  # initialize radius for distance counter
        marker = self.find_eye_radius(image)
        # calculate camera focallenght
        self.focalLength = (marker * self.KNOWN_DISTANCE) / self.KNOWN_WIDTH

        # TODO read from config file
        # bools
        self.showfeed = True
        self.showboundingboxes = True
        self.showdetected = True

        ######## detected objects ######
        self.detectedfaces = []
        self.detectedmoods = []

        # process first frame
        self.feed = self.process_frame()

        self.awake = True
        if self.awake:
            pass
            # TODO start vision thread
        self.filter = "None"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号