# PyOpencv code that displays color, b/w and canny images input from single live webcam camera

I have e single live webcam camera. I have displayed one color image, black and white image and canny edge image. Do you think I should put a scrollbar for the canny edge detection amount to make it a standard program or current threshold is fine?

import cv2
import cv
import numpy as np
import matplotlib.image as mpimg
from matplotlib import pyplot as plt

cam = cv2.VideoCapture(0)
cv2.namedWindow("test")

img_counter = 0

while True:

edges = cv2.Canny(color, 50,500)
gray = cv2.cvtColor(color,cv2.COLOR_RGB2GRAY)
grey_3_channel = cv2.cvtColor(gray, cv2.COLOR_GRAY2BGR)
edges_3_channel = cv2.cvtColor(edges, cv2.COLOR_GRAY2BGR)
#blank_image = np.zeros((color.height*3,color.width*3,3), np.uint8)

horiz = np.hstack((color, grey_3_channel,edges_3_channel))

cv2.imshow('HORIZONTAL', horiz)

if not ret:
break
k = cv2.waitKey(1)

if k%256 == 27:
# ESC pressed
print("Escape hit, closing...")
break

cam.release()

cv2.destroyAllWindows()


• I see you've posted three questions in under three hours. While it's not really a problem, don't you think it would be better if you waited to have answers for a question in order not to redo the same mistakes in every questions? :) Dec 3, 2019 at 16:56
• @IEatBagels: While the first question seems independent enough (it is about the underlying C++ code that performs the edge detection used here), the second question is certainly similar enough to this one that getting (more) feedback on that one first might make sense. Dec 3, 2019 at 17:28