From 613fd1dfb3d0c3f9f4c63150dc589418b2c6ba75 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 2 Jun 2024 11:52:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=91=84=E5=83=8F=E5=A4=B4?= =?UTF-8?q?=E7=94=B5=E6=BA=90=E7=9A=84=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PhoneDevice.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index a303882b..ecb8836e 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -333,6 +333,7 @@ bool CPhoneDevice::SelfTest(std::string& result) std::string path = m_appPath + (APP_PATH_CHANNELS DIR_SEP_STR); unsigned char cameraId = 0; + unsigned char usbCamera = 0; Json::Value channelCfg = Json::objectValue; content.clear(); filePath = m_appPath + (APP_DATA_DIR DIR_SEP_STR APP_FILE_NAME_APP_CONF); @@ -348,7 +349,7 @@ bool CPhoneDevice::SelfTest(std::string& result) const char* doc = (const char*)&(content[0]); if (reader->parse(doc, doc + content.size(), &channelCfg, NULL)) { - unsigned char val = 0; + GetJSONUInt8Value(channelCfg, "usbCamera", usbCamera); if (GetJSONUInt8Value(channelCfg, "cameraId", cameraId)) { result += "通道" + std::to_string(channel) + " Camera ID为 " + std::to_string(cameraId) + "\r\n"; @@ -368,8 +369,19 @@ bool CPhoneDevice::SelfTest(std::string& result) int32_t width = 0; int32_t height = 0; NdkCamera::CAMERA_PARAMS params = { 0 }; + if (usbCamera) + { + TurnOnOtg(NULL); + } + TurnOnCameraPower(NULL); + NdkCamera camera(width, height, params); int res = camera.selfTest(std::to_string(cameraId), width, height); + TurnOffCameraPower(NULL); + if (usbCamera) + { + TurnOffOtg(NULL); + } if (res == 0) { result += "通道" + std::to_string(channel) + "正常:最大分辨率:" + std::to_string(width) + "x" + std::to_string(height) + "\r\n";