#pragma once #include #include #include #include //set a struct to record the work queue typedef struct WaitingTailor{ cv::Point ptPosition; cv::Mat* pROI; unsigned char* pImage {NULL}; int nWidth; int nHeight; int nPitch; std::vector>* pvvOverlap; } WAIT_TAILOR, *LPWAITLOR; extern std::mutex g_CurFrameMutex; extern std::mutex g_PanoMutex; class ImageTailor { public: ImageTailor(); ~ImageTailor(); //set a function to initialize the Tailor void Init(unsigned char* pImage, int nPanoWidth, int nPanoHeight, cv::Point cvLeftTop); void Init_Gpu(unsigned char* pImage,unsigned char* pImageGpu, int nPanoWidth, int nPanoHeight, cv::Point cvLeftTop); //set a function to calculate the stitching position int StitchingOnPano(cv::Point LeftTop, cv::Mat* FrameImage, std::vector>* pvvOverlap); //define a function to Copy the YUV I420 image int StitchingOnPanoYUV(cv::Point LeftTop, unsigned char* pImage, int nWidth, int nHeight, int nPitch, std::vector>* pvvOverlap); int StitchingOnPanoYUV(cv::Point LeftTop,cv::Mat* FrameImage, std::vector>* pvvOverlap); static void TailorWordInThread(ImageTailor* pClass); int StitchingOnPanoYUVByGPU(cv::Point LeftTop, unsigned char* FrameImage,int nWidth,int nHeight,int nPitch, std::vector>* pvvOverlap); //stitching int Stitching(int nPostion, cv::Mat& ROI, std::vector>* pvvOverlap); //set a function to Set the overlap void SetOverlap(std::vector>* pvvOverlap); //set a function to start the tailor thread bool StartTailorThread(); bool EndTailorThread(); void AddWorkOrderInqueue(cv::Point LeftTop, cv::Mat* FrameImage, std::vector>* pvvOverlap); void ClearWorkOrder(); void AddWorkOrderInQueueGpu(cv::Point LeftTop, unsigned char* pData, int nWidth, int nHeight, int nPitch, std::vector>* pvvOverlap); //set a pointer to store the image,and this image has been aligned4 unsigned char* pPanoImageBuffer; //另一个用于显存的图像指针 unsigned char* pPanoImageBufferInGpu; //pano image width int nPanoWidth; //pano image height int nPanoHeight; //pano image pitch int nPanoPitch; //Current panoImage LeftTop position,for the situation that the leftTop is not (0,0) cv::Point LeftTop; //save overlap std::vector> vvOverlap; //work queue use by tailor thread std::queue qWorkQueue; //thread handle std::thread* pTailorThread; //thread switch bool bTailorThreadOut; //thread work status bool bTailorThreadWork; // is use yuv or not bool bUseYUV; };