Commit 3a53ac7d authored by 于水才's avatar 于水才

gongfu detect

parent 9b38daef
cmake-build-debug
data/*
model/*
out/*
weight
\ No newline at end of file
# Default ignored files # Default ignored files
/shelf/ /shelf/
/workspace.xml /workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files # Datasource local storage ignored files
/dataSources/ /dataSources/
/dataSources.local.xml /dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
<serverData>
<paths name="huawei (6bde78cd-c07c-4854-97ce-5e00fae79afe)">
<serverdata>
<mappings>
<mapping deploy="/usr/local/samples/cplusplus/level3_application/1_cv/detect_and_classify" local="$PROJECT_DIR$" />
</mappings>
<excludedPaths>
<excludedPath local="true" path="$PROJECT_DIR$/cmake-build-debug" />
<excludedPath local="true" path="$PROJECT_DIR$/cmake-build-debug" />
</excludedPaths>
</serverdata>
</paths>
</serverData>
</component>
</project>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/.idea/detect_and_classify.iml" filepath="$PROJECT_DIR$/.idea/detect_and_classify.iml" /> <module fileurl="file://$PROJECT_DIR$/.idea/atlas_huawei_cpp_demo.iml" filepath="$PROJECT_DIR$/.idea/atlas_huawei_cpp_demo.iml" />
</modules> </modules>
</component> </component>
</project> </project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoUploadManager">
<option name="hosts">
<list>
<option value="6bde78cd-c07c-4854-97ce-5e00fae79afe" />
</list>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
...@@ -155,6 +155,7 @@ namespace INSTANCENAME{ ...@@ -155,6 +155,7 @@ namespace INSTANCENAME{
const int COCO_PERSON_INFERENCE_INSTANCE = 4; const int COCO_PERSON_INFERENCE_INSTANCE = 4;
const int YANGCHEN_INFERENCE_INSTANCE = 5; const int YANGCHEN_INFERENCE_INSTANCE = 5;
const int MASK_INFERENCE_INSTANCE = 6; const int MASK_INFERENCE_INSTANCE = 6;
const int GONGFU_INFERENCE_INSTANCE =7;
} }
struct ObjDetectDataMsg { struct ObjDetectDataMsg {
......
[base_options] [base_options]
device_num = 3 device_num = 3
RtspNumPerDevice = 4 RtspNumPerDevice = 1
[options_param_0] [options_param_0]
inputType_0 = video inputType_0 = pic
outputType_0 = mqtt outputType_0 = pic
skip_0 = 25 skip_0 = 25
threshold_0 = 0.5 threshold_0 = 0.5
inputDataPath_0 = ../data/1920x1080test.mp4 inputDataPath_0 = ../data/data/pic/gongfu
outputFrameWidth_0 = 1280 outputFrameWidth_0 = 1280
outputFrameHeight_0 = 720 outputFrameHeight_0 = 720
......
...@@ -5,41 +5,21 @@ RtspNumPerDevice=1 # the number of rtsp/video running on each device is RtspNum ...@@ -5,41 +5,21 @@ RtspNumPerDevice=1 # the number of rtsp/video running on each device is RtspNum
[options_param_0] # 第1路的配置参数 [options_param_0] # 第1路的配置参数
inputType_0=video # 第1路的输入数据类型 inputType_0=pic # 第1路的输入数据类型
outputType_0=mqtt # 第1路的输出数据类型 outputType_0=pic # 第1路的输出数据类型
inputDataPath_0=../data/1920x1080test.mp4 # 第1cd路的输入数据路径 inputDataPath_0 = ../data/pic/t2 # 第1cd路的输入数据路径
#inputDataPath_0=../data/pic/t1 # 第1cd路的输入数据路径 #inputDataPath_0=../data/pic/t1 # 第1cd路的输入数据路径
outputFrameWidth_0=1280 outputFrameWidth_0=1280
skip_0=10 skip_0=10
threshold_0=0.45 threshold_0=0.5
outputFrameHeight_0=720 outputFrameHeight_0=720
[options_param_1] # 第1路的配置参数 #[options_param_1] # 第1路的配置参数
inputType_1=video # 第1路的输入数据类型 #inputType_1=video # 第1路的输入数据类型
outputType_1=mqtt # 第1路的输出数据类型 #outputType_1=mqtt # 第1路的输出数据类型
inputDataPath_1=../data/firetest2.mp4 # 第1cd路的输入数据路径 #inputDataPath_1=../data/firetest2.mp4 # 第1cd路的输入数据路径
#inputDataPath_0=../data/pic/t1 # 第1cd路的输入数据路径 #inputDataPath_0=../data/pic/t1 # 第1cd路的输入数据路径
skip_1=10 #skip_1=10
threshold_1=0.5 #threshold_1=0.5
outputFrameWidth_1=1280 #outputFrameWidth_1=1280
outputFrameHeight_1=720 #outputFrameHeight_1=720
[options_param_2] # 第1路的配置参数
inputType_2=video # 第1路的输入数据类型
outputType_2=mqtt # 第1路的输出数据类型
inputDataPath_2=../data/firetest.mp4 # 第1cd路的输入数据路径
#inputDataPath_0=../data/pic/t1 # 第1cd路的输入数据路径
skip_2=10
threshold_2=0.5
outputFrameWidth_2=1280
outputFrameHeight_2=720
[options_param_3] # 第1路的配置参数
inputType_3=video # 第1路的输入数据类型
outputType_3=mqtt # 第1路的输出数据类型
inputDataPath_3=../data/fireshow.mp4 # 第1cd路的输入数据路径
#inputDataPath_0=../data/pic/t1 # 第1cd路的输入数据路径
skip_3=10
threshold_3=0.5
outputFrameWidth_3=1280
outputFrameHeight_3=720
\ No newline at end of file
...@@ -138,6 +138,15 @@ public: ...@@ -138,6 +138,15 @@ public:
}; };
// 工服 -----------------------------------------------------------
class gongfuInferenceInstance : public GetInferenceInstance{
public:
gongfuInferenceInstance();
void Init(const char* kConfigFile) override;
~gongfuInferenceInstance();
void getInstance(std::vector<AclLiteThreadParam>& threadTbl, int32_t deviceId,aclrtContext& context, aclrtRunMode& runMode, int rtspNumPerDevice,bool kDisplay, int addrtspNumPerDevice=0);
};
...@@ -154,6 +163,7 @@ public: ...@@ -154,6 +163,7 @@ public:
case INSTANCENAME::YANGCHEN_INFERENCE_INSTANCE : return new yangChenInferenceInstance; case INSTANCENAME::YANGCHEN_INFERENCE_INSTANCE : return new yangChenInferenceInstance;
case INSTANCENAME::COCO_PERSON_INFERENCE_INSTANCE : return new cocoInferenceInstance; case INSTANCENAME::COCO_PERSON_INFERENCE_INSTANCE : return new cocoInferenceInstance;
case INSTANCENAME::MASK_INFERENCE_INSTANCE : return new centerfaceMaskInferenceInstance; case INSTANCENAME::MASK_INFERENCE_INSTANCE : return new centerfaceMaskInferenceInstance;
case INSTANCENAME::GONGFU_INFERENCE_INSTANCE : return new gongfuInferenceInstance;
default : break; default : break;
} }
} }
......
...@@ -680,4 +680,86 @@ void centerfaceMaskInferenceInstance::getInstance(std::vector<AclLiteThreadParam ...@@ -680,4 +680,86 @@ void centerfaceMaskInferenceInstance::getInstance(std::vector<AclLiteThreadParam
threadTbl.push_back(InferParam); threadTbl.push_back(InferParam);
} }
//---------------------------------------------------------------------------------------------------------------------------------- //工服 ----------------------------------------------------------------------------------------------------------------------------------
\ No newline at end of file gongfuInferenceInstance::gongfuInferenceInstance() {
}
void gongfuInferenceInstance::Init(const char *kConfigFile) {
kConfigFile_ = kConfigFile;
modelInfo_.classnum = 3;
modelInfo_.conf = 0.5;
modelInfo_.Label = { "xiaji_hese", "dongji_heise", "others"};
detectNameInfo_.kInferName = "gongfuference";
detectNameInfo_.kDetectPreName = "gongfudetectPre";
detectNameInfo_.kDetectPostName = "gongfudetectPost";
detectNameInfo_.kRtspUrl = "gongfurtspDisplay";
detectNameInfo_.kMqttName = "gongfumqtt";
modelInfo_.activateLabel = {0,1,2};
}
gongfuInferenceInstance::~gongfuInferenceInstance() {
}
void gongfuInferenceInstance::getInstance(std::vector<AclLiteThreadParam> &threadTbl, int32_t deviceId,
aclrtContext &context, aclrtRunMode &runMode, int rtspNumPerDevice,
bool kDisplay,int addrtspNumPerDevice) {
AclLiteThreadParam detectPreThreadParam;
for (int index = 0; index < rtspNumPerDevice + addrtspNumPerDevice; index++) {
int channelId = deviceId*rtspNumPerDevice+index;
if (kDisplay) {
detectPreThreadParam.threadInst =
new helmetPreprocessThread(kConfigFile_, deviceId, channelId, runMode, detectNameInfo_,true,1);
} else {
detectPreThreadParam.threadInst =
new helmetPreprocessThread(kConfigFile_, deviceId, channelId, runMode,detectNameInfo_,false,1);
}
std::string DetectPreName = detectNameInfo_.kDetectPreName + std::to_string(channelId);
detectPreThreadParam.threadInstName.assign(DetectPreName.c_str());
detectPreThreadParam.context = context;
detectPreThreadParam.runMode = runMode;
threadTbl.push_back(detectPreThreadParam);
//后处理
AclLiteThreadParam detectPostThreadParam;
detectPostThreadParam.threadInst = new onlyDetectPostprocessThread(kConfigFile_, channelId, modelInfo_);
std::string DetectPostName = detectNameInfo_.kDetectPostName + std::to_string(channelId);
detectPostThreadParam.threadInstName.assign(DetectPostName.c_str());
detectPostThreadParam.context = context;
detectPostThreadParam.runMode = runMode;
threadTbl.push_back(detectPostThreadParam);
//链接 MQTT
AclLiteThreadParam cocomqttThreadParam;
cocomqttThreadParam.threadInst = new MqttSendThread("0.0.0.0",1883);
std::string mqttName = detectNameInfo_.kMqttName + std::to_string(channelId);
cocomqttThreadParam.threadInstName.assign(mqttName.c_str());
cocomqttThreadParam.context = context;
cocomqttThreadParam.runMode = runMode;
threadTbl.push_back(cocomqttThreadParam);
if (readOutputTypeConfig(channelId)) {
AclLiteThreadParam rtspDisplayThreadParam;
rtspDisplayThreadParam.threadInst = new PushRtspThread(kRtspUrl_ + std::to_string(channelId));
std::string RtspDisplayName = detectNameInfo_.kRtspUrl + std::to_string(channelId);
rtspDisplayThreadParam.threadInstName.assign(RtspDisplayName.c_str());
rtspDisplayThreadParam.context = context;
rtspDisplayThreadParam.runMode = runMode;
threadTbl.push_back(rtspDisplayThreadParam);
}
}
//加载模型
AclLiteThreadParam InferParam;
InferParam.threadInst = new helmetDetectInferenceThread(runMode,INSTANCENAME::GONGFU_INFERENCE_INSTANCE); // helmetDetectInferenceThread 为仅检测的infer线程。
std::string InferName = detectNameInfo_.kInferName + std::to_string(deviceId);
InferParam.threadInstName.assign(InferName.c_str());
InferParam.context = context;
InferParam.runMode = runMode;
threadTbl.push_back(InferParam);
}
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
using namespace std; using namespace std;
// 这里只是模型和推理函数
helmetDetectInferenceThread::helmetDetectInferenceThread(aclrtRunMode& runMode,const int type) helmetDetectInferenceThread::helmetDetectInferenceThread(aclrtRunMode& runMode,const int type)
:runMode_(runMode), imageInfoSize_(0),imageInfoBuf_(nullptr), classifyInputSize_(0), classifyInputBuf_(nullptr) :runMode_(runMode), imageInfoSize_(0),imageInfoBuf_(nullptr), classifyInputSize_(0), classifyInputBuf_(nullptr)
{ {
...@@ -101,10 +101,17 @@ AclLiteError helmetDetectInferenceThread::DetectMsgSend(shared_ptr<ObjDetectData ...@@ -101,10 +101,17 @@ AclLiteError helmetDetectInferenceThread::DetectMsgSend(shared_ptr<ObjDetectData
return ACLLITE_OK; return ACLLITE_OK;
} }
// 工服 --------------------------------------------------------------
AclLiteError helmetDetectInferenceThread::ModelSwith(int type) { AclLiteError helmetDetectInferenceThread::ModelSwith(int type) {
switch (type) { switch (type) {
case INSTANCENAME::CAR_COLOR_INFERENCE_INSTANCE : kDetectModelPath_ = "../model/yolov3.om"; break; case INSTANCENAME::CAR_COLOR_INFERENCE_INSTANCE : kDetectModelPath_ = "../model/yolov3.om"; break;
case INSTANCENAME::HELMET_INFERENCE_INSTANCE : kDetectModelPath_ = "../model/helmet_3class_640x448_yuv420_zipp.om"; break; case INSTANCENAME::HELMET_INFERENCE_INSTANCE : kDetectModelPath_ = "../model/helmet_3class_640x448_yuv420_zipp.om"; break;
case INSTANCENAME::GONGFU_INFERENCE_INSTANCE : kDetectModelPath_ = "../weights/yolov5-6.0-gongfu-i14k-448_640_noaipp.om"; break;
case INSTANCENAME::FIRESMOKE_INFERENCE_INSTANCE : kDetectModelPath_ = "../model/firesmokem_ap95_079_640x448_yuvaipp448.om"; break; case INSTANCENAME::FIRESMOKE_INFERENCE_INSTANCE : kDetectModelPath_ = "../model/firesmokem_ap95_079_640x448_yuvaipp448.om"; break;
case INSTANCENAME::YANGCHEN_INFERENCE_INSTANCE : kDetectModelPath_ = "../model/yangchen/yangchen_yolo5s_640_448_ap95_044_rgb.om"; break; case INSTANCENAME::YANGCHEN_INFERENCE_INSTANCE : kDetectModelPath_ = "../model/yangchen/yangchen_yolo5s_640_448_ap95_044_rgb.om"; break;
case INSTANCENAME::COCO_PERSON_INFERENCE_INSTANCE : kDetectModelPath_ = "../model/coco/yolo5s_coco_640x448_yuvaipp448_rgb.om"; break; case INSTANCENAME::COCO_PERSON_INFERENCE_INSTANCE : kDetectModelPath_ = "../model/coco/yolo5s_coco_640x448_yuvaipp448_rgb.om"; break;
......
...@@ -247,7 +247,7 @@ void StartApp(AclLiteResource& aclDev,int programType,const char* configFile) ...@@ -247,7 +247,7 @@ void StartApp(AclLiteResource& aclDev,int programType,const char* configFile)
return; return;
} }
// -c /home/censoft/ysc/atlas_huawei_cpp_demo/scripts/2023_4_13_1.conf -p 4
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
cmdline::parser configArgs; cmdline::parser configArgs;
...@@ -259,7 +259,8 @@ int main(int argc, char** argv) ...@@ -259,7 +259,8 @@ int main(int argc, char** argv)
" 吸烟睡岗检测 id = 3" " 吸烟睡岗检测 id = 3"
" coco 人员检测 id = 4" " coco 人员检测 id = 4"
" 扬尘检测 id = 5" " 扬尘检测 id = 5"
" 口罩检测 id = 6", true,1); " 口罩检测 id = 6"
" 工服检测 id = 7", true,1);
// const int CAR_COLOR_INFERENCE_INSTANCE = 0; // const int CAR_COLOR_INFERENCE_INSTANCE = 0;
// const int HELMET_INFERENCE_INSTANCE = 1; // const int HELMET_INFERENCE_INSTANCE = 1;
......
aipp_op{
aipp_mode:static
src_image_size_w : 640
src_image_size_h : 448
crop:false
input_format : YUV420SP_U8
csc_switch : true
rbuv_swap_switch : false
matrix_r0c0 : 256
matrix_r0c1 : 0
matrix_r0c2 : 359
matrix_r1c0 : 256
matrix_r1c1 : -88
matrix_r1c2 : -183
matrix_r2c0 : 256
matrix_r2c1 : 454
matrix_r2c2 : 0
input_bias_0 : 0
input_bias_1 : 128
input_bias_2 : 128
mean_chn_0 : 0
mean_chn_1 : 0
mean_chn_2 : 0
min_chn_0 : 0.0
min_chn_1 : 0.0
min_chn_2 : 0.0
var_reci_chn_0 :0.003921568627451
var_reci_chn_1 :0.003921568627451
var_reci_chn_2 :0.003921568627451
}
\ No newline at end of file
{
"graph_fusion": {
"AConv2dMulFusion": {
"effect_times": "0",
"match_times": "57"
},
"ConstToAttrPass": {
"effect_times": "5",
"match_times": "5"
},
"ConstToAttrStridedSliceV2Fusion": {
"effect_times": "9",
"match_times": "9"
},
"ConvConcatFusionPass": {
"effect_times": "0",
"match_times": "17"
},
"ConvToFullyConnectionFusionPass": {
"effect_times": "0",
"match_times": "60"
},
"ConvWeightCompressFusionPass": {
"effect_times": "0",
"match_times": "60"
},
"FIXPIPEAPREQUANTFUSIONPASS": {
"effect_times": "0",
"match_times": "60"
},
"FIXPIPEFUSIONPASS": {
"effect_times": "0",
"match_times": "60"
},
"MulAddFusionPass": {
"effect_times": "0",
"match_times": "14"
},
"MulSquareFusionPass": {
"effect_times": "0",
"match_times": "69"
},
"Pow2SquareFusionPass": {
"effect_times": "3",
"match_times": "3"
},
"RefreshInt64ToInt32FusionPass": {
"effect_times": "1",
"match_times": "1"
},
"RemoveCastFusionPass": {
"effect_times": "0",
"match_times": "142"
},
"ReshapeTransposeFusionPass": {
"effect_times": "0",
"match_times": "3"
},
"SplitConvConcatFusionPass": {
"effect_times": "0",
"match_times": "17"
},
"StridedSliceRemovePass": {
"effect_times": "0",
"match_times": "9"
},
"SubFusionPass": {
"effect_times": "0",
"match_times": "3"
},
"TransdataCastFusionPass": {
"effect_times": "0",
"match_times": "63"
},
"TransposeSigmoidMulAddPowConcatFusionPass": {
"effect_times": "0",
"match_times": "3"
},
"TransposedUpdateFusionPass": {
"effect_times": "9",
"match_times": "9"
},
"V200NotRequantFusionPass": {
"effect_times": "0",
"match_times": "10"
},
"ZConcatDFusionPass": {
"effect_times": "0",
"match_times": "17"
}
},
"session_and_graph_id": "0_0",
"ub_fusion": {
"AutomaticUbFusion": {
"effect_times": "4",
"match_times": "4",
"repository_hit_times": "0"
},
"TbeAippCommonFusionPass": {
"effect_times": "1",
"match_times": "1",
"repository_hit_times": "0"
},
"TbeConvSigmoidMulQuantFusionPass": {
"effect_times": "56",
"match_times": "56",
"repository_hit_times": "0"
},
"TbeEltwiseFusionPass": {
"effect_times": "3",
"match_times": "3",
"repository_hit_times": "0"
}
}
}
\ No newline at end of file
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