#ifndef IMAGESTITCHER_H #define IMAGESTITCHER_H #include #include #include class param; using namespace std; using namespace cv; int curl_upload(const QString filename); class ImageStitcher : public QObject { Q_OBJECT Q_PROPERTY(QStringList p_list READ p_listGet WRITE p_listSet NOTIFY p_listChanged ) //图片路径 signals: void stitchSuccess(QString result_path); void stitchFailed(); void pathChanged(QStringList imagepath); void process(QString log_info); void p_listChanged(); void change_stitch_photonum(int val); public: ImageStitcher(); void optimizeSeam(cv::Mat leftImage, cv::Mat leftImageTransform, cv::Mat rightImageTransform, cv::Mat &dstImage, std::vector sceneCorners); int stitch_default(); Q_INVOKABLE void stitch_thread(); QStringList p_listGet() const { return param::ptlist; } void p_listSet(QStringList n_list) { param::ptlist = n_list; emit p_listChanged(); } void saveStitchPamera(int index) { param::stitch_photonum = index; emit change_stitch_photonum(index); } void merge_pic(vector& images); private: QString m_resultPath; QStringList m_imagepath; QFuture future_stitch; static inline QImage cvMatToQImage( const cv::Mat &inMat ) { switch ( inMat.type() ) { // 8-bit, 4 channel case CV_8UC4: { QImage image( inMat.data, inMat.cols, inMat.rows, inMat.step, QImage::Format_RGB32 ); return image; } // 8-bit, 3 channel case CV_8UC3: { QImage image( inMat.data, inMat.cols, inMat.rows, inMat.step, QImage::Format_RGB888 ); return image.rgbSwapped(); } // 8-bit, 1 channel case CV_8UC1: { static QVector sColorTable; // only create our color table once if ( sColorTable.isEmpty() ) { for ( int i = 0; i < 256; ++i ) sColorTable.push_back( qRgb( i, i, i ) ); } QImage image( inMat.data, inMat.cols, inMat.rows, inMat.step, QImage::Format_Indexed8 ); image.setColorTable( sColorTable ); return image; } default: qWarning() << "ASM::cvMatToQImage() - cv::Mat image type not handled in switch:" << inMat.type(); break; } return QImage(); } }; #endif // IMAGESTITCHER_H