takephoto_test.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // +build ignore
  2. #include "takephoto.h"
  3. // 主函数入口, 测试拍照
  4. int main(int argc,char *argv[])
  5. {
  6. int ret = 0; unsigned long stime, wtime, etime; HKImgMark imgMark = { 0 };
  7. char filename[MAX_PATH_CHARS] = { 0 }; int timeout = 5*60;
  8. if(HK_GetSysUsbfsMemCurrentSize() < 200) ret = HK_SetSysUsbfsMemSize(200);
  9. if(0 != ret)
  10. {
  11. sw_log_error("Failed to set system usbfs's memory size, ret=%d!!", ret);
  12. return ret;
  13. }
  14. sw_log_info("Get HK camera count: %d", HK_GetCameraCount());
  15. sw_log_info("Photo taking...");
  16. for(int i = 0; i < 9; i++)
  17. {
  18. sprintf(filename, "test%d.jpg", i+1);
  19. xgettickcount(&stime);
  20. ret = HK_TakePhoto(IMG_TYPE_JPG, filename, timeout, &imgMark);
  21. xgettickcount(&etime);
  22. wtime = etime - stime;
  23. if(0 == ret) sw_log_info("+++ Take a photo: \"%s\", time: %lums, exposure time: %fus, camera sn: %s, camera model: %s +++", filename, wtime, imgMark.imgExposureTime, imgMark.camSerialNum, imgMark.camModelName);
  24. else sw_log_error("+++ Failed to take a photo, ret=%d, time: %lums!! +++", ret, wtime);
  25. sw_thrd_delay(1000); // 轮询拍照测试时, 给系统预留一定的相机释放时间
  26. }
  27. return 0;
  28. }