opencv 多個攝像頭
阿新 • • 發佈:2018-11-19
Hello! Could any-one help me with the issue? I have the next code:
int CamID = 0; // cams counter int camFind = 0; // counter for founded cameras // looking for all cameras for(int i = 0; i < 128; i++) { std::string strDevName = "/dev/video" + std::to_string(i) + "\0"; if (access(strDevName.c_str(), F_OK) == 0) camFind++; } printf("%d camera(s) founded. Trying to connect...\n", camFind); // trying to connect to cameras do { VideoCapture tmpCam(CamID); // trying to get camera with ID CamID if (!tmpCam.isOpened()) { CamID++; continue; } VideoCamera vCam; vCam.Init(tmpCam, vCams.size() + 1); vCams.push_back(vCam); // add camera to vector CamID++; } while(vCams.size() < camFind);
But I've got the next output:
8 camera(s) founded. Trying to connect... HIGHGUI ERROR: V4L: index 0 is not correct! HIGHGUI ERROR: V4L: index 2 is not correct! HIGHGUI ERROR: V4L: index 3 is not correct! HIGHGUI ERROR: V4L: index 4 is not correct! ... HIGHGUI ERROR: V4L: index 99 is not correct!
What is wrong? How can I determine indexes of my cameras?
Files in /dev:
/dev/video1
/dev/video8
/dev/video9
/dev/video10
/dev/video11
/dev/video12
/dev/video13
/dev/video14
Yes, I have eight cameras. Yes, all of them are connected correctly.
One note: if I restart my computer, I get the following set of files:
/dev/video0
/dev/video1
/dev/video2
/dev/video3
/dev/video4
/dev/video5
/dev/video6
/dev/video7
In this case all cameras will be connected by using of the previous code. WHY?! What is wrong?