Cloud AI - 2. 클라우드 AI 서비스 개요 및 기초 실습 (이미지 및 영상 분석 AI)

2025. 3. 18. 20:26AI/AI

📌 이미지 및 영상 분석 AI

이미지 및 영상 분석 AI는 컴퓨터 비전(Computer Vision) 기술을 활용하여 이미지 및 영상 데이터를 자동으로 분석하는 AI 서비스다. Google Vision AI와 AWS Rekognition은 객체 인식(Object Detection), 얼굴 감지(Face Detection), OCR(문자 인식, Optical Character Recognition) 등의 기능을 제공하며, 다양한 산업에서 활용되고 있다.


🔹 1️⃣ 이미지 및 영상 분석 AI 개요

✅ 이미지 및 영상 분석 AI란?

  • 이미지 및 영상 데이터를 자동으로 분석하고, 객체, 얼굴, 텍스트 등의 요소를 감지하는 AI 기술
  • 컴퓨터 비전(Computer Vision) 모델을 기반으로 이미지 속 패턴을 분석
  • AI 모델이 사람의 시각적 인식을 흉내 내어 자동화된 분석 기능을 제공

주요 기능
객체 인식(Object Detection) → 사진 속 사물 및 개체 감지
얼굴 감지(Face Detection) → 얼굴 위치, 감정 분석, 나이 추정
OCR(문자 인식, Optical Character Recognition) → 이미지 속 문자 분석 및 변환
영상 분석(Video Analysis) → 실시간 비디오 처리, 행동 분석


🔹 2️⃣ Google Vision AI (Google Cloud Vision API)

Google Vision AI는 Google Cloud가 제공하는 머신러닝 기반 이미지 및 영상 분석 서비스로, 객체 인식, 얼굴 감지, OCR 기능을 강력하게 지원한다.

✅ Google Vision AI 주요 기능

기능  설명
객체 인식 (Label Detection) 이미지 속 사물(예: 자동차, 동물, 음식 등) 식별
얼굴 감지 (Face Detection) 얼굴 위치, 감정(웃음, 화남 등), 나이 추정
OCR (Text Detection, Document AI) 이미지 속 문자 인식 (영수증, 문서 자동화)
로고 및 랜드마크 감지 브랜드 로고, 유명한 건축물 또는 장소 식별
부적절한 콘텐츠 감지 폭력, 음란물, 혐오 콘텐츠 분석

📌 Vision AI 객체 인식 예제

from google.cloud import vision

# 인증 설정 (서비스 계정 키 파일 필요)
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "your-service-account.json"

client = vision.ImageAnnotatorClient()

# 이미지 URL을 Vision AI에 전달
image = vision.Image()
image.source.image_uri = "https://example.com/sample.jpg"

# 객체 인식 실행
response = client.label_detection(image=image)

# 결과 출력
for label in response.label_annotations:
    print(f"Label: {label.description}, Score: {label.score:.2f}")

특징:

  • label_detection()을 사용하여 이미지 속 객체를 분석하고 신뢰도(Score) 출력
  • URL 이미지뿐만 아니라 Base64 인코딩 이미지도 처리 가능

📌 Vision AI 얼굴 감지 예제

from google.cloud import vision

client = vision.ImageAnnotatorClient()

# 이미지 파일 로드
with open("face-image.jpg", "rb") as image_file:
    content = image_file.read()

image = vision.Image(content=content)

# 얼굴 감지 실행
response = client.face_detection(image=image)

# 결과 출력
for face in response.face_annotations:
    print(f"Joy: {face.joy_likelihood}, Anger: {face.anger_likelihood}, Surprise: {face.surprise_likelihood}")

특징:

  • 감정 분석(Joy, Anger, Surprise 등) 기능 제공
  • 얼굴 위치(바운딩 박스) 정보도 함께 제공

📌 Vision AI OCR(문자 인식) 예제

from google.cloud import vision

client = vision.ImageAnnotatorClient()

# 이미지 파일 로드
with open("document.jpg", "rb") as image_file:
    content = image_file.read()

image = vision.Image(content=content)

# OCR 실행
response = client.text_detection(image=image)

# 결과 출력
for text in response.text_annotations:
    print(f"Detected Text: {text.description}")

특징:

  • text_detection()을 통해 OCR 기능 지원
  • 한국어, 영어, 중국어 등 다국어 인식 가능

🔹 3️⃣ AWS Rekognition

AWS Rekognition은 Amazon이 제공하는 이미지 및 영상 분석 AI 서비스로, 객체 인식, 얼굴 감지, OCR 기능을 제공한다.

✅ AWS Rekognition 주요 기능

기능  설명
객체 인식 (Object Detection) 이미지 속 사물(예: 차량, 동물 등) 감지
얼굴 감지 (Face Detection) 얼굴 위치, 감정 분석, 나이 예측
OCR (Text Detection) 이미지 속 문자 인식
비디오 분석 (Video Analysis) 실시간 영상 분석, 행동 감지
유사 이미지 검색 대량의 이미지에서 특정 얼굴/객체 검색

📌 AWS Rekognition 객체 인식 예제

import boto3

client = boto3.client('rekognition')

# S3에 저장된 이미지 분석
response = client.detect_labels(
    Image={'S3Object': {'Bucket': 'your-bucket', 'Name': 'image.jpg'}},
    MaxLabels=10
)

# 결과 출력
for label in response['Labels']:
    print(f"Label: {label['Name']}, Confidence: {label['Confidence']:.2f}%")

특징:

  • AWS S3와 통합하여 대규모 데이터 분석 가능
  • detect_labels()를 통해 이미지 속 객체를 분석

📌 AWS Rekognition 얼굴 감지 예제

import boto3

client = boto3.client('rekognition')

with open("face-image.jpg", "rb") as image_file:
    image_bytes = image_file.read()

# 얼굴 감지 실행
response = client.detect_faces(
    Image={'Bytes': image_bytes},
    Attributes=['ALL']
)

# 결과 출력
for face in response['FaceDetails']:
    print(f"Age Range: {face['AgeRange']}")
    print(f"Emotion: {face['Emotions'][0]['Type']}, Confidence: {face['Emotions'][0]['Confidence']:.2f}%")

특징:

  • 얼굴 감지와 함께 감정 분석 제공
  • 나이 예측 및 성별 예측도 가능

📌 AWS Rekognition OCR(문자 인식) 예제

import boto3

client = boto3.client('rekognition')

with open("document.jpg", "rb") as image_file:
    image_bytes = image_file.read()

# OCR 실행
response = client.detect_text(Image={'Bytes': image_bytes})

# 결과 출력
for text in response['TextDetections']:
    print(f"Detected Text: {text['DetectedText']}, Confidence: {text['Confidence']:.2f}%")

특징:

  • detect_text()를 통해 OCR 기능 제공
  • AWS Lambda와 연동하여 자동화 가능

📌 최종 정리

1️⃣ Google Vision AI vs AWS Rekognition 비교

기능  Google Vision AI AWS Rekognition
객체 인식 Label Detection Object Detection
얼굴 감지 감정 분석, 얼굴 특징 추출 감정 분석, 성별, 나이 예측
OCR (문자 인식) Text Detection, Document AI Text Detection
비디오 분석 제한적 지원 실시간 영상 분석 가능
클라우드 연동 Google Cloud Storage AWS S3

Google Vision AI → 데이터 분석, 문서 처리에 강점
AWS Rekognition → 영상 분석, 실시간 감지에 강점