파이썬

파이썬

[파이썬] OpenCV, YOLO를 이용하여 이미지 속 객체 인식

import cv2 import numpy as np 필요한 모듈 import def yolo(frame, size, score_threshold, nms_threshold): # YOLO 네트워크 불러오기 net = cv2.dnn.readNet(f"yolov3_{size}.weights", "yolov3.cfg") layer_names = net.getLayerNames() output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()] # 클래스의 갯수만큼 랜덤 RGB 배열을 생성 colors = np.random.uniform(0, 255, size=(len(classes), 3)) # 이미지의 높이, 너비, 채널 받아오기..

파이썬

다리를 지나는 트럭 (Python Queue)

def solution(bridge_length, weight, truck_weights): bridge_list = [] sum = 0 count = 0 while True: if count > 0 and sum == 0: break if len(bridge_list) > bridge_length - 1: sum -= bridge_list[0] bridge_list.pop(0) if len(truck_weights) != 0: if sum + truck_weights[0]

파이썬

OpenCV, OpenPose, math를 이용하여 옆모습 사진 속 인물의 허리가 숙여졌는지 추정 (Python)

import cv2 import math 필요한 모듈 import def output_keypoints(image_path, proto_file, weights_file, threshold, model_name, BODY_PARTS): global points # 이미지 읽어오기 frame = cv2.imread(image_path) # 네트워크 불러오기 net = cv2.dnn.readNetFromCaffe(proto_file, weights_file) # 입력 이미지의 사이즈 정의 image_height = 368 image_width = 368 # 네트워크에 넣기 위한 전처리 input_blob = cv2.dnn.blobFromImage(frame, 1.0 / 255, (image_width, im..

파이썬

Selenium을 이용하여 구글 이미지 크롤링 (Python)

import os import time import socket from urllib.request import urlretrieve from urllib.error import HTTPError, URLError from selenium import webdriver from selenium.common.exceptions import ElementClickInterceptedException, NoSuchElementException, \ ElementNotInteractableException from PIL import Image from pygame import mixer 필요한 모듈 import def scroll_down(): scroll_count = 0 print("ㅡ 스크롤 다운 시작 ..

파이썬

OpenCV, OpenPose를 이용하여 영상 속 인물의 자세 추정 (Python)

import cv2 필요한 모듈 import def output_keypoints(frame, net, threshold, BODY_PARTS, now_frame, total_frame): global points # 입력 이미지의 사이즈 정의 image_height = 368 image_width = 368 # 네트워크에 넣기 위한 전처리 input_blob = cv2.dnn.blobFromImage(frame, 1.0 / 255, (image_width, image_height), (0, 0, 0), swapRB=False, crop=False) # 전처리된 blob 네트워크에 입력 net.setInput(input_blob) # 결과 받아오기 out = net.forward() # The outpu..

IntegerString
'파이썬' 카테고리의 글 목록 (3 Page)