forked from hybridgroup/gocv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
video.cpp
73 lines (57 loc) · 2.74 KB
/
video.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "video.h"
BackgroundSubtractorMOG2 BackgroundSubtractorMOG2_Create() {
return new cv::Ptr<cv::BackgroundSubtractorMOG2>(cv::createBackgroundSubtractorMOG2());
}
BackgroundSubtractorMOG2 BackgroundSubtractorMOG2_CreateWithParams(int history, double varThreshold, bool detectShadows) {
return new cv::Ptr<cv::BackgroundSubtractorMOG2>(cv::createBackgroundSubtractorMOG2(history,varThreshold,detectShadows));
}
BackgroundSubtractorKNN BackgroundSubtractorKNN_Create() {
return new cv::Ptr<cv::BackgroundSubtractorKNN>(cv::createBackgroundSubtractorKNN());
}
BackgroundSubtractorKNN BackgroundSubtractorKNN_CreateWithParams(int history, double dist2Threshold, bool detectShadows) {
return new cv::Ptr<cv::BackgroundSubtractorKNN>(cv::createBackgroundSubtractorKNN(history,dist2Threshold,detectShadows));
}
void BackgroundSubtractorMOG2_Close(BackgroundSubtractorMOG2 b) {
delete b;
}
void BackgroundSubtractorMOG2_Apply(BackgroundSubtractorMOG2 b, Mat src, Mat dst) {
(*b)->apply(*src, *dst);
}
void BackgroundSubtractorKNN_Close(BackgroundSubtractorKNN k) {
delete k;
}
void BackgroundSubtractorKNN_Apply(BackgroundSubtractorKNN k, Mat src, Mat dst) {
(*k)->apply(*src, *dst);
}
void CalcOpticalFlowFarneback(Mat prevImg, Mat nextImg, Mat flow, double scale, int levels,
int winsize, int iterations, int polyN, double polySigma, int flags) {
cv::calcOpticalFlowFarneback(*prevImg, *nextImg, *flow, scale, levels, winsize, iterations, polyN,
polySigma, flags);
}
void CalcOpticalFlowPyrLK(Mat prevImg, Mat nextImg, Mat prevPts, Mat nextPts, Mat status, Mat err) {
cv::calcOpticalFlowPyrLK(*prevImg, *nextImg, *prevPts, *nextPts, *status, *err);
}
void CalcOpticalFlowPyrLKWithParams(Mat prevImg, Mat nextImg, Mat prevPts, Mat nextPts, Mat status, Mat err, Size winSize, int maxLevel, TermCriteria criteria, int flags, double minEigThreshold){
cv::Size sz(winSize.width, winSize.height);
cv::calcOpticalFlowPyrLK(*prevImg, *nextImg, *prevPts, *nextPts, *status, *err, sz, maxLevel, *criteria, flags, minEigThreshold);
}
bool Tracker_Init(Tracker self, Mat image, Rect boundingBox) {
cv::Rect bb(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height);
(*self)->init(*image, bb);
return true;
}
bool Tracker_Update(Tracker self, Mat image, Rect* boundingBox) {
cv::Rect bb;
bool ret = (*self)->update(*image, bb);
boundingBox->x = int(bb.x);
boundingBox->y = int(bb.y);
boundingBox->width = int(bb.width);
boundingBox->height = int(bb.height);
return ret;
}
TrackerMIL TrackerMIL_Create() {
return new cv::Ptr<cv::TrackerMIL>(cv::TrackerMIL::create());
}
void TrackerMIL_Close(TrackerMIL self) {
delete self;
}