수강한 개념
VideoCapture
canny
sobel
setMouseCallback
filter2D
bilateralFilter
drawKeyPoints
SiftFeatureDetector
SiftDescriptorExtractor
class SIFT
ㄴdectect
ㄴcompute
cd /usr/share/opencv4/haarcascades/
ㄴ학습된 데이터모델 세트
class CascadeClassifier
detectMultiScale
rpicam-hello --list-cameras
컴파일 : g++ [filename].cpp -o [name] $(pkg-config --cflags --libs opencv4)
문제 구현 / 개선방안
#include <opencv2/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/flann/flann.hpp>
#include <opencv2/objdetect.hpp>
using namespace cv;
String face_cascade="/usr/share/opencv4/haarcascades/haarcascade_frontalface_alt.xml";
String eye_cascade="/usr/share/opencv4/haarcascades/haarcascade_eye.xml";
CascadeClassifier face;
CascadeClassifier eye;
void FaceAndEyeDetect(Mat);
int main()
{
std::string pipeline ="libcamerasrc camera-name=/base/axi/pcie@120000/rp1/i2c@88000/ov5647@36 \
! video/x-raw,width=640,height=480,framerate=10/1,format=RGBx ! videoconvert ! videoscale ! appsink"; //줄바꿈시 \가 없으면 오류 발생
VideoCapture v(pipeline,cv::CAP_GSTREAMER);
assert(v.isOpened());
bool b1 = face.load(face_cascade);
bool b2 = eye.load(eye_cascade);
assert(b1 && b2);
Mat frame;
while(true)
{
v.read(frame);
FaceAndEyeDetect(frame);
if((char)waitKey(20)==27) break;
}
return 0;
}
void FaceAndEyeDetect(Mat img)
{
Mat gray;
cvtColor(img, gray, COLOR_BGR2GRAY);
std::vector<Rect> face_pos;
face.detectMultiScale(gray, face_pos, 1.1, 2, 0|CASCADE_SCALE_IMAGE, Size(10, 10));
for(int i=0; i<face_pos.size(); i++)
rectangle(img, face_pos[i],Scalar(255,0,0),2);
for(int i=0; i<face_pos.size(); i++)
{
std::vector<Rect> eye_pos;
Mat roi=gray(face_pos[i]);
eye.detectMultiScale(roi, eye_pos, 1.1,2,0|CASCADE_SCALE_IMAGE, Size(10, 10));
for(int j=0; j<eye_pos.size();j++)
{
Point center(face_pos[i].x+eye_pos[j].x+eye_pos[j].width*0.5,face_pos[i].y+eye_pos[j].y+eye_pos[j].height*0.5);
int radius = cvRound((eye_pos[j].width+eye_pos[j].height*0.25));
circle(img,center,radius,Scalar(0,0,255),2,8,0);
}
}
namedWindow("cascade"); imshow("cascade", img);
}
기타 사항
VEDA 바로가기 : www.vedacademy.co.kr
VEDA(한화비전 아카데미) 영상으로 확인하기 : https://url.kr/zy9afd
본 후기는 VEDA(한화비전 아카데미) 1기 학습 기록으로 작성되었습니다.
#VEDA #개발의한계를veda #한화비전 #엣지디바이스 #한화비전아카데미 #KDT
'교육관련 > 한화비전 VEDA 수강일지' 카테고리의 다른 글
[VEDA 1기 수강일지] 57일차 - 임베디드 리눅스 (3) : 장치파일 / yocto (1) | 2024.10.16 |
---|---|
[VEDA 1기 수강일지] 55일차 - 임베디드 리눅스 이론 (1) : 임베디드 리눅스 구성요소 (0) | 2024.10.14 |
[VEDA 1기 수강일지] 48일차 - 라즈베리파이와 GPIO (2) : 조도센서, 멀티스레드 실습 (0) | 2024.09.30 |
[VEDA 1기 수강일지] 42일차 - linux 미니프로젝트 : tcp 통신을 이용한 채팅프로그램 (2) (0) | 2024.09.13 |
[VEDA 1기 수강일지] 40일차 - linux 미니프로젝트 : tcp 통신을 이용한 채팅프로그램 (1) (0) | 2024.09.11 |
댓글