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


Python cv.IPL_DEPTH_8U属性代码示例

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


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

示例1: pretty_depth_cv

# 需要导入模块: import cv [as 别名]
# 或者: from cv import IPL_DEPTH_8U [as 别名]
def pretty_depth_cv(depth):
    """Converts depth into a 'nicer' format for display

    This is abstracted to allow for experimentation with normalization

    Args:
        depth: A numpy array with 2 bytes per pixel

    Returns:
        An opencv image who's datatype is unspecified
    """
    import cv
    depth = pretty_depth(depth)
    image = cv.CreateImageHeader((depth.shape[1], depth.shape[0]),
                                 cv.IPL_DEPTH_8U,
                                 1)
    cv.SetData(image, depth.tostring(),
               depth.dtype.itemsize * depth.shape[1])
    return image 
开发者ID:sightmachine,项目名称:SimpleCV2,代码行数:21,代码来源:frame_convert.py

示例2: video_cv

# 需要导入模块: import cv [as 别名]
# 或者: from cv import IPL_DEPTH_8U [as 别名]
def video_cv(video):
    """Converts video into a BGR format for opencv

    This is abstracted out to allow for experimentation

    Args:
        video: A numpy array with 1 byte per pixel, 3 channels RGB

    Returns:
        An opencv image who's datatype is 1 byte, 3 channel BGR
    """
    import cv
    video = video[:, :, ::-1]  # RGB -> BGR
    image = cv.CreateImageHeader((video.shape[1], video.shape[0]),
                                 cv.IPL_DEPTH_8U,
                                 3)
    cv.SetData(image, video.tostring(),
               video.dtype.itemsize * 3 * video.shape[1])
    return image 
开发者ID:sightmachine,项目名称:SimpleCV2,代码行数:21,代码来源:frame_convert.py

示例3: detectFaces

# 需要导入模块: import cv [as 别名]
# 或者: from cv import IPL_DEPTH_8U [as 别名]
def detectFaces(im):
    # This function takes a PIL image and finds the patterns defined in the
    # haarcascade function modified from: http://www.lucaamore.com/?p=638

    # Convert a PIL image to a greyscale cv image
    # from: http://pythonpath.wordpress.com/2012/05/08/pil-to-opencv-image/
    im = im.convert('L')
    cv_im = cv.CreateImageHeader(im.size, cv.IPL_DEPTH_8U, 1)
    cv.SetData(cv_im, im.tobytes(), im.size[0])

    # variables
    min_size = (20, 20)
    haar_scale = 1.1
    min_neighbors = 3
    haar_flags = 0

    # Equalize the histogram
    cv.EqualizeHist(cv_im, cv_im)

    # Detect the faces
    faces = cv.HaarDetectObjects(
        cv_im, faceCascade, cv.CreateMemStorage(0),
        haar_scale, min_neighbors, haar_flags, min_size
        )

    return faces 
开发者ID:mysociety,项目名称:yournextrepresentative,代码行数:28,代码来源:faces.py

示例4: process_file

# 需要导入模块: import cv [as 别名]
# 或者: from cv import IPL_DEPTH_8U [as 别名]
def process_file(filenameIN, WIDTH = 31, HEIGHT = 31):
    
    print "processing file: "+ filenameIN
    if not (os.path.exists(filenameIN)):
        print "file not found. Aborting."
        return
    else :
        srcImg = cv.LoadImage(filenameIN,0)
        res = cv.CreateImage( (WIDTH, HEIGHT), cv.IPL_DEPTH_8U, 1 )
        cv.Set(res, 255)
        xmin=WIDTH
        xmax=0
        ymin=HEIGHT
        ymax=0
        for i in range(srcImg.width):
            for j in range(srcImg.height):
                #print "xmax"
                #print cv.Get2D(srcImg, j, i)
                if cv.Get2D(srcImg, j, i)[0] == 0.0 :
                    #print "xin"
                    if i<xmin:
                        xmin = i
                    if i>xmax:
                        xmax = i
                    if j<ymin:
                        ymin=j
                    if j>ymax:
                        ymax=j
        
        offsetx = (WIDTH - (xmax-xmin))/2
        offsety = (HEIGHT - (ymax-ymin))/2
        #print 'WIDTH',WIDTH,"offset",offsety,offsetx
        for i in range(xmax-xmin):
            for j in range(ymax-ymin):
                if ((offsety+j>0) and (offsety+j<res.height) and (offsetx+i>0) and (offsetx+i<res.width)):
                    #print "haha"
                    cv.Set2D(res, offsety+j, offsetx+i, cv.Get2D(srcImg, ymin+j, xmin+i))

        cv.SaveImage(filenameIN, res) 
开发者ID:00nanhai,项目名称:captchacker2,代码行数:41,代码来源:characters_center.py

示例5: disp_thresh

# 需要导入模块: import cv [as 别名]
# 或者: from cv import IPL_DEPTH_8U [as 别名]
def disp_thresh(lower, upper):
    depth, timestamp = freenect.sync_get_depth()
    depth = 255 * np.logical_and(depth > lower, depth < upper)
    depth = depth.astype(np.uint8)
    image = cv.CreateImageHeader((depth.shape[1], depth.shape[0]),
                                 cv.IPL_DEPTH_8U,
                                 1)
    cv.SetData(image, depth.tostring(),
               depth.dtype.itemsize * depth.shape[1])
    cv.ShowImage('Depth', image)
    cv.WaitKey(10) 
开发者ID:sightmachine,项目名称:SimpleCV2,代码行数:13,代码来源:demo_cv_thresh_sweep.py

示例6: show_depth

# 需要导入模块: import cv [as 别名]
# 或者: from cv import IPL_DEPTH_8U [as 别名]
def show_depth():
    global threshold
    global current_depth

    depth, timestamp = freenect.sync_get_depth()
    depth = 255 * np.logical_and(depth >= current_depth - threshold,
                                 depth <= current_depth + threshold)
    depth = depth.astype(np.uint8)
    image = cv.CreateImageHeader((depth.shape[1], depth.shape[0]),
                                 cv.IPL_DEPTH_8U,
                                 1)
    cv.SetData(image, depth.tostring(),
               depth.dtype.itemsize * depth.shape[1])
    cv.ShowImage('Depth', image) 
开发者ID:sightmachine,项目名称:SimpleCV2,代码行数:16,代码来源:demo_cv_threshold.py


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