| 73 | } |
| 74 | |
| 75 | Status OpenCamera(int* camera_handle) { |
| 76 | const char* dev_name = "/dev/video0"; |
| 77 | int fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0); |
| 78 | if (fd < 0) { |
| 79 | LOG(ERROR) << "Cannot open camera device"; |
| 80 | return tensorflow::errors::NotFound("V4L2 camera device not found"); |
| 81 | } |
| 82 | *camera_handle = fd; |
| 83 | return Status::OK(); |
| 84 | } |
| 85 | |
| 86 | Status CloseCamera(int camera_handle) { |
| 87 | v4l2_close(camera_handle); |