参见官网https://docs.openvinotoolkit.org/latest/_inference_engine_samples_crossroad_camera_demo_README.html
模仿security_barrier_camera _demo.sh创建一个crossroad_camera_demo.sh,用于播放一段mp4视频,识别人员、人员属性、人员记数。我写的脚本在文章结尾处,模仿security_barrier_camera _demo.sh的目的是让大家知道openVINO大概的框架和运行、编译、步骤,各文件所在目录。
运行crossroad_camera_demo.sh脚本时
1.下载英特尔型号
下载模型到/ home / root1 / openvino_models / ir / FP32 /路径下
家用/目录root1 / openvino_models / IR / FP32 /安全/ object_detection /十字路口/ 0078 / dldt /
家用/目录root1 / openvino_models / IR / FP32 /安全/ OBJECT_ATTRIBUTES /行人/人的属性识别-十字路口-0230 / dldt /
家用/目录root1 / openvino_models / IR / FP32 /零售/ object_reidentification /行人/ rmnet_based / 0079 / dldt /
2.建立样本
编译/选择/英特尔/ openvino / inference_engine /样品/ crossroad_camera_demo
到/家庭/目录root1 / inference_engine_samples_build / Intel64位/发行/下
3.执行crossroad_camera_demo
./crossroad_camera_demo -d CPU -i /opt/intel/openvino/deployment_tools/demo/1.mp4 -m / home / root1 / openvino_models / ir / FP32 / Security / object_detection / crossroad / 0078 / dldt / person-vehicle-bike -detection-crossroad-0078.xml -m_pa /home/root1/openvino_models/ir/FP32/Security/object_attributes/pedestrian/person-attributes-recognition-crossroad-0230/dldt/person-attributes-recognition-crossroad-0230.xml -m_reid /home/root1/openvino_models/ir/FP32/Retail/object_reidentification/pedestrian/rmnet_based/0079/dldt/person-reidentification-retail-0079.xml
如果运行出现以下错误,一般都是环境变量地址错误引起的,先把环境变量脚本运行起来。
请参考如下处理步骤:
if [-e“$ ROOT_DIR /../../ bin / setupvars.sh”]; 然后
setupvars_path = “$ ROOT_DIR /../../斌/ setupvars.sh”
其他
printf“错误:找不到setupvars.sh \ n”
科幻
如果!。$ setupvars_path; 然后
printf "Unable to run ./setupvars.sh. Please check its presence. ${run_again}"
exit 1
fi
4、使用./crossroad_camera_demo -h 可查看参数
-h打印用法消息。
-i“
-m“
-m_pa“
-m_reid“
-l“
要么
-c“
-d“
-d_pa“
-d_reid“
-pc可选。启用每层性能统计信息。
-r可选。输出推断结果为原始值。
-t可选。人/车/自行车十字路口检测的概率阈值。
-t_reid可选。用于人重新识别的两个向量之间的余弦相似性阈值。
-no_show可选。没有显示处理过的视频
-auto_resize可选。支持可调整大小的输入,支持ROI裁剪和自动调整大小。
./crossroad_camera_demo -d CPU
-i /opt/intel/openvino/deployment_tools/demo/1.mp4
-m /home/root1/openvino_models/ir/FP32/Security/object_detection/crossroad/0078/dldt/person-vehicle-bike-detection-crossroad-0078.xml
-m_pa /home/root1/openvino_models/ir/FP32/Security/object_attributes/pedestrian/person-attributes-recognition-crossroad-0230/dldt/person-attributes-recognition-crossroad-230.xml
-m_reid /home/root1/openvino_models/ir/FP32/Retail/object_reidentification/pedestrian/rmnet_based/0079/dldt/person-reidentification-retail-0079.xml
5 以下贴出脚本完整代码,创建一个crossroad_camera_demo.sh,把以下代码粘贴进去。
#!/usr/bin/env bash
target="CPU"
target_precision="FP32"
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
target_image_path="$ROOT_DIR/1.mp4"
if [ -e "$ROOT_DIR/../../bin/setupvars.sh" ]; then
setupvars_path="$ROOT_DIR/../../bin/setupvars.sh"
else
printf "Error: setupvars.sh is not found\n"
fi
if ! . $setupvars_path ; then
printf "Unable to run ./setupvars.sh. Please check its presence. ${run_again}"
exit 1
fi
# Step 1. Downloading Intel models
printf "Downloading Intel models\n"
downloader_path="${INTEL_OPENVINO_DIR}/deployment_tools/tools/model_downloader/downloader.py"
models_path="$HOME/openvino_models/ir/${target_precision}"
person_attributes_recognition_crossroad=person-attributes-recognition-crossroad-0230
person_vehicle_bike_detection_crossroad=person-vehicle-bike-detection-crossroad-0078
person_reidentification_retail=person-reidentification-retail-0079
person_attributes_recognition_crossroad_path=${models_path}/Security/object_attributes/pedestrian/${person_attributes_recognition_crossroad}/dldt/${person_attributes_recognition_crossroad}
person_vehicle_bike_detection_crossroad_path=${models_path}/Security/object_detection/crossroad/0078/dldt/${person_vehicle_bike_detection_crossroad}
person_reidentification_retail_path=${models_path}/Retail/object_reidentification/pedestrian/rmnet_based/0079/dldt/${person_reidentification_retail}
# 下载模型
if ! [ -f "${person_attributes_recognition_crossroad_path}.xml" ] && ! [ -f "${person_attributes_recognition_crossroad_path}.bin" ]; then
printf "\nRun $downloader_path --name $person_attributes_recognition_crossroad --output_dir ${models_path}\n\n"
$python_binary $downloader_path --name $person_attributes_recognition_crossroad --output_dir ${models_path}
else
printf "\n${person_attributes_recognition_crossroad} have been loaded previously, skip loading model step."
fi
if ! [ -f "${person_vehicle_bike_detection_crossroad_path}.xml" ] && ! [ -f "${person_vehicle_bike_detection_crossroad_path}.bin" ]; then
printf "\nRun $downloader_path --name $person_vehicle_bike_detection_crossroad --output_dir ${models_path}\n\n"
$python_binary $downloader_path --name $person_vehicle_bike_detection_crossroad --output_dir ${models_path}
else
printf "\n${person_vehicle_bike_detection_crossroad} have been loaded previously, skip loading model step."
fi
if ! [ -f "${person_reidentification_retail_path}.xml" ] && ! [ -f "${person_reidentification_retail_path}.bin" ]; then
printf "\nRun $downloader_path --name $person_reidentification_retail --output_dir ${models_path}\n\n"
$python_binary $downloader_path --name $person_reidentification_retail --output_dir ${models_path}
else
printf "\n${person_reidentification_retail} have been loaded previously, skip loading model step.\n\n"
fi
# Step 2. Build samples
printf "Build Inference Engine samples\n"
samples_path="${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/samples"
#是否存在cmake命令
if ! command -v cmake &>/dev/null; then
printf "\n\nCMAKE is not installed. It is required to build Inference Engine samples. Please install it. ${run_again}"
exit 1
fi
# demo所在目录
OS_PATH=$(uname -m)
NUM_THREADS="-j2"
if [ $OS_PATH == "x86_64" ]; then
OS_PATH="intel64"
NUM_THREADS="-j8"
fi
build_dir="$HOME/inference_engine_samples_build"
if [ -e $build_dir/CMakeCache.txt ]; then
rm -rf $build_dir/CMakeCache.txt
fi
mkdir -p $build_dir
cd $build_dir
# 编译demo
# cmake -DCMAKE_BUILD_TYPE=Release $samples_path
# make $NUM_THREADS crossroad_camera_demo
# Step 3. Run samples
binaries_dir="${build_dir}/${OS_PATH}/Release"
cd $binaries_dir
# ./crossroad_camera_demo -d CPU
# -i /opt/intel/openvino/deployment_tools/demo/1.mp4
# -m /home/root1/openvino_models/ir/FP32/Security/object_detection/crossroad/0078/dldt/person-vehicle-bike-detection-crossroad-0078.xml
# -m_pa /home/root1/openvino_models/ir/FP32/Security/object_attributes/pedestrian/person-attributes-recognition-crossroad-0230/dldt/person-attributes-recognition-crossroad-0230.xml
# -m_reid /home/root1/openvino_models/ir/FP32/Retail/object_reidentification/pedestrian/rmnet_based/0079/dldt/person-reidentification-retail-0079.xml
printf "Run ./crossroad_camera_demo -d $target -i $target_image_path -m "${person_vehicle_bike_detection_crossroad_path}.xml" -m_pa "${person_attributes_recognition_crossroad_path}.xml" -m_reid "${person_reidentification_retail_path}.xml" \n\n"
./crossroad_camera_demo -d $target -i $target_image_path -m "${person_vehicle_bike_detection_crossroad_path}.xml" -m_pa "${person_attributes_recognition_crossroad_path}.xml" -m_reid "${person_reidentification_retail_path}.xml"
printf "Demo completed successfully.\n\n"
# -i“
# -m“
# -m_pa“
# -m_reid“
# -l“
# 要么
# -c“
# -d“
# -d_pa“
#-d_reid“
#-pc可选。启用每层性能统计信息。
#-r可选。输出推断结果为原始值。
#-t可选。人/车/自行车十字路口检测的概率阈值。
#-t_reid可选。用于人重新识别的两个向量之间的余弦相似性阈值。
#-no_show可选。没有显示处理过的视频
#-auto_resize可选。支持可调整大小的输入,支持ROI裁剪和自动调整大小。