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.
Asked
Active
Viewed 8,026 times
1 Answers
3
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");

berak
- 39,159
- 9
- 91
- 89
-
hello.cpp:3:5: error: ‘Mat’ was not declared in this scope hello.cpp:3:9: error: expected ‘;’ before ‘frame’ hello.cpp:4:27: error: ‘namedWindow’ was not declared in this scope hello.cpp:5:5: error: ‘VideoCapture’ was not declared in this scope hello.cpp:5:18: error: expected ‘;’ before ‘cap’ hello.cpp:6:13: error: ‘cap’ was not declared in this scope hello.cpp:8:16: error: ‘frame’ was not declared in this scope hello.cpp:11:30: error: ‘imshow’ was not declared in this scope hello.cpp:12:22: error: ‘waitKey’ was not declared in this scope – iAmNotVeryGoodAtThis Oct 07 '13 at 01:04