资源简介
vs2013+opencv2.4.9亲测可用,运动目标检测效果良好,备注详细
代码片段和文件信息
#include “BackgroundSubtract.h“
BackgroundSubtract::BackgroundSubtract()
{
model = libvibeModelNew();
}
BackgroundSubtract::~BackgroundSubtract()
{
libvibeModelFree(model);
}
void BackgroundSubtract::init(cv::Mat &image)
{
int32_t width = image.size().width;
int32_t height = image.size().height;
int32_t stride = image.channels()*image.size().width;
int32_t image_step0 = image.step[0];
int32_t image_step1 = image.step[1];
uint8_t *image_data = (uint8_t*)image.data;
libvibeModelInit(model image_data width height stride image_step0 image_step1);
}
void BackgroundSubtract::subtract(const cv::Mat &image cv::Mat &foreground)
{
uint8_t *image_data = (uint8_t*)image.data;
uint8_t *segmentation_map = (uint8_t*)foreground.data;
int32_t image_step0 = image.step[0];
int32_t image_step1 = image.step[1];
cv::Mat erodeElement = cv::getStructuringElement( 0 cv::Size( 2 2 ) cv::Point( -1 -1 ) );
cv::Mat dilateElement = cv::getStructuringElement( 0 cv::Size( 2 2 ) cv::Point( -1 -1 ) );
libvibeModelUpdate(model image_data segmentation_map image_step0 image_step1);
/*cv::erode(foreground foreground erodeElement cv::Point(-1 -1) 1);
cv::dilate(foreground foreground dilateElement cv::Point(-1-1) 2);*/
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1260 2017-12-03 20:58 vibe\BackgroundSubtract.cpp
文件 321 2017-10-27 22:09 vibe\BackgroundSubtract.h
文件 2155 2017-12-03 20:41 vibe\main(datatest).cpp
文件 1078 2017-11-08 19:58 vibe\main.cpp
文件 368 2017-10-27 22:09 vibe\OpencvInclude.h
文件 9402 2017-12-03 20:47 vibe\VIBE.cpp
文件 1442 2017-10-30 22:48 vibe\VIBE.h
目录 0 2017-12-21 20:58 vibe
----------- --------- ---------- ----- ----
16026 8
- 上一篇:VC++基于mfc 实现对话框打开读取txt文件
- 下一篇:CH422原厂C语言驱动
评论
共有 条评论