import numpy as np import cv2 black_image = np.zeros((512,512,3), np.uint8 ) r = 200 for theta in range(0,360): radian = theta*np.pi/180 x=np.cos(radian)*r y=np.sin(radian)*r cv2.line( black_image, (250,250), (int(x+250),int(y+250)), (255,0,0), 1 ) cv2.imshow( "image", black_image ) cv2.waitKey(0) black_image = np.zeros((512,512,3), np.uint8 )512x512크기의 BGR 이미지를 생성. 0으로 채워지기때문에 블랙 이미지임 r = 200 f..
다음과 같이 필요한 패키지를 설치합니다. 그냥 저장소에 있는 버전을 사용할 경우에 데이터가 안넘어오는 문제가 있었습니다. 그래서 기존에 설치한 것을 지우고 pip를 이용하여 설치하였습니다. sudo apt-get purge python-pymssql python-pipsudo apt-get install freetds-devsudo pip install Cythonsudo pip install pymssql DB로부터 데이터를 가져오는 간단한 예제입니다. 윈도우에서 사용할시에도 아래처럼 사용하면 잘 동작합니다. import _mssql conn = _mssql.connect(server='서버 아이피', user='아이디', password='패스워드', database='데이터베이스 이름') conn...
OpenWeatherMap에서 제공하는 서울의 날씨 데이터를 JSON으로 받아와서 파이썬을 사용해서 파싱을 해봤습니다. 우선 전체 JSON 데이터의 형태입니다. 이 중에 몇 가지만 파싱해서 보기좋게 출력을 해보았습니다. { "coord":{"lon":126.98,"lat":37.57}, "sys":{"message":0.0103,"country":"KR","sunrise":1429735588,"sunset":1429784064}, "weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}], "base":"stations", "main":{"temp":288.243,"temp_min":288.243,"temp_max":288..
찾아가면서 공부하려니..간단한것도 막힌다.. 출처: http://www.johnkerl.org/python/sprintf.html#!/usr/bin/python -Wall # ================================================================ # John Kerl # kerl.john.r@gmail.com # 2007-05-15 # ================================================================ print "Here %s the number: %d" % ("is", 37) s = "Here %s the number: %d" % ("is", 37) print s