박민혀기
CELLON Kart Source Code(Tracker CSRT) (2023.08.30) 본문
CELLON Kart(Tracking)/Source Code
CELLON Kart Source Code(Tracker CSRT) (2023.08.30)
박민혀기 2023. 8. 30. 22:49Update Feature
- Tracker
Next Develop
- Combine CSRT, 1.3.5v
#include <opencv2/opencv.hpp>
#include <opencv2/tracking.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main() {
VideoCapture cap(0);
if (!cap.isOpened()) {
cerr << "Error: Could not open video file." << endl;
return -1;
}
double width = cap.get(CAP_PROP_FRAME_WIDTH);
double height = cap.get(CAP_PROP_FRAME_HEIGHT);
width = 640;
height = 480;
cap.set(CAP_PROP_FRAME_WIDTH, width);
cap.set(CAP_PROP_FRAME_HEIGHT, height);
Mat frame;
for(int i = 0; i < 20; i++){
cap >> frame;
if (frame.empty()) {
cerr << "Error: Could not read frame." << endl;
return -1;
}
}
Rect bbox = selectROI(frame, false);
Ptr<Tracker> tracker = TrackerCSRT::create();
tracker->init(frame, bbox);
while (true) {
cap >> frame;
if (frame.empty())
break;
bool success = tracker->update(frame, bbox);
if (success) {
rectangle(frame, bbox, Scalar(0, 255, 0), 2);
}
imshow("Object Tracking", frame);
if (waitKey(1) == 'q')
break;
}
cap.release();
destroyAllWindows();
return 0;
}
'CELLON Kart(Tracking) > Source Code' 카테고리의 다른 글
CELLON Kart Source Code 1.3.6v(Size, HSV Ratio) (2023.08.31) (0) | 2023.08.31 |
---|---|
CELLON Kart Source Code 1.3.5v(YCrCb_ROI) (2023.08.30) (0) | 2023.08.30 |
CELLON Kart Source Code 1.3.4v(YCrCb) (2023.08.28) (0) | 2023.08.22 |
CELLON Kart Source Code 1.3.3v (2023.08.22) (0) | 2023.08.22 |
CELLON Kart Source Code 1.3.2V (2023.08.02) (0) | 2023.08.02 |