当前位置:网站首页>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 .
边栏推荐
- C语言是低级和高级的分水岭
- STM32 learning record: play with keys to control buzzer and led
- STM32如何使用STLINK下载程序:点亮LED跑马灯(库版本)
- Path problem before dynamic planning
- Research Report of exterior wall insulation system (ewis) industry - market status analysis and development prospect prediction
- Cost accounting [21]
- 程序员的你,有哪些炫技的代码写法?
- Flex --- detailed explanation of flex layout attributes
- Learning record: USART serial communication
- Cost accounting [17]
猜你喜欢

数据在内存中的存储&载入内存,让程序运行起来

FSM and I2C experiment report

Learning record: USART serial communication

洛谷P1102 A-B数对(二分,map,双指针)

ucore lab5

信息安全-威胁检测引擎-常见规则引擎底座性能比较
![mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’](/img/e6/f4a696179282fe1f4193410c5a493a.png)
mysql导入数据库报错 [Err] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’

Eslint--- error: newline required at end of file but not found (EOL last) solution

学习记录:使用STM32F1看门狗

STM32学习记录:输入捕获应用
随机推荐
Research Report on surgical fluid treatment industry - market status analysis and development prospect prediction
China chart recorder market trend report, technology dynamic innovation and market forecast
学习记录:串口通信和遇到的错误解决方法
China medical check valve market trend report, technical dynamic innovation and market forecast
CS zero foundation introductory learning record
编程到底难在哪里?
cs零基础入门学习记录
LeetCode#62. Different paths
用C语言写网页游戏
JS --- BOM details of JS (V)
JS --- JS function and scope (II)
HDU-6025-Coprime Sequence(女生赛)
想应聘程序员,您的简历就该这样写【精华总结】
Research Report of pharmaceutical solvent industry - market status analysis and development prospect prediction
Research Report on shell heater industry - market status analysis and development prospect forecast
Es6--- two methods of capturing promise status as failed
信息安全-安全专业名称|CVE|RCE|POC|VUL|0DAY
LeetCode#118. Yanghui triangle
STM32学习记录:输入捕获应用
Cost accounting [18]