人工智能线程在发送识别命令后,如果接收到返回的识别结果,需要将结果传输到主线程完成显示及控制。
void MainWindow::GetPythonData(MsgPython msgPython)
{
switch (msgPython.int_PythonInfo2Main) {
case CANNOTLOADPYTHON: //提示未能成功加载Python模块
QMessageBox::warning(NULL, "警告", "未能加载Python模块!", \
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
break;
case CANNOTLOADMAIN: //提示未能成功加载主函数模块
QMessageBox::warning(NULL, "警告", "未能加载主函数,请检查路径!", \
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
break;
case CANNOTLOADIMAGEPREDICT: //提示未能成功加载图像识别函数
QMessageBox::warning(NULL, "警告", "未能成功加载图像识别函数!", \
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
break;
case CANNOTLOADVOICESTART: //提示未能成功加载开始录音函数
QMessageBox::warning(NULL, "警告", "未能成功加载开始录音函数!", \
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
break;
case CANNOTLOADVOICESHORTPREDICT: //提示未能成功加载简易控制命令识别函数
QMessageBox::warning(NULL, "警告", "未能成功加载简易控制命令识别函数!", \
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
break;
case CANNOTLOADVOICELONGPREDICT: //提示未能成功加载搬运控制命令识别函数
QMessageBox::warning(NULL, "警告", "未能成功加载搬运控制命令识别函数!", \
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
break;
case IMAGEPREDICT1: //仓库一(图像不旋转)图像识别成功标志位
//在仓库一的界面上显示结果
Box1DisplayImagePredict(msgPython.str_PythonInfo2Main);
//如果是AR的识别
if(dealARFlag){
//以UDP单波的形式将识别后的结果发送出去
SendUniCast2AR(sendToARPlace + " " + box1OriginalPlace1.right(2) \
+ " " + box1OriginalPlace2.right(2) + " " + \
box1OriginalPlace3.right(2) + " " + box1OriginalPlace4.right(2));
//将界面上的显示清空
Box1DisplayImagePredict("1F2F3F4F");
//清除标志位
dealARFlag = false;
}
if(predictImageBoxAndSort == ASCENDING){
//识别成功后,往串口发送以升序排序信号
WriteSerialData(sendDataToSort + "61" + msgPython.str_
PythonInfo2Main);
}else if(predictImageBoxAndSort == DESCENDING){
//识别成功后,往串口发送以降序排序信号
WriteSerialData(sendDataToSort + "62" + msgPython.str_
PythonInfo2Main);
}
break;
//仓库二(图像旋转180°)图像识别成功标志位
case IMAGEPREDICT2:
//在仓库二的界面上显示结果
Box2DisplayImagePredict(msgPython.str_PythonInfo2Main);
break;
//短语音识别结束
case VOICEPREDICTSHORT:
//识别结果显示在左侧的label
if(msgPython.str_PythonInfo2Main != "ab"){
ui->label2_1->setText(" 成功");
WriteSerialData(sendDoAction + msgPython.str_PythonInfo2Main);
}else{
ui->label2_1->setText(" 失败");
}
break;
//长语音识别结束
case VOICEPREDICTLONG:
//识别结果显示在左侧的label
if(msgPython.str_PythonInfo2Main != "ab"){
ui->label22->setText(" 成功");
WriteSerialData(sendGoodsMoveData + msgPython.str
PythonInfo2Main);
}else{
ui->label2_2->setText(" 失败");
}
break;
default:
break;
}
}