takephoto.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Author: NiuJiuRu
  2. // Email: niujiuru@qq.com
  3. // Date: 2025-07-21 【新增支持U口相机】
  4. // Date: 2026-01-06 【新增支持G口相机】
  5. #ifndef __HK_TAKEPHOTO_H__
  6. #define __HK_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. unsigned int imgWidth; // 拍照图像宽度, 单位: px
  16. unsigned int imgHeight;// 拍照图像高度, 单位: px
  17. } HKImgMark;
  18. // 图像类型
  19. typedef enum
  20. {
  21. IMG_TYPE_BMP = 1, // 拍照输出".bmp"格式的图像文件
  22. IMG_TYPE_JPG = 2, // 拍照输出".jpg"格式的图像文件
  23. } HKImgType;
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. // 获取系统当前USBFS内存大小(MB), 成功返回: >=0, 失败返回: <0值
  29. int HK_GetSysUsbfsMemCurrentSize();
  30. // 设置系统新的USBFS内存大小(MB), 成功返回: 0值, 失败返回: <0值
  31. int HK_SetSysUsbfsMemSize(int val);
  32. // 获取当前已连接的海康相机的数量, 成功返回: >=0, 失败返回: <0值
  33. int HK_GetCameraCount();
  34. // 单次拍照时, 如果相机处于自动曝光模式, 是否等待曝光稳定后再拍照
  35. int HK_SetWaitAEDoneForTakePhoto(int waitAE); // waitAE: 0=不等待, 1=等待(默认)
  36. // 单次执行相机拍照, 并保存到文件, 成功返回: 0值, 失败返回:非0值
  37. // "imgType" - 获取图像类型
  38. // "saveImgPath" - 保存的文件名
  39. // "timeout" - 等待超时时间, 单位:秒: < 0 表示无超时;
  40. // 无论超时怎么设置, 首次尝试拍照一定会执行
  41. // , 但时间不确定; 拍照成功、超时或发生错误
  42. // 时会自动结束任务(相机持续无数据的时间).
  43. // "pImgMark" - 输出本次拍照图像的水印信息, 可以设置NULL
  44. int HK_TakePhoto(HKImgType imgType, const char *saveImgPath, int timeout, HKImgMark *pImgMark);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif /* __HK_TAKEPHOTO_H__ */