main.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <iostream>
  2. #include "opencv/image_blur_detection.h"
  3. #include "count_down_latch.h"
  4. static void *detection_thread(void *arg) {
  5. const char *filename = "/Users/devyk/Downloads/IMG_3067.PNG";
  6. // const char *filename = "/Users/devyk/Downloads/black.png";
  7. FILE *fp = fopen(filename, "rb");
  8. if (!fp) return reinterpret_cast<void *>(-1);
  9. fseek(fp, 0L, SEEK_END);
  10. int size = ftell(fp);
  11. // fseek(fp, 0L, SEEK_SET);
  12. rewind(fp);
  13. uint8_t *data = (uint8_t *) malloc(sizeof(uint8_t) * size);
  14. size_t size2 = fread(data, size, 1, fp);
  15. printf("图片模糊度检测 %d \n", image_blur_detection(filename));
  16. printf("图片模糊度检测 %d \n", bytes_blur_detection(data, size));
  17. free(data);
  18. // printf("图片模糊度检测 %d \n", image_blur_detection("/Users/devyk/Downloads/black.png"));
  19. auto *countdown = (CountDownLatch *) arg;
  20. countdown->countDown();
  21. return reinterpret_cast<void *>(1);
  22. }
  23. int main() {
  24. int count = 1;
  25. for (int i = 0; i < 1; ++i) {
  26. auto *countdown = new CountDownLatch(count);
  27. for (int i = 0; i < count; ++i) {
  28. pthread_t id;
  29. pthread_create(&id, 0, detection_thread, countdown);
  30. }
  31. countdown->await();
  32. }
  33. return 0;
  34. }