findconfig.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <libmegapixels.h>
  2. #include <stdio.h>
  3. #include <limits.h>
  4. int
  5. main()
  6. {
  7. char configpath[PATH_MAX];
  8. int ret = libmegapixels_find_config(configpath);
  9. libmegapixels_devconfig *config = {0};
  10. if (ret) {
  11. printf("Using config: %s\n", configpath);
  12. libmegapixels_load_file(&config, configpath);
  13. } else {
  14. printf("No config found\n");
  15. libmegapixels_load_file(&config, "config/uvc.conf");
  16. }
  17. printf("Device: %s %s\n", config->make, config->model);
  18. printf("Found %d cameras\n", config->count);
  19. for (int i = 0; i < config->count; i++) {
  20. printf("\n----[ Camera %s (%d) ]----\n", config->cameras[i]->name, i);
  21. printf("Media : %s (%s)\n", config->cameras[i]->bridge_name, config->cameras[i]->media_path);
  22. printf("Sensor: %s (%s)\n", config->cameras[i]->sensor_name, config->cameras[i]->sensor_path);
  23. printf("Bridge: %s\n", config->cameras[i]->video_path);
  24. printf("Modes : ");
  25. for (int j = 0; j < config->cameras[i]->num_modes; j++) {
  26. if (j > 0) {
  27. printf(" ");
  28. }
  29. libmegapixels_mode *mode = config->cameras[i]->modes[j];
  30. printf("%dx%d@%d\n", mode->width, mode->height, mode->rate);
  31. }
  32. }
  33. return 0;
  34. }