Extract blue using OpenCV capture camera image under Python3

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.