How to create a simple application which show the color you specify.

import cv2
import numpy as np

black_image = np.zeros((400, 600, 3), np.uint8)

print(black_image)
def nothing (x):
    pass
cv2.namedWindow('window')
cv2.createTrackbar('Red', 'window', 0, 255, nothing)
cv2.createTrackbar('Green', 'window', 0, 255, nothing)
cv2.createTrackbar('Blue', 'window', 0, 255, nothing)


while True:
    cv2.imshow('window', black_image)
    if cv2.waitKey(1) == 27:
        break
    r = cv2.getTrackbarPos('Red', 'window')
    g = cv2.getTrackbarPos('Green', 'window')
    b = cv2.getTrackbarPos('Blue', 'window')

    black_image[:] = [b, g, r]

cv2.destroyAllWindows()



Comments

Popular posts from this blog

how to Create a Black Image in OpenCV

Playing a video from file with color BGR, RGB, GRAY, HSV in OpenCV

Capturing Video via webcam