Python cv2.CV_8UC3 Examples
The following are 24 code examples for showing how to use cv2.CV_8UC3(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
cv2
, or try the search function
.
Example 1
Project: robotics-rl-srl Author: araffin File: omnirobot_simulator_server.py License: MIT License | 6 votes |
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
Example 2
Project: python-opencv-gpu-video Author: Kjue File: UMatFileVideoStream.py License: MIT License | 6 votes |
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)
Example 3
Project: OpenCV-Python-Tutorial Author: makelove File: watershed.py License: MIT License | 5 votes |
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)
Example 4
Project: OpenCV-Python-Tutorial Author: makelove File: gabor_threads.py License: MIT License | 5 votes |
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
Example 5
Project: OpenCV-Python-Tutorial Author: makelove File: gabor_threads.py License: MIT License | 5 votes |
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
Example 6
Project: OpenCV-Python-Tutorial Author: makelove File: video.py License: MIT License | 5 votes |
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
Example 7
Project: OpenCV-Python-Tutorial Author: makelove File: video.py License: MIT License | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) return True, cv2.add(self.render.getNextFrame(), noise, dtype=cv2.CV_8UC3)
Example 8
Project: MachineLearning Author: mengli File: video.py License: Apache License 2.0 | 5 votes |
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
Example 9
Project: MachineLearning Author: mengli File: video.py License: Apache License 2.0 | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv2.randn(noise, np.zeros(3), np.ones(3) * 255 * self.noise) return True, cv2.add(self.render.getNextFrame(), noise, dtype=cv2.CV_8UC3)
Example 10
Project: MachineLearning Author: mengli File: video.py License: Apache License 2.0 | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv2.randn(noise, np.zeros(3), np.ones(3) * 255 * self.noise) return True, cv2.add(self.render.getNextFrame(), noise, dtype=cv2.CV_8UC3)
Example 11
Project: pi-tracking-telescope Author: tobykurien File: video.py License: MIT License | 5 votes |
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
Example 12
Project: TecoGAN Author: thunil File: video.py License: Apache License 2.0 | 5 votes |
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
Example 13
Project: TecoGAN Author: thunil File: video.py License: Apache License 2.0 | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) return True, cv.add(self.render.getNextFrame(), noise, dtype=cv.CV_8UC3)
Example 14
Project: TecoGAN Author: thunil File: video.py License: Apache License 2.0 | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) return True, cv.add(self.render.getNextFrame(), noise, dtype=cv.CV_8UC3)
Example 15
Project: PyCV-time Author: fatcloud File: watershed.py License: MIT License | 5 votes |
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)
Example 16
Project: PyCV-time Author: fatcloud File: gabor_threads.py License: MIT License | 5 votes |
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
Example 17
Project: PyCV-time Author: fatcloud File: gabor_threads.py License: MIT License | 5 votes |
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
Example 18
Project: PyCV-time Author: fatcloud File: video.py License: MIT License | 5 votes |
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
Example 19
Project: PyCV-time Author: fatcloud File: watershed.py License: MIT License | 5 votes |
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)
Example 20
Project: PyCV-time Author: fatcloud File: gabor_threads.py License: MIT License | 5 votes |
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
Example 21
Project: PyCV-time Author: fatcloud File: video.py License: MIT License | 5 votes |
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
Example 22
Project: OpenCV-Snapchat-DogFilter Author: sguduguntla File: video.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example 23
Project: OpenCV-Snapchat-DogFilter Author: sguduguntla File: video.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) return True, cv2.add(self.render.getNextFrame(), noise, dtype=cv2.CV_8UC3)
Example 24
Project: OpenCV-Snapchat-DogFilter Author: sguduguntla File: video.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
def read(self, dst=None): noise = np.zeros(self.render.sceneBg.shape, np.int8) cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) return True, cv2.add(self.render.getNextFrame(), noise, dtype=cv2.CV_8UC3)