当前位置: 首页>>代码示例>>Python>>正文


Python cv.fromarray方法代码示例

本文整理汇总了Python中cv2.cv.fromarray方法的典型用法代码示例。如果您正苦于以下问题:Python cv.fromarray方法的具体用法?Python cv.fromarray怎么用?Python cv.fromarray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cv2.cv的用法示例。


在下文中一共展示了cv.fromarray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_frames

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import fromarray [as 别名]
def process_frames(self):

        while True:
            frame = cv.QueryFrame(self.capture)

            aframe = numpy.asarray(frame[:, :])
            g = cv.fromarray(aframe)
            g = numpy.asarray(g)

            imgray = cv2.cvtColor(g, cv2.COLOR_BGR2GRAY)

            raw = str(imgray.data)
            scanner = zbar.ImageScanner()
            scanner.parse_config('enable')

            imagezbar = zbar.Image(frame.width, frame.height, 'Y800', raw)
            scanner.scan(imagezbar)

            # Process the frames
            for symbol in imagezbar:
                if not self.process_symbol(symbol):
                    return

            # Update the preview window
            cv2.imshow(self.window_name, aframe)
            cv.WaitKey(5) 
开发者ID:leonjza,项目名称:qrxfer,代码行数:28,代码来源:qrxfer.py

示例2: replace_color

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import fromarray [as 别名]
def replace_color(self,col=None):
        print self.hue[0][0]
        self.hue_val=col
        #cv2.imshow("hue",self.hue)
        if col!=None:
            cv.Set(cv.fromarray(self.hue),(self.hue_val),cv.fromarray(self.mask))
            
        self.scratch=cv2.merge([self.hue,self.sat,self.val])
        self.scratch=cv2.cvtColor(self.scratch,cv2.cv.CV_HSV2BGR)
        print 'replaced'
        return self.scratch 
开发者ID:akash0x53,项目名称:virtual-dressing-room,代码行数:13,代码来源:color_replace.py

示例3: getCurrentFrameAsImage

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import fromarray [as 别名]
def getCurrentFrameAsImage(self):
        im = numpy.array(self.currentFrame)
        im = cv.fromarray(im)
        cv.CvtColor(im, im, cv.CV_BGR2RGB)
        pgImg = pygame.image.frombuffer(im.tostring(), cv.GetSize(im), "RGB")
        return pgImg 
开发者ID:stbnps,项目名称:DanceCV,代码行数:8,代码来源:Input.py

示例4: undistort

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import fromarray [as 别名]
def undistort(self, image_or_2darray):
        """
        **SUMMARY**

        If given an image, apply the undistortion given by the camera's matrix and return the result.

        If given a 1xN 2D cvmat or a 2xN numpy array, it will un-distort points of
        measurement and return them in the original coordinate system.

        **PARAMETERS**

        * *image_or_2darray* - an image or an ndarray.

        **RETURNS**

        The undistorted image or the undistorted points. If the camera is un-calibrated
        we return None.

        **EXAMPLE**

        >>> img = cam.getImage()
        >>> result = cam.undistort(img)


        """
        if(type(self._calibMat) != cv.cvmat or type(self._distCoeff) != cv.cvmat ):
            logger.warning("FrameSource.undistort: This operation requires calibration, please load the calibration matrix")
            return None

        if (type(image_or_2darray) == InstanceType and image_or_2darray.__class__ == Image):
            inImg = image_or_2darray # we have an image
            retVal = inImg.getEmpty()
            cv.Undistort2(inImg.getBitmap(), retVal, self._calibMat, self._distCoeff)
            return Image(retVal)
        else:
            mat = ''
            if (type(image_or_2darray) == cv.cvmat):
                mat = image_or_2darray
            else:
                arr = cv.fromarray(np.array(image_or_2darray))
                mat = cv.CreateMat(cv.GetSize(arr)[1], 1, cv.CV_64FC2)
                cv.Merge(arr[:, 0], arr[:, 1], None, None, mat)

            upoints = cv.CreateMat(cv.GetSize(mat)[1], 1, cv.CV_64FC2)
            cv.UndistortPoints(mat, upoints, self._calibMat, self._distCoeff)

            #undistorted.x = (x* focalX + principalX);
            #undistorted.y = (y* focalY + principalY);
            return (np.array(upoints[:, 0]) *\
                [self.getCameraMatrix()[0, 0], self.getCameraMatrix()[1, 1]] +\
                [self.getCameraMatrix()[0, 2], self.getCameraMatrix()[1, 2]])[:, 0] 
开发者ID:sightmachine,项目名称:SimpleCV2,代码行数:53,代码来源:Camera.py


注:本文中的cv2.cv.fromarray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。