| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- #ifndef IMAGESTITCHER_H
- #define IMAGESTITCHER_H
- #include <QObject>
- #include <QImage>
- #include <main.h>
- 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<cv::Point2f> 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<Mat>& images);
- private:
- QString m_resultPath;
- QStringList m_imagepath;
- QFuture<int> 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<QRgb> 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
|