ch04 trackbar
#python codeimport cv2import numpy as npdef on_level_change(pos, img): img[:] = pos * 16 cv2.imshow("image", img)def main(): img = np.zeros((400, 400), dtype=np.uint8) cv2.namedWindow("image") cv2.createTrackbar("level", "image", 0, 16, lambda pos: on_level_change(pos, img)) cv2.imshow("image", img) cv2.waitKey()if __name__ == "__main__": main()// C++ code#include "opencv..
더보기
ch04 trackbar
#python codeimport cv2import numpy as npdef on_level_change(pos, img): img[:] = pos * 16 cv2.imshow("image", img)def main(): img = np.zeros((400, 400), dtype=np.uint8) cv2.namedWindow("image") cv2.createTrackbar("level", "image", 0, 16, lambda pos: on_level_change(pos, img)) cv2.imshow("image", img) cv2.waitKey()if __name__ == "__main__": main()// C++ code#include "opencv..
더보기
ch04 drawing
#python codeimport cv2import numpy as npdef drawLines(): img = np.full((400, 400, 3), (255, 255, 255), dtype=np.uint8) cv2.line(img, (50, 50), (200, 50), (0, 0, 255)) cv2.line(img, (50, 100), (200, 100), (255, 0, 255), 3) cv2.line(img, (50, 150), (200, 150), (255, 0, 0), 10) cv2.line(img, (250, 50), (350, 100), (0, 0, 255), 1, cv2.LINE_4) cv2.line(img, (250, 70), (350, 120), (2..
더보기
ch03 ScalarOp
#python codeimport cv2import numpy as npdef VecOp(): p1 = np.zeros(3, dtype=np.uint8) # Vec3b equivalent p2 = np.array([0, 0, 255], dtype=np.uint8) # Vec3b equivalent p1[0] = 100 print("p1:", p1) print("p2:", p2)def ScalarOp(): gray = np.array([128, 128, 128], dtype=np.uint8) # Scalar equivalent print("gray:", gray) yellow = np.array([0, 255, 255], dtype=np.uint8) # S..
더보기
ch03 MatOp
import cv2import numpy as npdef MatOp1(): img1 = np.empty((0, 0), dtype=np.uint8) # empty matrix img2 = np.zeros((480, 640), dtype=np.uint8) # unsigned char, 1-channel img3 = np.zeros((480, 640, 3), dtype=np.uint8) # unsigned char, 3-channels img4 = np.zeros((480, 640, 3), dtype=np.uint8) # Size(width, height) img5 = np.full((480, 640), 128, dtype=np.uint8) # initial values, ..
더보기