takephoto.h 1.7 KB

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