프로젝트

일반

사용자정보

개정판 ba6ef1c3

IDba6ef1c3a0541f08c655ded5cd0d281138d3fd1a
상위 ff7931a9
하위 745b4558, bf9a8c63

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

gcloud

Change-Id: I3eeba5a716a9ea1a4ebc1786be4588885ccc0d13

차이점 보기:

minorTools/gcloud_test.py
13 13

  
14 14
    image = vision.Image(content=content)
15 15

  
16
    response = client.text_detection(image=image)
16
    response = client.text_detection(image=image, image_context={"language_hints": ["en"]})
17 17
    #response = client.document_text_detection(image=image)
18

  
19
    bounds = []
20
    document = response.full_text_annotation
21

  
22
    for page in document.pages:
23
        for block in page.blocks:
24
            for paragraph in block.paragraphs:
25
                for word in paragraph.words:
26
                    '''
27
                    for symbol in word.symbols:
28
                        if feature == FeatureType.SYMBOL:
29
                            bounds.append(symbol.bounding_box)
30

  
31
                    if feature == FeatureType.WORD:
32
                        bounds.append(word.bounding_box)
33
                    '''
34
                    _vertices = [(vertex.x,vertex.y) for vertex in word.bounding_box.vertices]
35
                    cv2.rectangle(_image, _vertices[0], _vertices[2], (100, 100, 100), 2)
36
                    cv2.putText(_image, ''.join([s.text for s in word.symbols]), (_vertices[0][0] + 30, (_vertices[0][1] - 10)), cv2.FONT_HERSHEY_PLAIN, 1, (100, 100, 100), 1)
37

  
38
                _vertices = [(vertex.x,vertex.y) for vertex in paragraph.bounding_box.vertices]
39
                cv2.rectangle(_image, _vertices[0], _vertices[2], (100, 100, 100), 2)
40

  
41
                #if feature == FeatureType.PARA:
42
                #    bounds.append(paragraph.bounding_box)
43

  
44
            #if feature == FeatureType.BLOCK:
45
            #    bounds.append(block.bounding_box)
46

  
47
    '''
18 48
    texts = response.text_annotations
19 49
    #print("Texts:")
20 50

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

  
29 59
        cv2.rectangle(_image, _vertices[0], _vertices[2], (100, 100, 100), 2)
30
        cv2.putText(_image, text.description, (_vertices[0][0], (_vertices[0][1] - 10)), cv2.FONT_HERSHEY_PLAIN, 1, (100, 100, 100), 1)
60
        cv2.putText(_image, text.description, (_vertices[0][0] + 30, (_vertices[0][1] - 10)), cv2.FONT_HERSHEY_PLAIN, 1, (100, 100, 100), 1)
61
    '''
31 62
    
32 63
    cv2.imwrite(path.replace('test', 'test_res'), _image)
33 64
        

내보내기 Unified diff

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