当前位置:网站首页>Opencv learning log 31 -- background difference
Opencv learning log 31 -- background difference
2022-07-06 15:43:00 【@Spring sauce】
Preface
This article is mainly about opencv Background difference in image processing .
One 、 Background subtraction
// The first question is Background subtraction
#include <opencv2/opencv.hpp>
#include <iostream>
#include<cmath>
using namespace cv;
using namespace std;
int main()
{
// Counter
int cnt = 0;
Mat frame;
Mat background;
Mat subpic;
Mat bin_subpic;
VideoCapture cap;
cap.open("C://Users//john//Desktop//VID.mp4");
while (1)
{
cap.read(frame);
cvtColor(frame, frame, COLOR_BGR2GRAY);
if (cnt == 0) {
frame.copyTo(background);
}
else {
// The second frame starts with background subtraction
// The background image is subtracted from the current image
absdiff(frame, background, subpic);
// Binarization of difference results
threshold(subpic, bin_subpic, 50, 144, CV_THRESH_BINARY);
imshow("subpic", subpic);
imshow("bin_subpic", bin_subpic);
imshow("frame", frame);
waitKey(30);
}
cnt++;
}
return 0;
}
summary
1. The code can run directly , If you don't understand, you can leave a message .
2. Missing material pictures , Subsequent patch , thank you .
边栏推荐
- ucore lab5
- Research Report on market supply and demand and strategy of geosynthetics industry in China
- Accounting regulations and professional ethics [2]
- JS --- all basic knowledge of JS (I)
- Borg Maze (BFS+最小生成树)(解题报告)
- Es6---es6 content details
- LeetCode#268. Missing numbers
- csapp shell lab
- Record of force deduction and question brushing
- 毕业才知道IT专业大学生毕业前必做的1010件事
猜你喜欢
随机推荐
ucore lab 6
Research Report on market supply and demand and strategy of China's earth drilling industry
MATLAB实例:阶跃函数的两种表达方式
China's salt water membrane market trend report, technological innovation and market forecast
UCORE Lab 1 system software startup process
LeetCode#2062. Count vowel substrings in strings
LeetCode#204. Count prime
Cost accounting [21]
基于web的照片数码冲印网站
Research Report on market supply and demand and strategy of China's medical chair industry
Cost accounting [13]
China's PCB connector market trend report, technological innovation and market forecast
Market trend report, technical innovation and market forecast of lip care products in China and Indonesia
STM32 learning record: input capture application
Research Report on pharmaceutical R & D outsourcing service industry - market status analysis and development prospect forecast
通俗地理解什么是编程语言
Research Report on market supply and demand and strategy of China's Medical Automation Industry
Perinatal Software Industry Research Report - market status analysis and development prospect forecast
Research Report on market supply and demand and strategy of China's land incineration plant industry
Indonesian medical sensor Industry Research Report - market status analysis and development prospect forecast