In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how OpenCV can achieve intelligent video surveillance. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.
It was troublesome to find a complete implementation code on the Internet when I was doing the design before. After I finished it, I would like to share it with you
Because the code is relatively simple, there is no separate code written in different files, there is a need to integrate their own ha
Working with environments Visual Studio 2010 and OpenCV 2.4.9
#include #include #include using namespace std;using namespace cv; int videoplay();void on_Trackbar (int ,void*);char* str_gettime();int bSums(Mat src); char g_str[17];int g_nNum = 0;//Image name int g_nDelay = 0;int g_npic = 0;Mat g_filpdstMat;int g_pointnum = 1000;//Set pixel threshold to generate image int g_pixel = 0;//Pixels int main(){ VideoCapture (0); //Video output VideoWriter CvVideoWriter* outavi = NULL; //VideoWriter outavi; //outavi.open ("sre.avi",-1, 5. 0, Size(640, 480), true); outavi = cvCreateVideoWriter("Video.avi", -1, 5.0, cvSize(640, 480), 1); namedWindow("Camera",WINDOW_AUTOSIZE); namedWindow("Move Trajectory," WINDOW_AUTOSIZE); IplImage * cpframe = NULL; Mat tempframe, currentframe, preframe, cpframe; Mat frame,jpg; int framenum = 0; //Read a frame while (1) { if(! capture.isOpened()) { cout frame;//read camera and pass each frame to frame.copyTo(cpframe);//assign frame to cpframe without affecting frame tempframe = frame;//assign frame to tempframe without affecting frame flip (tempframe,g_filpdstMat,1);//Flip the image horizontally pcpframe = &IplImage(cpframe);//To free the window, convert Mat to IplImage using//cpframe=cvarrToMat (pcpframe); //ipl conversion matrix pBinary = &IplImage(Img) //7 frames capture once input video, frequent capture does not work if (framenum % 7 == 0) { //Video Write cvWriteFrame (outtavi, pcpframe); } //Determine the number of frames. If it is the first frame, use this frame as the comparison frame.//If it is greater than or equal to the second frame, perform frame difference processing framenum++; if (framenum == 1) { cvtColor (g_filpdstMat, preframe, CV_BGR2GRAY); } if (framenum >= 2) { cvtColor (g_filpdstMat, currentframe, CV_BGR2GRAY); //grayscale absdiff (currentframe,preframe,currentframe);//frame difference threshold (currentframe, currentframe, 30, 255.0, CV_THRESH_BINARY);(currentframe, currentframe,Mat());//corrosion dilute (currentframe, currentframe,Mat());//expand g_pixel = bSums(currentframe);//call bSums function to calculate white pixel and assign it to g_pixel //output the current pixel value after a small delay to prevent the data from being too fast to see g_nDelay++; if(g_nDelay > 5) { cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.