Created
November 29, 2016 05:27
-
-
Save Gotoryoo/354ab7c83619dc0e14a898ea7e4b36dc to your computer and use it in GitHub Desktop.
指定した大きさの図形を作成するプログラムである。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Aug 29 14:48:11 2015 | |
@author: ryousuke | |
""" | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu May 21 14:28:05 2015 | |
指定した大きさの図形を作成するプログラムである。 | |
cv2.rectangle で長方形を作成する。 | |
cv2.circle で円を作成する。 | |
cv2.putTex で指定した文書を画像中に表示する。 | |
@author: ryousuke | |
""" | |
from PIL import Image | |
import numpy as np | |
import math | |
import glob | |
import os | |
import cv2 | |
objects = glob.glob('C:\\Users\\ryousuke\\Desktop\\lab_log\\20150827_mod64_sec10_2\\*') | |
for obj in objects: | |
if os.path.isdir(obj)==False: | |
continue | |
print obj | |
center_pixels = [] | |
f = open(obj+'\\center_pixel.txt') | |
lines = f.readlines() | |
f.close | |
for line in lines: | |
print line, | |
index = line.split(" ") | |
center_pixels.append( (int(index[1]), int(index[2])) ) | |
for l in range(11): | |
filepath = obj+'\\img_l_{0}.bmp'.format(l) | |
img = cv2.imread(filepath, 1) | |
posx = center_pixels[l][0] | |
posy = center_pixels[l][1] | |
linelength = 15 | |
cv2.line(img,(posx-linelength,posy),(posx-5,posy),(0,0,255)) | |
cv2.line(img,(posx+linelength,posy),(posx+5,posy),(0,0,255)) | |
cv2.line(img,(posx,posy-5),(posx,posy-linelength),(0,0,255)) | |
cv2.line(img,(posx,posy+5),(posx,posy+linelength),(0,0,255)) | |
cv2.putText(img, filepath, (10,20),cv2.FONT_HERSHEY_COMPLEX,0.3,(0,0,255)) | |
cv2.imshow('img', img) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() | |
#cv2.imwrite('img_l_0_m.bmp',img) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment