Before you call two or more camera You have got to ensure the cameras to use different HUB!
//Here hide some headers and common callings
int main()
{
VideoCapture cap(0);
while(1)
{
Mat frame;
cap >> frame;
imshow("camera",frame);
if(waitKey(0) == 27)break;
}
return 0;
}