當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。