本文整理匯總了Python中cv2.CV_8UC3屬性的典型用法代碼示例。如果您正苦於以下問題:Python cv2.CV_8UC3屬性的具體用法?Python cv2.CV_8UC3怎麽用?Python cv2.CV_8UC3使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類cv2
的用法示例。
在下文中一共展示了cv2.CV_8UC3屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: renderEnvLuminosityNoise
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_8UC3 [as 別名]
def renderEnvLuminosityNoise(self, origin_image, noise_var=0.1, in_RGB=False, out_RGB=False):
"""
render the different environment luminosity
"""
# variate luminosity and color
origin_image_LAB = cv2.cvtColor(
origin_image, cv2.COLOR_RGB2LAB if in_RGB else cv2.COLOR_BGR2LAB, cv2.CV_32F)
origin_image_LAB[:, :, 0] = origin_image_LAB[:,
:, 0] * (np.random.randn() * noise_var + 1.0)
origin_image_LAB[:, :, 1] = origin_image_LAB[:,
:, 1] * (np.random.randn() * noise_var + 1.0)
origin_image_LAB[:, :, 2] = origin_image_LAB[:,
:, 2] * (np.random.randn() * noise_var + 1.0)
out_image = cv2.cvtColor(
origin_image_LAB, cv2.COLOR_LAB2RGB if out_RGB else cv2.COLOR_LAB2BGR, cv2.CV_8UC3)
return out_image
示例2: __init__
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_8UC3 [as 別名]
def __init__(self, path, queueSize=128):
# initialize the file video stream along with the boolean
# used to indicate if the thread should be stopped or not
self.stream = cv2.VideoCapture(path)
self.stopped = False
self.count = 0
# initialize the queue used to store frames read from
# the video file
self.Q = Queue(maxsize=queueSize)
# We need some info from the file first. See more at:
# https://docs.opencv.org/4.1.0/d4/d15/group__videoio__flags__base.html#gaeb8dd9c89c10a5c63c139bf7c4f5704d
self.width = int(self.stream.get(cv2.CAP_PROP_FRAME_WIDTH))
self.height = int(self.stream.get(cv2.CAP_PROP_FRAME_HEIGHT))
# since this version uses UMat to store the images to
# we need to initialize them beforehand
self.frames = [0] * queueSize
for ii in range(queueSize):
self.frames[ii] = cv2.UMat(self.height, self.width, cv2.CV_8UC3)
示例3: watershed
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_8UC3 [as 別名]
def watershed(self):
m = self.markers.copy()
cv2.watershed(self.img, m)
overlay = self.colors[np.maximum(m, 0)]
vis = cv2.addWeighted(self.img, 0.5, overlay, 0.5, 0.0, dtype=cv2.CV_8UC3)
cv2.imshow('watershed', vis)
示例4: process
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_8UC3 [as 別名]
def process(img, filters):
accum = np.zeros_like(img)
for kern in filters:
fimg = cv2.filter2D(img, cv2.CV_8UC3, kern)
np.maximum(accum, fimg, accum)
return accum
示例5: process_threaded
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_8UC3 [as 別名]
def process_threaded(img, filters, threadn = 8):
accum = np.zeros_like(img)
def f(kern):
return cv2.filter2D(img, cv2.CV_8UC3, kern)
pool = ThreadPool(processes=threadn)
for fimg in pool.imap_unordered(f, filters):
np.maximum(accum, fimg, accum)
return accum
示例6: read
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_8UC3 [as 別名]
def read(self, dst=None):
w, h = self.frame_size
if self.bg is None:
buf = np.zeros((h, w, 3), np.uint8)
else:
buf = self.bg.copy()
self.render(buf)
if self.noise > 0.0:
noise = np.zeros((h, w, 3), np.int8)
cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise)
buf = cv2.add(buf, noise, dtype=cv2.CV_8UC3)
return True, buf
示例7: read
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_8UC3 [as 別名]
def read(self, dst=None):
w, h = self.frame_size
if self.bg is None:
buf = np.zeros((h, w, 3), np.uint8)
else:
buf = self.bg.copy()
self.render(buf)
if self.noise > 0.0:
noise = np.zeros((h, w, 3), np.int8)
cv2.randn(noise, np.zeros(3), np.ones(3) * 255 * self.noise)
buf = cv2.add(buf, noise, dtype=cv2.CV_8UC3)
return True, buf
示例8: read
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_8UC3 [as 別名]
def read(self, dst=None):
w, h = self.frame_size
if self.bg is None:
buf = np.zeros((h, w, 3), np.uint8)
else:
buf = self.bg.copy()
self.render(buf)
if self.noise > 0.0:
noise = np.zeros((h, w, 3), np.int8)
cv.randn(noise, np.zeros(3), np.ones(3)*255*self.noise)
buf = cv.add(buf, noise, dtype=cv.CV_8UC3)
return True, buf