Giter Club home page Giter Club logo

ros-yolov5's Introduction

README

环境:ubuntu18.04 + ros-melodic + python3.8 + pytorch1.0+

编译依赖:catkin_simple_pkg 下载放入同一个rosws下catkin_make 编译

此外

ROS Service

实现yolo作为service的server,发送sensor::Imge 图片,得到yolo检测的结果(置信度,2dbbox左上右下点坐标,附加文本信息,分类结果), 使用步骤如下:

  1. 依赖安装

    1. 安装好pytorch
    2. catkin-simple放入本包同一工程下
  2. 填写config/config.demo中参数,其中

    1. weight为保存的pytorch模型.pt文件 ,
    2. img_size为图片大小,必须和训练时的设置一致
    3. action 为选择使用action模式还是service模式来使用ros2yolo功能
  3. demo_server.py开头#!/home/ou/software/anaconda3/envs/dl/bin/python换为自己装有pytorch的虚拟环境下的解释器

    1. 设置脚本为可执行权限
    2. 运行launch/service_demo.launch 启动service-server
  4. 参考src/service_client_demo.cpp

    #include <cv_bridge/cv_bridge.h>
    #include <ros_yolo/yolo.h>
    
    //instance of server-client
    ros::ServiceClient client = n.serviceClient<ros_yolo::yolo>("yolo_service");
    //request once
    ros_yolo::yolo srv;
    srv.request.image =  //sensor_msgs::Image  variable
    //send request
     if (client.call(srv)) {
    	ROS_INFO("request succeed");
         // analyze each result
    	for (auto &result:srv.response.results){
            auto prob = result.prob;  // probability of this classification
            auto xyxy = result.bbox.xyxy;  // coordinates of the upper left corner and the lower right corner
            auto text = result.label;  // addtional infomation 
            auto cls = result.id;  // classification result 
            // ....
        }
    }else {
    	ROS_ERROR("request fail");
    }

ROS Action

填写config/config.demo中参数 action=True

action-client 参考src/action_client_demo.cpp

action_client发出的goal只需包含iamge即goal.image = //sensor_msgs::Image

action_client接受到的结果result包含原始图像msg和检测结果即result->image 和 result->result

ros-yolov5's People

Contributors

ouyangjunyuan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.