takephoto.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Author: NiuJiuRu
  2. // Email: niujiuru@qq.com
  3. // Date: 2025-07-21 【新增支持U口相机】
  4. // Date: 2026-01-06 【新增支持G口相机】
  5. #ifndef __TAKEPHOTO_H__
  6. #define __TAKEPHOTO_H__
  7. #include "./include/MvCameraControl.h"
  8. #include "../swapi/include_swapiLib.h"
  9. // 图像水印
  10. typedef struct
  11. {
  12. char camModelName[MAX_LINE_CHARS]; // 相机型号名
  13. char camSerialNum[MAX_LINE_CHARS]; // 相机序列号
  14. float imgExposureTime; // 拍照曝光时间, 单位: us
  15. } SImgMark;
  16. // 图像类型
  17. typedef enum
  18. {
  19. IMG_TYPE_BMP = 1, // 拍照输出".bmp"格式的图像文件
  20. IMG_TYPE_JPG = 2, // 拍照输出".jpg"格式的图像文件
  21. } EImgType;
  22. #ifdef __cplusplus
  23. extern "C"
  24. {
  25. #endif
  26. // 获取系统当前USBFS内存大小(MB), 成功返回: >=0, 失败返回: <0值
  27. int GetSysUsbfsMemCurrentSize();
  28. // 设置系统新的USBFS内存大小(MB), 成功返回: 0值, 失败返回: <0值
  29. int SetSysUsbfsMemSize(int val);
  30. // 获取当前已连接的海康相机的数量, 成功返回: >=0, 失败返回: <0值
  31. int GetHKCameraCount();
  32. // 单次执行相机拍照, 并保存到文件, 成功返回: 0值, 失败返回:非0值
  33. // "imgType" - 获取图像类型
  34. // "saveImgPath" - 保存的文件名
  35. // "timeout" - 等待超时时间, 单位:秒: < 0 表示无超时;
  36. // 无论超时怎么设置, 首次尝试拍照一定会执行
  37. // , 但时间不确定; 拍照成功、超时或发生错误
  38. // 时会自动结束任务(相机持续无数据的时间).
  39. // "pImgMark" - 输出本次拍照图像的水印信息, 可以设置NULL
  40. int TakePhoto(EImgType imgType, const char *saveImgPath, int timeout, SImgMark *pImgMark);
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif /* __TAKEPHOTO_H__ */