Commit 22f4b088 by “liusq”

修复ping命令进程生命周期问题01

parent 6c388318
......@@ -143,7 +143,7 @@ int XNetSDK_MediaCallBack(XSDK_HANDLE hMedia, int nDataType, int nDataLen, int n
if (EXCMD_DOWNLOAD_DATA == nDataType)
{
qDebug()<<"EXCMD_DOWNLOAD_DATA"<<nDataType;
qInfo()<<"EXCMD_DOWNLOAD_DATA"<<nDataType;
/*if (g_hRecordDownload > 0 && g_hRecordDownload == hMedia)
{
......@@ -197,9 +197,9 @@ int XNetSDK_MediaCallBack(XSDK_HANDLE hMedia, int nDataType, int nDataLen, int n
// 等待 ffmpeg 进程结束
if (ffmpegProcess.waitForFinished(20000)) {
//QFile::remove(dName);
qDebug() << "ffmpeg process finished successfully.";
qInfo() << "ffmpeg process finished successfully.";
} else {
qDebug() << "Error: ffmpeg process did not finish.";
qInfo() << "Error: ffmpeg process did not finish.";
}
// 销毁 QProcess 对象
......@@ -354,7 +354,7 @@ void CameraHandle::sdkDownloadFileByTime(XSDK_HANDLE hDevice,int id,
//param.result = sdkInitCallback; // 结果回调(必填)
SMsgReceiver sms(nullptr,XNetSDK_MediaCallBack,this);
param.result=sms;
qDebug() << "XSDK_MediaRecordDownload hDevice:"<<this->hDevice;
qInfo() << "XSDK_MediaRecordDownload hDevice:"<<this->hDevice;
this->mediaHandle = XSDK_MediaRecordDownload(this->hDevice, &param, 0, 4000);
if ( this->mediaHandle < 0)
......@@ -390,7 +390,7 @@ int CameraHandle::callbackFunction(XSDK_HANDLE hObject, QString &szString) {
}
else
{
qDebug() << "OnDevAlarmCallback[Dev:" << hObject << "][Event:" << szString << "]";
qInfo() << "OnDevAlarmCallback[Dev:" << hObject << "][Event:" << szString << "]";
}
cv::Mat image;
MediaFaceImage* mediaFaceImage= MediaFaceImage::getInstance();
......@@ -429,7 +429,7 @@ void CameraHandle::sdkDevSnapSyn(XSDK_HANDLE hDevice, int nChannel){
int ret=mediaFaceImage->FaceImageCallBack(hDevice,nChannel, image);
if (ret < 0) {
offlineCount++; // 累加计数器
qDebug() << "offlineCount: " << loginParam->sDevId<<offlineCount;
qInfo() << "offlineCount: " << loginParam->sDevId<<offlineCount;
if (offlineCount >= 3) { // 判断是否连续3次返回0
qInfo() << "设备离线";
......@@ -954,7 +954,7 @@ void CameraHandle::printWifi(XSDK_HANDLE hDevice,XSDK_CFG::NetWork_Wifi &cfg){
// 获取并解析配置
int nResult = XSDK_DevGetSysConfigSyn(hDevice, JK_NetWork_Wifi, szOutBuffer, &nInOutSize, 3000, EXCMD_CONFIG_GET);
qDebug()<<szOutBuffer;
qInfo()<<szOutBuffer;
if (nResult >= 0) {
cfg.Parse(szOutBuffer);
......@@ -1009,7 +1009,7 @@ void CameraHandle::sdkDevSystemTimeZoneSyn(QString &time){
//录像设置
void CameraHandle::sdkRecordCfg(const char * recordJson){
qDebug()<<recordJson;
qInfo()<<recordJson;
char szOutBuffer[512] = { 0 };
int nLen = sizeof(szOutBuffer);;
int res=XSDK_DevSetSysConfigSyn(hDevice,JK_Record,recordJson,strlen(recordJson),szOutBuffer,&nLen,3000,EXCMD_CONFIG_SET);
......
......@@ -37,7 +37,7 @@ cv::Mat FaceReconitionHandle::loadImage(const QString &path) {
std::string stdPath = path.toStdString();
cv::Mat image = cv::imread(stdPath, cv::IMREAD_COLOR);
if (!image.empty()) {
qDebug() << "图像以OpenCV成功加载。";
qInfo() << "图像以OpenCV成功加载。";
return image;
}
......@@ -151,7 +151,7 @@ void FaceReconitionHandle::featureRemove(){
if(customIds.size()>0){
for(auto customId:customIds){
HResult ret= HF_FeaturesGroupFeatureRemove(ctxHandle,customId);
qDebug()<<"ret:featureRemove "<<ret;
qInfo()<<"ret:featureRemove "<<ret;
}
setImageChanged(false);
}
......@@ -180,10 +180,10 @@ cv::Mat FaceReconitionHandle::loadImageFromByteStream(const QString& filePath) {
}
return mat;
} catch (const CImgException& e) {
qDebug() << "CImg Error: " << e.what();
qInfo() << "CImg Error: " << e.what();
return cv::Mat();;
} catch (const cv::Exception& e) {
qDebug() << "OpenCV Error: " << e.what();
qInfo() << "OpenCV Error: " << e.what();
return cv::Mat(); ;
}
......@@ -218,7 +218,7 @@ void FaceReconitionHandle::doesItExistEmployee(const cv::Mat &source,std::list<v
HF_FaceContextRunFaceTrack(ctxHandle, imageSteamHandle, &multipleFaceData);
if (multipleFaceData.detectedNum <= 0) {
qDebug()<<QString("search 未检测到人脸");
qInfo()<<QString("search 未检测到人脸");
return ;
}
......@@ -227,11 +227,11 @@ void FaceReconitionHandle::doesItExistEmployee(const cv::Mat &source,std::list<v
HInt32 featureNum;
HF_GetFeatureLength(ctxHandle, &featureNum);
for(int j=0;j< multipleFaceData.detectedNum; ++j){
qDebug()<<QString("doesItExistEmployee==>面部索引: %1").arg(j);
qInfo()<<QString("doesItExistEmployee==>面部索引: %1").arg(j);
std::vector<float> newfeature(featureNum,0.0f);
ret = HF_FaceFeatureExtractCpy(ctxHandle, imageSteamHandle, multipleFaceData.tokens[j], newfeature.data());
if(ret != HSUCCEED) {
qDebug()<<QString("特征提取出错: %1").arg(ret);
qInfo()<<QString("特征提取出错: %1").arg(ret);
HF_ReleaseImageStream(imageSteamHandle);
return ;
}
......@@ -252,9 +252,9 @@ void FaceReconitionHandle::doesItExistEmployee(const cv::Mat &source,std::list<v
return ;
}
qDebug()<<QString("搜索置信度: %1").arg(confidence);
qDebug()<<QString("匹配到的tag: %1").arg(searchIdentity.tag);
qDebug()<<QString("匹配到的customId: %1").arg(searchIdentity.customId);
qInfo()<<QString("搜索置信度: %1").arg(confidence);
qInfo()<<QString("匹配到的tag: %1").arg(searchIdentity.tag);
qInfo()<<QString("匹配到的customId: %1").arg(searchIdentity.customId);
// Face Pipeline
//printf("人脸特征数量: %d", faceNum);
if (confidence > configConfidence) {
......
......@@ -391,7 +391,7 @@ inline QString getDefaultGateway() {
return gateway;
}
inline bool pingAddress(const QString &address) {
bool pingAddress(const QString &address) {
QProcess process;
QString program = "ping";
QStringList arguments;
......@@ -407,21 +407,28 @@ inline bool pingAddress(const QString &address) {
return false;
}
if (!process.waitForFinished(1000)) {
// 使用较长的超时值,确保进程有足够时间完成
if (!process.waitForFinished(3000)) {
process.kill(); // 如果超时,强制终止进程
return false;
}
QString output(process.readAllStandardOutput());
// 此处可以使用更复杂的逻辑来解析 Ping 输出
// 简单的 Ping 成功检查逻辑
#ifdef Q_OS_WIN
return output.contains("TTL=");
#else
return output.contains("1 packets transmitted, 1 received");
#endif
}
inline int GetCpuIdByAsm_arm(char* cpu_id)
{
FILE *fp = fopen("/proc/cpuinfo", "r");
if(nullptr == fp)
{
qDebug()<<"failed to open cpuinfo";
qInfo()<<"failed to open cpuinfo";
return -1;
}
......@@ -457,7 +464,7 @@ inline int GetCpuIdByAsm_arm(char* cpu_id)
inline QString getCpuSerialNumber() {
QFile file("/proc/cpuinfo");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "无法打开 /proc/cpuinfo 文件";
qInfo() << "无法打开 /proc/cpuinfo 文件";
return QString();
}
QTextStream in(&file);
......
......@@ -124,7 +124,7 @@ MainWindow::MainWindow()
if (!server.listen(QHostAddress::Any, port)) {
qInfo() << "Error: Unable to start the server on port 12345";
} else {
qDebug() << "Server started, listening on port 12345";
qInfo() << "Server started, listening on port 12345";
}
config.mqttConfig.clientId=serialNumber;
......@@ -253,7 +253,7 @@ void MainWindow::handleMatNewConnection(){
QRegExp urlRegEx("GET /cameras/([^/]+)/current_image HTTP");
if(urlRegEx.indexIn(request) != -1) {
QString sn = urlRegEx.cap(1);
qDebug() << "Requested Camera SN: " << sn;
qInfo() << "Requested Camera SN: " << sn;
bool foundCamera = false;
for (auto it = faceDetectionParkingPushs.begin(); it != faceDetectionParkingPushs.end(); ++it) {
QString currentSn = it->second->getSSn();
......@@ -307,7 +307,7 @@ void MainWindow::removeImageFiles(QString id){
QString value = localIt->second;
QFile file(value);
if (!file.open(QIODevice::WriteOnly)) {
qDebug() << "removeImageFiles open fail" << value;
qInfo() << "removeImageFiles open fail" << value;
} else {
file.remove();
}
......@@ -370,7 +370,7 @@ void MainWindow::updateLocalFace(const QString &httpurl) {
if (localIt != localImageMap.end()) {
QFile file(localIt->second);
if (!file.open(QIODevice::WriteOnly)) {
qDebug() << "open fail" << localIt->second;
qInfo() << "open fail" << localIt->second;
} else {
file.remove();
qSetting->beginGroup("localImageMap");
......@@ -716,14 +716,14 @@ void MainWindow::initEncodeToString(QString &enCodeJson) {
}
bool MainWindow::iniWorkSpVMn(vides_data::responseGb28181 *gb28181,QString &workSpWMn,QString &sn){
qDebug()<<"iniWorkSpVMn=="<<sn;
qInfo()<<"iniWorkSpVMn=="<<sn;
QString jsonfile=QCoreApplication::applicationDirPath()+"/camera_config.json";
bool isEqual=true;
// 读取 JSON 配置文件
QFile file(jsonfile);
if (!file.open(QIODevice::ReadOnly)) {
qDebug() << "Failed to open the camera_config.json";
qInfo() << "Failed to open the camera_config.json";
return isEqual;
}
QJsonObject toJsonObject;
......@@ -975,7 +975,7 @@ void MainWindow::initCameras(vides_data::cameraParameters &parameter,vides_data:
CameraHandle * cameraHandle =new CameraHandle(parameter.sDevId,parameter.httpUrl,parameter.sSn,parameter.channel,image_save,heightReference,devConfig);
int sdk_handle=cameraHandle->sdkDevLoginSyn(parameter.sDevId,parameter.nDevPort,parameter.sUserName,parameter.sPassword,3000);
qDebug()<<"句柄为2:"<<sdk_handle;
qInfo()<<"句柄为2:"<<sdk_handle;
if(sdk_handle<=0){
qInfo() << "登录失败";
return ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment