목록이미지 (3)
Head vs breakz
from google.cloud import vision import os,io os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ='구글에서받은.json' # def detect_text(path): client = vision.ImageAnnotatorClient() with io.open(path, 'rb') as image_file: content = image_file.read() image = vision.types.Image(content=content) response = client.text_detection(image=image) texts = response.text_annotations print(texts) for text in texts: print..
이미지파일은 PNG 파일이여야 한다. JPG로 했다가 안된다는 걸 늦게 보았다... from PIL import Image for i in range(1,1001): im = Image.open('./image_test/'+str(i)+'.jpg') im.save(str(i)+'.png') img = Image.open(str(i)+'.png') img = img.convert("RGBA") datas =img.getdata() newData = [] cutOff = 50 for item in datas: if item[0] < cutOff and item[1] < cutOff and item[2] < cutOff: newData.append((0, 0, 0, 0)) # RGB의 각 요소가 모두 cutO..
import numpy as np import cv2 from matplotlib import pyplot as plt for i in range(1,1001): img = cv2.imread('./image/'+str(i)+'.jpg') #이미지 크기조절 img = cv2.resize(img,dsize=(350,200),interpolation=cv2.INTER_LINEAR) mask = np.zeros(img.shape[:2],np.uint8) bgdModel = np.zeros((1,65),np.float64) fgdModel = np.zeros((1,65),np.float64) height,width,c= img.shape #이미지 내 위치 확인 후 rect 조절 a = int(width*0.06..