프로그래밍 꿀팁
2015년 6월 29일 월요일
[OpenCV - Python ] Draw 테스트
Python - OpenCV
목표 : 사각형을 Draw 하고, 움직여보자!
import cv2 import numpy as np ## 이미지 배경 검은색으로 img1 = np.zeros((500,500,3), np.uint8) ## 사각형 그린다. ## rectangle (image context, 포인트1, 포인트2, 색, 두께) fxpoint = 1 fypoint = 1 point1 = 0 direction = 1 point2 = 0 direciton2 = 1 ## 루프문 while (True): if (point1 > 400): direction = -1 if (point1 < 400 & point1 >= 0): direction = 1 if (point2 > 400): direciton2 = -1 if (point2 < 400 & point2 >= 0): direciton2 = 1 point1 = point1 + 1 * direction point2 = point2 + 2 * direciton2 img1 = np.zeros((500,500,3), np.uint8) cv2.rectangle(img1,(fxpoint + point1, fypoint + point2),(101 + point1,101 + point2),(255,255,0),2) cv2.imshow('draw',img1) k = cv2.waitKey(1) & 0xFF if k == 27: break cv2.destroyAllWindows()
실행 결과
움직이는 사각형을 볼 수 있을 겁니다
댓글 없음:
댓글 쓰기
최근 게시물
이전 게시물
홈
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기