페이지 이동경로
  • Docs>
  • Vision>
  • Development guide

Vision

Development guide

This document describes how to integrate Vision APIs into your service with a REST API.

You can test the features described in this document in [Tools] > [REST API Test].

Common notice

  • When you call from a server, send a POST request using a REST API.
  • When calling APIs, request with either the image or image_url parameter. When calling the OCR API, only image is supported.
  • An image uploaded as image or specified as image_url supports PNG and JPG format only. However, OCR API supports BMP, DIB, JPEG, JPE, JP2, WEBP, PBM, PGM, PPM, SR, RAS, TIFF, and TIF format as well as PNG and JPG.
  • An image must be 2048x2048 pixels or less, and the file size must be 2 MB or less.
  • When uploading an image file using image, set Content-Type to 'multipart/form-data'.
  • When specifying an image URL using image_url, set Content-Type to 'application/x-www-form-urlencoded'.

Face detection

The Face detection API detects a face in the given image and returns the key points, position, angle of the face, and the estimated gender and age. To see what you should know when calling Vision APIs, refer to Common notice.

If the request is successful, the result object containing the information of the detected face is returned in JSON format.

Image that Face detection API is applied to

Request

URL
POST /v2/vision/face/detect HTTP/1.1
Host: dapi.kakao.com
Authorization: KakaoAK ${REST_API_KEY}
Parameter
Name Type Description Required
image Binary Image file. O*
image_url String Image URL. O*
threshold Float Reference value to detect as a face.
A value between 0 and 1.0.
(Default: 0.7)
*If this value is set too high, some faces may not be able to be detected as a face. On the other hand, if too low, other area can be detected as a face.
X

* Either 'image` or 'image_url' is required.

Response

Key
Name Type Description
result Result Object containing the results of face detection.
Refer to Result below.
rid String ID assigned for your request.
Result
Name Type Description
width Integer Width of the requested image.
height Integer Height of the requested image.
faces Face[] Array of objects containing detected face information.
Face
Name Type Description
facial_attributes FacialAttributes Object containing the estimated gender and age of the detected face.
Refer to FacialAttributes below.
facial_points FacialPoints Object containing the 68 key points of the detected face in the array of (x,y) for each key point.
All coordinates are sorted from left to right and from top to bottom.
Refer to FacialPoints below.
score Float Confidence score of the detected face.
Only the face with the specified threshold value or higher is returned in the result.
A value between 0 and 1.0.
class_idx Integer Index of the detected object.
As of now, 0 is returned only.
x Float X coordinate of the face.
A value between 0 and 1.0 that is proportional to the image width.
y Float Y coordinate of the face.
A value between 0 and 1.0 that is proportional to the image height.
w Float Horizontal facial width.
A value between 0 and 1.0 that is proportional to the width of the image.
h Float Vertical facial height.
A value between 0 and 1.0 that is proportional to the height of the image.
pitch Radian The angle of the X-axis of the face to describe the head movement in a vertical direction.
yaw Radian The angle of the Y-axis of the face to describe the head movement in a horizontal direction.
roll Radian The angle of the Z-axis of the face to describe the head rotation.

The pitch, yaw, and roll parameters indicate the angle of the face as shown in the following image.

Image that illustrates pitch, yaw, roll

Image source: Enhanced real-time head pose estimation system for mobile device

FacialAttributes
Name Type Description
gender Gender Estimated gender of the detected face.
Use the gender with a higher confidence score between male and female.
Refer to Gender below.
age Float Estimated age of the detected person.
Gender
Name Type Description
male Float Confidence score that the detected face is considered as a male.
A value between 0 and 1.0.
female Float Confidence score that the detected face is considered as a female.
A value between 0 and 1.0
FacialPoints
Name Type Description
jaw List<Number[]> Array of 17 coordinates of the detected jaw line.
Array of X and Y coordinates ​​between 0 and 1.0.
right_eyebrow List<Number[]> Array of 5 coordinates of the detected right eyebrow.
Array of X and Y coordinates ​​between 0 and 1.0.
left_eyebrow List<Number[]> Array of 6 coordinates of the detected left eyebrow.
Array of X and Y coordinates ​​between 0 and 1.0.
nose List<Number[]> Array of 9 coordinates of the detected nose.
Array of X and Y coordinates ​​between 0 and 1.0.
right_eye List<Number[]> Array of 6 coordinates of the detected right eye.
Array of X and Y coordinates ​​between 0 and 1.0.
left_eye List<Number[]> Array of 6 coordinates of the detected left eye.
Array of X and Y coordinates ​​between 0 and 1.0.
lip List<Number[]> Array of 20 coordinates of the detected lip.
Array of X and Y coordinates ​​between 0 and 1.0.

Sample

Request: Specifying an image URL
curl -v -X POST "https://dapi.kakao.com/v2/vision/face/detect" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    --data-urlencode "image_url=https://t1.daumcdn.net/alvolo/_vision/openapi/r2/images/01.jpg" 
Request: Uploading an image file
curl -v -X POST "https://dapi.kakao.com/v2/vision/face/detect" \
    -H "Content-Type: multipart/form-data" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    -F "image=@sample_face.jpg" 
Response

For the sample response, refer to REST API Tool.

Product detection

Product detection API returns the position and type of products within the given image. You can detect fashion goods, bags, shoes, etc. in the image with this API. To see what you should know when calling Vision APIs, refer to Common notice.

If the request is successful, the result object containing the information of the detected product is returned in JSON format.

Image that Product detection API is applied to

Request

URL
POST /v2/vision/product/detect HTTP/1.1
Host: dapi.kakao.com
Authorization: KakaoAK ${REST_API_KEY}
Parameter
Name Type Description Require
image Binary Image file. O*
image_url String Image URL. O*
threshold Float Reference value to detect as a product.
A value between 0 and 1.0.
(Default: 0.8)
X

* Either 'image` or 'image_url' is required.

Response

Key
Name Type Description
result Result Object containing the results of product detection.
Refer to Result below.
rid String ID assigned for your request.
Result
Name Type Description
width Integer Width of the requested image.
height Integer Height of the requested image.
objects Product[] Array of objects containing detected product information.
Product
Name Type Description
x1 Float X coordinate of the upper left corner of the detected product area box.
A value between 0 and 1.0 that is proportional to the image width.
y1 Float Y coordinate of the upper left corner of the detected product area box.
A value between 0 and 1.0 that is proportional to the image height.
x2 Float X coordinate of the lower right corner of the detected product area box.
A value between 0 and 1.0 that is proportional to the image width.
y2 Float Y coordinate of the lower right corner of the detected product area box.
A value between 0 and 1.0 that is proportional to the image height.
class String Product name.

Sample

Request: Specifying an image URL
curl -v -X POST "https://dapi.kakao.com/v2/vision/product/detect" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    --data-urlencode "image_url=https://t1.daumcdn.net/alvolo/_vision/openapi/r2/images/06.jpg" 
Request: Uploading an image file
curl -v -X POST "https://dapi.kakao.com/v2/vision/product/detect" \
    -H "Content-Type: multipart/form-data" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    -F "image=@sample_product.jpg"
Response

For the sample response, refer to REST API Tool.

Adult image detection

The Adult image detection API determines the level of nudity or adult content. You can use this API to filter image spam. It returns the scores of normal , soft and adult as a result. If the soft or adult score of an image is high, it is likely to be nudity or porn images. The sum of the three scores is 1.0 (normal + soft + adult = 1.0).

To see what you should know when calling Vision APIs, refer to Common notice.

Image that Adult image detection API is applied to

Request

URL
POST /v2/vision/adult/detect HTTP/1.1
Host: dapi.kakao.com
Authorization: KakaoAK ${REST_API_KEY}
Parameter
Name Type Description Required
image Binary Image file. O*
image_url String Image URL. O*

* Either 'image` or 'image_url' is required.

Response

Key
Name Type Description
result Result Object containing the results of adult content.
rid String ID assigned for your request.
Result
Name Type Description
normal Float The probability that the image is normal.
A value between 0 and 1.0.
soft Float The probability that the image contains nudity, such as swimsuit photos.
A value between 0 and 1.0.
adult Float The probability that the image contains adult content.
A value between 0 and 1.0.

Sample

Request: Specifying an image URL
curl -v -X POST "https://dapi.kakao.com/v2/vision/adult/detect" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    --data-urlencode "image_url=https://t1.daumcdn.net/alvolo/_vision/openapi/r2/images/09.jpg" 
Request: Uploading an image file
curl -v -X POST "https://dapi.kakao.com/v2/vision/adult/detect" \
    -H "Content-Type: multipart/form-data" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    -F "image=@sample_adult.jpg"
Response

For the sample response, refer to REST API Tool.

Thumbnail creation

The Thumbnail creation API crops the representative area out of the given image and creates a thumbnail image. It returns the URL of the cropped area with the designated width and height ratio. To see what you should know when calling Vision APIs, refer to Common notice.

If the request is successful, the result object containing the thumbnail information is returned in JSON format.

Image that Thumbnail creation API is applied to

Request

URL
POST /v2/vision/thumbnail/crop HTTP/1.1
Host: dapi.kakao.com
Authorization: KakaoAK ${REST_API_KEY}
Parameter
Name Type Description Required
image Binary Image file. O*
image_url String Image URL. O*
width Integer Image width. O
height Integer Image height. O

* Either 'image` or 'image_url' is required.

Response

Key
Name Type Description
thumbnail_image_url String URL of the cropped thumbnail image.

Sample

Request: Specifying an image URL
curl -v -X POST "https://dapi.kakao.com/v2/vision/thumbnail/crop" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    --data-urlencode "image_url=https://t1.daumcdn.net/alvolo/_vision/openapi/r2/images/07.jpg"
    -d "width=200" \
    -d "height=200" 
Request: Uploading an image file
curl -v -X POST "https://dapi.kakao.com/v2/vision/thumbnail/crop" \
    -H "Content-Type: multipart/form-data" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    -F "image=@sample_thumbnail.jpg" \
    -F "width=200" \
    -F "height=200" 
Response

For the sample response, refer to REST API Tool.

Thumbnail detection

The Thumbnail detection API helps to create a thumbnail image by detecting the representative area out of the given image. It returns the information on the suggested area as a thumbnail image with the requested width and height ratio. To see what you should know when calling Vision APIs, refer to Common notice.

If the request is successful, the result object containing the suggested area information is returned in JSON format. When creating an actual thumbnail image, you must resize the cropped area as you desire after cropping an image as suggested.

Image that Thumbnail detection API is applied to

Request

URL
POST /v2/vision/thumbnail/detect HTTP/1.1
Host: dapi.kakao.com
Authorization: KakaoAK ${REST_API_KEY}
Parameter
Name Type Description Required
image Binary Image file. O*
image_url String Image URL. O*
width Integer Image length. O
height Integer Image height. O

* Either 'image` or 'image_url' is required.

Response

Key
Name Type Description
result Result Object containing the results of image detection.
rid String ID assigned for your request.
Result
Name Type Description
width Integer Width of the requested image.
height Integer Height of the requested image.
thumbnail Thumbnail Object containing the coordinates of the suggested area.
Thumbnail
Name Type Description
x Intger X coordinate of the point starting the thumbnail image.
y Intger Y coordinate of the point starting the thumbnail image.
width Intger Thumbnail width.
height Intger Thumbnail height.

Sample

Request: Specifying an image URL
curl -v -X POST "https://dapi.kakao.com/v2/vision/thumbnail/detect" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    --data-urlencode "image_url=https://t1.daumcdn.net/alvolo/_vision/openapi/r2/images/07.jpg" \
    -d "width=200" \
    -d "height=200" 
Request: Uploading an image file
curl -v -X POST "https://dapi.kakao.com/v2/vision/thumbnail/detect" \
    -H "Content-Type: multipart/form-data" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    -F "image=@sample_thumbnail.jpg" \
    -F "width=200" \
    -F "height=200" 
Response

For the sample response, refer to REST API Tool.

Multi-tag creation

The Multi-tag creation API creates a tag according to image content. It helps you categorize your images. To see what you should know when calling Vision APIs, refer to Common notice.

If the request is successful, the result object containing the detected tag information is returned in JSON format.

Image that Multi-tag creation API is applied to

Request

URL
POST /v2/vision/multitag/generate HTTP/1.1
Host: dapi.kakao.com
Authorization: KakaoAK ${REST_API_KEY}
Parameter
Name Type Description Required
image Binary Image file. O*
image_url String Image URL. O*

* Either 'image` or 'image_url' is required.

Response

Key
Name Type Description
result Result Object containing the results of tag creation.
rid String ID assigned for your request.
Result
Name Description Type
label String[] List of detected tags in English.
label_kr String[] List of detected tags in Korean.

Sample

Request: Specifying an image URL
curl -v -X POST "https://dapi.kakao.com/v2/vision/multitag/generate" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    --data-urlencode "image_url=https://t1.daumcdn.net/alvolo/_vision/openapi/r2/images/08.jpg" 
Request: Uploading an image file
curl -v -X POST "https://dapi.kakao.com/v2/vision/multitag/generate" \
    -H "Content-Type: multipart/form-data" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    -F "image=@sample_tag.jpg" 
Response

For the sample response, refer to REST API Tool.

OCR

The OCR(Optical Character Recognition) API detects and extracts text from the given image. To do so, it firstly detects a bounding box around text, and then converts the detected characters into text information. If there are multiple lines of text in an image, one bounding box is created for each line as shown in the image below.

To see what you should know when calling Vision APIs, refer to Common notice. If the request is successful, the result object containing the information of the detected bounding box and extracted text is returned in JSON format.

Image that OCR API is applied to

Request

URL
POST /v2/vision/text/ocr HTTP/1.1
Host: dapi.kakao.com
Authorization: KakaoAK ${REST_API_KEY}
Content-Type: multipart/form-data
Parameter
Name Type Description Required
image Binary Image file. O

Response

Key
Name Type Description
result Result Object containing the coordinates of the bonding box and extracted text in the bounding box.
Refer to Result below.
Result
Name Type Description
boxes List<number[]> X and Y coordinates of the bounding box.
The coordinates of the bounding box corners are sorted in [[X of top left corner, Y of top left corner], [X of top right corner, Y of top right corner], [X of bottom right corner, Y of bottom right corner], [X of bottom left corner, Y of bottom left corner]] order.
Top and bottom indicates the top and bottom of the monitor. The X coordinate increases from left to right, and the Y coordinate increases from top to bottom.
recognition_words String[] Extracted text in the bonding box.

Sample

Request
curl -v -X POST "https://dapi.kakao.com/v2/vision/text/ocr" \
    -H "Content-Type: multipart/form-data" \
    -H "Authorization: KakaoAK ${REST_API_KEY}" \
    -F "image=@sample.jpg" 
Response

For the sample response, refer to REST API Tool.

Samples

Here are code snippets showing how to use Vision APIs simply using Python. It is recommended to use Python version 2.7, 3.6 or higher.

Here are the requirements of the Python module that you need to install:

requests==2.14.2
Pillow==5.0.0

Face detection

This code snippet shows a process to detect a face in an image and apply the mosaics filter to the detected face in a rectangle.

import sys
import argparse
import requests
from PIL import Image, ImageFilter

API_URL = 'https://dapi.kakao.com/v2/vision/face/detect'
MYAPP_KEY = 'YOUR_APP_KEY'

def detect_face(filename):
    headers = {'Authorization': 'KakaoAK {}'.format(MYAPP_KEY)}

    try:
        files = { 'image' : open(filename, 'rb')}
        resp = requests.post(API_URL, headers=headers, files=files)
        resp.raise_for_status()
        return resp.json()
    except Exception as e:
        print(str(e))
        sys.exit(0)

def mosaic(filename, detection_result):
    image = Image.open(filename)

    for face in detection_result['result']['faces']:
        x = int(face['x']*image.width)
        w = int(face['w']*image.width)
        y = int(face['y']*image.height)
        h = int(face['h']*image.height)
        box = image.crop((x,y,x+w, y+h))
        box = box.resize((20,20), Image.NEAREST).resize((w,h), Image.NEAREST)
        image.paste(box, (x,y,x+w, y+h))

    return image



if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Mosaic faces.')
    parser.add_argument('image_file', type=str, nargs='?', default="./images/05.jpg",
                        help='image file to hide faces')

    args = parser.parse_args()

    detection_result = detect_face(args.image_file)
    image = mosaic(args.image_file, detection_result)
    image.show()

Product detection

This code snippet shows a process to detect a product in an image and show the name of the detected product.

import sys
import argparse
import requests
from PIL import Image, ImageDraw, ImageFont
from io import BytesIO

API_URL = 'https://dapi.kakao.com/v2/vision/product/detect'
MYAPP_KEY = 'YOUR_APP_KEY'

def detect_product(image_url):
    headers = {'Authorization': 'KakaoAK {}'.format(MYAPP_KEY)}

    try:
        data = { 'image_url' : image_url}
        resp = requests.post(API_URL, headers=headers, data=data)
        resp.raise_for_status()
        return resp.json()
    except Exception as e:
        print(str(e))
        sys.exit(0)

def show_products(image_url, detection_result):
    try:
        image_resp = requests.get(image_url)
        image_resp.raise_for_status()
        file_jpgdata = BytesIO(image_resp.content)
        image = Image.open(file_jpgdata)
    except Exception as e:
        print(str(e))
        sys.exit(0)


    draw = ImageDraw.Draw(image)
    for obj in detection_result['result']['objects']:
        x1 = int(obj['x1']*image.width)
        y1 = int(obj['y1']*image.height)
        x2 = int(obj['x2']*image.width)
        y2 = int(obj['y2']*image.height)
        draw.rectangle([(x1,y1), (x2, y2)], fill=None, outline=(255,0,0,255))
        draw.text((x1+5,y1+5), obj['class'], (255,0,0))
    del draw

    return image

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Detect Products.')
    parser.add_argument('image_url', type=str, nargs='?',
        default="http://t1.daumcdn.net/alvolo/_vision/openapi/r2/images/06.jpg",
        help='image url to show product\'s rect')

    args = parser.parse_args()

    detection_result = detect_product(args.image_url)
    image = show_products(args.image_url, detection_result)
    image.show()

Adult image detection

This code snippet shows a process to determine whether the given image contains nudity or adult content and shows the level of nudity as a score.

import sys
import argparse
import requests
from PIL import Image, ImageDraw, ImageFont
from io import BytesIO

API_URL = 'https://dapi.kakao.com/v2/vision/adult/detect'
MYAPP_KEY = 'YOUR_APP_KEY'

def detect_adult(image_url):
    headers = {'Authorization': 'KakaoAK {}'.format(MYAPP_KEY)}

    try:
        data = { 'image_url' : image_url}
        resp = requests.post(API_URL, headers=headers, data=data)
        resp.raise_for_status()
        result = resp.json()['result']
        if result['adult'] > result['normal'] and result['adult'] > result['soft']:
            print("The probability to be porn image is {}%.".format(float(result['adult'])*100)
        elif result['soft'] > result['normal'] and result['soft'] > result['adult']:
            print("The probability to be nudity image is {}%.".format(float(result['soft'])*100)
        else :
            print("The probability to be normal image is {}%.".format(float(result['normal'])*100

    except Exception as e:
        print(str(e))
        sys.exit(0)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Classify adult image.')
    parser.add_argument('image_url', type=str, nargs='?',
        default="http://t1.daumcdn.net/alvolo/_vision/openapi/r2/images/10.jpg",
        help='image url to classify')

    args = parser.parse_args()

    detect_adult(args.image_url)

Thumbnail detection

This code snippet shows a process to detect the representative part in the given image, crop the area as a thumbnail with the designated width and height, and show the created thumbnail.

import sys
import argparse
import requests
from PIL import Image, ImageFilter

API_URL = 'https://dapi.kakao.com/v2/vision/thumbnail/detect'
MYAPP_KEY = 'YOUR_APP_KEY'

def detect_thumbnail(filename, width, height):
    headers = {'Authorization': 'KakaoAK {}'.format(MYAPP_KEY)}

    try:
        files = { 'image' : open(filename, 'rb')}
        params = {'width': width, 'height': height}
        resp = requests.post(API_URL, headers=headers, data=params, files=files)
        resp.raise_for_status()
        return resp.json()
    except Exception as e:
        print(str(e))
        sys.exit(0)

def show_thumbnail(filename, detection_result, width, height):
    image = Image.open(filename)
    rect = detection_result['result']['thumbnail']
    thumbnail = image.crop((rect['x'], rect['y'], rect['x'] + rect['width'], rect['y'] + rect['height']))
    thumbnail = thumbnail.resize((width, height))

    return thumbnail


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Make a thumbnail.')
    parser.add_argument('image_file', type=str, nargs='?', default="./images/07.jpg",
                        help='image file to make a thumbnail')
    parser.add_argument('width', type=int, nargs='?', default=150,
                        help='thumbnail width')
    parser.add_argument('height', type=int, nargs='?', default=200,
                        help='thumbnail height')

    args = parser.parse_args()

    detection_result = detect_thumbnail(args.image_file, args.width, args.height)
    image = show_thumbnail(args.image_file, detection_result, args.width, args.height)
    image.show()

Multi-tag creation

This code snippet shows a process to create a tag that represents the given image and show the detected tag.

import sys
import argparse
import requests
from PIL import Image, ImageDraw, ImageFont
from io import BytesIO

API_URL = 'https://dapi.kakao.com/v2/vision/multitag/generate'
MYAPP_KEY = 'YOUR_APP_KEY'

def generate_tag(image_url):
    headers = {'Authorization': 'KakaoAK {}'.format(MYAPP_KEY)}

    try:
        data = { 'image_url' : image_url}
        resp = requests.post(API_URL, headers=headers, data=data)
        resp.raise_for_status()
        result = resp.json()['result']
        if len(result['label_kr']) > 0:
            if type(result['label_kr'][0]) != str:
                result['label_kr'] = map(lambda x: str(x.encode("utf-8")), result['label_kr'])
            print("The tag that represents this image is \"{}\".".format(','.join(result['label_kr'])))
        else:
            print("Failed to create a tag from the image.")

    except Exception as e:
        print(str(e))
        sys.exit(0)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Classify Tags')
    parser.add_argument('image_url', type=str, nargs='?',
        default="http://t1.daumcdn.net/alvolo/_vision/openapi/r2/images/08.jpg",
        help='image url to classify')

    args = parser.parse_args()

    generate_tag(args.image_url)

OCR

This code snippet shows a process to detect text as a bounding box in the given image and extract text from the bounding box.

import json

import cv2
import requests
import sys

LIMIT_PX = 1024
LIMIT_BYTE = 1024*1024  # 1MB
LIMIT_BOX = 40


def kakao_ocr_resize(image_path: str):
    """
    ocr detect/recognize api helper
    For an image that does not meet the requirements of OCR API, pre-processing is required before requesting API. 

    If exceeding the maximum pixel: resize the image.
    If exceeding the maximum file size: Compress the image with another format or additional process such as image separation is required. (Not provided in this sample.)

    :param image_path: Image file path 
    :return:
    """
    image = cv2.imread(image_path)
    height, width, _ = image.shape

    if LIMIT_PX < height or LIMIT_PX < width:
        ratio = float(LIMIT_PX) / max(height, width)
        image = cv2.resize(image, None, fx=ratio, fy=ratio)
        height, width, _ = height, width, _ = image.shape

        # If image is resized before using this api, you must use the resized result for recognizing OCR. 
        image_path = "{}_resized.jpg".format(image_path)
        cv2.imwrite(image_path, image)

        return image_path
    return None


def kakao_ocr(image_path: str, appkey: str):
    """
    OCR api request example
    :param image_path: Image file path 
    :param appkey: Your app's REST API key
    """
    API_URL = 'https://dapi.kakao.com/v2/vision/text/ocr'

    headers = {'Authorization': 'KakaoAK {}'.format(appkey)}

    image = cv2.imread(image_path)
    jpeg_image = cv2.imencode(".jpg", image)[1]
    data = jpeg_image.tobytes()


    return requests.post(API_URL, headers=headers, files={"image": data})


def main():
    if len(sys.argv) != 3:
        print("Please run with args: $ python example.py /path/to/image appkey")
    image_path, appkey = sys.argv[1], sys.argv[2]

    resize_impath = kakao_ocr_resize(image_path)
    if resize_impath is not None:
        image_path = resize_impath
        print("Use the resized image instead of the original image.")

    output = kakao_ocr(image_path, appkey).json()
    print("[OCR] output:\n{}\n".format(json.dumps(output, sort_keys=True, indent=2)))


if __name__ == "__main__":
    main()

See more