I've 4 Axis IP cams. I need a code to capture image from those cams. I've opencv code to capture image from USB cams but I don't kno how to capture from IP cams.
int main()
{
Mat frame;
namedWindow("video", 1);
VideoCapture cap("http://150.214.93.55/mjpg/video.mjpg");
while ( cap.isOpened() )
{
cap >> frame;
if(frame.empty()) break;
imshow("video", frame);
if(waitKey(30) >= 0) break;
}
return 0;
}
no idea, how your urls look like, but opencv seems to insist, it has to end with mjpg. so if it doesn't, the trick is to append a dummy parameter:
http://my/cool/ip-cam.ie?dummy=video.mjpg
if you need to open all 4 cams at once, you need a VideoCapture for each one:
VideoCapture cap1("url1");
VideoCapture cap2("url2");
VideoCapture cap3("url3");
VideoCapture cap4("url4");
来源:https://stackoverflow.com/questions/15462323/c-code-capturing-image-from-ip-ethernet-cameras-axis-cam