프로젝트

일반

사용자정보

개정판 65eb78a7

ID65eb78a74526af6d208199fb1b3b2a17c94133c7
상위 db6ea25f
하위 213c18d3, 5959f70a

함의성이(가) 일년 이상 전에 추가함

gcloud test

Change-Id: I71c5b6e1d2c62590b3f7cf4cf754a1b78e3a632f

차이점 보기:

DTI_PID/WebServer/CRAFT_pytorch_master/text_craft.py
29 29
import json
30 30
import zipfile
31 31

  
32
from google.cloud import vision
33

  
32 34
#from CRAFT_pytorch_master.craft import CRAFT
33 35
from craft import CRAFT
34 36

  
......
113 115
    return boxes_list
114 116

  
115 117
def get_gcloud_ocr(img):
116
    return ['test']
118
    #path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'gcloud.png')
119
    #cv2.imwrite(path, img)
120

  
121
    client = vision.ImageAnnotatorClient()
122

  
123
    #content = img.tobytes()
124
    content = cv2.imencode('.jpg', img)[1].tostring()
125
    image = vision.Image(content=content)
126
    
127
    #response = client.text_detection(image=image)
128
    response = client.document_text_detection(image=image)
129
    texts = response.text_annotations
130

  
131
    infos = []
132
    for text in texts[1:]:
133
        _vertices = [(vertex.x,vertex.y) for vertex in text.bounding_poly.vertices]
134
        _vertices.insert(0, text.description)
135
        infos.append(_vertices)
136

  
137
    return infos
117 138

  
118 139
def get_text_box(img, img_path=None, score_path=None, trained_model=None):
119 140
    if img.shape[0] == 2: img = img[0]
minorTools/gcloud_test.py
24 24
        #vertices = [ f"({vertex.x},{vertex.y})" for vertex in text.bounding_poly.vertices ]
25 25
        #print("bounds: {}".format(",".join(vertices)))
26 26

  
27
        _vertices = [(vertex.x,vertex.y) for vertex in text.bounding_poly.vertices ]
27
        _vertices = [(vertex.x,vertex.y) for vertex in text.bounding_poly.vertices]
28 28

  
29 29
        cv2.rectangle(_image, _vertices[0], _vertices[2], (100, 100, 100), 2)
30 30
        cv2.putText(_image, text.description, (_vertices[0][0], (_vertices[0][1] - 10)), cv2.FONT_HERSHEY_PLAIN, 1, (100, 100, 100), 1)

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)