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;
}