Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Capture from two webcam

$
0
0
i have two web cams ( Laptop's cam and an USB webcam ) i tried to capture from two cams at the same time with the code below. it is working but one of the cams is lagging. when i make two exe file ( one exe capturing from `cam 0` other from `cam 1` ) and run two exe at the same time, both cam streaming without lagging. any advice to this problem ? >EDIT: i edited the code according to @pklab 's comment.> yes! i get better result with this modification.> but still not good as two running exe :( Note: running on Windows 10 Video I/O: DirectShow #include #include using namespace cv; using namespace std; int main(int argc, const char * argv[]) { VideoCapture cap0(0); VideoCapture cap1(1); cap0.set(CV_CAP_PROP_FPS, 15); cap1.set(CV_CAP_PROP_FPS, 15); Mat frame0, frame1; for (;;) { if (!(cap0.grab() && cap0.grab())) { std::cerr << "Unable to grab from one or both cameras"; break; } cap0.retrieve(frame0); cap1.retrieve(frame1); if (!frame0.empty()) { imshow("cap0", frame0); } if (!frame1.empty()) { imshow("cap1", frame1); } int key = waitKey(10); if (key == 27) break; } }

Viewing all articles
Browse latest Browse all 19555

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>