本文整理汇总了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
示例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
示例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()