opencv IP camera video stream capture and people detection
In that tutorial, I just want to introduce how to read the more video streams in threads. In some cases, you need to have FFMPEG installed. Hopefully, Windows nuger default installation in Visual Studio should be enough. Let me know if there is any problem.
Opencv environment for tutorial
Just use the installation of Opencv in Visual Studio 2015 by Nuget packages. In package console just type and wait for the message that your opencv is successfully installed in your project. More info in tutorial HereType to package console
PM> Install-Package opencvdefault
On the Linux distribution, i can recommend my tutorial Here. In the case of Debian like packages.
Opencv video stream verification
http://IP:PORT/mjpeg/video.mjpg?counterrtsp://IP:PORT/various url
Find your IP camera model on http://www.ispyconnect.com
Select for example for Axis and the model..
There is various stream url for each of this. There is no standard way of URL format.
Find your for the camera and model.
rtsp://IP:PORT/axis-cgi/mjpg/video.cgi
http://IP:PORT/mjpg/video.mjpg
And milion of others different kind of URL formats.
And milion of others different kind of URL formats.
Opencv tutorial code IP camera pseudo code
There is 3 function..
First of all, the main function at the end, where are established 2 threads to read the camera stream..
In Main
In Main
- Thread call the stream function for both camera with different IP camera URL thread cam1(stream, "http://xxxxxxxR");
- To run the function stream inside the thread with url as parametr use. cam1.join();
- Capture video from url strCamera VideoCapture cap(strCamera)
- Fill the frame from cap cap >> frame;
- Detect people in camera detect(frame, strCamera);
Opencv C++ IP camera code
#include <iostream>
#include <thread>
#include "opencv2/opencv.hpp"
#include <vector>
using namespace std;
using namespace cv;
void detect(Mat img, String strCamera) {
string cascadeName1 = "haar_cascade_for_people_detection.xml";
CascadeClassifier detectorBody;
bool loaded1 = detectorBody.load(cascadeName1);
Mat original;
img.copyTo(original);
vector human;
cvtColor(img, img, CV_BGR2GRAY);
equalizeHist(img, img);
detectorBody.detectMultiScale(img, human, 1.1, 2, 0 | 1, Size(40, 80), Size(400,480 ));
if (human.size() > 0)
{
for (int gg = 0; gg < human.size(); gg++)
{
rectangle(original, human[gg].tl(), human[gg].br(), Scalar(0, 0, 255), 2, 8, 0);
}
}
imshow("Detect " + strCamera, original);
int key6 = waitKey(40);
//End of the detect
}
void stream(String strCamera) {
VideoCapture cap(strCamera);
if (cap.isOpened()) {
while (true) {
Mat frame;
cap >> frame;
resize(frame, frame, Size(640, 480));
detect(frame, strCamera);
}
}
}
int main() {
thread cam1(stream, "http://xxxxxxxR");
thread cam2(stream, "http://xxxxxxxR");
cam1.join();
cam2.join();
return 0;
}
This post is very useful. Thnks for sharing it.
CCTV Camera Dealers | Fire Hydrant Dealers in India
Thank you. It is important sometime to have install ffmpe.
For camera reading I am using threads to lock the resources. for example for 3 4 ip address..
#include
This call function stream.
thread cam1(stream, "http://90.1xxxxxxxxxxxjpg",1);
cam1.join();
Inside stream there is a standard reading loop of opencvg input sources
void stream(String strCamera, int mode) {
}
is this works with WiFi ip camera
شرکت هوشمند افزار آسیا یکی از قدرتمند ترین شرکت های حوزه سیستم های امنیتی و نظارت تصویری و دوربین های مداربسته
نماینده فروش دوربین های مداربسته هایک ویژن در کرج و تهران
نصب دوربین مداربسته
نماینده فروش دوربین های مداربسته هایک ویژن در کرج و تهران
نماینده فروش دوربین های مداربسته هایک ویژن در کرج و تهران
مجله تخصصی دوربین مداربسته و سیستم های حفاظتی و امنیتی
02634216001-02634216002
Thank you for sharing like this information. If you want more information regarding CCTV Camera visit shipgig website.
Very good post. we are doing CCTV Industry in chennai. Thank you.
CCTV Camera Dealers in Chennai
CCTV Camera Installation Chennai
thanks
This is a great article, this provide more information in it, these type of articles keeps the users interest on a security camera for homes and business. Thanks for sharing good information and keep on sharing more content.
Thanks and Regards,
Jordan Caver
Home Theater Vancouver
Home Theater Toronto
. I will be using it to pan the FourthFest activities in Bayfront Park and the Harbor in general.https://www.cameresupraveghereieftine.ro/19-kit-camere-supraveghere
Accurate multiple person counting program using OpenCV and Visual Studio. Axis camera
Fantastic and useful we blog thanks for publishing this.it's useful and informative.keep up the great.
ENER-J CCTV Security Camera
HighMark Security is a direct supplier of security cameras, video surveillance systems, and CCTV equipment. We supply analog CCTV cameras, HD security cameras, IP cameras, and complete video surveillance systems worldwide. We supply our equipment to homeowners, business owners, government agencies, and any other type of organization, any size. Most of our business comes from the Da Nang, however, we do ship our products everywhere in the world. No project is too small or too large for us to handle. We have trained sales engineers that can help design a system that will fit your requirements and budget. Mua may dinh vi, class="st">CCTV Camera, IP Camera Lap Camera Da Nang, Security Systems, Analog Camera, Smart Home Store, Omnipolis, DVR, NVR, Video Management Software, camera ip wifi da nang, read more: lap dat camera da nang. HighMark Security has earned a reputation with the best technical support and customer service in the Da Nang security camera industry, lap camera …
Can I know which model of ip camera you use?
Thank you for share such great information about security alarm system. Home security is important thing for every home and business. I consider you to choose secure and reliable wireless burglar alarm to protect your home, property and family from thieves and criminals. Its really helpful for everyone.