コード例 #1
0
ファイル: facel.py プロジェクト: iliucan/ua-cs665-ros-pkg
    def findFaces(self, img):
        faces = []

        self.detect_time = time.time()
        rects = self.face_detector.detect(img)
        self.detect_time = time.time() - self.detect_time

        cvtile = opencv.cvCreateMat(128, 128, opencv.CV_8UC3)
        bwtile = opencv.cvCreateMat(128, 128, opencv.CV_8U)

        cvimg = img.asOpenCV()

        self.eye_time = time.time()

        for rect in rects:
            faceim = opencv.cvGetSubRect(cvimg, rect.asOpenCV())
            opencv.cvResize(faceim, cvtile)

            affine = pv.AffineFromRect(rect, (128, 128))

            opencv.cvCvtColor(cvtile, bwtile, cv.CV_BGR2GRAY)

            leye, reye, lcp, rcp = self.fel.locateEyes(bwtile)
            leye = pv.Point(leye)
            reye = pv.Point(reye)

            leye = affine.invertPoint(leye)
            reye = affine.invertPoint(reye)

            faces.append([rect, leye, reye])

        self.eye_time = time.time() - self.eye_time
        self.current_faces = faces

        return faces
コード例 #2
0
def tile_images(img_width, img_height, num_width, num_height, images, channels=3):
    w = img_width * num_width
    h = img_height * num_height
    image = cv.cvCreateImage(cv.cvSize(int(w), int(h)), 8, channels)
    cv.cvSet(image, cv.cvScalar(255,255,255))
    while len(images) > 0:
        try:
            for y in range(int(num_height)):
                for x in range(int(num_width)):
                    small_tile = images.pop()
                    img_x = x * img_width
                    img_y = y * img_height
                    cropped = cv.cvGetSubRect(image, cv.cvRect(img_x, img_y, img_width,img_height))
                    cv.cvCopy(small_tile, cropped)
        except exceptions.IndexError, e:
            break
コード例 #3
0
def tile_images(img_width,
                img_height,
                num_width,
                num_height,
                images,
                channels=3):
    w = img_width * num_width
    h = img_height * num_height
    image = cv.cvCreateImage(cv.cvSize(int(w), int(h)), 8, channels)
    cv.cvSet(image, cv.cvScalar(255, 255, 255))
    while len(images) > 0:
        try:
            for y in range(int(num_height)):
                for x in range(int(num_width)):
                    small_tile = images.pop()
                    img_x = x * img_width
                    img_y = y * img_height
                    cropped = cv.cvGetSubRect(
                        image, cv.cvRect(img_x, img_y, img_width, img_height))
                    cv.cvCopy(small_tile, cropped)
        except exceptions.IndexError, e:
            break
コード例 #4
0
ファイル: image_utils.py プロジェクト: opengazer/HeadTracker
def CropImage(i_ipl_image, i_ipl_roi):
    src_region = cv.cvGetSubRect( i_ipl_image, i_ipl_roi)
    cropped_image = cv.cvCreateImage( cv.cvSize( i_ipl_roi.width,  i_ipl_roi.height) , 8 , 1)
    cv.cvCopy(src_region, cropped_image)
    return cropped_image
コード例 #5
0
ファイル: image_utils.py プロジェクト: Boosting/HeadTracker
def CropImage(i_ipl_image, i_ipl_roi):
    src_region = cv.cvGetSubRect(i_ipl_image, i_ipl_roi)
    cropped_image = cv.cvCreateImage(
        cv.cvSize(i_ipl_roi.width, i_ipl_roi.height), 8, 1)
    cv.cvCopy(src_region, cropped_image)
    return cropped_image
コード例 #6
0
 def crop(self, i_image):
     src_region = cv.cvGetSubRect(i_image, self.__roi)
     self.__cropped_image = cv.cvCreateImage(
         cv.cvSize(self.__roi.width, self.__roi.height), 8, 1)
     cv.cvCopy(src_region, self.__cropped_image)
     return self.__cropped_image
コード例 #7
0
 def crop(self, i_image):
     src_region = cv.cvGetSubRect(i_image, self.__roi)
     self.__cropped_image = cv.cvCreateImage( cv.cvSize(self.__roi.width, self.__roi.height) , 8 , 1)
     cv.cvCopy(src_region, self.__cropped_image)
     return self.__cropped_image