Example #1
0
    def nextFrame(self):
        """Read the next frame from the capturing device.
           Note that the captured image is flipped horisontally."""
        current_frame = cv.highgui.cvQueryFrame(self.__capture_device)
        if not (current_frame == None):
            cv.cvFlip(current_frame, None, 1)

            if self.__scale < 1.0:
                width = int(current_frame.width * self.__scale + 0.5)
                height = int(current_frame.height * self.__scale + 0.5)
                current_frame = image_utils.IplResize(current_frame, width,
                                                      height)

            if not self.__is_color:
                current_frame = image_utils.IplRGBToGray(current_frame)

            self.__current_frame.setFrame(current_frame)
            t = time.time()
            diff = t - self.__time_start
            if diff > 1:
                self.__fps = self.__frame_cnt
                self.__frame_cnt = 0
                self.__time_start = t
            else:
                self.__frame_cnt += 1
            return self.currentFrame()
Example #2
0
def Ipl2Pil(i_image):
    o_flipped_image = cv.cvCreateImage(
        cv.cvSize(i_image.width, i_image.height), i_image.depth,
        i_image.nChannels)
    cv.cvFlip(i_image, o_flipped_image)
    o_pil_image = cv.adaptors.Ipl2Pil(o_flipped_image)
    return o_pil_image
Example #3
0
    def __init__(self, src="", time=None, flipped=False, thresh=128, thmode=0):

        self.src = src
        self.time = time
        self.bthresh = thresh
        self.bthreshmode = thmode
        if self.time:
            hg.cvSetCaptureProperty(self.src, hg.CV_CAP_PROP_POS_FRAMES, self.time)
        self.iplimage = hg.cvQueryFrame(self.src)
        if flipped:
            opencv.cvFlip(self.iplimage, None, 1)
        self.width = self.iplimage.width
        self.height = self.iplimage.height
Example #4
0
    def __init__(self, src="", time=None, flipped=False, thresh=128, thmode=0):

        self.src = src
        self.time = time
        self.bthresh = thresh
        self.bthreshmode = thmode
        if self.time:
            hg.cvSetCaptureProperty(self.src, hg.CV_CAP_PROP_POS_FRAMES, self.time)    
        self.iplimage = hg.cvQueryFrame(self.src)
        if flipped:
            opencv.cvFlip (self.iplimage, None, 1)    
        self.width = self.iplimage.width
        self.height = self.iplimage.height
Example #5
0
def Ipl2Pil(i_image):    
    o_flipped_image = cv.cvCreateImage( cv.cvSize( i_image.width, i_image.height ) , i_image.depth, i_image.nChannels )
    cv.cvFlip( i_image, o_flipped_image )
    o_pil_image = cv.adaptors.Ipl2Pil( o_flipped_image )
    return o_pil_image