123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #pragma once
- #include <opencv2/opencv.hpp>
- #include <queue>
- #include <thread>
- #include <mutex>
- //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<std::vector<int>>* 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<std::vector<int>>* 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<std::vector<int>>* pvvOverlap);
- int StitchingOnPanoYUV(cv::Point LeftTop,cv::Mat* FrameImage, std::vector<std::vector<int>>* pvvOverlap);
- static void TailorWordInThread(ImageTailor* pClass);
- int StitchingOnPanoYUVByGPU(cv::Point LeftTop, unsigned char* FrameImage,int nWidth,int nHeight,int nPitch, std::vector<std::vector<int>>* pvvOverlap);
- //stitching
- int Stitching(int nPostion, cv::Mat& ROI, std::vector<std::vector<int>>* pvvOverlap);
- //set a function to Set the overlap
- void SetOverlap(std::vector<std::vector<int>>* pvvOverlap);
- //set a function to start the tailor thread
- bool StartTailorThread();
-
- bool EndTailorThread();
- void AddWorkOrderInqueue(cv::Point LeftTop, cv::Mat* FrameImage, std::vector<std::vector<int>>* pvvOverlap);
- void ClearWorkOrder();
- void AddWorkOrderInQueueGpu(cv::Point LeftTop, unsigned char* pData, int nWidth, int nHeight, int nPitch, std::vector<std::vector<int>>* 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<std::vector<int>> vvOverlap;
- //work queue use by tailor thread
- std::queue<WAIT_TAILOR> qWorkQueue;
- //thread handle
- std::thread* pTailorThread;
- //thread switch
- bool bTailorThreadOut;
- //thread work status
- bool bTailorThreadWork;
- // is use yuv or not
- bool bUseYUV;
- };
|