查看: 6407|回复: 2

【角蜂鸟试用】2.SungemSDK-ROS源码浅析及目标检测体验

[复制链接]
  • TA的每日心情
    开心
    2018-9-6 15:08
  • 签到天数: 11 天

    连续签到: 1 天

    [LV.3]偶尔看看II

    发表于 2018-8-15 09:45:17 | 显示全部楼层 |阅读模式
    分享到:
    本帖最后由 阿莫斯 于 2018-8-15 10:51 编辑

                                                       基于ROS智能陪伴扫地机:2.源码浅析及目标检测实例


    一、角蜂鸟程序架构和流程

    思路:以linux系统Python开发环境的example示例分析程序流程,再ROS环境下将以上example示例再移植一遍;
    为什么这样操作?

    首先本人是图像识别初学者对整个图像识别流程不太熟悉,
    其次官网中对Python的例程资料最多,ROS实例的教程官网还未做出,因此只能自己撸代码;

    linux系统Python开发环境为例:

    • 人脸检测器
    • 物体检测器
    • 情景记录器
    • 图像识别器(底层API教程)
    • 人脸检测+识别器(双角蜂鸟集联教程)
    • OCR 文字检测识别 (进行中)

    拓展到ROS环境下实例:

    <占位符>后续填充


    二、分析SungemSDK-ROS文件架构

    1. <font size="1">├── object_msgs
    2. │   ├── CMakeLists.txt
    3. │   ├── msg
    4. │   │   ├── ObjectInBox.msg
    5. │   │   ├── Object.msg
    6. │   │   ├── ObjectsInBoxes.msg
    7. │   │   └── Objects.msg
    8. │   └── package.xml
    9. ├── Readme.md
    10. └── ros_horned_sungem
    11.     ├── horned_sungem_example
    12.     │   ├── CMakeLists.txt
    13.     │   ├── package.xml
    14.     │   └── src
    15.     │       ├── stream_classification.cpp
    16.     │       └── stream_detection.cpp
    17.     ├── horned_sungem_launch
    18.     │   ├── CMakeLists.txt
    19.     │   ├── config
    20.     │   │   ├── alexnet.yaml
    21.     │   │   ├── googlenet.yaml
    22.     │   │   ├── inception_v1.yaml
    23.     │   │   ├── inception_v2.yaml
    24.     │   │   ├── inception_v3.yaml
    25.     │   │   ├── inception_v4.yaml
    26.     │   │   ├── mobilenetssd.yaml
    27.     │   │   ├── mobilenet.yaml
    28.     │   │   ├── squeezenet.yaml
    29.     │   │   └── yolo.yaml
    30.     │   ├── launch
    31.     │   │   ├── hs_camera.launch
    32.     │   │   ├── hs_classification_example.launch
    33.     │   │   ├── hs_detection_example.launch
    34.     │   │   └── includes
    35.     │   │       ├── hs_stream_classification.launch
    36.     │   │       └── hs_stream_detection.launch
    37.     │   └── package.xml
    38.     ├── horned_sungem_lib
    39.     │   ├── CMakeLists.txt
    40.     │   ├── include
    41.     │   │   └── horned_sungem_lib
    42.     │   │       ├── connect.h
    43.     │   │       ├── device.h
    44.     │   │       ├── exception.h
    45.     │   │       ├── exception_util.h
    46.     │   │       ├── graph.h
    47.     │   │       ├── hs_cpp.h
    48.     │   │       ├── hs_manager.h
    49.     │   │       ├── result.h
    50.     │   │       └── tensor.h
    51.     │   ├── package.xml
    52.     │   └── src
    53.     │       ├── connect.cpp
    54.     │       ├── device.cpp
    55.     │       ├── exception.cpp
    56.     │       ├── exception_util.cpp
    57.     │       ├── graph.cpp
    58.     │       ├── hs_manager.cpp
    59.     │       ├── result.cpp
    60.     │       └── tensor.cpp
    61.     └── horned_sungem_stream
    62.         ├── CMakeLists.txt
    63.         ├── include
    64.         │   └── horned_sungem_stream
    65.         │       └── hs_nodelet.h
    66.         ├── nodelet_plugins.xml
    67.         ├── package.xml
    68.         └── src
    69.             └── hs_nodelet.cpp

    70. 17 directories, 52 files</font>
    复制代码
    2.1 SungemSDK-ROS一级目录下内容是:
    • object_msgs 包中使用的消息类型信息;
    • Readme.md  提示文档
    • ros_horned_sungem 核心部分:角蜂鸟包

    2.2 ros_horned_sungem对应的二级目录下内容是:
    • horned_sungem_example ,
    • horned_sungem_launch ,类似批处理的launch启动文件
    • horned_sungem_lib ,
    • horned_sungem_stream,


    三、分析horned_sungem_launch包3.1.初步分析
    官网教程中调用的第一个launch文件是
    1. roslaunch horned_sungem_launch hs_camera.launch cnn_type:=googlenet camera:=hs pixels:=360
    复制代码
    调用的包是horned_sungem_launch,启动的文件是hs_camera.launch,
    设置的参数是
    • cnn_type:模型名称,googlenet表示模模型是图像识别模型
    • camera : 摄像头类型,hs表示摄像头为角蜂鸟摄像头
    • pixels :像素,360表示为360p

    关于整个系统的参数有哪些可以用rostopic list查看
    1. amos@amos-desktop:~/catkin_ws/src/SungemSDK-ROS/ros_horned_sungem$ rosparam  list
    2. /horned_sungem_nodelet/horned_sungem_stream/camera
    3. /horned_sungem_nodelet/horned_sungem_stream/category_file_path
    4. /horned_sungem_nodelet/horned_sungem_stream/channel1_mean
    5. /horned_sungem_nodelet/horned_sungem_stream/channel2_mean
    6. /horned_sungem_nodelet/horned_sungem_stream/channel3_mean
    7. /horned_sungem_nodelet/horned_sungem_stream/cnn_type
    8. /horned_sungem_nodelet/horned_sungem_stream/graph_file_path
    9. /horned_sungem_nodelet/horned_sungem_stream/log_level
    10. /horned_sungem_nodelet/horned_sungem_stream/max_device_number
    11. /horned_sungem_nodelet/horned_sungem_stream/network_dimension
    12. /horned_sungem_nodelet/horned_sungem_stream/pixels
    13. /horned_sungem_nodelet/horned_sungem_stream/scale
    14. /horned_sungem_nodelet/horned_sungem_stream/start_device_index
    15. /horned_sungem_nodelet/horned_sungem_stream/top_n
    16. /hs/camera/image_raw/compressed/format
    17. /hs/camera/image_raw/compressed/jpeg_quality
    18. /hs/camera/image_raw/compressed/png_level
    19. /hs/camera/image_raw/compressedDepth/depth_max
    20. /hs/camera/image_raw/compressedDepth/depth_quantization
    21. /hs/camera/image_raw/compressedDepth/png_level
    22. /hs/camera/image_raw/theora/keyframe_frequency
    23. /hs/camera/image_raw/theora/optimize_for
    24. /hs/camera/image_raw/theora/quality
    25. /hs/camera/image_raw/theora/target_bitrate
    26. /rosdistro
    27. /roslaunch/uris/host_amos_desktop__42426
    28. /rosversion
    29. /run_id
    复制代码

    启动摄像头

    启动摄像头

    从直观的功能角度来看,它是启动了摄像头和配置了某一种卷积神经网络算法(cnn),打开了设备并加装了摄像头拍摄的图片!

    官网教程中调用的第二个launch文件是
    1. roslaunch horned_sungem_launch hs_classification_example.launch camera_topic:="/hs/camera/image_raw"
    复制代码
    调用的包是horned_sungem_launch,启动的文件是hs_classification_example.launch,
    设置的参数是
    • camera_topic:摄像头话题,/hs/camera/image_raw表示从角蜂鸟摄像头获取图片;

    启动图片阅读器

    启动图片阅读器

    终端虽然会报错,但是iamge_viewer可以正常启动!不会影响ROS的正常使用,可以不用处理!
    (补充:libEGL问题是树莓派会有的问题,https://pi3d.github.io/html/FAQ.html )
    从直观的功能角度来看,它打了image_viewer窗口,将摄像头拍照和检测结果同步显示出!

    这仅仅是官方的一个ROS执行示例,也是唯一示例!
    那如果用户想体验和执行其他的类似Python教程的中的示例该怎么办呢?或者更简单的实现官网图片中的yolo卷积神经网络算法呢?
    实测:yolo替代googlenet
    1. roslaunch horned_sungem_launch hs_camera.launch cnn_type:=yolo camera:=hs pixels:=360
    复制代码
    1. roslaunch horned_sungem_launch hs_classification_example.launch camera_topic:="/hs/camera/image_raw"
    复制代码
    以上操作虽然不报错,但是iamge_viewer不会启动,不知道是什么情况!!!那么只有通过分析源码,来一探其用法了!

    3.2.进一步分析源码

    以上两次指令执行的包都是horned_sungem_launch,其实它并不是源码功能包,这是一个启动文件包,它可以一次启动多个功能包,有点类似批处理功能,同时能够进行参数配置(缺省时为默认配置),同时可以修改节点的名称!下面具体分析上面两条指令的内容:
    3.2.1 hs_camera.launch
    具体分析是如何执行的!
    文件在~/catkin_ws/src/SungemSDK-ROS/ros_horned_sungem/horned_sungem_launch/launch/路径下,内容如下:
    1. <!--
    2. Copyright (c) 2018 HornedSungem Corporation

    3. Licensed under the Apache License, Version 2.0 (the "License");
    4. you may not use this file except in compliance with the License.
    5. You may obtain a copy of the License at

    6.      http://www.apache.org/licenses/LICENSE-2.0

    7. Unless required by applicable law or agreed to in writing, software
    8. distributed under the License is distributed on an "AS IS" BASIS,
    9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    10. See the License for the specific language governing permissions and
    11. limitations under the License.
    12. -->

    13. <launch>
    14.   <!-- 一堆参数配置 -->
    15.   <arg name="manager" default="hornedsungem_manager" />
    16.   <arg name="namespace" default="horned_sungem_nodelet" />

    17.   <!-- CNN model related parameter -->
    18.   <arg name="cnn_type" default="googlenet" />
    19.   <arg name="output_topic" value="classified_objects"
    20.        if="$(eval cnn_type == 'alexnet' or cnn_type == 'googlenet'
    21.        or cnn_type == 'inception_v1' or cnn_type == 'inception_v2'
    22.        or cnn_type == 'inception_v3' or cnn_type == 'inception_v4'
    23.        or cnn_type == 'mobilenet' or cnn_type == 'squeezenet')" />
    24.   <arg name="output_topic" value="detected_objects" if="$(eval cnn_type == 'yolo' or cnn_type == 'mobilenetssd')" />
    25.   <arg name="param_file" value="$(find horned_sungem_launch)/config/alexnet.yaml" if="$(eval cnn_type == 'alexnet')"/>
    26.   <arg name="param_file" value="$(find horned_sungem_launch)/config/googlenet.yaml" if="$(eval cnn_type == 'googlenet')"/>
    27.   <arg name="param_file" value="$(find horned_sungem_launch)/config/inception_v1.yaml" if="$(eval cnn_type == 'inception_v1')"/>
    28.   <arg name="param_file" value="$(find horned_sungem_launch)/config/inception_v2.yaml" if="$(eval cnn_type == 'inception_v2')"/>
    29.   <arg name="param_file" value="$(find horned_sungem_launch)/config/inception_v3.yaml" if="$(eval cnn_type == 'inception_v3')"/>
    30.   <arg name="param_file" value="$(find horned_sungem_launch)/config/inception_v4.yaml" if="$(eval cnn_type == 'inception_v4')"/>
    31.   <arg name="param_file" value="$(find horned_sungem_launch)/config/mobilenet.yaml" if="$(eval cnn_type == 'mobilenet')"/>
    32.   <arg name="param_file" value="$(find horned_sungem_launch)/config/squeezenet.yaml" if="$(eval cnn_type == 'squeezenet')"/>
    33.   <arg name="param_file" value="$(find horned_sungem_launch)/config/yolo.yaml" if="$(eval cnn_type == 'yolo')"/>
    34.   <arg name="param_file" value="$(find horned_sungem_launch)/config/mobilenetssd.yaml" if="$(eval cnn_type == 'mobilenetssd')"/>
    35.   <arg name="top_n" default="3" />

    36.   <!-- HS related parameter -->
    37.   <arg name="max_device_number" default="255" />
    38.   <arg name="start_device_index" default="0" />
    39.   <arg name="log_level" default="1" />


    40.   <!-- camera related parameters -->
    41.   <arg name="camera" default="hs" />
    42.   <arg name="frame_topic" value="/usb_cam/image_raw" if="$(eval camera == 'usb')" />
    43.   <arg name="frame_topic" default="/hs/camera/image_raw" if="$(eval camera == 'hs')" />
    44.       
    45.   <!-- camera size parameters -->
    46.   <arg name="pixels" default="360" />

    47.   <!-- 启动摄像头节点 -->
    48.   <!-- launch usb camera with the relevant parameters if any -->
    49.   <group if="$(eval camera == 'usb')">
    50.     <arg name="image_width" default="640" />
    51.     <arg name="image_height" default="480" />
    52.     <arg name="video_device" default="/dev/video0" />

    53.     <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
    54.       <param name="video_device" value="$(arg video_device)" />
    55.       <param name="image_width" value="$(arg image_width)" />
    56.       <param name="image_height" value="$(arg image_height)" />
    57.       <param name="pixel_format" value="yuyv" />
    58.       <param name="camera_frame_id" value="usb_cam" />
    59.       <param name="io_method" value="mmap"/>
    60.     </node>
    61.   </group>

    62. <!-- 启动角蜂鸟节点 -->
    63. <!-- launch HS nodelet -->
    64.   <group ns="$(arg namespace)">
    65.     <node pkg="nodelet" type="nodelet" name="$(arg manager)" args="manager" output="screen" />
    66.    
    67.     <!-- 分类处理 -->
    68.     <!-- for classification -->
    69.     <group if="$(eval cnn_type == 'alexnet' or cnn_type == 'googlenet'
    70.              or cnn_type == 'inception_v1' or cnn_type == 'inception_v2'
    71.              or cnn_type == 'inception_v3' or cnn_type == 'inception_v4'
    72.              or cnn_type == 'mobilenet' or cnn_type == 'squeezenet')">
    73.       <include file="$(find horned_sungem_launch)/launch/includes/hs_stream_classification.launch">
    74.         <arg name="manager" value="$(arg manager)" />
    75.         <arg name="frame_topic" value="$(arg frame_topic)" />
    76.         <arg name="output_topic" value="$(arg output_topic)" />
    77.         <arg name="max_device_number" value="$(arg max_device_number)" />
    78.         <arg name="start_device_index" value="$(arg start_device_index)" />
    79.         <arg name="log_level" value="$(arg log_level)" />
    80.         <arg name="top_n" value="$(arg top_n)" />
    81.         <arg name="pixels" value="$(arg pixels)" />
    82.         <arg name="camera" value="$(arg camera)"/>
    83.         <arg name="cnn_type" value="$(arg cnn_type)"  />
    84.         <arg name="param_file" value="$(arg param_file)" />
    85.       </include>
    86.     </group>
    87.    
    88.     <!-- 检测处理 -->
    89.     <!-- for detection -->
    90.     <group if="$(eval cnn_type == 'mobilenetssd' or cnn_type == 'yolo')">
    91.       <include file="$(find horned_sungem_launch)/launch/includes/hs_stream_detection.launch">
    92.         <arg name="manager" value="$(arg manager)" />
    93.         <arg name="frame_topic" value="$(arg frame_topic)" />
    94.         <arg name="output_topic" value="$(arg output_topic)" />
    95.         <arg name="max_device_number" value="$(arg max_device_number)" />
    96.         <arg name="start_device_index" value="$(arg start_device_index)" />
    97.         <arg name="log_level" value="$(arg log_level)" />
    98.         <arg name="top_n" value="$(arg top_n)" />
    99.         <arg name="pixels" value="$(arg pixels)" />
    100.         <arg name="camera" value="$(arg camera)"/>
    101.         <arg name="cnn_type" value="$(arg cnn_type)"  />
    102.         <arg name="param_file" value="$(arg param_file)" />
    103.       </include>
    104.     </group>
    105.   </group>
    106. </launch>
    复制代码
    代码解释:代码可以分成四段
    • ①<!-- 一堆参数配置 -->
    • <!-- 启动摄像头节点 -->
    • ③<!-- 启动角蜂鸟节点 -->
               <!-- 分类处理 --> 或<!-- 检测处理 -->

    1).参数配置:
    1. <arg name="manager" default="hornedsungem_manager" />
    复制代码
    1. <arg name="param_file" value="$(find horned_sungem_launch)/config/googlenet.yaml" if="$(eval cnn_type == 'googlenet')"/>
    复制代码
    前面为参数名,后面对参数名的赋值,这个参数配置是全局的,有直接对参数赋值的,也有通过加载参数配置文件yaml文件进行赋值的!
    8种cnn模式对应了8份yaml配置文件,实际使用时选择其一!特别注意:output_topic参数的赋值根据cnn的模式分了两类:classified_objects和detected_objects,此次带过,后续详解;
    以上参数配置分别对识别的模式,摄像头的像素等方面进行了配置!

    2).启动摄像头节点
    1. <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
    复制代码
    3).启动角蜂鸟节点
    1. <node pkg="nodelet" type="nodelet" name="$(arg manager)" args="manager" output="screen" />
    复制代码
    分类再一次出现,也是根据对角蜂鸟模式cnn_type的选择,因此将其暂时分为两大类classification和detection,二选一:
    1. <!-- for classification -->
    2.     <group if="$(eval cnn_type == 'alexnet' or cnn_type == 'googlenet'
    3.              or cnn_type == 'inception_v1' or cnn_type == 'inception_v2'
    4.              or cnn_type == 'inception_v3' or cnn_type == 'inception_v4'
    5.              or cnn_type == 'mobilenet' or cnn_type == 'squeezenet')">
    6.      ......
    7. <!-- for detection -->
    8.      <group if="$(eval cnn_type == 'mobilenetssd' or cnn_type == 'yolo')">
    复制代码
    这两大类又分别调用了不同的launch文件;
    1. <include file="$(find horned_sungem_launch)/launch/includes/hs_stream_classification.launch">
    复制代码
    1. <include file="$(find horned_sungem_launch)/launch/includes/hs_stream_detection.launch">
    复制代码
    在此本人小白,觉得有必要科普下Detection和Classification,目标检测是根据阈值获得Bounding box (两类问题),分类检测是将分割后的内容直接进行分类处理(一般是多类问题);目标检测实现给定一幅图像,只需要找到一类目标所在的矩形框 ,例如人脸为目标,框出一幅图片中所有人脸所在的位置,背景为非目标,分类检测根据图像的主要内容进行分类;
    还是看图更直观!

    detection-classification

    detection-classification

    a)hs_stream_classification.launch
    1. <!--
    2. Copyright (c) 2018 HornedSungem Corporation

    3. Licensed under the Apache License, Version 2.0 (the "License");
    4. you may not use this file except in compliance with the License.
    5. You may obtain a copy of the License at

    6.      http://www.apache.org/licenses/LICENSE-2.0

    7. Unless required by applicable law or agreed to in writing, software
    8. distributed under the License is distributed on an "AS IS" BASIS,
    9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    10. See the License for the specific language governing permissions and
    11. limitations under the License.
    12. -->

    13. <launch>
    14.   <arg name="manager" />
    15.   <arg name="frame_topic" default="/hs/camera/image_raw" />
    16.   <arg name="output_topic" default="/horned_sungem_nodelet/classified_objects" />
    17.   <arg name="max_device_number" default="255" />
    18.   <arg name="start_device_index" default="0" />
    19.   <arg name="log_level" default="0" />
    20.    <arg name="pixels" default="360" />
    21.   <arg name="camera" default="hs"/>
    22.   <arg name="cnn_type" default="googlenet" />
    23.   <arg name="param_file" default="$(find horned_sungem_launch)/config/googlenet.yaml" />
    24.   <arg name="top_n" default="3" />

    25.   <node pkg="nodelet" type="nodelet" name="horned_sungem_stream"
    26.         args="load horned_sungem_stream/HSNodelet $(arg manager)"
    27.         output="screen">
    28.       <remap from="/hs/camera/image_raw" to="$(arg frame_topic)" />
    29.       <remap from="classified_objects" to="$(arg output_topic)" />
    30.       <param name="max_device_number" value="$(arg max_device_number)" />
    31.       <param name="start_device_index" value="$(arg start_device_index)" />
    32.       <param name="log_level" value="$(arg log_level)" />
    33.        <param name="pixels" value="$(arg pixels)"/>
    34.       <param name="camera" value="$(arg camera)"/>
    35.       <param name="cnn_type" value="$(arg cnn_type)"  />
    36.       <param name="top_n" value="$(arg top_n)" />
    37.       <rosparam command="load" file="$(arg param_file)" />
    38.   </node>
    39. </launch>
    复制代码
    b)hs_stream_detection.launch
    1. <!--
    2. Copyright (c) 2018 HornedSungem Corporation

    3. Licensed under the Apache License, Version 2.0 (the "License");
    4. you may not use this file except in compliance with the License.
    5. You may obtain a copy of the License at

    6.      http://www.apache.org/licenses/LICENSE-2.0

    7. Unless required by applicable law or agreed to in writing, software
    8. distributed under the License is distributed on an "AS IS" BASIS,
    9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    10. See the License for the specific language governing permissions and
    11. limitations under the License.
    12. -->

    13. <launch>
    14.   <arg name="manager" />
    15.   <arg name="frame_topic" default="/hs/camera/image_raw" />
    16.   <arg name="output_topic" default="/horned_sungem_nodelet/detected_objects" />
    17.   <arg name="max_device_number" default="255" />
    18.   <arg name="start_device_index" default="0" />
    19.   <arg name="log_level" default="0" />
    20.   <arg name="pixels" default="360" />
    21.   <arg name="camera" default="hs"/>
    22.   <arg name="cnn_type" default="mobilenetssd" />
    23.   <arg name="param_file" default="$(find horned_sungem_launch)/config/mobilenetssd.yaml" />
    24.   <arg name="top_n" default="1" />

    25.   <node pkg="nodelet" type="nodelet" name="horned_sungem_stream"
    26.         args="load horned_sungem_stream/HSNodelet $(arg manager)"
    27.         output="screen">
    28.       <remap from="/hs/camera/image_raw" to="$(arg frame_topic)" />
    29.       <remap from="detected_objects" to="$(arg output_topic)" />
    30.       <param name="max_device_number" value="$(arg max_device_number)" />
    31.       <param name="start_device_index" value="$(arg start_device_index)" />
    32.       <param name="log_level" value="$(arg log_level)" />
    33.       <param name="pixels" value="$(arg pixels)"/>
    34.       <param name="camera" value="$(arg camera)"/>
    35.       <param name="cnn_type" value="$(arg cnn_type)"  />
    36.       <param name="top_n" value="$(arg top_n)" />
    37.       <rosparam command="load" file="$(arg param_file)" />
    38.   </node>
    39. </launch>            
    复制代码
    对比以上两个launch文件,其实摄像头方面程序配置相同,仅仅在“cnn_type”和“param_file”存在差异!
    1. <arg name="cnn_type" default="googlenet" />
    2.   <arg name="param_file" default="$(find horned_sungem_launch)/config/googlenet.yaml" />
    复制代码
    vs
    1.   <arg name="cnn_type" default="mobilenetssd" />
    2.   <arg name="param_file" default="$(find horned_sungem_launch)/config/mobilenetssd.yaml" />
    复制代码


    3.2.2 hs_classification_example.launch
    1. <!--
    2. Copyright (c) 2018 HornedSungem Corporation

    3. Licensed under the Apache License, Version 2.0 (the "License");
    4. you may not use this file except in compliance with the License.
    5. You may obtain a copy of the License at

    6.      http://www.apache.org/licenses/LICENSE-2.0

    7. Unless required by applicable law or agreed to in writing, software
    8. distributed under the License is distributed on an "AS IS" BASIS,
    9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    10. See the License for the specific language governing permissions and
    11. limitations under the License.
    12. -->

    13. <launch>
    14.   <arg name="camera_topic" default="/hs/camera/image_raw" />

    15.   <node name="horned_sungem_example_stream_classification" pkg="horned_sungem_example" type="horned_sungem_example_stream_classification" output="screen" >
    16.     <remap from="/hs/camera/image_raw" to="$(arg camera_topic)" />
    17.   </node>
    18. </launch>
    复制代码
    该段代码,实现了不使用源码中的节点名,重新创建了一个名为horned_sungem_example_stream_classification的节点!调用的包是horned_sungem_example,可执行文件名为horned_sungem_example_stream_classification!通过重映射将摄像头的图像数据发布到camera_topic,即默认的/hs/camera/image_raw;
    这个启动文件实现了将订阅节点horned_sungem_example_stream_classification的视频流输出的功能!
    回顾3.1中最后的操作,
    1. roslaunch horned_sungem_launch hs_camera.launch cnn_type:=yolo camera:=hs pixels:=360

    2. roslaunch horned_sungem_launch hs_classification_example.launch camera_topic:="/hs/camera/image_raw"
    复制代码
    这实际上是发布了一个detection的话题,却订阅了一个classification的话题,自然不会有显示结果啦!
    通过目录树可知,文件夹下其实还有一个启动文件hs_detection_example.launch

    3.2.3 hs_detection_example.launch
    1. <!--
    2. Copyright (c) 2018 HornedSungem Corporation

    3. Licensed under the Apache License, Version 2.0 (the "License");
    4. you may not use this file except in compliance with the License.
    5. You may obtain a copy of the License at

    6.      http://www.apache.org/licenses/LICENSE-2.0

    7. Unless required by applicable law or agreed to in writing, software
    8. distributed under the License is distributed on an "AS IS" BASIS,
    9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    10. See the License for the specific language governing permissions and
    11. limitations under the License.
    12. -->

    13. <launch>
    14.   <arg name="camera_topic" default="/hs/camera/image_raw" />
    15.   <node name="horned_sungem_example_stream_detection" pkg="horned_sungem_example" type="horned_sungem_example_stream_detection" output="screen" >
    16.     <remap from="/hs/camera/image_raw" to="$(arg camera_topic)" />

    17.   </node>
    18. </launch>
    复制代码
    该段代码实现了不使用源码中的节点名,重新创建了一个名为horned_sungem_example_stream_detection的节点!调用的包是horned_sungem_example,可执行文件名为horned_sungem_example_stream_detection!
    通过重映射将摄像头的图像数据发布到camera_topic,即默认的/hs/camera/image_raw;
    这个启动文件实现了将订阅节点horned_sungem_example_stream_detection的视频流输出的功能!
    因此,如果要使用yolo卷积编码算法实现目标检测,正确操作如下:发布detection的话题,订阅detection的话题
    1. roslaunch horned_sungem_launch hs_camera.launch cnn_type:=yolo camera:=hs pixels:=360
    复制代码
    1. roslaunch horned_sungem_launch hs_detection_example.launch camera_topic:="/hs/camera/image_raw"
    复制代码

    detection效果

    detection效果


    矩形窗口会跟随人脸移动,且会标识出百分比可信度!
    回顾整个过程,其实最后的执行结果很简单!可能只需要官网大大说一下就可以实现!
    但是通过以上步骤可以加深对程序架构的理解!其他cnn算法实现功能依此类推,只需要注意其属于哪一类即可,下面汇总了cnn所属的类!
    (补充目前yolo卷积编码算法tiny yolo v1)



    Classification:
    • alexnet
    • googlenet
    • inception_v1
    • inception_v2
    • inception_v3
    • inception_v4
    • mobilenet
    • squeezenet

    Detection:
    • mobilenetssd
    • yolo



    下一步:分析源码cpp文件
    —————————————————————————————————————————————————
    参考文献:
    目标检测入门之(二)综述(下)
    https://blog.csdn.net/weixin_41278720/article/details/81187091
    计算机视觉领域不同的方向:目标识别、目标检测、语义分割等
    https://blog.csdn.net/u011574296/article/details/78933427
    图像分割、图像识别、图像检测的区别
    http://blog.sina.com.cn/s/blog_9b8abe6b0102x2hp.html
    图像文字识别(OCR)用什么算法小结
    http://www.cnblogs.com/ys99/p/9201229.html
    图像物体分类与检测算法综述
    https://wenku.baidu.com/view/dd75d728240c844768eaee09.html

























    评分

    参与人数 1与非币 +100 收起 理由
    satoll + 100 赞一个!

    查看全部评分

    回复

    使用道具 举报

  • TA的每日心情
    擦汗
    4 天前
  • 签到天数: 43 天

    连续签到: 1 天

    [LV.5]常住居民I

    发表于 2018-8-16 10:23:07 | 显示全部楼层
    6666,好详细,排版也美观,给大佬跪了
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条

    手机版|小黑屋|与非网

    GMT+8, 2024-4-26 06:29 , Processed in 0.159947 second(s), 24 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.