Trackbars – OpenCV 3.4 with python 3 Tutorial 8

Source code: import cv2 import numpy as np def nothing(x): pass cap = cv2.VideoCapture(0) cv2.namedWindow("frame") cv2.createTrackbar("test", "frame", 50, 500, nothing) cv2.createTrackbar("color/gray", "frame", 0, 1, nothing) while True: _, frame = cap.read() test = cv2.getTrackbarPos("test", "frame") font = cv2.FONT_HERSHEY_COMPLEX cv2.putText(frame, str(test), (50, 150), font, 4, (0,…

Bitwise Operators – OpenCV 3.4 with python 3 Tutorial 7

Source code: import cv2 import numpy as np img1 = cv2.imread("drawing_1.png") img2 = cv2.imread("drawing_2.png") bit_and = cv2.bitwise_and(img2, img1) bit_or = cv2.bitwise_or(img2, img1) bit_xor = cv2.bitwise_xor(img1, img2) bit_not = cv2.bitwise_not(img1) bit_not2 = cv2.bitwise_not(img2) cv2.imshow("img1", img1) cv2.imshow("img2", img2) cv2.imshow("bit_and", bit_and) cv2.imshow("bit_or", bit_or) cv2.imshow("bit_xor", bit_xor) cv2.imshow("bit_not", bit_not) cv2.imshow("bit_not2",…

Blending images – OpenCV 3.4 with python 3 Tutorial 6

Source code: import cv2 import numpy as np img1 = cv2.imread("road.jpg") img2 = cv2.imread("car.jpg") img2_gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY) ret, mask = cv2.threshold(img2_gray, 240, 255, cv2.THRESH_BINARY) mask_inv = cv2.bitwise_not(mask) road = cv2.bitwise_and(img1, img1, mask=mask) car = cv2.bitwise_and(img2, img2, mask=mask_inv) result = cv2.add(road, car) cv2.imshow("img1", img1) cv2.imshow("img2",…

Add images and Threshold – OpenCV 3.4 with python 3 Tutorial 5

Source Code: import cv2 import numpy as np img1 = cv2.imread("road.jpg") img2 = cv2.imread("car.jpg") img2_gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY) print(img1[0, 0]) print(img2[0, 0]) weighted = cv2.addWeighted(img1, 1, img2, 0.1, 0) ret, mask = cv2.threshold(img2_gray, 252, 255, cv2.THRESH_BINARY_INV) sum = cv2.add(img2, img2, mask=mask) cv2.imshow("sum", sum) cv2.imshow("threshold", mask)…

Tutorial: Remove background – opencv 3.2 with python 3

Source code: import cv2 import numpy as np cap = cv2.VideoCapture(0) panel = np.zeros([100, 700], np.uint8) cv2.namedWindow('panel') def nothing(x): pass cv2.createTrackbar('L – h', 'panel', 0, 179, nothing) cv2.createTrackbar('U – h', 'panel', 179, 179, nothing) cv2.createTrackbar('L – s', 'panel', 0, 255, nothing) cv2.createTrackbar('U – s', 'panel',…

Copyright © Pysource 2017-2019, VAT: PL9721276174, Poznan (Poland) - Privacy Policy