当前位置:网站首页>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 .
边栏推荐
- Record of brushing questions with force deduction -- complete knapsack problem (I)
- STM32學習記錄:輸入捕獲應用
- Market trend report, technological innovation and market forecast of pneumonia drugs obtained by Chinese hospitals
- 0-1背包問題(一)
- Research Report on market supply and demand and strategy of Chinese graphic screen printing equipment industry
- JS --- detailed explanation of JS facing objects (VI)
- China's earthwork tire market trend report, technical dynamic innovation and market forecast
- Learning record: how to perform PWM output
- Research Report on pharmaceutical R & D outsourcing service industry - market status analysis and development prospect forecast
- Learning record: Tim - Basic timer
猜你喜欢
Learning record: Tim - Basic timer
学习记录:TIM—基本定时器
ucore lab 6
Learning record: STM32F103 clock system overview working principle
学习记录:串口通信和遇到的错误解决方法
MATLAB实例:阶跃函数的两种表达方式
JS --- BOM details of JS (V)
csapp shell lab
LeetCode#19. Delete the penultimate node of the linked list
STM32 learning record: LED light flashes (register version)
随机推荐
CS zero foundation introductory learning record
MATLAB实例:阶跃函数的两种表达方式
MATLAB综合练习:信号与系统中的应用
Opencv learning log 12 binarization of Otsu method
STM32学习记录:输入捕获应用
HDU-6025-Coprime Sequence(女生赛)
Accounting regulations and professional ethics [5]
VS2019初步使用
力扣刷题记录
Cost accounting [17]
Flex --- detailed explanation of flex layout attributes
Research Report on surgical fluid treatment industry - market status analysis and development prospect prediction
JS --- all knowledge of JS objects and built-in objects (III)
Medical colposcope Industry Research Report - market status analysis and development prospect forecast
Market trend report, technical innovation and market forecast of lip care products in China and Indonesia
Cost accounting [24]
China's earthwork tire market trend report, technical dynamic innovation and market forecast
Unpleasant error typeerror: cannot perform 'ROR_‘ with a dtyped [float64] array and scalar of type [bool]
STM32 learning record: play with keys to control buzzer and led
信息安全-威胁检测-NAT日志接入威胁检测平台详细设计