Ask Your Question
0

Webcam and IP cam recording with openCv

asked 2014-12-01 19:24:30 -0600

monev gravatar image

updated 2014-12-02 06:38:47 -0600

thdrksdfthmn gravatar image

i have a problem with capture frames from 2 different cameras in the same time. I know that is probably impossible (or it's quite difficult) to connect in this way 2 USB cams, but connecting one USB cam and one IPcam maybe is easier. Of course if they works separatly i don't have problems. For example this code doesn't work:

int main() {

const std::string videoStreamAddress = "http://........../img/video.mjpeg";
cv::VideoCapture camera0(0);
cv::VideoCapture camera1(1);
camera0.open(videoStreamAddress);
cv::Mat3b frame0;
cv::Mat3b frame1;
while (true) {
    camera0 >> frame0;
    camera1 >> frame1;
    cv::imshow("Video0", frame0);
    cv::imshow("Video1", frame1);
    int c = cvWaitKey(40);
    if (27 == char(c)) break;
}

return 0;
}

I hope that anybody can help me

edit retag flag offensive close merge delete

Comments

Doing cv::VideoCapture camera0(0); will initialize the capture to reading default camera. See this first and then tell us what is not working.

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-12-02 06:42:37 -0600 )edit

But even i write sth like this:

const std::string videoStreamAddress = "http://.........../img/video.mjpeg";

cv::VideoCapture camera0(0);

cv::VideoCapture camera1(videoStreamAddress);

it still doesn't work. It's compilate, run and working for while but then it crash with this error "Unhandled exception at 0x757EC42D in iptest.exe: Microsoft C++ exception: cv::Exception at memory location 0x003AF768."

monev gravatar imagemonev ( 2014-12-02 15:07:50 -0600 )edit

Maybe adding a verification before displaying the frames: if (!frame.empty()) imshow("frame", frame); It is possible that it does not receive some frames and you will get an empty frame instead...

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-12-03 02:03:12 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-01-05 06:16:48 -0600

monev gravatar image

The answer is very very easy... camera is old and not very good. That how thdrksdfthmn said this cam from time to time send empty frames. I change camera and problem is solved.

edit flag offensive delete link more

Comments

Would any new IP camera work though as a solution? What about doing this on Android?

aliavci gravatar imagealiavci ( 2015-02-24 22:52:10 -0600 )edit

Question Tools

Stats

Asked: 2014-12-01 19:24:30 -0600

Seen: 337 times

Last updated: Dec 02 '14