머신러닝을 이용한 사이트
https://quickdraw.withgoogle.com/#
https://www.autodraw.com/
https://magenta.tensorflow.org/assets/sketch_rnn_demo/index.html
pip install opencv-python
import cv2
# 이미지 읽기
img1 = cv2.imread('sea.jpg', cv2.IMREAD_COLOR)
img2 = cv2.imread('sea.jpg', cv2.IMREAD_GRAYSCALE)
# 이미지 화면에 표시
cv2.imshow('sea color', img1)
cv2.imshow('sea gray', img2)
cv2.waitKey(0)
# 이미지 윈도우 삭제
cv2.destroyAllWindows()
# 카메라 영상 처리
import cv2
cap = cv2.VideoCapture(0) # default camera
# cap = cv2.VideoCapture('test.mp4') # 동영상 파일에서 읽기
while cap.isOpened():
# 카메라 프레임 읽기
success, frame = cap.read()
if success :
# 프레임 출력
cv2.imshow('Camera Window', frame)
# ESC 키를 누르면 종료
key = cv2.waitKey(1)
if(key == 27): # 27 : ESC 키의 아스키코드
break
cap.release()
cv2.destroyAllWindows()
X 버튼을 누르면 종료가 안되고 ESC키를 눌러야 종료됨.
# 카메라 영상 처리
import cv2
cap = cv2.VideoCapture(0) # default camera
# cap = cv2.VideoCapture('test.mp4') # 동영상 파일에서 읽기
width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
print("size : {0} x {1}".format(width, height))
# 영상 저장을 위한 VideoWriter 인스턴스 생성
fourcc = cv2.VideoWriter_fourcc(*'XVID')
writer = cv2.VideoWriter("cam.avi", fourcc, 24, (int(width), int(height)) )
while cap.isOpened():
# 카메라 프레임 읽기
success, frame = cap.read()
if success :
# 프레임 출력
cv2.imshow('Camera Window', frame)
writer.write(frame) # 프레임 저장
# ESC 키를 누르면 종료
key = cv2.waitKey(1)
if(key == 27): # 27 : ESC 키의 아스키코드
break
cap.release()
writer.release()
cv2.destroyAllWindows()
실행했다 종료하면 자동저장 됨.
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('sea.png', 1)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
plt.imshow(img)
plt.show()
from cProfile import label
from tkinter import *
root = Tk()
root.title("Python GUI")
root.geometry("800x640+500+100")
photo1 = PhotoImage(file="logo.png")
# label = Label(root, text = "땅땅")
label = Label(root, image=photo1)
label.pack()
def btncmd():
print('좋아요')
photo = PhotoImage(file="logo.png")
btn = Button(root, image=photo, command=btncmd)
btn.pack()
root.mainloop()
from cProfile import label
from tkinter import *
root = Tk()
root.title("Python GUI")
root.geometry("800x640+500+100")
label1 = Label(root, text="최선을 다하자")
label1.pack()
def change():
# label1.config(text="시러요")
global photo1 # lable1은 photo1이 누구인지 모르므로 global로 만들어줌
photo1 = PhotoImage(file="sea.png")
label1.config(image=photo1)
photo = PhotoImage(file="logo.png")
btn = Button(root, image=photo, command=change)
btn.pack()
root.mainloop()
버튼을 클릭하면 레이블이 이미지로 변화