The work requires the camera to be debugged, the Python platform greatly improves debugging efficiency.
Find the segment code from the net, you can key out the blue from the camera image.
Import Cv2
Import NumPy as NP
Cap = Cv2. Videocapture (0)
For I in range (0, 19):
Print (Cap.get (i))
while (1):
RET, frame = Cap.read ()
HSV = Cv2.cvtcolor (frame, cv2. COLOR_BGR2HSV)
Lower_blue = Np.array ([100, 47, 47])
Upper_blue = Np.array ([124, 255,255])
Mask = Cv2.inrange (HSV, Lower_blue, Upper_blue) #蓝色掩模
res = Cv2.bitwise_and (frame, frame, mask = mask)
Cv2.imshow (U "Capture", frame)
Cv2.imshow (U "Mask", mask)
Cv2.imshow (U "res", RES)
Key = Cv2.waitkey (1)
If key & 0xff = = Ord (' q ') or key = = 27:
Print (Frame.shape,ret)
Break
Cap.release ()
Cv2.destroyallwindows ()
Below is the range of HSV color components truncated from the Wangyblzu blog
Https://www.cnblogs.com/wangyblzu/p/5710715.html
Three result diagram
Technorati TAGS:PYTHON3,OPENCV
Extract blue using OpenCV capture camera image under Python3