#pragma once #include #include "DataProcess.h" struct ExtendState { bool LastState = false; //上一帧状态 false:静止 true :运行 bool MovingExtendedState = false; // true: 实际已经判为静置,但强制改为是工作运行状态 int MovingExtendedNum = 0; // 实际已经判为静置,但强制改为是工作运行状态的帧数 int TrueMovingNum = 0; // 真正的扫查中的帧数 bool StationaryExtendedState = false; // true: 实际已经判为扫查中,但强制改为是静置的状态 int StationaryExtendedNum = 0; // 实际已经判为是扫查中,但强制改为是静置的帧数 int TrueStationaryNum = 0; // 真正的静置状态的帧数 }; enum CurrentVideoState { Notjudged = 0, //不能判断当前状态 Stationary = 1,//静止状态 Moving = 2, //运行状态 HaveError = 3, //存在错误 }; enum ColorType { Gray8, Gray16, Rgb, Bgr, Bgra, Rgba, GrayF32, }; struct ImageInfo { int width; int height; ColorType colorType; uint8_t* dataBuffer; }; enum ImreadModes { Unchanged = -1, Grayscale = 0, Color = 1, AnyDepth = 2, AnyColor = 4, LoadGdal = 8, }; #ifdef __cplusplus extern "C" { #endif // 将图像转成所需的灰度图,且进行缩放 bool ConvertImage(const char* srcImgData, int imgwidth, int imgheight, ColorType colorType, int newW, int newH, const char* dstImgData); // 对图像进行canny运算,计算得到的边缘所占的比值 bool ProcessOneImage(const char* imgData, int imgwidth, int imgheight, ColorType colorType, double& cannyRatio); // 根据累积的一些信息,判断当前图像的状态 CurrentVideoState JudgeImage(double* diffData, double* corrData, double* cannyData, int num, int movingDelayNum, int stationaryDelayNum, int movingDelayTriggerNum, int stationaryDelayTriggerNum, bool manuallyUnfreeze, ExtendState& state); // 对两幅图像进行互相关计算 double CompareTwoImage(const char* pSrc1, const char* pSrc2, int width, int height, int widthstep, double& corr, double& diff); // 对图像进行解码 bool ImgDataDecode(const uint8_t* srcImgData, const int srcDataSize,ImreadModes imReadMode, ImageInfo* imageInfo); // 得到解码后的图像尺寸 int GetDecodedImgSize(const uint8_t* srcImgData, const int srcDataSize, ImreadModes imReadMode); #ifdef __cplusplus } #endif