'yolos-cpp'에 해당되는 글 2건

  1. 2026.02.15 [YOLO] YOLOs-CPP Simple Example
  2. 2026.02.15 [YOLO] YOLOs-CPP build 빌드하기
반응형

YOLOs-CPP를 빌드하고 간단한 예제를 만들어 보자.

 

2026.02.15 - [AI, ML, DL] - [YOLO] YOLOs-CPP build 빌드하기

 

CPU 사용 예.

#include "yolos/yolos.hpp"

int main() {
	// Initialize Use CPU
	yolos::det::YOLODetector detector("yolo11n.onnx", "coco.names", false);
	
	// Detect
	cv::Mat frame = cv::imread("catsdogs.png");
	std::vector<yolos::Detection> detections = detector.detect(frame, 0.25f, 0.45f);

	// Process results
	for (const yolos::det::Detection& det : detections) {
		std::cout << "Class: " << det.classId << " Conf: " << det.conf << std::endl;
		std::cout << "Box: (" << det.box.width << ", " << det.box.height << ")" << std::endl;
	}

	// Visualize
	detector.drawDetections(frame, detections);

	// Show
	cv::imshow("frame", frame);
	cv::waitKey(0);
		
	return 0;
}

 

OpenCV가 Debug 모드로 빌드되어 불필요한 경고가 많다.

 

 

GPU 사용 예.

#include "yolos/yolos.hpp"

int main() {
	// Initialize Use GPU
	yolos::det::YOLODetector detector("yolo11n.onnx", "coco.names", true);
	
	// Detect
	cv::Mat frame = cv::imread("catsdogs.png");
	std::vector<yolos::Detection> detections = detector.detect(frame, 0.25f, 0.45f);

	// Process results
	for (const yolos::det::Detection& det : detections) {
		std::cout << "Class: " << det.classId << " Conf: " << det.conf << std::endl;
		std::cout << "Box: (" << det.box.width << ", " << det.box.height << ")" << std::endl;
	}

	// Visualize
	detector.drawDetections(frame, detections);

	// Show
	cv::imshow("frame", frame);
	cv::waitKey(0);
		
	return 0;
}

 

 

 

  • Performance Tips
    Reuse detector instances — Create once, infer many times
    Use GPU when available — 5-10x faster than CPU
    Adjust thresholds — Higher confidence = fewer detections, faster NMS
    Match input resolution — Use model's expected size (640x640)

 

※ 참고

Usage Guide

 

반응형
Posted by J-sean
:

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.