-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfind_cameras.cpp
More file actions
41 lines (35 loc) · 955 Bytes
/
find_cameras.cpp
File metadata and controls
41 lines (35 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "find_cameras.h"
#include <iostream>
#include <filesystem>
#include <vector>
#include "opencv2/opencv.hpp"
namespace fs = std::filesystem;
int GetIdFromName(std::string name) {
int loc = name.find("camera-");
if (loc == -1) {
return -1;
}
return (int)(name[loc+7]-'0');
}
/*
std::unique_ptr OpenConnectedCameras() {
// std::vector<USBCamera> out;
fs::path usb_directory("/dev/v4l/by-id");
for (auto& p : fs::directory_iterator(usb_directory)) {
fs::path current_camera = fs::read_symlink(p);
std::string video_num = current_camera;
if (video_num.find("video") != 6) {
continue;
}
int id = (int)(video_num[11]-'0');
cv::VideoCapture cap(id);
if (cap.isOpened()) {
// std::cout << " id: " << id << " GOOD" << std::endl;
}
}
}
*/
int main() {
std::cout << GetIdFromName("usb-Arducam_Technology_Co.__Ltd._camera-2_UC762-video-index0") << std::endl;
// GetConnectedCameras();
}