def read(self, dst=None):\r
w, h = self.frame_size\r
\r
- buf = np.zeros((h, w, 3), np.uint8)\r
- if self.bg is not None:\r
- buf[:] = self.bg\r
+ if self.bg is None:\r
+ buf = np.zeros((h, w, 3), np.uint8)\r
+ else:\r
+ buf = self.bg.copy()\r
if self.noise > 0.0:\r
- noise = np.random.normal(scale = 255*self.noise, size=(h, w, 3))\r
+ noise = np.zeros((h, w, 3), np.int8)\r
+ cv2.randn(noise, np.zeros(3), np.ones(3)*255*self.noise)\r
buf = cv2.add(buf, noise, dtype=cv2.CV_8UC3)\r
return True, buf\r
\r