๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ‘จ๐Ÿผ‍๐Ÿ’ป๊ฐœ๋ฐœ/OpenCV

OpenCV - ์ปค์Šคํ…€ Cascade ๋งŒ๋“ค๊ธฐ(CASCADE TRAINER GUI) ๋ฐ ๋ฌผ์ฒด ํƒ์ง€

by Janger 2022. 5. 19.
728x90
๋ฐ˜์‘ํ˜•

์•„๋ž˜ ๋งํฌ์—์„œ Cascade Trainer GUI๋ฅผ ์ž์‹ ์˜ ์ปดํ“จํ„ฐ ํ™˜๊ฒฝ์— ๋งž๋Š” ๋ฒ„์ „์œผ๋กœ ์„ค์น˜(64๋น„ํŠธ๊ฐ€ 32๋น„ํŠธ ๋ฒ„์ „์œผ๋กœ ์„ค์น˜ํ•˜๋ฉด ์ค‘๊ฐ„์— ์˜ค๋ฅ˜๊ฐ€ ์ƒ๊น€)

https://amin-ahmadi.com/cascade-trainer-gui/

 

Cascade Trainer GUI - Amin

 Cascade Trainer GUI 1. Introduction Cascade Trainer GUI is a program that can be used to train, test and improve cascade classifier models. It uses a graphical interface to set the parameters and make it easy to use OpenCV tools for training and testing

amin-ahmadi.com

 

๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ํ•˜๋‚˜ ๋งŒ๋“ค์–ด์ค€ ๋‹ค์Œ ์•ˆ์—๋‹ค n, p ํด๋”๋ฅผ ์ƒ์„ฑ

n - negative: ์ฐพ๊ณ ์‹ถ์ง€ ์•Š๋Š” ์ด๋ฏธ์ง€๋“ค์„ ์—ฌ๊ธฐ์— ์ €์žฅ

p - positive: ์ฐพ๊ณ ์ž ํ•˜๋Š” ์ด๋ฏธ์ง€๋“ค์ด ์—ฌ๊ธฐ์— ์ €์žฅ

 

๊ทธ๋ฆฌ๊ณ  ์˜ต์…˜์—์„œ Sample Width, Sample Height๋ฅผ ์กฐ์ •ํ•˜๋Š” ๋ถ€๋ถ„์ด ์žˆ๋Š”๋ฐ, ์—ฌ๊ธฐ์—๋Š” ์ฐพ๊ณ ์ž ํ•˜๋Š” ์ด๋ฏธ์ง€ ํŒŒ์ผ๋“ค์˜ width, height๋ฅผ ๋‚˜๋ˆ„๊ธฐ 10ํ•ด์ค€ ์‚ฌ์ด์ฆˆ๋ฅผ ๋„ฃ์–ด์คŒ( 200x120 => 20x12 )

 

tip - ๊ฐ์ง€ํ•˜๊ณ ์ž ํ•˜๋Š” ๋ฌผ์ฒด๋Š” ์ตœ๋Œ€ํ•œ ๋‹ค๋ฐฉ๋ฉด์—์„œ ์ฐ๋Š” ๊ฒƒ์€ ๋น„์ถ”ํ•˜๊ณ , ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋‹ค์–‘ํ•œ ๋ฐฐ๊ฒฝ์ด ๋‚˜์˜ค๋„๋ก ์ฐ๋Š” ๊ฒƒ์„ ์ถ”์ฒœ

 

[๋ฌผ์ฒด ๊ฐ์ง€ ์Šคํฌ๋ฆฝํŠธ]

import cv2

w_cascade = cv2.CascadeClassifier('cascade.xml')

cap = cv2.VideoCapture(0)

while cv2.waitKey(33) < 0:
    ret, img = cap.read()
    if ret:
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        w = w_cascade.detectMultiScale(gray,
        scaleFactor = 1.3,
        minNeighbors = 10,
        minSize=(70, 70))

        for (x, y, w, h) in w:
            cv2.rectangle(img, (x, y), (x + w, y + h), (255, 255, 0), 2)
            font = cv2.FONT_HERSHEY_SIMPLEX
            cv2.putText(img, 'Detected', (x - w, y - h), font, 0.5, (11, 255, 255),  2, cv2.LINE_AA)

        cv2.imshow('img', img)

cap.release()
cv2.destroyAllWindows()

 

 

 

 

 

์ฐธ๊ณ : 

https://www.youtube.com/watch?v=v_cwOq06g9E&t=47s&ab_channel=OMES 

https://www.youtube.com/watch?v=kLajDbq3eyI 

https://stackoverflow.com/questions/63609586/how-to-make-custom-any-object-cascade-xml-for-opencv-python

 

How to make custom 'any object' Cascade (.xml) for opencv-python?

I want to make a haar cascade so that I can use it to detect a object in opencv-python.For eg, I want to detect a watch. I tried making a cascade using cascade trainer gui but it isn't giving me ex...

stackoverflow.com

 

728x90
๋ฐ˜์‘ํ˜•