Export.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include<opencv2/opencv.hpp>
  3. #include "DataProcess.h"
  4. struct ExtendState
  5. {
  6. bool LastState = false; //上一帧状态 false:静止 true :运行
  7. bool MovingExtendedState = false; // true: 实际已经判为静置,但强制改为是工作运行状态
  8. int MovingExtendedNum = 0; // 实际已经判为静置,但强制改为是工作运行状态的帧数
  9. int TrueMovingNum = 0; // 真正的扫查中的帧数
  10. bool StationaryExtendedState = false; // true: 实际已经判为扫查中,但强制改为是静置的状态
  11. int StationaryExtendedNum = 0; // 实际已经判为是扫查中,但强制改为是静置的帧数
  12. int TrueStationaryNum = 0; // 真正的静置状态的帧数
  13. };
  14. enum CurrentVideoState
  15. {
  16. Notjudged = 0, //不能判断当前状态
  17. Stationary = 1,//静止状态
  18. Moving = 2, //运行状态
  19. HaveError = 3, //存在错误
  20. };
  21. enum ColorType
  22. {
  23. Gray8,
  24. Gray16,
  25. Rgb,
  26. Bgr,
  27. Bgra,
  28. Rgba,
  29. GrayF32,
  30. };
  31. struct ImageInfo
  32. {
  33. int width;
  34. int height;
  35. ColorType colorType;
  36. uint8_t* dataBuffer;
  37. };
  38. enum ImreadModes
  39. {
  40. Unchanged = -1,
  41. Grayscale = 0,
  42. Color = 1,
  43. AnyDepth = 2,
  44. AnyColor = 4,
  45. LoadGdal = 8,
  46. };
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50. // 将图像转成所需的灰度图,且进行缩放
  51. bool ConvertImage(const char* srcImgData, int imgwidth, int imgheight, ColorType colorType,
  52. int newW, int newH, const char* dstImgData);
  53. // 对图像进行canny运算,计算得到的边缘所占的比值
  54. bool ProcessOneImage(const char* imgData, int imgwidth, int imgheight, ColorType colorType, double& cannyRatio);
  55. // 根据累积的一些信息,判断当前图像的状态
  56. CurrentVideoState JudgeImage(double* diffData, double* corrData, double* cannyData,
  57. int num, int movingDelayNum, int stationaryDelayNum, int movingDelayTriggerNum, int stationaryDelayTriggerNum, bool manuallyUnfreeze, ExtendState& state);
  58. // 对两幅图像进行互相关计算
  59. double CompareTwoImage(const char* pSrc1, const char* pSrc2, int width, int height, int widthstep, double& corr, double& diff);
  60. // 对图像进行解码
  61. bool ImgDataDecode(const uint8_t* srcImgData, const int srcDataSize,ImreadModes imReadMode, ImageInfo* imageInfo);
  62. // 得到解码后的图像尺寸
  63. int GetDecodedImgSize(const uint8_t* srcImgData, const int srcDataSize, ImreadModes imReadMode);
  64. #ifdef __cplusplus
  65. }
  66. #endif