Why don’t you use the included VideoCapture class?
cv::VideoCapture camA(0),camB(1);
if((!camA.isOpened)||(!camB.isOpened)) {
std::cout<<"Camera error"<<std::endl;
return;
}
cv::Mat frame1,frameB,frame;
camA>>frameA;
camB>>frameB;
If you want to show them in one window, just concatenate them:
hconcat(frameA,frameB,frame);
imshow("Frame",frame);
Normally your cameras are managed by V4L2 and have the addresses /dev/video0 and /dev/video1.