본문 바로가기

Python31

[Python] 삼각형 넓이 구하기 123456width = int(input('width: '))height = int(input('height: ')) area = width * height / 2 # /는 소수점, //는 정수형으로 계산함. print('area: ', area) 2020. 11. 23.
[Python, OpenCV] 두 개의 이미지 파일 합성하기 12345678910111213141516171819202122232425262728293031# apple.jpg 그림에 opencv_logo 그림을 Mask_inverse하여 합성. import cv2import numpy as np src1 = cv2.imread('../data/apple.jpg') #사과파일 읽기src2 = cv2.imread('../data/opencv_logo.png') #로고파일 읽기 rows, cols, channels = src2.shape #로고파일 픽셀값 저장roi = src1[50:rows+50,50:cols+50] #로고파일 필셀값을 관심영역(ROI)으로 저장함. gray = cv2.cvtColor(src2, cv2.COLOR_BGR2GRAY) #로고파일의 색상을.. 2020. 11. 11.
[Python, OpenCV] boxFilter 와 bilateralFilter 를 5초 간격으로 번갈아 실행시키기 123456789101112131415161718192021222324252627282930313233import cv2import time cap = cv2.VideoCapture(0) #윈도우 카메라 실행frame_size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)),                int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)))oldTime = time.time() #시작 시간 측정while True:    retval, frame = cap.read() #retval: 비디오영상을 캡쳐했는지(T/F), frame: 비디오영상 프레임 저장    if not retval:        break; #False면 while문 탈출.   .. 2020. 11. 11.
[Flask] SQLite 예제 Flask – SQLite - TutorialspointFlask – SQLite Python has an in-built support for SQlite. SQlite3 module is shipped with Python distribution. For a detailed tutorial on using SQLite database in Python, please refer to this link. In this section we shall see how a Flask application intewww.tutorialspoint.com     1234567891011121314import sqlite3 conn = sqlite3.connect('database.db')print('데이터베이스.. 2020. 9. 24.
[Flask] File Uploading 예제 (파일 제출 안할 경우 flash로 에러메시지 출력) Uploading Files — Flask Documentation (1.1.x)Uploading Files Ah yes, the good old problem of file uploads. The basic idea of file uploads is actually quite simple. It basically works like this: A tag is marked with enctype=multipart/form-data and an is placed in that form. The application accesses thflask.palletsprojects.com  Flask – File Uploading - TutorialspointFlask – File Uploading Handli.. 2020. 9. 24.
[Flask] Message Flashing 예제 Flask – Message Flashing - TutorialspointFlask – Message Flashing A good GUI based application provides feedback to a user about the interaction. For example, the desktop applications use dialog or message box and JavaScript uses alerts for similar purpose. Generating such informative messageswww.tutorialspoint.com     123456789101112131415161718192021222324from flask import Flask, flash, redi.. 2020. 9. 24.
[Flask] Redirect & Errors 예제 Flask – Redirect & Errors - TutorialspointFlask – Redirect & Errors Flask class has a redirect() function. When called, it returns a response object and redirects the user to another target location with specified status code. Prototype of redirect() function is as below − Flask.redirect(locatwww.tutorialspoint.com    12345678910111213141516171819202122from flask import Flask, redirect, url_fo.. 2020. 9. 24.