當前位置: 首頁>>代碼示例>>Python>>正文


Python cv2.bitwise_xor方法代碼示例

本文整理匯總了Python中cv2.bitwise_xor方法的典型用法代碼示例。如果您正苦於以下問題:Python cv2.bitwise_xor方法的具體用法?Python cv2.bitwise_xor怎麽用?Python cv2.bitwise_xor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cv2的用法示例。


在下文中一共展示了cv2.bitwise_xor方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: movement

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import bitwise_xor [as 別名]
def movement(mat_1,mat_2):
    mat_1_gray     = cv2.cvtColor(mat_1.copy(),cv2.COLOR_BGR2GRAY)
    mat_1_gray     = cv2.blur(mat_1_gray,(blur1,blur1))
    _,mat_1_gray   = cv2.threshold(mat_1_gray,100,255,0)
    mat_2_gray     = cv2.cvtColor(mat_2.copy(),cv2.COLOR_BGR2GRAY)
    mat_2_gray     = cv2.blur(mat_2_gray,(blur1,blur1))
    _,mat_2_gray   = cv2.threshold(mat_2_gray,100,255,0)
    mat_2_gray     = cv2.bitwise_xor(mat_1_gray,mat_2_gray)
    mat_2_gray     = cv2.blur(mat_2_gray,(blur2,blur2))
    _,mat_2_gray   = cv2.threshold(mat_2_gray,70,255,0)
    mat_2_gray     = cv2.erode(mat_2_gray,np.ones((erodeval,erodeval)))
    mat_2_gray     = cv2.dilate(mat_2_gray,np.ones((4,4)))
    _, contours,__ = cv2.findContours(mat_2_gray,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
    if len(contours) > 0:return True #If there were any movements
    return  False                    #if not


#Pedestrian Recognition Thread 
開發者ID:PiSimo,項目名稱:PiCamNN,代碼行數:20,代碼來源:picam.py

示例2: logical_xor

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import bitwise_xor [as 別名]
def logical_xor(bin_img1, bin_img2):
    """Join two images using the bitwise XOR operator.

    Inputs:
    bin_img1   = Binary image data to be compared to bin_img2
    bin_img2   = Binary image data to be compared to bin_img1

    Returns:
    merged     = joined binary image

    :param bin_img1: numpy.ndarray
    :param bin_img2: numpy.ndarray
    :return merged: numpy.ndarray
    """

    params.device += 1
    merged = cv2.bitwise_xor(bin_img1, bin_img2)
    if params.debug == 'print':
        print_image(merged, os.path.join(params.debug_outdir, str(params.device) + '_xor_joined.png'))
    elif params.debug == 'plot':
        plot_image(merged, cmap='gray')
    return merged 
開發者ID:danforthcenter,項目名稱:plantcv,代碼行數:24,代碼來源:logical_xor.py

示例3: main

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import bitwise_xor [as 別名]
def main():
    basePath = "../data/"

    imageFileOne = basePath + "4.1.04.tiff"
    imageFileTwo = basePath + "4.1.05.tiff"

    imageOne = cv2.imread(imageFileOne, 1)
    imageTwo = cv2.imread(imageFileTwo, 1)

    imageOneRGB = cv2.cvtColor(imageOne, cv2.COLOR_BGR2RGB)
    imageTwoRGB = cv2.cvtColor(imageTwo, cv2.COLOR_BGR2RGB)

    negativeImage = cv2.bitwise_not(imageOneRGB)
    andImage = cv2.bitwise_and(imageOneRGB, imageTwoRGB)
    orImage = cv2.bitwise_or(imageOneRGB, imageTwoRGB)
    xorImage = cv2.bitwise_xor(imageOneRGB, imageTwoRGB)

    imageNames = [imageOneRGB, imageTwoRGB, negativeImage, andImage, orImage, xorImage]
    imageTitles = ["Image One", "Image Two", "Negative", "AND", "OR", "XOR"]

    for i in range(6):
        plt.subplot(2, 3, i + 1)
        plt.imshow(imageNames[i])
        plt.title(imageTitles[i])
        plt.xticks([])
        plt.yticks([])

    plt.show() 
開發者ID:amarlearning,項目名稱:Finger-Detection-and-Tracking,代碼行數:30,代碼來源:LogicalOperation.py


注:本文中的cv2.bitwise_xor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。