提交 beb3e6ff 编写于 作者: V Vladislav Vinogradov

added GMG_GPU to bgfg_segm sample

上级 f7f1fb2b
...@@ -14,7 +14,8 @@ enum Method ...@@ -14,7 +14,8 @@ enum Method
FGD_STAT, FGD_STAT,
MOG, MOG,
MOG2, MOG2,
VIBE VIBE,
GMG
}; };
int main(int argc, const char** argv) int main(int argc, const char** argv)
...@@ -22,7 +23,7 @@ int main(int argc, const char** argv) ...@@ -22,7 +23,7 @@ int main(int argc, const char** argv)
cv::CommandLineParser cmd(argc, argv, cv::CommandLineParser cmd(argc, argv,
"{ c | camera | false | use camera }" "{ c | camera | false | use camera }"
"{ f | file | 768x576.avi | input video file }" "{ f | file | 768x576.avi | input video file }"
"{ m | method | mog | method (fgd_stat, mog, mog2, vibe) }" "{ m | method | mog | method (fgd, mog, mog2, vibe, gmg) }"
"{ h | help | false | print help message }"); "{ h | help | false | print help message }");
if (cmd.get<bool>("help")) if (cmd.get<bool>("help"))
...@@ -37,13 +38,13 @@ int main(int argc, const char** argv) ...@@ -37,13 +38,13 @@ int main(int argc, const char** argv)
string file = cmd.get<string>("file"); string file = cmd.get<string>("file");
string method = cmd.get<string>("method"); string method = cmd.get<string>("method");
if (method != "fgd_stat" && method != "mog" && method != "mog2" && method != "vibe") if (method != "fgd" && method != "mog" && method != "mog2" && method != "vibe" && method != "gmg")
{ {
cerr << "Incorrect method" << endl; cerr << "Incorrect method" << endl;
return -1; return -1;
} }
Method m = method == "fgd_stat" ? FGD_STAT : method == "mog" ? MOG : method == "mog2" ? MOG2 : VIBE; Method m = method == "fgd" ? FGD_STAT : method == "mog" ? MOG : method == "mog2" ? MOG2 : method == "vibe" ? VIBE : GMG;
VideoCapture cap; VideoCapture cap;
...@@ -67,6 +68,8 @@ int main(int argc, const char** argv) ...@@ -67,6 +68,8 @@ int main(int argc, const char** argv)
MOG_GPU mog; MOG_GPU mog;
MOG2_GPU mog2; MOG2_GPU mog2;
VIBE_GPU vibe; VIBE_GPU vibe;
GMG_GPU gmg;
gmg.numInitializationFrames = 40;
GpuMat d_fgmask; GpuMat d_fgmask;
GpuMat d_fgimg; GpuMat d_fgimg;
...@@ -93,12 +96,16 @@ int main(int argc, const char** argv) ...@@ -93,12 +96,16 @@ int main(int argc, const char** argv)
case VIBE: case VIBE:
vibe.initialize(d_frame); vibe.initialize(d_frame);
break; break;
case GMG:
gmg.initialize(d_frame.size());
break;
} }
namedWindow("image", WINDOW_NORMAL); namedWindow("image", WINDOW_NORMAL);
namedWindow("foreground mask", WINDOW_NORMAL); namedWindow("foreground mask", WINDOW_NORMAL);
namedWindow("foreground image", WINDOW_NORMAL); namedWindow("foreground image", WINDOW_NORMAL);
if (m != VIBE) if (m != VIBE && m != GMG)
namedWindow("mean background image", WINDOW_NORMAL); namedWindow("mean background image", WINDOW_NORMAL);
for(;;) for(;;)
...@@ -108,6 +115,8 @@ int main(int argc, const char** argv) ...@@ -108,6 +115,8 @@ int main(int argc, const char** argv)
break; break;
d_frame.upload(frame); d_frame.upload(frame);
int64 start = cv::getTickCount();
//update the model //update the model
switch (m) switch (m)
{ {
...@@ -130,8 +139,15 @@ int main(int argc, const char** argv) ...@@ -130,8 +139,15 @@ int main(int argc, const char** argv)
case VIBE: case VIBE:
vibe(d_frame, d_fgmask); vibe(d_frame, d_fgmask);
break; break;
case GMG:
gmg(d_frame, d_fgmask);
break;
} }
double fps = cv::getTickFrequency() / (cv::getTickCount() - start);
std::cout << "FPS : " << fps << std::endl;
d_fgimg.setTo(Scalar::all(0)); d_fgimg.setTo(Scalar::all(0));
d_frame.copyTo(d_fgimg, d_fgmask); d_frame.copyTo(d_fgimg, d_fgmask);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册