main.cpp 1.2 KB

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