zhunk 1 year ago
parent
commit
ca35128772

+ 15 - 15
q6_felgo_iot/CMakeLists.txt.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 14.0.1, 2025-07-25T12:07:40. -->
+<!-- Written by QtCreator 14.0.1, 2025-09-09T09:18:08. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
@@ -103,23 +103,23 @@
     <value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
     <valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
     <value type="QString" key="CMake.Initial.Parameters">-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DANDROID_SDK_ROOT:PATH=F:/Android_Env/android_sdk
--DCMAKE_GENERATOR:STRING=Ninja
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
--DANDROID_NDK:PATH=F:/Android_Env/android-ndk-r23c
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DANDROID_ABI:STRING=arm64-v8a
--DQT_HOST_PATH:PATH=%{Qt:QT_HOST_PREFIX}
+-DANDROID_NATIVE_API_LEVEL:STRING=23
+-DQT_NO_GLOBAL_APK_TARGET_PART_OF_ALL:BOOL=ON
+-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
 -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
+-DQT_HOST_PATH:PATH=%{Qt:QT_HOST_PREFIX}
 -DCMAKE_BUILD_TYPE:STRING=Release
+-DCMAKE_FIND_ROOT_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=F:/Android_Env/android-ndk-r23c/build/cmake/android.toolchain.cmake
+-DCMAKE_GENERATOR:STRING=Ninja
+-DANDROID_SDK_ROOT:PATH=F:/Android_Env/android_sdk
+-DANDROID_STL:STRING=c++_shared
+-DANDROID_NDK:PATH=F:/Android_Env/android-ndk-r23c
 -DANDROID_USE_LEGACY_TOOLCHAIN_FILE:BOOL=OFF
--DCMAKE_FIND_ROOT_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DQT_NO_GLOBAL_APK_TARGET_PART_OF_ALL:BOOL=ON
--DANDROID_NATIVE_API_LEVEL:STRING=23
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
--DANDROID_STL:STRING=c++_shared</value>
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
+-DANDROID_ABI:STRING=arm64-v8a</value>
     <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">F:\QT_WorkSpace\qt6_iot_all\build-q6_felgo_iot-Qt_6_4_1_android_arm64_v8a_Clang_arm64_v8a-Release</value>
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
@@ -135,7 +135,7 @@
      </valuemap>
      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
       <value type="QString" key="BuildTargetSdk">android-31</value>
-      <value type="QString" key="BuildToolsVersion">30.0.2</value>
+      <value type="QString" key="BuildToolsVersion"></value>
       <value type="QString" key="KeystoreLocation">F:/QT_WorkSpace/qt6_iot_all/key/android_release.keystore</value>
       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建安卓 APK</value>

+ 4 - 0
q6_felgo_iot/Readme.md

@@ -0,0 +1,4 @@
+## 20250829
+    #define APP_VERSION "1.2.10"
+    更新说明:
+        增加每隔24小时系统重启;

+ 7 - 3
q6_felgo_iot/header/cameramanager.h

@@ -38,8 +38,12 @@
 //USBCamera:   https://blog.csdn.net/hanshiying007/article/details/124118486
 #define CameraType  2   //0-QCamera  , 1-OPENCV,    2-libuvc
 
-#define movY_f "f55"    //多图移动,正向
-#define movY_b "b55"    //多图移动,反向
+#define movZ_f "f55"    //多图移动,正向80
+#define movZ_b "b55"    //多图移动,反向80
+
+#define movX_f "f55"    //多图移动,正向
+#define movX_b "b55"    //多图移动,反向
+
 
 #define focux_f "f4"    //单步对焦,正向
 #define focus_b "b4"    //单步对焦,反向
@@ -420,7 +424,7 @@ public slots:
         }
 #endif
     }
-    void parseFrame(const cv::Mat& frame);
+//    void parseFrame(const cv::Mat& frame);
     void upload_handle(void);
     void handle_reult_upload(bool success, const QString &error);
 #if 0

+ 1 - 0
q6_felgo_iot/header/m_opencv.h

@@ -26,6 +26,7 @@ public:
     QString  Laplacian(cv::Mat &image);
     QString  Tenengrad(cv::Mat &image);
     QString  calculateSharpness(const QImage& image);
+    int CustomSharpening(const QString &path);
     Mat qim2mat(QImage &qim);
 };
 

+ 1 - 7
q6_felgo_iot/header/main.h

@@ -37,7 +37,7 @@
 #include <opencv2/features2d/features2d.hpp>
 #include <opencv2/xfeatures2d/nonfree.hpp>
 
-#define APP_VERSION "1.1.10"
+#define APP_VERSION "1.2.12"
 
 using namespace std;
 
@@ -147,10 +147,4 @@ private:
 
  #pragma pack(pop)
 
-
-
-
-
-
-
 #endif // MAIN_H

+ 39 - 12
q6_felgo_iot/header/mserial.h

@@ -13,7 +13,7 @@
 #include <QStandardPaths>
 #include <QVideoFrame>
 #include <mysql.h>
-
+#include <m_loger.h>
 class SerialThread: public QThread
 {
     Q_OBJECT
@@ -49,7 +49,8 @@ public:
     }
 
     Q_INVOKABLE void readPathinfo(){
-        getDirectoryStats(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
+
+        analyzeDirectory(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
     }
 
     Q_INVOKABLE void removepic(){
@@ -71,6 +72,13 @@ public:
             jClass.callMethod<void>("setScreenLight","(Landroid/content/Context;I)V",qtContext.object(),val);
         }
     }
+    Q_INVOKABLE QString getId(){
+        return param::imei;
+    }
+
+    Q_INVOKABLE QString getIccid(){
+        return param::iccid;
+    }
 
 signals:
     void dataReceived(const QByteArray &data);
@@ -109,6 +117,11 @@ private:
     QString qst_dirPath;
     int int_fileCount;
     qint64 int_totalSize;
+    // 用于存储目录统计结果的结构体
+    struct DirectoryStats {
+        qint64 totalSize = 0;
+        int fileCount = 0;
+    };
 
     void deleteAllFilesInDirectory(const QString &directoryPath)
     {
@@ -130,13 +143,13 @@ private:
                 QFile::remove(fileInfo.filePath());
             }
         }
-        getDirectoryStats(directoryPath);
+        analyzeDirectory(directoryPath);
     }
-
-    void getDirectoryStats(const QString &directoryPath)
+    // 递归获取目录统计信息
+    DirectoryStats getDirectoryStats(const QString &directoryPath)
     {
         QDir directory(directoryPath);
-
+        DirectoryStats stats;
         if (!directory.exists()) {
             qDebug() << "Directory does not exist.";
         }
@@ -149,18 +162,32 @@ private:
         foreach (const QFileInfo &fileInfo, fileInfoList) {
             if (fileInfo.isDir()) {
                 // 递归获取子目录的统计信息
-                getDirectoryStats(fileInfo.filePath());
+                DirectoryStats subStats = getDirectoryStats(fileInfo.filePath());
+                stats.fileCount += subStats.fileCount;
+                stats.totalSize += subStats.totalSize;
             } else {
-                totalSize += fileInfo.size();
-                fileCount++;
+                stats.fileCount++;
+                stats.totalSize += fileInfo.size();
             }
         }
+        return stats;
         qst_dirPath = directoryPath;
         int_fileCount = fileCount;
         int_totalSize = totalSize;
-        qDebug() << "Directory: " << directoryPath;
-        qDebug() << "File count: " << fileCount;
-        qDebug() << "Total size: " << totalSize << " bytes";
+        LOG("Directory:{}",directoryPath.toStdString());
+        LOG("File count:{}",fileCount);
+        LOG("Total size:{} bytes",totalSize);
+    }
+    // 使用示例
+    void analyzeDirectory(const QString &directoryPath) {
+        qDebug() << "Analyzing directory:" << directoryPath;
+
+        DirectoryStats stats = getDirectoryStats(directoryPath);
+        qst_dirPath = directoryPath;
+        int_fileCount = stats.fileCount;
+        int_totalSize = stats.totalSize;
+        LOG("Total files:{}",int_totalSize);
+        LOG("Total size:{} MB",stats.totalSize / (1024.0 * 1024.0));
     }
 };
 

+ 2 - 0
q6_felgo_iot/header/ymodem.h

@@ -52,6 +52,7 @@ class YMODEM : public QThread
 private:
     bool m_cancel;
     QSerialPort *m_serialPort;
+    QByteArray dataBuf;
     QString m_fp;
     double percent;
     int yTransmitRead(unsigned short timeout);
@@ -60,6 +61,7 @@ private:
     void yTransmitFlush();
     unsigned short crc16_ccitt(const unsigned char *buf, unsigned int len);
     int yTransmitPacket(const QFileInfo &fileInfo, QIODevice &dev, const quint32 &payloadSize, quint8 sequenceNum = 0,bool firstPacket = true);
+    void configureForProtocolMode(bool enable);
 public:
     enum YMODEMResponce {
         MODEM_TIMEOUT = 1,

+ 162 - 107
q6_felgo_iot/qml/pages/HomePage.qml

@@ -15,6 +15,8 @@ AppPage {
   id: home_Page
   signal updatebv(string bv)
   property string originalString: ""
+  property string iccidString: ""
+  property string boxtemptureString: ""
   property string collectString: ""
   property string gps_state: "定位中..."
   property bool connect_board: false
@@ -90,18 +92,30 @@ AppPage {
           if(jsonData.ext.imei){
               originalString = jsonData.ext.imei
           }
+          if(jsonData.ext.iccid){
+              iccidString= jsonData.ext.iccid
+          }
 
-          if(jsonData.ext.coll_time){
+          if(jsonData.ext.coll_time&&jsonData.ext.coll_min){
               var sh1Arry = jsonData.ext.coll_time[0].split('-')
               var sh2Arry = jsonData.ext.coll_time[1].split('-')
               var sh3Arry = jsonData.ext.coll_time[2].split('-')
-              sh1.text = parseInt(sh1Arry[0])+ ":00 - " + parseInt(sh1Arry[1]) + ":00"
-              sh2.text = parseInt(sh2Arry[0])+ ":00 - " + parseInt(sh2Arry[1]) + ":00"
-              sh3.text = parseInt(sh3Arry[0])+ ":00 - " + parseInt(sh3Arry[1]) + ":00"
+
+              var min_arry0 = jsonData.ext.coll_min[0].split('-')
+              var min_arry1 = jsonData.ext.coll_min[1].split('-')
+              var min_arry2 = jsonData.ext.coll_min[2].split('-')
+
+
+              sh1.text = parseInt(sh1Arry[0])+ ":" + parseInt(min_arry0[0]) + " - " + parseInt(sh1Arry[1]) + ":" + parseInt(min_arry0[1])
+              sh2.text = parseInt(sh2Arry[0])+ ":" + parseInt(min_arry1[0]) + " - " + parseInt(sh2Arry[1]) + ":" + parseInt(min_arry1[1])
+              sh3.text = parseInt(sh3Arry[0])+ ":" + parseInt(min_arry2[0]) + " - " + parseInt(sh3Arry[1]) + ":" + parseInt(min_arry2[1])
           }
           if(jsonData.ext.dat_f){
               serial.update_dat_f_main(jsonData.ext.dat_f);
           }
+          if(jsonData.ext.boxtem){
+              text_tempture0.text = "箱内温度:" + jsonData.ext.boxtem + "℃"
+          }
           text_tempture.text = "温度:" + jsonData.ext.at + "℃"
           text_humidity.text  = "湿度:" + jsonData.ext.ah + "%RH"
           text_vbat.text = "电压:" + jsonData.ext.vbat + "V"
@@ -123,6 +137,8 @@ AppPage {
       }
       onDisconnect_485:{
            text_devicesta.text =qsTr("485未连接,读取数据失败");
+           originalString =serial.getId()
+           iccidString=serial.getIccid()
       }
 
   }
@@ -227,18 +243,120 @@ AppPage {
             spacing:5
 
             Rectangle {
+                id: container
                 width: parent.width * 0.245
                 height: parent.height
                 color: app.cardColor
                 radius: 5
-                Column {
-                    anchors {
-                        top: parent.top
-                        left: parent.left
-                        right: parent.right
-                        margins: 10
+
+                Rectangle {
+                    id: focus_setting
+                    anchors.fill: parent
+                    visible: false
+                        // X坐标输入行(结构同优化前)
+                    Column {
+                        anchors.fill: parent
+                        spacing: 10
+                        Row {
+                            width: parent.width*0.6
+                            spacing: 5
+                            AppText {
+                                text: "X坐标:"
+                                color: app.fontColor
+                                font.pixelSize: 20
+                            }
+                            // 使用边框包裹
+                            ItemDelegate {
+                                width: parent.width
+                                height: 42
+                                padding: 0
+                                contentItem: AppTextInput {
+                                    id: textInput_x
+                                    width: parent.width
+                                    height: parent.height
+                                    placeholderText: "x_init_dis"
+                                    text: "0"
+                                    font.family: "Arial"
+                                    font.pixelSize: 20
+
+                                    // 使用验证器替代inputMask
+                                    validator: DoubleValidator {
+                                        decimals: 2
+                                    }
+
+                                    property real numericValue_x: Number(text) || 0
+
+                                    onAccepted: {
+                                        console.log("X坐标:", numericValue_x)
+                                        serial.setHt_xy_dis(numericValue_x, textInput_y.numericValue_y)
+                                        coordinateInputs.visible = false
+                                    }
+                                }
+
+                                // 边框样式
+                                Rectangle {
+                                    anchors.fill: parent
+                                    color: "transparent"
+                                    border.color: textInput_x.activeFocus ? "blue" : "gray"
+                                    border.width: 1
+                                    radius: 4
+                                }
+                            }
+                        }
+                        // Y坐标输入行(结构同优化前)
+                        Row {
+                            width: parent.width*0.6
+                            spacing: 5
+                            AppText {
+                                text: "Y坐标:"
+                                color: app.fontColor
+                                font.pixelSize: 20
+                            }
+                            // 使用边框包裹
+                            ItemDelegate {
+                                width: parent.width
+                                height: 42
+                                padding: 0
+                                contentItem: AppTextInput {
+                                    id: textInput_y
+                                    width: parent.width
+                                    height: parent.height
+                                    placeholderText: "y_init_dis"
+                                    text: "0"
+                                    font.family: "Arial"
+                                    font.pixelSize: 20
+
+                                    // 使用验证器替代inputMask
+                                    validator: DoubleValidator {
+                                        decimals: 2
+                                    }
+
+                                    property real numericValue_y: Number(text) || 0
+
+                                    onAccepted: {
+                                        console.log("Y坐标:", numericValue_y)
+                                        serial.setHt_xy_dis(textInput_x.numericValue_x, numericValue_y)
+                                        coordinateInputs.visible = false
+                                    }
+                                }
+
+                                // 边框样式
+                                Rectangle {
+                                    anchors.fill: parent
+                                    color: "transparent"
+                                    border.color: textInput_x.activeFocus ? "blue" : "gray"
+                                    border.width: 1
+                                    radius: 4
+                                }
+                            }
+                        }
                     }
-                    spacing: 10
+                }
+
+                Column {
+                    anchors.centerIn: parent
+                    spacing: 12
+                    visible: true
                     AppImage {
                         id: image_01
                         anchors.horizontalCenter: parent.horizontalCenter
@@ -254,101 +372,26 @@ AppPage {
                         font.bold: true
                         font.pixelSize: 16
                     }
-                    // X坐标输入框
-                    Row {
-                        width: parent.width*0.6
-                        spacing: 5
-
-                        AppText {
-                            text: "X坐标:"
-                            color: app.fontColor
-                            font.pixelSize: 20
-                        }
-                        // 使用边框包裹
-                        ItemDelegate {
-                            width: parent.width
-                            height: 42
-                            padding: 0
-                            contentItem: AppTextInput {
-                                id: textInput_x
-                                width: parent.width
-                                height: parent.height
-                                placeholderText: "x_init_dis"
-                                text: "0"
-                                font.family: "Arial"
-                                font.pixelSize: 20
-
-                                // 使用验证器替代inputMask
-                                validator: DoubleValidator {
-                                    decimals: 2
-                                }
 
-                                property real numericValue_x: Number(text) || 0
-
-                                onAccepted: {
-                                    console.log("X坐标:", numericValue_x)
-                                    serial.setHt_xy_dis(numericValue_x, textInput_y.numericValue_y)
-                                }
-                            }
-
-                            // 边框样式
-                            Rectangle {
-                                anchors.fill: parent
-                                color: "transparent"
-                                border.color: textInput_x.activeFocus ? "blue" : "gray"
-                                border.width: 1
-                                radius: 4
-                            }
-                        }
-                    }
-                    // Y坐标输入框
-                    Row {
-                        width: parent.width*0.6
-                        spacing: 5
-
-                        AppText {
-                            text: "Y坐标:"
-                            color: app.fontColor
-                            font.pixelSize: 20
-                        }
-                        // 使用边框包裹
-                        ItemDelegate {
-                            width: parent.width
-                            height: 42
-                            padding: 0
-                            contentItem: AppTextInput {
-                                id: textInput_y
-                                width: parent.width
-                                height: parent.height
-                                placeholderText: "y_init_dis"
-                                text: "0"
-                                font.family: "Arial"
-                                font.pixelSize: 20
-
-                                // 使用验证器替代inputMask
-                                validator: DoubleValidator {
-                                    decimals: 2
-                                }
-
-                                property real numericValue_y: Number(text) || 0
-
-                                onAccepted: {
-                                    console.log("Y坐标:", numericValue_y)
-                                    serial.setHt_xy_dis(textInput_x.numericValue_x, numericValue_y)
-                                }
-                            }
+                    AppImage {
+                        id: focus_xy_set
+                        anchors.horizontalCenter: parent.horizontalCenter   //垂直居中显示
+                        fillMode: Image.PreserveAspectFit  // 保持纵横比适应
+                        source: "../../assets/set.svg"
+                        AppButton{
 
-                            // 边框样式
-                            Rectangle {
-                                anchors.fill: parent
-                                color: "transparent"
-                                border.color: textInput_x.activeFocus ? "blue" : "gray"
-                                border.width: 1
-                                radius: 4
+                            anchors.fill: parent
+                            //text:" 修改"
+                            textColor: "GRAY"
+                            textSize: 10
+                            flat: true
+                            onClicked: {
+                                focus_setting.visible = !focus_setting.visible
+                                text_devicesta.visible = !text_devicesta.visible
+                                image_01.visible = !image_01.visible
                             }
                         }
                     }
-
                 }
             }
 
@@ -381,13 +424,13 @@ AppPage {
                           mac.text = qsTr("<b>[MAC] </b> %1").arg(net_list[3])
                           datt_text.text = "数据上传间隔:" + net_list[6] + "分钟"
                           netxd_text.text = "下一次数据上传:" + net_list[7] + "秒"
-
+                          iccid_text.text = "SIM卡号:" + iccidString
                       }
                   }
                 }
 
                 Column{
-                    anchors.fill: parent
+                    anchors.centerIn: parent
                     spacing: 5
                     AppImage {
                         anchors.horizontalCenter: parent.horizontalCenter   //垂直居中显示
@@ -438,6 +481,13 @@ AppPage {
                         fontSize: 10
                         color: "gray"
                     }
+                    AppText{
+                        id: iccid_text
+                        anchors.horizontalCenter: parent.horizontalCenter   //垂直居中显示
+                        text:"SIM卡号:"
+                        fontSize: 10
+                        color: "gray"
+                    }
                 }
 
             }
@@ -449,8 +499,7 @@ AppPage {
 
 
                 Column{
-                    anchors.top: parent.top
-                    anchors.horizontalCenter: parent.horizontalCenter   //垂直居中显示
+                    anchors.centerIn: parent
                     spacing: 5
                     AppImage {
                         anchors.horizontalCenter: parent.horizontalCenter   //垂直居中显示
@@ -647,8 +696,7 @@ AppPage {
 
                 Column{
                     id: column_colt
-                    anchors.top: parent.top
-                    anchors.horizontalCenter: parent.horizontalCenter   //垂直居中显示
+                    anchors.centerIn: parent
                     spacing: 5
                     AppImage {
                         id: image_timesvg
@@ -753,6 +801,13 @@ AppPage {
                         color: app.fontColor
                         font.bold: true
                     }
+                    AppText{
+                        id: text_tempture0
+                        anchors.horizontalCenter: parent.horizontalCenter   //垂直居中显示
+                        text: "箱内温度:"
+                        fontSize: 10
+                        color: "gray"
+                    }
                 }
 
             }

+ 56 - 54
q6_felgo_iot/qml/pages/PhotostitcherPage.qml

@@ -32,50 +32,70 @@ AppPage {
         Flickable {
             id: flick
             anchors.fill: parent
-            contentWidth: imgFull.width * imgFull.scale
-            contentHeight: imgFull.height * imgFull.scale
-            interactive: contentWidth > width || contentHeight > height
+            clip: true
+            boundsBehavior: Flickable.DragAndOvershootBounds
 
             Image {
-                id: imgFull
-                x: (flick.width - width * scale)/2
-                y: (flick.height - height * scale)/2
-                sourceSize.width: 4096
+                id: image
+                anchors.fill: parent
                 asynchronous: true
                 fillMode: Image.PreserveAspectFit
+                width: Math.min(implicitWidth, parent.width)
+                height: Math.min(implicitHeight, parent.height)
+                property real scale: 1.0
+            }
 
-                // 自动计算初始缩放比例
-                function calculateScale() {
-                    const widthScale = flick.width / implicitWidth
-                    const heightScale = flick.height / implicitHeight
-                    initScale = Math.min(widthScale, heightScale) * 0.9
-                    scale = initScale
-                }
 
-                onStatusChanged: if(status === Image.Ready) calculateScale()
+            PinchArea {
+              anchors.fill: parent
 
-            }
+              pinch.target: image
+              pinch.minimumRotation: -360
+              pinch.maximumRotation: 360
+              pinch.minimumScale: 0.1
+              pinch.maximumScale: 10
+              pinch.dragAxis: Pinch.XAndYAxis
 
-            // 手势缩放
-            PinchArea {
+              // MouseArea handles drag gestures
+              MouseArea {
                 anchors.fill: parent
-                pinch.target: imgFull
-                pinch.minimumScale: imgFull.minScale
-                pinch.maximumScale: imgFull.maxScale
-                onPinchFinished: flick.returnToBounds()
-            }
 
-            // 双击缩放
-            MouseArea {
-                anchors.fill: parent
-                onDoubleClicked: {
-                    if(imgFull.scale === imgFull.initScale) {
-                        imgFull.scale = imgFull.maxScale
-                    } else {
-                        imgFull.scale = imgFull.initScale
-                    }
-                    flick.returnToBounds()
-                }
+                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)
             }
         }
 
@@ -125,8 +145,9 @@ AppPage {
     }
 
     function showFullscreen(path) {
-        imgFull.source = "file://" + path
+        image.source = "file://" + path
         fullscreenPopup.open()
+        resetTransform()
     }
 
 
@@ -217,25 +238,6 @@ AppPage {
                     required property int column    //行
                     // 自动生成正确的模型索引
 
-
-                    // ✅ 获取正确的模型索引
-                    //property var modelIndex: treeView.model.index(row, 0)
-
-                    // Rectangle {
-                    //         visible: model.changed
-                    //         width: 8
-                    //         height: 8
-                    //         radius: 4
-                    //         color: "red"
-                    //         anchors.right: parent.right
-                    //         anchors.verticalCenter: parent.verticalCenter
-                    //         SequentialAnimation on opacity {
-                    //             loops: Animation.Infinite
-                    //             NumberAnimation { from: 1; to: 0.3; duration: 1000 }
-                    //             NumberAnimation { from: 0.3; to: 1; duration: 1000 }
-                    //         }
-                    // }
-
                     Rectangle {
                         width: parent.width
                         height: parent.height

+ 24 - 457
q6_felgo_iot/src/cameramanager.cpp

@@ -41,7 +41,6 @@
 #include <main.h>
 #include <m_loger.h>
 #include <QMessageBox>
-#define MAX_FRAME 4
 
 class param;
 
@@ -276,8 +275,8 @@ Frames::Frames(QObject * parent)
    connect(this,&Frames::startGrabbing,
            this,&Frames::handleGrab);
 
-    connect(this,&Frames::uvcframeAvailable,
-            this,&Frames::parseFrame);
+//    connect(this,&Frames::uvcframeAvailable,
+//            this,&Frames::parseFrame);
 
     connect(this,&Frames::frameAvailable,
             this,&Frames::displayFrame);
@@ -288,8 +287,8 @@ Frames::Frames(QObject * parent)
     connect(this,&Frames::signal_photo_saved,
             this,&Frames::upload_handle);
 
-    connect(&sender_custom,&SenderCustom::signalToSend,
-            this,&Frames::parseFrame);
+    // connect(&sender_custom,&SenderCustom::signalToSend,
+    //         this,&Frames::parseFrame);
 
     connect(&sender_custom,&SenderCustom::signalQStr,
             this,&Frames::processUvchandle);
@@ -375,72 +374,8 @@ Frames::setCameraSw(bool stat_cam)
     if(m_streaming_active&&camera_sta) return;  //如果已经是打开状态,退出
     static int fd = 0;
     if(camera_sta){
-        if(param::camera_type.contains("qcamera")){             //QCamera
-            m_cam->start();
-            m_fps_timer->setRunning(camera_sta);
-            m_1s->start();
-        }else if(param::camera_type.contains("uvc")){           //libuvc
-            #if 1
-            if(qtContext.isValid()&&jClass->isValid()){
-                jClass->callMethod<void>("SetCamera_State","(Landroid/content/Context;Z)V",qtContext.object(),javaState);
-            }
-            #else
-            fd = checkPermission();
-            Logger::instance()->log("checkPermission:" + QString::number(fd));
-            if(fd){
-                res_uvc = uvc_init(&ctx_, NULL);    //必须要加,否则第二次打开会无法取流
-                if(res_uvc==UVC_SUCCESS){
-                    Logger::instance()->log("uvc_init Success!");
-                    res_uvc = uvc_find_device(
-                        ctx_, &dev_,
-                        0, 0, NULL);
-                }else{
-                    uvc_error_handler(res_uvc);
-                }
-                // important for Android
-                #if 0
-                res_uvc =  uvc_get_device_with_fd(ctx_,&dev_,0,0,0,fd,0,0);
-                qDebug() << "uvc_get_device_with_fd res:" << res_uvc;
-                #endif
-                // Set libusb option to disable device discovery
-                #if 0
-                 int r = unrooted_usb_description(fd);
-                 qDebug() << "unrooted_usb_description!" << r;
-                #endif
-
-                res_uvc = uvc_open(dev_, &devh_);
-                if(res_uvc==UVC_SUCCESS){                    
-                    Logger::instance()->log("uvc_open Success!");
-                    checkDeviceCapabilities();
-                    // 设置相机流格式和帧回调函数
-                    res_uvc = uvc_get_stream_ctrl_format_size(devh_,&streamCtrl,UVC_FRAME_FORMAT_MJPEG,1920,1080,30);        //UVC_FRAME_FORMAT_MJPEG
-                    /* Print out the result */
-                    uvc_print_stream_ctrl(&streamCtrl, stderr);
-                    if(res_uvc==UVC_SUCCESS){
-                        Logger::instance()->log("uvc_get_stream_ctrl_format_size Success!");
-                    }else{
-                        uvc_error_handler(res_uvc);
-                    }
-
-                    //启动相机流
-                    res_uvc = uvc_start_streaming(devh_, &streamCtrl, &frameCallback, this,0);
-                    if(res_uvc == UVC_SUCCESS){
-                        m_1s->start();
-                        m_fps_timer->setRunning(true);
-                        m_streaming_active = true;
-                        Logger::instance()->log("UVC streaming started...");
-                    }
-                }else{
-                    camera_sta = false;
-                    m_streaming_active = false;
-                    uvc_error_handler(res_uvc);
-                }
-            }else{
-                camera_sta = false;
-                m_streaming_active = false;
-            }
-            #endif
-        }else if(param::camera_type.contains("hikrobot")){
+        if(param::camera_type.contains("hikrobot"))
+        {
             int ret = testJNI();
             qDebug()<<"testJNI ret:" << ret;
             #if 0
@@ -784,8 +719,9 @@ Frames::handleGrab(bool sta_cam){
                                 LOG("图片名称:{}",pic_name.toStdString());
                                 if(m_image.save(pic_name,"jpg",80))
                                 {
+                                    //图片锐化
+                                    //m_opencvfunc.CustomSharpening(pic_name);
                                     param::ptlist.append(pic_name);
-
                                     /*z3x7*/
                                     if(z_step==3&&x_step==7){
                                         emit stopGrabbing(false);
@@ -793,7 +729,7 @@ Frames::handleGrab(bool sta_cam){
 
                                     if(z_step<=2&&x_step==7){
                                         z_step++;
-                                        emit serial_data(m_json.MotorMove("movz","b80","50"));
+                                        emit serial_data(m_json.MotorMove("movz",movX_b,"50"));
                                     }
 
 
@@ -803,11 +739,11 @@ Frames::handleGrab(bool sta_cam){
                                         //emit stopGrabbing(false);
                                         x_step++;
                                         z_step = 0;
-                                        emit serial_data(m_json.MotorMove("movx","f80","50"));
+                                        emit serial_data(m_json.MotorMove("movx",movX_f,"50"));
                                     }
                                     if(z_step<=2&&x_step==6){
                                         z_step++;
-                                        emit serial_data(m_json.MotorMove("movz","f80","50"));
+                                        emit serial_data(m_json.MotorMove("movz",movZ_f,"50"));
                                     }
 
                                     /*z3x5*/
@@ -816,11 +752,11 @@ Frames::handleGrab(bool sta_cam){
                                         //emit stopGrabbing(false);
                                         x_step++;
                                         z_step = 0;
-                                        emit serial_data(m_json.MotorMove("movx","f80","50"));
+                                        emit serial_data(m_json.MotorMove("movx",movX_f,"50"));
                                     }
                                     if(z_step<=2&&x_step==5){
                                         z_step++;
-                                        emit serial_data(m_json.MotorMove("movz","b80","50"));
+                                        emit serial_data(m_json.MotorMove("movz",movZ_b,"50"));
                                     }
 
                                     /*z3x4*/
@@ -828,11 +764,11 @@ Frames::handleGrab(bool sta_cam){
                                     {
                                         x_step++;
                                         z_step = 0;
-                                        emit serial_data(m_json.MotorMove("movx","f80","50"));
+                                        emit serial_data(m_json.MotorMove("movx",movX_f,"50"));
                                     }
                                     if(z_step<=2&&x_step==4){
                                         z_step++;
-                                        emit serial_data(m_json.MotorMove("movz","f80","50"));
+                                        emit serial_data(m_json.MotorMove("movz",movZ_f,"50"));
                                     }
 
                                     /*z3x3*/
@@ -840,11 +776,11 @@ Frames::handleGrab(bool sta_cam){
                                     {
                                         x_step++;
                                         z_step = 0;
-                                        emit serial_data(m_json.MotorMove("movx","f80","50"));
+                                        emit serial_data(m_json.MotorMove("movx",movX_f,"50"));
                                     }
                                     if(z_step<=2&&x_step==3){
                                         z_step++;
-                                        emit serial_data(m_json.MotorMove("movz","b80","50"));
+                                        emit serial_data(m_json.MotorMove("movz",movZ_b,"50"));
                                     }
                                     /**/
 
@@ -853,11 +789,11 @@ Frames::handleGrab(bool sta_cam){
                                     {
                                         x_step++;
                                         z_step = 0;
-                                        emit serial_data(m_json.MotorMove("movx","f80","50"));
+                                        emit serial_data(m_json.MotorMove("movx",movX_f,"50"));
                                     }
                                     if(z_step<=2&&x_step==2){
                                         z_step++;
-                                        emit serial_data(m_json.MotorMove("movz","f80","50"));
+                                        emit serial_data(m_json.MotorMove("movz",movZ_f,"50"));
                                     }
                                     /**/
 
@@ -866,12 +802,12 @@ Frames::handleGrab(bool sta_cam){
                                     {
                                         x_step++;
                                         z_step = 0;
-                                        emit serial_data(m_json.MotorMove("movx","f80","50"));
+                                        emit serial_data(m_json.MotorMove("movx",movX_f,"50"));
                                     }
 
                                     if(z_step<=2&&x_step==1){
                                         z_step++;
-                                        emit serial_data(m_json.MotorMove("movz","b80","50"));
+                                        emit serial_data(m_json.MotorMove("movz",movZ_b,"50"));
                                     }
 
                                     /*z3x0*/
@@ -879,12 +815,12 @@ Frames::handleGrab(bool sta_cam){
                                     {
                                         x_step++;
                                         z_step = 0;
-                                        emit serial_data(m_json.MotorMove("movx","f80","50"));
+                                        emit serial_data(m_json.MotorMove("movx",movX_f,"50"));
                                     }
                                     if(z_step<=2&&x_step==0)
                                     {
                                         z_step++;
-                                        emit serial_data(m_json.MotorMove("movz","f80","50"));
+                                        emit serial_data(m_json.MotorMove("movz",movZ_f,"50"));
                                     }
                                 }
                             }
@@ -919,360 +855,6 @@ Frames::handleGrab(bool sta_cam){
 #endif
 }
 
-void
-Frames::parseFrame(const cv::Mat& frame){
-    if(!isDecoding()&&m_processThread.isFinished()){
-        m_decoding = true;
-        // 使用互斥锁保护对帧缓冲区的访问
-        m_processThread = QtConcurrent::run([=]() {
-            frameMutex.lock();
-            if(!frame.empty()){
-#if 1
-                //进行色彩转换
-                // 将YUV422数据转换为RGB格式
-                //cv::cvtColor(frame,m_frame,cv::COLOR_RGB2RGBA);
-                const int size_frame = m_frame.total()*m_frame.elemSize();  //字节数
-
-                // 创建 QVideoFrame 对象,并设置相关参数
-                QVideoFrameFormat frame_format(QSize(m_frame.cols, m_frame.rows),
-                                               QVideoFrameFormat::Format_RGBA8888);
-                QVideoFrame f(frame_format);
-                if(f.map(QVideoFrame::WriteOnly)){
-                   // 将共享内存数据复制到 QVideoFrame
-                   memcpy(f.bits(0), m_frame.data, size_frame);
-                   f.unmap();
-                   if(m_videoSink != nullptr){
-                       m_videoSink->setVideoFrame(f);
-                   }
-                }
-                #if 0
-                if(m_1s->isActive())
-                    m_qulityString = m_opencvfunc.brenner(m_frame);     //计算对比度
-                #endif            
-#if 1
-                QDateTime currentDateTime = QDateTime::currentDateTime();
-                QString currentDateTimeString = currentDateTime.toString("yyyyMMddhhmmss");
-                QString appDataPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
-                QString setup_s;
-                if(param::camera_tc==100){       //拍照上传
-                    param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
-                    LOG("Pt1 is:{}",param::ptlist.at(0).toStdString());
-                    if(param::camera_type.contains("hikrobot")){
-                        if(cv::imwrite(param::ptlist.at(0).toStdString(), m_frame)){
-                            param::camera_tc = 10;
-                        }else{  //失败
-                            qDebug() << "Failed to imwrite";
-                            return;
-                        }
-                    }else{
-                        if(f.isValid()) m_image = f.toImage().convertToFormat(QImage::Format_RGB32);
-                        //m_image = m_videoSink->videoFrame().toImage().convertToFormat(QImage::Format_RGB32);
-                        if(m_image.save(param::ptlist.at(0),"jpg",100)) param::camera_tc = 10;
-                    }
-                 }else if(param::camera_tc==1){
-                    if(f.isValid()) m_image = f.toImage().convertToFormat(QImage::Format_RGB32);
-                    //m_image = m_videoSink->videoFrame().toImage().convertToFormat(QImage::Format_RGB32);
-                    param::camera_tc = 0;
-                    switch(param::stitch_photonum){ //拼接数量
-                        case 1:
-                            param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
-                            LOG("pt1 is:{}",param::ptlist.at(0).toStdString());
-                            if(m_image.save(param::ptlist.at(0),"jpg",100)) param::camera_tc = 10;
-                            break;
-                        case 2:
-                        /*
-                         * movx b
-                        */
-                            switch(param::ptlist.size()){
-                                case 0:
-                                    if(stitch_des==0){
-                                        param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
-                                        LOG("pt1 is:{}",param::ptlist.at(0).toStdString());
-                                        if(m_image.save(param::ptlist.at(0),"jpg",100)){
-                                            //movx b
-                                            setup_s = "b" + QString::number(param::photo_width);
-                                            emit serial_data(m_json.MotorMove("movx",setup_s,""));
-                                            stitch_des = 1;
-                                        }
-                                    }
-
-                                    break;
-                                case 1:
-                                    if(stitch_des==1){
-                                        param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-2.jpg");
-                                        LOG("pt2 is:{}",param::ptlist.at(1).toStdString());
-                                        if(m_image.save(param::ptlist.at(1),"jpg",100)){
-                                            stitch_des = 10;
-                                        }
-                                    }
-                                    break;
-                            }
-                            break;
-                        case 3:
-                        /*
-                         * movx b
-                         * movx b
-                        */
-                            switch(param::ptlist.size()){
-                                case 0:
-                                    if(stitch_des==0){
-                                        param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
-                                        LOG("pt1 is:{}",param::ptlist.at(0).toStdString());
-                                        if(m_image.save(param::ptlist.at(0),"jpg",100)){
-                                            //movx b
-                                            setup_s = "b" + QString::number(param::photo_width);
-                                            emit serial_data(m_json.MotorMove("movx",setup_s,""));
-                                            stitch_des = 1;
-                                        }
-                                    }
-
-                                    break;
-                                case 1:
-                                    if(stitch_des==1){
-                                        param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-2.jpg");;
-                                        LOG("pt2 is:{}",param::ptlist.at(1).toStdString());
-                                        if(m_image.save(param::ptlist.at(1),"jpg",100)){
-                                            //movx b
-                                            setup_s = "b" + QString::number(param::photo_width);
-                                            emit serial_data(m_json.MotorMove("movx",setup_s,""));
-                                            stitch_des = 2;
-                                        }
-                                    }
-                                    break;
-                                case 2:
-                                    if(stitch_des==2){
-                                        param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-3.jpg");
-
-                                        LOG("pt3 is:{}",param::ptlist.at(2).toStdString());
-                                        if(m_image.save(param::ptlist.at(1),"jpg",100)) stitch_des = 10;
-                                    }
-                                    break;
-                            }
-                            break;
-                        case 4:
-                        /*
-                         * movx b
-                         * movz f
-                         * movx f
-                        */
-                            switch(param::ptlist.size()){
-                                case 0:
-                                    if(stitch_des==0){
-                                        param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
-
-                                        LOG("pt1 is:{}",param::ptlist.at(0).toStdString());
-                                        if(m_image.save(param::ptlist.at(0),"jpg",100)){
-                                            //movx b
-                                            setup_s = "b" + QString::number(param::photo_width);
-                                            emit serial_data(m_json.MotorMove("movx",setup_s,""));
-                                            stitch_des = 1;
-                                        }
-                                    }
-
-                                    break;
-                                case 1:
-                                    if(stitch_des==1){
-                                        param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-2.jpg");
-
-                                        LOG("pt2 is:{}",param::ptlist.at(1).toStdString());
-                                        if(m_image.save(param::ptlist.at(1),"jpg",100)){
-                                            //movz f
-                                            setup_s = "f" + QString::number(param::photo_height);
-                                            emit serial_data(m_json.MotorMove("movz",setup_s,""));
-                                            stitch_des = 2;
-                                        }
-
-                                    }
-                                    break;
-                                case 2:
-                                    if(stitch_des==2){
-                                        param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-3.jpg");
-
-                                        LOG("pt3 is:{}",param::ptlist.at(2).toStdString());
-                                        if(m_image.save(param::ptlist.at(2),"jpg",100)){
-                                            //movx b
-                                            setup_s = "f" + QString::number(param::photo_width);
-                                            emit serial_data(m_json.MotorMove("movx",setup_s,""));
-                                            stitch_des = 3;
-                                        }
-
-                                    }
-                                    break;
-                                case 3:
-                                    if(stitch_des==3){
-                                        param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-4.jpg");
-
-                                        LOG("pt4 is:{}",param::ptlist.at(3).toStdString());
-                                        if(m_image.save(param::ptlist.at(3),"jpg",100)){
-                                            param::camera_tc = 10;
-                                        }
-
-                                    }
-                                    break;
-                            }
-                            break;
-                        case 5:
-                            break;
-                        case 6:
-                            break;
-                        case 7:
-                            break;
-                        case 8:
-                            break;
-                        case 9:
-                        /*
-                         * movx b
-                         * movx b
-                         * movz f
-                         * movx f
-                         * movx f
-                         * movz f
-                         * movx b
-                         * movx b
-                        */
-                        switch(param::ptlist.size()){
-                            case 0:
-                                if(stitch_des==0){
-                                    param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
-
-                                    LOG("pt1 is:{}",param::ptlist.at(0).toStdString());
-                                    if(m_image.save(param::ptlist.at(0),"jpg",90)){
-                                        //movx b
-                                        setup_s = "b" + QString::number(param::photo_width);
-                                        emit serial_data(m_json.MotorMove("movx",setup_s,""));
-                                        stitch_des = 1;
-                                    }
-                                }
-
-                                break;
-                            case 1:
-                                if(stitch_des==1){
-                                    param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-2.jpg");
-                                    LOG("pt2 is:{}",param::ptlist.at(1).toStdString());
-                                    if(m_image.save(param::ptlist.at(1),"jpg",90)){
-                                        //movx b
-                                        setup_s = "b" + QString::number(param::photo_height);
-                                        emit serial_data(m_json.MotorMove("movx",setup_s,""));
-                                        stitch_des = 2;
-                                    }
-
-                                }
-                                break;
-                            case 2:
-                                if(stitch_des==2){
-                                    param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-3.jpg");
-
-                                    LOG("pt3 is:{}",param::ptlist.at(2).toStdString());
-                                    if(m_image.save(param::ptlist.at(2),"jpg",90)){
-                                        //movz f
-                                        setup_s = "f" + QString::number(param::photo_width);
-                                        emit serial_data(m_json.MotorMove("movz",setup_s,""));
-                                        stitch_des = 3;
-                                    }
-
-                                }
-                                break;
-                            case 3: //movx f
-                                if(stitch_des==3){
-                                    param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-4.jpg");
-
-                                    LOG("pt4 is:{}",param::ptlist.at(3).toStdString());
-                                    if(m_image.save(param::ptlist.at(3),"jpg",90)){
-                                        //movx f
-                                        setup_s = "f" + QString::number(param::photo_width);
-                                        emit serial_data(m_json.MotorMove("movx",setup_s,""));
-                                        stitch_des = 4;
-                                    }
-                                }
-                                break;
-                            case 4: //movx f
-                                if(stitch_des==4){
-                                    param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-5.jpg");
-
-                                    LOG("pt5 is:{}",param::ptlist.at(4).toStdString());
-                                    if(m_image.save(param::ptlist.at(4),"jpg",90)){
-                                        //movx f
-                                        setup_s = "f" + QString::number(param::photo_width);
-                                        emit serial_data(m_json.MotorMove("movx",setup_s,""));
-                                        stitch_des = 5;
-                                    }
-                                }
-                                break;
-                            case 5: //movz f
-                                if(stitch_des==5){
-                                    param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-6.jpg");
-
-                                    LOG("pt6 is:{}",param::ptlist.at(5).toStdString());
-                                    if(m_image.save(param::ptlist.at(5),"jpg",90)){
-
-                                        setup_s = "f" + QString::number(param::photo_width);
-                                        emit serial_data(m_json.MotorMove("movz",setup_s,""));
-                                        stitch_des = 6;
-                                    }
-                                }
-                                break;
-                            case 6: //movx b
-                                if(stitch_des==6){
-                                    param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-7.jpg");
-
-                                    LOG("pt7 is:{}",param::ptlist.at(6).toStdString());
-                                    if(m_image.save(param::ptlist.at(6),"jpg",90)){
-                                        //movx f
-                                        setup_s = "b" + QString::number(param::photo_width);
-                                        emit serial_data(m_json.MotorMove("movx",setup_s,""));
-                                        stitch_des = 7;
-                                    }
-                                }
-                                break;
-                            case 7: //movx b
-                                if(stitch_des==7){
-                                    param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-8.jpg");
-
-                                    LOG("pt8 is:{}",param::ptlist.at(7).toStdString());
-                                    if(m_image.save(param::ptlist.at(7),"jpg",90)){
-                                        //movx f
-                                        setup_s = "b" + QString::number(param::photo_width);
-                                        emit serial_data(m_json.MotorMove("movx",setup_s,""));
-                                        stitch_des = 8;
-                                    }
-                                }
-                                break;
-                            case 8:
-                                if(stitch_des==8){
-                                    param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-9.jpg");
-                                    LOG("pt9 is:{}",param::ptlist.at(8).toStdString());
-                                    if(m_image.save(param::ptlist.at(8),"jpg",90)){
-                                        param::camera_tc = 10;
-                                        stitch_des = 9;
-                                        max_image_qulity = 0.0;
-                                    }
-                                }
-                                break;
-                        }
-                            break;
-                    default:
-                        break;
-                    }
-                }
-#endif  //拼接
-
-
-#endif  //解析
-            m_fps_timer->incrementFrame();
-            }else{
-                qDebug() << "消息队列为空!";
-            }
-            frameMutex.unlock();
-            m_decoding = false;
-        });
-    }
-
-    if(param::camera_tc == 10){
-        emit signal_stitch();
-        setCameraSw(false);
-    }
-}
-
 
 void
 Frames::registerQmlType()
@@ -1472,17 +1054,12 @@ Frames::saveImage()
     emit qulityStringChanged();
     LOG("image_gray:{}",grayvalue);
     LOG("Tenengrad:{}",m_qulityString.toStdString());
-    if(grayvalue<50.0){
+    if(grayvalue<10.0){
         emit dataUpload(m_json.MakeJsonWarn("Photo ERROR",QString::number(grayvalue)));
         setCameraSw(false); //关闭相机
         emit signal_photoerr();
         return;
     }
-    // if(param::ptlist.empty()){
-    //     emit serial_data(m_json.MotorMove("movy","f20","1"));
-    // }else{
-    //     emit serial_data(m_json.MotorMove("movy","f4","1"));
-    // }
     #endif
 }
 
@@ -1605,16 +1182,6 @@ Frames::displayCameraError(){
     }
 }
 
-#if 0
-void
-Frames::sendImage(QImage frame){
-    m_pImgProvider->updateImage(frame);
-    emit callQmlRefeshImg();
-}
-#endif
-
-
-
 
 
 } /* namespace Qt6QCamera */

+ 3 - 7
q6_felgo_iot/src/m_json.cpp

@@ -104,14 +104,10 @@ JsonFunc::BoardMessage()
         }
     }
 
-    if (isConnected) {
-            param::net_alive = true;
-            net_value="0";
-        qDebug() << "已连接";
+    if (param::net_alive) {
+        net_value="0";
     } else {
-            param::net_alive = false;
-            net_value="1";
-        qDebug() << "未连接";
+        net_value="1";
     }
 
     QByteArray transmitDataTemp;

+ 39 - 1
q6_felgo_iot/src/m_opencv.cpp

@@ -1,7 +1,7 @@
 #include <m_opencv.h>
 #include <QDebug>
 #include <QString>
-
+#include <m_loger.h>
 OpencvFunc::OpencvFunc()
 {
 
@@ -121,6 +121,44 @@ QString OpencvFunc::Tenengrad(cv::Mat &image)
     return QString::number(sharpness,'f',3);
 }
 
+int OpencvFunc::CustomSharpening(const QString &path)
+{
+    Mat image = imread(path.toStdString());
+    if (image.empty()) {
+       ERROR("无法加载图像!");
+       return -1;
+    }
+    // 转换为浮点型以便进行精确计算
+    Mat srcFloat;
+    image.convertTo(srcFloat,CV_32F);
+    // 步骤1: 多尺度高斯模糊
+    Mat blurred1, blurred2;
+    GaussianBlur(srcFloat, blurred1, Size(0, 0), 1.0);
+    GaussianBlur(srcFloat, blurred2, Size(0, 0), 2.5);
+    // 步骤2: 计算细节层(多尺度)
+    Mat detail1 = srcFloat - blurred1;
+    Mat detail2 = blurred1 - blurred2;
+    // 步骤3: 自适应增强细节
+    // 创建边缘掩模以区分平坦区域和边缘区域
+    Mat edgeMask;
+    cv::Laplacian(srcFloat, edgeMask, CV_32F);
+    convertScaleAbs(edgeMask, edgeMask);
+    threshold(edgeMask, edgeMask, 20, 255, THRESH_BINARY);
+    // 对边缘区域使用较强锐化,平坦区域使用较弱锐化
+    Mat enhancedDetails;
+    detail1.copyTo(enhancedDetails);
+    // 边缘区域增强更多
+    Mat strongEnhance = detail1 * 1.8 + detail2 * 0.5;
+    strongEnhance.copyTo(enhancedDetails, edgeMask);
+    /// 步骤4: 将增强的细节加回原图
+    Mat result = srcFloat + enhancedDetails;
+    // 转换回8位图像
+    result.convertTo(result, CV_8U);
+    imwrite(path.toStdString(),result);
+    return 0;
+}
+
+
 Mat OpencvFunc::qim2mat(QImage &qim)
 {
     Mat mat;

+ 4 - 9
q6_felgo_iot/src/main.cpp

@@ -661,15 +661,10 @@ int main(int argc, char *argv[])
         gps_start->deleteLater();
     });
 
-    // 10秒后恢复屏幕休眠
-    // 延时一段时间后恢复屏幕常亮
-    QTimer::singleShot(10000, [](){
-        LOG("关闭屏幕背光");
-        #if 0
-        auto act = QJniObject(QtAndroidPrivate::activity());
-        QAndroidIntent activityIntent(act.object(),"com/yfkj/cb/Q6iot/MainActivity");
-        QtAndroidPrivate::startActivity(activityIntent.handle(),0);
-        #endif
+    // 每过24小时重启系统
+    QTimer::singleShot(1000*60*60*24, [](){
+        LOG("重启");
+        sendBroadcastFromQt("rebootSystem");
     });
     
 

+ 4 - 1
q6_felgo_iot/src/mqtthandler.cpp

@@ -141,6 +141,7 @@ MqttHandler::onConnected()
     if(m_client->state()==QMqttClient::Connected){
         emit connected();
         LOG("mqtt连接成功!");
+        param::net_alive = true;
         subscribe_m(param::mqtt_main_sub+param::imei);
         //QMqttTopicName topicName("/yfkj/bzy/c2s/202308051121");
         QByteArray da("turnon");
@@ -154,6 +155,7 @@ MqttHandler::onDisconnected()
     if(m_client->state()==QMqttClient::Disconnected){
         emit disconnected();
         ERROR("mqtt断开连接!");
+        param::net_alive = false;
         // Try to auto-reconnect
         QTimer::singleShot(10000, this, &MqttHandler::reConnect);
     }
@@ -236,7 +238,8 @@ MqttHandler::onMessageReceived(const QByteArray &message, const QMqttTopicName &
                       ||value_cmd=="windoff"
                       ||value_cmd=="translate"
                       ||value_cmd=="takephoto"
-                      ||value_cmd=="slide"){
+                      ||value_cmd=="slide"
+                      ||value_cmd=="sensor"){
                 emit dataReceived(m_client_dataBuf);
              }
         }

+ 1 - 1
q6_felgo_iot/src/mserial.cpp

@@ -132,7 +132,7 @@ SerialThread::SerialThread(QObject *parent)
     : QThread(parent), m_running(false)
 {
     QString directoryPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
-    getDirectoryStats(directoryPath);
+    analyzeDirectory(directoryPath);
     if(int_totalSize>=1073741824)
            deleteAllFilesInDirectory(directoryPath);
     QString db_config = "config.db";

+ 67 - 13
q6_felgo_iot/src/ymodem.cpp

@@ -35,6 +35,7 @@
 #include <QEventLoop>
 #include <QTimer>
 #include <QDateTime>
+#include <m_loger.h>
 
 YMODEM::YMODEM( SerialThread *sp, QObject *parent /*= 0*/ ) : QThread(parent)
 {
@@ -108,6 +109,7 @@ int YMODEM::yTransmitRead( unsigned short timeout )
 {
     char byte;
     int byte_int;
+
     m_serialPort->waitForReadyRead(timeout);
     m_serialPort->getChar(&byte);
     byte_int = byte;
@@ -146,12 +148,48 @@ void YMODEM::cancel()
     m_cancel = true;
 }
 
+
+// 配置串口为协议专用模式
+void YMODEM::configureForProtocolMode(bool enable)
+{
+    if (enable) {
+        // 禁用所有缓冲和非必要功能
+        m_serialPort->setReadBufferSize(128);
+        m_serialPort->clearError();
+
+// 在 Windows 上禁用底层缓冲
+#ifdef Q_OS_WIN
+        DCB dcb;
+        if (GetCommState(m_serialPort->handle(), &dcb)) {
+            dcb.fOutX = FALSE; // 禁用 XON/XOFF
+            dcb.fInX = FALSE;
+            dcb.fErrorChar = FALSE;
+            dcb.fNull = TRUE; // 丢弃 NULL 字符
+            dcb.fAbortOnError = TRUE;
+            SetCommState(m_serialPort->handle(), &dcb);
+        }
+#endif
+    } else {
+        // 恢复原始设置
+        m_serialPort->setReadBufferSize(0);
+    }
+}
+
+
 int YMODEM::yTransmit()
 {
-    qDebug() << "yTransmit!";
-    //m_serialPort->setPortName("ttyS4");
+    LOG("Starting YMODEM transmission...");
+
+
+    // 进入协议专用模式
+    m_serialPort->setDataTerminalReady(false);
+    m_serialPort->clear(QSerialPort::AllDirections);
+
+    // 配置特殊串口模式(忽略非协议字符)
+    configureForProtocolMode(true);
+
     if (!m_serialPort->open(QIODevice::ReadWrite)) {
-        qDebug() << "串口打开失败!";
+        ERROR("串口打开失败!");
         return -1;
     }
 
@@ -161,8 +199,16 @@ int YMODEM::yTransmit()
     QFileInfo fileInfo(m_fp);
     if (!file.open(QIODevice::ReadOnly))
         return MODEM_FILE_NOT_OPEN_ERROR;
+
+
+    // 预计算文件大小和块数
+    qint64 fileSize = file.size();
+    int totalBlocks = (fileSize + 1023) / 1024;
+    int currentBlock = 0;
+
     quint32 payloadSize = 1024; // 1K
     int response = 0;
+
     //尝试30次收不到C则返回
     for(int retry = 0; retry < 30; ++retry)
     {
@@ -180,7 +226,7 @@ int YMODEM::yTransmit()
         emit modem_result(MODEM_TIMEOUT);
         return MODEM_TIMEOUT;
     }
-    downloadStart("发送升级文件到控制模块!");
+    downloadStart(QString("Sending %1 (%2 bytes)").arg(fileInfo.fileName()).arg(fileSize));
     for(int retry = 0; retry < 10 && !m_cancel; ++retry)
     {
         int c;
@@ -194,7 +240,6 @@ int YMODEM::yTransmit()
             case NAK:
                 qDebug() << "NAK";
                 response = yTransmitPacket(fileInfo,file,payloadSize);
-
                 if (response == MODEM_RESTART)
                 {
                     file.seek(0);
@@ -213,7 +258,7 @@ int YMODEM::yTransmit()
                 break;
             default:
                 m_serialPort->clear(QSerialPort::Input);
-                qDebug() << "XYMODEM::yTransmit - Unknown : " << c;
+                qDebug() << "XYMODEM::yTransmit - Unknown : " << m_serialPort->readAll();;
                 break;
             }
         }
@@ -237,7 +282,6 @@ int YMODEM::yTransmit()
     }
 }
 
-
 int YMODEM::yTransmitPacket(const QFileInfo &fileInfo, QIODevice &dev, const quint32 &payloadSize, quint8 sequenceNum, bool firstPacket)
 {
     QByteArray payload;
@@ -299,14 +343,24 @@ int YMODEM::yTransmitPacket(const QFileInfo &fileInfo, QIODevice &dev, const qui
     Q_ASSERT(packet.size() == 1029);
     for (int retry = 0; retry < 10 && !m_cancel; ++retry) {
         yTransmitWrite(packet);
+        int time_read = 0;
+        while (firstPacket){
+            time_read++;
+            m_serialPort->waitForReadyRead(100);
+            dataBuf.append(m_serialPort->readAll());
+            LOG("Serial Read ALL:{}",dataBuf.constData());
+            if(dataBuf.contains("Size")||time_read>5){
+                break;
+            }
+        }
         if ((res = yTransmitRead(DLY_1S)) >= 0 ) {
             switch (res) {
             case ACK:
-                qDebug() << "ACK";
+                WARN("ACK");
                 return yTransmitPacket(fileInfo,dev,payloadSize,sequenceNum+1,false);
 
             case CAN:
-                qDebug() << "CAN";
+                WARN("CAN");
                 if ((res = yTransmitRead(DLY_1S)) == CAN) {
                     yTransmitWrite(ACK);
                     yTransmitFlush();
@@ -316,21 +370,21 @@ int YMODEM::yTransmitPacket(const QFileInfo &fileInfo, QIODevice &dev, const qui
                 }
                 break;
             case NAK:
-                qDebug() << "NAK";
+                 WARN("NAK");
                 break;
             case 'c':
             case 'C':
-                qDebug() << "C-2";
+                WARN("C");
                 return yTransmitPacket(fileInfo,dev,payloadSize,sequenceNum+1,false);
                 retry--;
                 continue;
             case '>':
                 return MODEM_RESTART;
             case '\0':
-                qDebug() << "\\0";
+                WARN('\0');
                 break;
             default:
-                qDebug() << "XYMODEM::yTransmitPacket - Unknown " << res;
+                ERROR("XYMODEM::yTransmitPacket - Unknown {}",res);
                 break;
             }
         }