# Output webcam image as JPEG
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
plt.figure(1, figsize=(10, 10))
plt.imshow(frame_vga[:,:,[2,1,0]])
plt.show()
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
plt.figure(1, figsize=(10, 10))
plt.imshow(laplacian_frame[:,:,[2,1,0]])
plt.show()
# Sobelフィルタのコードは【Python/OpenCV】Sobelフィルタで輪郭検出(エッジ抽出)の方法まる3を参考にした
# https://algorithm.joho.info/programming/python/opencv-sobel-filter-py/
import time
num_frames = 60
readError = 0
start = time.time()
for i in range (num_frames):
# read next image
ret, frame_vga = videoIn.read()
if (ret):
outframe = displayport.newframe()
frame_vga_gray = cv2.cvtColor(frame_vga, cv2.COLOR_RGB2GRAY)
sobel_framex = cv2.Sobel(frame_vga_gray, cv2.CV_32F, 1, 0)
sobel_framey = cv2.Sobel(frame_vga_gray, cv2.CV_32F, 0, 1)
sobel_frame = np.sqrt(sobel_framex ** 2 + sobel_framey ** 2)
outframe[:,:,0] = sobel_frame
outframe[:,:,1] = sobel_frame
outframe[:,:,2] = sobel_frame
displayport.writeframe(outframe)
else:
readError += 1
end = time.time()
print("Frames per second: " + str((num_frames-readError) / (end - start)))
print("Number of read errors: " + str(readError))
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
plt.figure(1, figsize=(10, 10))
plt.imshow(outframe)
plt.show()
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | - | - | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 | - | - | - | - | - | - |