zhunk 2 ay önce
ebeveyn
işleme
8bf9eb2f22

+ 10 - 0
q6_felgo_iot/docs/Readme.md

@@ -1,3 +1,13 @@
+## 20260908
+    #define APP_VERSION "2.8.0"
+    1. 异步处理上传图片
+    2. GPS经纬度精度
+    3. 图片查看优化,修复图片无法放大缩小
+    4. 增加可以通过指令远程校准Y坐标
+    5. 图片增加水印
+    6. 拍照界面增加抓图按钮
+    7. 图片上传展示调整,修改为展示32个格子
+    
 ## 20260827
     #define APP_VERSION "2.7.0"
     1. 【修复】补录/重传图片未跟随后台归档规则:新增图片入库时同时记录父目录(parent_path),网络恢复触发补录时读取该父路径对齐远端归档目录(photo_hard/<imei>/<归档目录>/xxx.jpg);重传定时器信号 signal_reupload_image 携带 parent_path,上传端优先用入库父路径判定归档、再回退按文件父目录,融合/拼接补录同样适用

+ 2 - 1
q6_felgo_iot/header/app_curlFunc.h

@@ -28,7 +28,7 @@ public:
 
 signals:
     void downloadStart(const QString &tips);
-    void progressChanged(double uploadedPercent);  // 进度百分比 (0.0 ~ 100.0)
+    void progressChanged(double uploadedPercent, const QString &filePath);  // 进度百分比 (0.0 ~ 100.0) 与上传文件路径
     void finished(bool success, const QString &error); // 完成信号
     void sglProgress(double val,double timeLeft,double speed);  //进度信号
 private:
@@ -48,6 +48,7 @@ private:
     int m_port;
     QString m_remotePath;
     QString update_type;
+    QString m_currentFilePath;   // 当前正在上传的文件路径,用于进度信号携带
 };
 
 

+ 10 - 2
q6_felgo_iot/header/cameramanager.h

@@ -164,6 +164,8 @@ public:
 
     void saveImage();
     Q_INVOKABLE void captureImage();
+    //抓图按钮:模拟MCU拍照指令(camera_tc=1),下一帧按序号保存/锐化/上传
+    Q_INVOKABLE void manualCapture();
     //inline ImageProvider *getImageProvider() { return m_pImgProvider; }
     //ImageProvider* imageProvider() const;
     static void ImageCallBackEx(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser);
@@ -211,6 +213,7 @@ signals:
     void signal_photo_saved();
     void signal_wait_upload(const QString &path);
     void signal_cache_image(const QString &path);
+    void signal_sharp_processed(const QString &name_sharp);  //锐化/对比度后台处理完成,回主线程统一入队入库
     void stepCountChanged(const QString step);
 public slots:
 
@@ -255,6 +258,7 @@ private slots:
     void update_qulstr(QString q_str);
     //
     void saveMatAsJpeg(const QVideoFrame &frame);
+    void onSharpProcessed(const QString &name_sharp);
     //void sendData(QByteArray m_byte);
     void displayFrame(const QVideoFrame &frame);
     void mov_x_z_run();
@@ -281,7 +285,9 @@ private:
     JsonFunc m_json;
 
     QFuture<void> m_grabThread;
-
+    //独立上传队列:与param::ptlist(拼接输入)隔离,每保存一张锐化/对比度图立即入队逐张上传
+    QStringList m_uploadQueue;
+    bool m_isUploading = false;   //是否正在上传,防止并发启动多个上传线程
     QJniObject *jClass;
 
     bool camera_sta;
@@ -306,7 +312,9 @@ private:
 
     int z_step = 0;
     int x_step = 0;
-
+    //保护 image_num/z_step/x_step 及"取号-建名-存图-自增-移轴"整段流程,
+    //saveMatAsJpeg 由 QtConcurrent 线程池并发调用,无锁会导致重号覆盖、序号跳变、轴重复移动
+    mutable QMutex m_saveMutex;
     //图片归档路径
     QString picture_path_floader;
     QVector<cv::Mat> m_frame_buffer;

+ 1 - 0
q6_felgo_iot/header/mqtthandler.h

@@ -141,6 +141,7 @@ signals:
     void signal_upload_log(const QString &path);
     void signal_set_camera_exposure(int exposureTime);
     void signal_reconfigure_mqtt(int channel); // 1=主通道, 2=备通道
+    void signal_open_camera();   //远程校准/相机开启指令:跳转相机界面并打开相机
 public:
     // 发送 JSON-RPC 响应(供内部和 QML 调用)
     Q_INVOKABLE void sendJsonRpcResponse(int id, bool success, const QString &message = QString());

+ 8 - 0
q6_felgo_iot/qml/Main.qml

@@ -256,6 +256,14 @@ App {
             }
         }
     }
+    // 远程校准指令: {"cmd":"slide","ext":{"calibrate":"y","speed":"50"}} → 跳转相机界面(Tab 1 测试维护)
+    Connections {
+        target: mqtt
+        function onSignal_open_camera() {
+            console.log("[Main] 收到远程相机开启指令,跳转相机界面!")
+            navigation.setCurrentTab(1)
+        }
+    }
 
     Component.onCompleted: {
         console.log("App Component.onCompleted, starting phased loading...")

+ 5 - 23
q6_felgo_iot/qml/pages/LocalNotificationPage.qml

@@ -41,7 +41,7 @@ AppPage {
 
 
     Connections{
-        target: curl
+        target:curl
         function onSglProgress(val,timeLeft,speed) {
             console.log("更新curl进度条:",val,timeLeft)
             progressBar.value = val
@@ -67,30 +67,12 @@ AppPage {
 
     }
 
+    // 图片上传进度已改为 TestPage 右上角 32 格进度网格展示, 不再弹出上传进度窗口
     Connections{
         target:curl_picture
-        function onProgressChanged(uploadedPercent){
-            console.log("更新进度条:",uploadedPercent)
-            progressBar.value = uploadedPercent
-            process_text.text = uploadedPercent.toFixed(2) + "%";
-
-        }
-
-        function onDownloadStart(tips){
-            notificationPage.visible = true
-            notificationtext.text = tips
-        }
-
-        function onFinished(success,error){
-            //notificationPage.visible = false
-            if(success){
-                notificationtext.color = "green"
-            }else{
-                notificationtext.text = error
-                notificationtext.color = "red"
-            }
-
-        }
+        function onProgressChanged(uploadedPercent){ }
+        function onDownloadStart(tips){ }
+        function onFinished(success,error){ }
     }
 
 

+ 245 - 91
q6_felgo_iot/qml/pages/PhotostitcherPage.qml

@@ -14,6 +14,7 @@ AppPage {
     property var selectedImages: []
     property bool isSelecting: false
     property bool isFusing: false
+    property bool showSharp: true
 
     // 融合按钮
     AppButton {
@@ -30,23 +31,14 @@ AppPage {
             if (selectedImages.length >= 2) {
                 isFusing = true
                 console.log("开始融合", selectedImages.length, "张图片")
+                app.isGlobalFusing = true
+                app.globalFusionMessage = "开始融合..."
+                app.globalFusionPercent = 0
                 opencvFunc.fuseImagesAsync(selectedImages)
             }
         }
     }
 
-    // 融合加载动画
-    BusyIndicator {
-        id: fuseBusyIndicator
-        anchors.bottom: parent.bottom
-        anchors.right: parent.right
-        anchors.margins: 20
-        visible: isFusing
-        width: 60
-        height: 60
-        z: 100
-    }
-
     // 取消选择按钮
     AppButton {
         id: cancelButton
@@ -63,11 +55,28 @@ AppPage {
         }
     }
 
+    // 原图/锐化切换按钮
+    AppButton {
+        id: sharpToggleButton
+        anchors.bottom: parent.bottom
+        anchors.horizontalCenter: parent.horizontalCenter
+        anchors.margins: 20
+        text: showSharp ? "切换到原图" : "切换到锐化图"
+        visible: imageListModel.count > 0 && !isSelecting && !isFusing
+        backgroundColor: "#3b82f6"
+        textColor: "white"
+        z: 100
+        onClicked: {
+            setShowSharp(!showSharp)
+        }
+    }
+
     // 连接融合完成信号
     Connections {
         target: opencvFunc
         function onFuseFinished(resultPath) {
             isFusing = false
+            app.isGlobalFusing = false
             if (resultPath) {
                 console.log("融合完成:", resultPath)
                 // 显示融合结果
@@ -78,6 +87,12 @@ AppPage {
                 console.error("融合失败")
             }
         }
+
+        // 融合进度信号
+        function onFusionProgress(message, percent) {
+            console.log("融合进度:", message, percent + "%")
+            // 全局弹窗由 Main.qml 监听
+        }
     }
 
     function clearSelection() {
@@ -121,73 +136,80 @@ AppPage {
             color: "#CC000000"
         }
 
-        Flickable {
-            id: flick
+        Item {
+            id: viewport
             anchors.fill: parent
             clip: true
-            boundsBehavior: Flickable.DragAndOvershootBounds
 
             Image {
                 id: image
-                anchors.fill: parent
+                x: 0
+                y: 0
+                width: Math.min(implicitWidth, viewport.width)
+                height: Math.min(implicitHeight, viewport.height)
                 asynchronous: true
                 fillMode: Image.PreserveAspectFit
-                width: Math.min(implicitWidth, parent.width)
-                height: Math.min(implicitHeight, parent.height)
-                property real scale: 1.0
+                transformOrigin: Item.TopLeft
+                scale: 1.0
+                property real minZoom: 1.0
+                property real maxZoom: 5.0
+                onStatusChanged: {
+                    if (status === Image.Ready) {
+                        clampPos()
+                    }
+                }
             }
 
+            // 平移
+            DragHandler {
+                id: dragHandler
+                target: null
+                acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchScreen
+                property real startX: 0
+                property real startY: 0
+                onActiveChanged: {
+                    if (active) {
+                        startX = image.x
+                        startY = image.y
+                    }
+                }
+                onTranslationChanged: {
+                    image.x = startX + translation.x
+                    image.y = startY + translation.y
+                    clampPos()
+                }
+            }
 
+            // 捏合缩放 (触摸):双指缩放在视口中心缩放,保持图像居中
             PinchArea {
-              anchors.fill: parent
-
-              pinch.target: image
-              pinch.minimumRotation: -360
-              pinch.maximumRotation: 360
-              pinch.minimumScale: 0.1
-              pinch.maximumScale: 10
-              pinch.dragAxis: Pinch.XAndYAxis
-
-              // MouseArea handles drag gestures
-              MouseArea {
+                id: pinchArea
                 anchors.fill: parent
+                pinch.target: null
+                pinch.minimumRotation: 0
+                pinch.maximumRotation: 0
+                pinch.minimumScale: 1.0
+                pinch.maximumScale: 5.0
+                property real pinchStartZoom: 1.0
+                onPinchStarted: {
+                    pinchStartZoom = image.scale
+                }
+                onPinchUpdated: {
+                    var newZoom = Math.max(image.minZoom, Math.min(image.maxZoom, pinchStartZoom * pinch.scale))
+                    // 以视口中心为锚点缩放,图像保持居中
+                    zoomToPoint(viewport.width / 2, viewport.height / 2, newZoom)
+                }
+            }
 
-                drag.target: image
-                drag.minimumX: -image.width
-                drag.maximumX: fullscreenPopup.width
-                drag.minimumY: -image.height
-                drag.maximumY: fullscreenPopup.height
-              }
-              onPinchStarted: {
-                  // 保存当前缩放中心和比例
-                  pinchStartScale = image.scale
-                  pinchStartCenter = Qt.point(pinch.center.x, pinch.center.y)
-              }
-              onPinchUpdated: {
-                  // 计算新的缩放比例
-                  var newScale = pinchStartScale * pinch.scale
-
-                  // 限制缩放范围
-                  newScale = Math.max(image.minScale, Math.min(image.maxScale, newScale))
-
-                  // 应用缩放
-                  image.scale = newScale
-
-                  // 计算缩放中心点相对于图片的坐标
-                  var imageCenterX = (pinch.center.x - flick.contentX) / image.scale
-                  var imageCenterY = (pinch.center.y - flick.contentY) / image.scale
-
-                  // 调整内容位置以保持缩放中心
-                  flick.contentX = pinch.center.x - imageCenterX * image.scale
-                  flick.contentY = pinch.center.y - imageCenterY * image.scale
-              }
-
-              onPinchFinished: {
-                  flick.returnToBounds()
-              }
-
-              property real pinchStartScale: 1.0
-              property point pinchStartCenter: Qt.point(0, 0)
+            // 鼠标滚轮缩放
+            WheelHandler {
+                id: wheelHandler
+                target: null
+                acceptedDevices: PointerDevice.Mouse
+                onWheel: (event) => {
+                    var factor = event.angleDelta.y > 0 ? 1.15 : (1 / 1.15)
+                    var newZoom = Math.max(image.minZoom, Math.min(image.maxZoom, image.scale * factor))
+                    zoomToPoint(event.x, event.y, newZoom)
+                }
             }
         }
 
@@ -238,8 +260,50 @@ AppPage {
 
     function showFullscreen(path) {
         image.source = "file://" + path
-        fullscreenPopup.open()
+        // 等待图片加载出尺寸后再居中
         resetTransform()
+        fullscreenPopup.open()
+    }
+
+    // 重置缩放为初始大小并居中
+    function resetTransform() {
+        image.scale = 1.0
+        clampPos()
+    }
+
+    // 约束图片位置:小于视口时居中,大于视口时限制不露出空白边缘
+    function clampPos() {
+        var sw = image.width * image.scale
+        var sh = image.height * image.scale
+        var minX, maxX, minY, maxY
+        if (sw <= viewport.width) {
+            minX = (viewport.width - sw) / 2
+            maxX = minX
+        } else {
+            minX = viewport.width - sw
+            maxX = 0
+        }
+        if (sh <= viewport.height) {
+            minY = (viewport.height - sh) / 2
+            maxY = minY
+        } else {
+            minY = viewport.height - sh
+            maxY = 0
+        }
+        image.x = Math.max(minX, Math.min(maxX, image.x))
+        image.y = Math.max(minY, Math.min(maxY, image.y))
+    }
+
+    // 以视口坐标点(px,py)为锚点缩放图片到 newZoom,保证锚点内容不漂移
+    function zoomToPoint(px, py, newZoom) {
+        var oldZoom = image.scale
+        // 锚点相对图片左上角的偏移(未缩放坐标)
+        var relX = (px - image.x) / oldZoom
+        var relY = (py - image.y) / oldZoom
+        image.scale = newZoom
+        image.x = px - relX * newZoom
+        image.y = py - relY * newZoom
+        clampPos()
     }
 
 
@@ -252,8 +316,8 @@ AppPage {
             id: imageGridView
             SplitView.preferredWidth: parent.width * 0.7
             clip: true
-            cellWidth: 200
-            cellHeight: 200
+            cellWidth: Math.max(45, Math.floor((imageGridView.width - 10) / 8))
+            cellHeight: cellWidth
 
             model: ListModel { id: imageListModel }
 
@@ -263,39 +327,69 @@ AppPage {
 
                 Rectangle {
                     anchors.fill: parent
-                    anchors.margins: 5
+                    anchors.margins: 2
                     color: model.selected ? "#28a779" : "transparent"
-                    border.color: model.selected ? "#28a779" : "#eee"
-                    border.width: model.selected ? 3 : 1
-                    radius: 4
+                    border.color: model.selected ? "#28a779" : (model.filePath ? "#eee" : "#bbb")
+                    border.width: 1
+                    radius: 3
 
+                    // 有图片时加载缩略图,缺图时显示灰色占位
                     Image {
                         anchors.fill: parent
                         anchors.margins: 2
-                        source: "file://" + filePath
+                        source: model.filePath ? "file://" + model.filePath : ""
                         asynchronous: true
                         sourceSize.width: 200
                         sourceSize.height: 200
                         fillMode: Image.PreserveAspectFit
                         cache: true
+                        visible: model.filePath !== ""
 
                         BusyIndicator {
                             anchors.centerIn: parent
                             running: parent.status === Image.Loading
-                            width: 32
-                            height: 32
+                            width: 24
+                            height: 24
+                        }
+                    }
+
+                    // 缺图占位提示
+                    Text {
+                        anchors.centerIn: parent
+                        visible: model.filePath === ""
+                        text: "缺图"
+                        color: "#999"
+                        font.pixelSize: 11
+                    }
+
+                    // 序号角标(左上角,右上角为1)
+                    Rectangle {
+                        x: 0
+                        y: 0
+                        width: 18
+                        height: 18
+                        color: Qt.rgba(0, 0, 0, 0.55)
+                        radius: 9
+                        visible: model.serial !== undefined && model.serial >= 1
+
+                        Text {
+                            anchors.centerIn: parent
+                            text: model.serial
+                            color: "white"
+                            font.bold: true
+                            font.pixelSize: 11
                         }
                     }
                 }
 
-                // 选择标记(使用绝对定位代替anchors.topRight)
+                // 选择标记(右侧勾选)
                 Rectangle {
-                    x: parent.width - width - 7
-                    y: 7
-                    width: 24
-                    height: 24
-                    color: model.selected ? "#28a779" : "rgba(0,0,0,0.5)"
-                    radius: 12
+                    x: parent.width - width
+                    y: 0
+                    width: 18
+                    height: 18
+                    color: "#28a779"
+                    radius: 9
                     visible: model.selected  // 只对已选中的图片显示勾选标记
 
                     Text {
@@ -309,15 +403,18 @@ AppPage {
                 // MouseArea(在外层Rectangle外面,使用delegate Item作为parent)
                 MouseArea {
                     anchors.fill: parent
+                    enabled: model.filePath !== ""
                     onClicked: {
+                        if (!model.filePath) return
                         if (isSelecting) {
                             toggleImageSelection(model.filePath)
                         } else {
-                            console.log("Selected image:", filePath)
-                            showFullscreen(filePath)
+                            console.log("Selected image:", model.filePath)
+                            showFullscreen(model.filePath)
                         }
                     }
                     onPressAndHold: {
+                        if (!model.filePath) return
                         toggleImageSelection(model.filePath)
                     }
                 }
@@ -464,24 +561,81 @@ AppPage {
         }
     }
 
-    // PhotoArchivePage.qml
+    // 长按文件夹:按蛇形网格(8列x4行=32格,右上角为1)展示图片,默认显示锐化图
     function loadFolderContents(folderPath) {
-        imageListModel.clear()
-
+        var bySerial = {}
+        var byBase = {}
         var stack = [folderPath]
         while (stack.length > 0) {
             var currentPath = stack.pop()
-            var dir = Qt.createQmlObject('import QtQuick 2.0; QtObject {}', parent)
-
             var files = treeModel.getFolderContents(currentPath)
             for (var i = 0; i < files.length; i++) {
                 if (files[i].isFolder) {
                     stack.push(files[i].path)
                 } else {
-                    imageListModel.append({filePath: files[i].path, selected: false})
+                    collectImageFile(files[i].path, bySerial, byBase)
                 }
             }
         }
+        rebuildImageGrid(bySerial, byBase)
+    }
+
+    // 解析图片文件名:有序号(1-32)归入 bySerial 蛇形网格,无序号归入 byBase 按基础名(时间戳)排序
+    function collectImageFile(path, bySerial, byBase) {
+        var base = path.slice(path.lastIndexOf('/') + 1)
+        var dot = base.lastIndexOf('.')
+        var stem = dot > 0 ? base.slice(0, dot) : base
+        var isSharp = stem.indexOf('_sharp_') >= 0
+        // 去掉 sharp 后缀得到基础名(用于原图/锐化配对)
+        var key = isSharp ? stem.replace('_sharp', '') : stem
+        var us = key.lastIndexOf('_')
+        var serial = us >= 0 ? parseInt(key.slice(us + 1)) : 0
+        if (serial >= 1 && serial <= 32) {
+            if (!bySerial[serial]) bySerial[serial] = {orig: "", sharp: ""}
+            if (isSharp) bySerial[serial].sharp = path
+            else bySerial[serial].orig = path
+        } else {
+            // 无序号:按基础名(通常含时间戳)配对,用于按时间先后排序
+            if (!byBase[key]) byBase[key] = {orig: "", sharp: "", name: key}
+            if (isSharp) byBase[key].sharp = path
+            else byBase[key].orig = path
+        }
+    }
+
+    // 按蛇形显示顺序重建网格(模型顺序=画面从左到右、从上到下),无序号图片按时间先后追加在末尾
+    function rebuildImageGrid(bySerial, byBase) {
+        imageListModel.clear()
+        var order = [
+            32,25,24,17,16,9,8,1,
+            31,26,23,18,15,10,7,2,
+            30,27,22,19,14,11,6,3,
+            29,28,21,20,13,12,5,4
+        ]
+        for (var i = 0; i < order.length; i++) {
+            var s = order[i]
+            var e = bySerial[s] || {orig: "", sharp: ""}
+            var fp = showSharp ? (e.sharp || e.orig) : (e.orig || e.sharp)
+            imageListModel.append({filePath: fp, serial: s, origPath: e.orig, sharpPath: e.sharp, selected: false})
+        }
+        // 无序号图片:按基础名(时间戳)先后排序追加
+        var names = []
+        for (var k in byBase) names.push(k)
+        names.sort()
+        for (var j = 0; j < names.length; j++) {
+            var be = byBase[names[j]]
+            var bfp = showSharp ? (be.sharp || be.orig) : (be.orig || be.sharp)
+            imageListModel.append({filePath: bfp, serial: -1, origPath: be.orig, sharpPath: be.sharp, selected: false})
+        }
+    }
+
+    // 切换显示 原图/锐化图
+    function setShowSharp(v) {
+        showSharp = v
+        for (var i = 0; i < imageListModel.count; i++) {
+            var it = imageListModel.get(i)
+            var fp = showSharp ? (it.sharpPath || it.origPath) : (it.origPath || it.sharpPath)
+            imageListModel.setProperty(i, "filePath", fp)
+        }
     }
 
     function loadRootDirectory() {

+ 178 - 1
q6_felgo_iot/qml/pages/TestPage.qml

@@ -1,4 +1,5 @@
-import QtQuick
+import QtQuick
+import QtQuick.Layouts
 import Felgo
 import QtMultimedia
 import QtQuick.Controls
@@ -28,6 +29,58 @@ AppPage {
     property string fExposureTime: "0"
     property bool motorUnlocked: false
 
+
+    // ===== 上传进度网格(32格), 蛇形编号, 1 在右上角 =====
+    // 数组下标 = GridLayout 摆放顺序(左上→右下), 元素 = 该格显示/对应的图片序号
+    property var uploadGridSerials: [
+        32,25,24,17,16, 9, 8, 1,
+        31,26,23,18,15,10, 7, 2,
+        30,27,22,19,14,11, 6, 3,
+        29,28,21,20,13,12, 5, 4
+    ]
+
+    ListModel { id: uploadGridModel }
+
+    Component.onCompleted: {
+        for(var i = 0; i < 32; i++){
+            uploadGridModel.append({serial: uploadGridSerials[i], percent: 0, done: false})
+        }
+    }
+
+    // 从上传文件路径解析图片序号(文件名形如 ..._sharp_7.jpg)
+    function uploadSerialFromPath(filePath) {
+        if(!filePath) return -1
+        var m = filePath.match(/sharp_(\d+)/)
+        if(m && m.length > 1) return parseInt(m[1])
+        return -1
+    }
+    // 由图片序号(1..32)换算成网格摆放索引(0..31, 蛇形, 1 在右上角)
+    function uploadSerialToIndex(serial){
+        var n = serial - 1
+        var q = Math.floor(n / 4)     // 0..7 列组(自右向左)
+        var pos = n % 4               // 组内 0..3
+        var col = 7 - q
+        var row = (q % 2 === 0) ? pos : (3 - pos)
+        return row * 8 + col
+    }
+
+    // 更新某个网格格子的状态
+    function setUploadCell(serial, percent, done) {
+        var idx = uploadSerialToIndex(serial)
+        if(idx < 0 || idx > 31) return
+        var p = Math.max(0, Math.min(100, percent))
+        uploadGridModel.setProperty(idx, "percent", p)
+        uploadGridModel.setProperty(idx, "done", done)
+    }
+
+    // 清空网格全部状态(percent=0, done=false)
+    function resetUploadGrid() {
+        for(var i = 0; i < uploadGridModel.count; i++){
+            uploadGridModel.setProperty(i, "percent", 0)
+            uploadGridModel.setProperty(i, "done", false)
+        }
+    }
+
     function autotake(sw){
         if(sw)
         {
@@ -151,6 +204,24 @@ AppPage {
             console.log("收到远程相机曝光设置指令,曝光时间:" + exposureTime)
             frames.cam_ExposureTime = exposureTime.toString()
         }
+
+        // 远程校准指令: {"cmd":"slide","ext":{"calibrate":"y","speed":"50"}} → 打开相机
+        function onSignal_open_camera() {
+            console.log("收到远程相机开启指令,打开相机!")
+            frames.camera_sw = true
+        }
+    }
+    // 图片上传进度 → 右上角 32 格进度网格
+    Connections {
+        target: curl_picture
+        function onProgressChanged(uploadedPercent, filePath){
+            var serial = uploadSerialFromPath(filePath)
+            if(serial < 1 || serial > 32){
+                console.log("上传进度: 无法识别图片序号", filePath)
+                return
+            }
+            setUploadCell(serial, uploadedPercent, uploadedPercent >= 100)
+        }
     }
 
     Connections{
@@ -297,6 +368,112 @@ AppPage {
                   color:  "green"
                 }
             }
+            // 图片上传进度网格(8列 x 4行 = 32格), 蛇形编号 1 在右上角, 常显示; 可按住拖动位置
+            Rectangle {
+                id: uploadGridWrap
+                visible: true
+                width: uploadGrid.implicitWidth
+                height: uploadGrid.implicitHeight
+                color: "transparent"
+
+                // 初始位置: 画面右上角
+                Component.onCompleted: {
+                    uploadGridWrap.x = uploadGridWrap.parent.width - uploadGridWrap.width - dp(10)
+                    uploadGridWrap.y = dp(10)
+                }
+
+                GridLayout {
+                    id: uploadGrid
+                    columns: 8
+                    columnSpacing: dp(2)
+                    rowSpacing: dp(2)
+                    Repeater {
+                        id: uploadGridRepeater
+                        model: uploadGridModel
+                        Rectangle {
+                            width: dp(42)
+                            height: dp(34)
+                            radius: dp(3)
+                            color: model.done ? "#8C1f9e4d" : "transparent"
+                            border.color: model.done ? "#37a24b" : "#66ffffff"
+                            border.width: 1
+                            Column {
+                                anchors.fill: parent
+                                spacing: 0
+                                AppText {
+                                    text: model.serial
+                                    color: "white"
+                                    font.bold: true
+                                    font.pixelSize: 11
+                                    anchors.horizontalCenter: parent.horizontalCenter
+                                }
+                                AppText {
+                                    text: model.percent > 0 ? Math.round(model.percent) + "%" : ""
+                                    color: model.done ? "white" : "#ffb020"
+                                    font.pixelSize: 10
+                                    anchors.horizontalCenter: parent.horizontalCenter
+                                }
+                            }
+                        }
+                    }
+                }
+
+                // 按住拖动整个网格(DragHandler原生手势,平滑不卡顿;支持鼠标与触摸)
+                DragHandler {
+                    id: gridDragHandler
+                    target: null
+                    acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchScreen
+                    property real startX: 0
+                    property real startY: 0
+                    onActiveChanged: {
+                        if(active){
+                            // 记录按下瞬间网格位置
+                            startX = uploadGridWrap.x
+                            startY = uploadGridWrap.y
+                        }
+                    }
+                    onTranslationChanged: {
+                        if(!active) return
+                        var nx = startX + translation.x
+                        var ny = startY + translation.y
+                        // 限制在父容器范围内
+                        nx = Math.max(0, Math.min(uploadGridWrap.parent.width - uploadGridWrap.width, nx))
+                        ny = Math.max(0, Math.min(uploadGridWrap.parent.height - uploadGridWrap.height, ny))
+                        uploadGridWrap.x = nx
+                        uploadGridWrap.y = ny
+                    }
+                }
+            }
+            // 抓图按钮:仅相机打开时显示,画面右下角透明背景,点击=模拟MCU拍照指令(按序号保存/锐化/上传)
+            Rectangle {
+                id: captureBtn
+                visible: frames.camera_sw
+                width: dp(56)
+                height: dp(56)
+                radius: width / 2
+                color: "transparent"
+                border.color: "#80ffffff"
+                border.width: dp(2)
+                anchors.right: parent.right
+                anchors.bottom: parent.bottom
+                anchors.rightMargin: dp(12)
+                anchors.bottomMargin: dp(12)
+
+                AppImage {
+                    anchors.centerIn: parent
+                    width: dp(34)
+                    height: dp(34)
+                    source: "../../assets/photoico.svg"
+                }
+
+                MouseArea {
+                    anchors.fill: parent
+                    onClicked: {
+                        console.log("抓图按钮点击!")
+                        frames.manualCapture()
+                    }
+                }
+            }
         }
 
         ScrollView

+ 2 - 1
q6_felgo_iot/src/app_curlFunc.cpp

@@ -48,6 +48,7 @@ void CurlFtpUploader::performUpload(const QString &localFilePath) {
 }
 
 void CurlFtpUploader::performUpload(const QString &localFilePath, const QString &parentPath) {
+    m_currentFilePath = localFilePath;   // 记录当前上传文件,供进度回调使用
     curl_global_init(CURL_GLOBAL_ALL);
     CURL *curl = curl_easy_init();
     if (!curl) {
@@ -144,7 +145,7 @@ int CurlFtpUploader::progressCallback(void *clientp, curl_off_t dltotal, curl_of
     CurlFtpUploader *uploader = static_cast<CurlFtpUploader*>(clientp);
     if (ultotal > 0) {
         double percent = (static_cast<double>(ulnow) / ultotal) * 100.0;
-        emit uploader->progressChanged(percent);
+        emit uploader->progressChanged(percent, uploader->m_currentFilePath);
     }
     // 计算剩余时间
     double remainingTime = 0.0;

+ 60 - 22
q6_felgo_iot/src/cameramanager.cpp

@@ -155,6 +155,8 @@ Frames::Frames(QObject * parent)
 
     connect(this,&Frames::signal_photo_saved,
             this,&Frames::upload_handle);
+    connect(this,&Frames::signal_sharp_processed,
+            this,&Frames::onSharpProcessed,Qt::QueuedConnection);
 
     initCam();
 
@@ -679,20 +681,21 @@ Frames::setExposureTime(const QString &exptime)
 void
 Frames::upload_handle()
 {
-    if(!param::ptlist.empty()){
-        emit signal_wait_upload(param::ptlist.first());
-        param::ptlist.removeFirst();
-    }
+    if(m_isUploading) return;              //当前有上传在进行,等完成后继续下一个
+    if(m_uploadQueue.isEmpty()) return;    //上传队列为空
+    QString first = m_uploadQueue.takeFirst();
+    m_isUploading = true;
+    emit signal_wait_upload(first);
 }
 
 void
 Frames::handle_reult_upload(bool success, const QString &error)
 {
+    m_isUploading = false;
     if(success)
     {
         LOG("上传成功:{}",error.toStdString());
         //匹配数据库进行删除
-
     }else
     {
         WARN("上传失败:{}",error.toStdString());
@@ -813,6 +816,10 @@ Frames::saveMatAsJpeg(const QVideoFrame &frame){
     cv::setNumThreads(2);
     QString ts = QDateTime::currentDateTime().toString("yyyyMMddhhmmss");
     if (frame.isValid()) {
+        //并发互斥:saveMatAsJpeg 由 QtConcurrent 线程池多线程并发执行,
+        //"取号-建名-存图-自增-移轴"必须整段原子化,否则两个线程会取到同一序号,
+        //导致同名覆盖、image_num 跳号、mov_x_z_run 重复发轴指令
+        QMutexLocker locker(&m_saveMutex);
         QString name = picture_path_floader + "/" + ts +
                        "z" + QString::number(z_step) +
                        "x" + QString::number(x_step) +
@@ -823,23 +830,35 @@ Frames::saveMatAsJpeg(const QVideoFrame &frame){
                      "_sharp" +
                      "_" + QString::number(image_num) + ".jpg";
         if (frame.toImage().save(name,"jpg",90)) {
-            //图像锐化
-            Mat image = imread(name.toStdString());
-            cv::Mat fused_sharp = m_opencvfunc.unsharpMask(image, 2.0, 3.0);
-            //对比度
-            cv::Mat Contrast_Image = m_opencvfunc.enhanceContrast(fused_sharp,0);
-            std::vector<int> jpegParams = {cv::IMWRITE_JPEG_QUALITY, 95};
-            if (!cv::imwrite(name_sharp.toStdString(), Contrast_Image, jpegParams)) {
-                ERROR("Failed to save fused image:{}",name_sharp.toStdString());
-            } else {
-                image_num++;
-                // 保存清晰图路径,用于景深融合后的清晰度对比
+            //原图保存成功立即占用并递增序号,保证文件名序号连续不重复
+            //(若等锐化任务完成后再递增,锐化未完成时下一张已拍照会复用旧序号,导致缺号)
+            image_num++;
+            mov_x_z_run();      //原图已保存,立即移动电机,不被锐化/对比度阻塞
+            locker.unlock();    //锐化在后台执行,无需继续持锁
+            //图像锐化+对比度增强+保存 sharp,异步后台处理,不阻塞抓图与电机移动
+            QtConcurrent::run([=](){
+                //图像锐化
+                Mat image = imread(name.toStdString());
+                cv::Mat fused_sharp = m_opencvfunc.unsharpMask(image, 2.0, 3.0);
+                //对比度
+                cv::Mat Contrast_Image = m_opencvfunc.enhanceContrast(fused_sharp,0);
+                //左上角水印:白色字体,文字为图片名称(不含目录)
+                cv::putText(Contrast_Image,
+                            QFileInfo(name_sharp).fileName().toStdString(),
+                            cv::Point(15, 40),
+                            cv::FONT_HERSHEY_SIMPLEX,
+                            1.2,
+                            cv::Scalar(144,238,144),  //浅绿色 lightgreen
+                            2);
+                std::vector<int> jpegParams = {cv::IMWRITE_JPEG_QUALITY, 95};
+                if (!cv::imwrite(name_sharp.toStdString(), Contrast_Image, jpegParams)) {
+                    ERROR("Failed to save fused image:{}",name_sharp.toStdString());
+                    return;
+                }
                 LOG("[saveMatAsJpeg] sharp image path:{}", name_sharp.toStdString());
-                param::ptlist.append(name_sharp);
-                emit signal_cache_image(name_sharp);    //路径入库
-            }
-            LOG("[saveMatAsJpeg] saved:{}",name.toStdString());
-            mov_x_z_run();
+                //回主线程统一处理(入队/入库),避免线程池线程直接操作共享队列
+                emit signal_sharp_processed(name_sharp);
+            });
         } else {
             WARN("[saveMatAsJpeg] write failed:{}",name.toStdString());
         }
@@ -849,6 +868,16 @@ Frames::saveMatAsJpeg(const QVideoFrame &frame){
 }
 
 void
+Frames::onSharpProcessed(const QString &name_sharp){
+    //主线程执行,安全操作共享队列
+    param::ptlist.append(name_sharp);
+    emit signal_cache_image(name_sharp);    //路径入库
+    //每处理一张锐化/对比度增强图片,立即加入上传队列异步逐张上传
+    m_uploadQueue.append(name_sharp);
+    QMetaObject::invokeMethod(this, "upload_handle", Qt::QueuedConnection);
+}
+
+void
 Frames::processFrameAsync(const RawFrame& frame){
     // ✅ 异步化:取帧线程不再阻塞在图像处理上,帧按值传入
     //   (QByteArray 引用计数保证原始数据在任务执行期间存活),
@@ -1200,6 +1229,15 @@ Frames::captureImage(){
         //创建文件夹
     });
 }
-
+//*抓图按钮:模拟MCU拍照指令,下一帧触发按序号保存/锐化/上传*/
+void
+Frames::manualCapture(){
+    if(!camera_sw()){
+        WARN("manualCapture: 相机未打开,忽略抓图!");
+        return;
+    }
+    param::camera_tc = 1;   //与MCU拍照指令一致:processFrameAsync检测到后保存一帧
+    LOG("manualCapture: 收到抓图指令!");
+}
 
 } /* namespace Qt6QCamera */

+ 6 - 4
q6_felgo_iot/src/main.cpp

@@ -195,10 +195,12 @@ private slots://槽函数中实现了GPS部分信息的读取
                  positionSource->stopUpdates();
             }
         }
-        param::gps_lat = QString::number(nowLatitude);
-        param::gps_lng = QString::number(nowLongitude);
-        LOG("经度:{}",nowLongitude);
-        LOG("纬度:{}",nowLatitude);
+        // 保留7位小数(约1厘米精度),避免QString::number默认6位有效数字把经纬度截断到小数点后3位
+        param::gps_lat = QString::number(nowLatitude, 'f', 7);
+        param::gps_lng = QString::number(nowLongitude, 'f', 7);
+        LOG("经度:{:.7f}",nowLongitude);
+        LOG("纬度:{:.7f}",nowLatitude);
+
         LOG("角度:{}",nowDirection);
         LOG("地表速度:{}",nowGroundSpeed);
         LOG("垂直速度:{}",nowVerticalSpeed);

+ 13 - 1
q6_felgo_iot/src/mqtthandler.cpp

@@ -419,6 +419,19 @@ MqttHandler::onMessageReceived(const QByteArray &message, const QMqttTopicName &
                      }
                  }
              }
+             else if(value_cmd=="slide"){
+                 // {"cmd":"slide","ext":{"calibrate":"y","speed":"50"}}:远程校准指令,跳转相机界面并打开相机
+                 if(extValue.isObject()){
+                     QJsonObject extObj = extValue.toObject();
+                     QJsonValue cal = extObj["calibrate"];
+                     if(!cal.isNull() && cal.toString()=="y"){
+                         LOG("收到远程校准指令,跳转相机界面并打开相机!");
+                         emit signal_open_camera();
+                     }
+                 }
+                 //同时将指令转发给串口(电机移动等处理)
+                 emit dataReceived(m_client_dataBuf);
+             }
              else if(value_cmd=="paramconf"
                       ||value_cmd=="read"
                       ||value_cmd=="ledon"
@@ -427,7 +440,6 @@ MqttHandler::onMessageReceived(const QByteArray &message, const QMqttTopicName &
                       ||value_cmd=="windoff"
                       ||value_cmd=="translate"
                       ||value_cmd=="takephoto"
-                      ||value_cmd=="slide"
                       ||value_cmd=="sensor"){
                 emit dataReceived(m_client_dataBuf);
              }else if(value_cmd=="cache_read")  //{"cmd":"cache_read","ext":{"type": "data"}} photo