1.环境
- 双系统 win7 + ubuntu18.04
- ROS Melodic安装:http://wiki.ros.org/cn/melodic/Installation/Ubuntu
注:Melodic可以安装在 Ubuntu Artful (17.10),Bionic (18.04 LTS),Debian Stretch 和其他一些平台上。
Kinetic在Ubuntu Wily(15.10)和Ubuntu Xenial (16.04 LTS)可用。
Indigo在Ubuntu Trusty (14.04 LTS) 和其他平台可用。 - libreasense(Intel® RealSense™ SDK 2.0)安装: https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md
- opencv:https://docs.opencv.org/master/d2/de6/tutorial_py_setup_in_ubuntu.html
- dlib:https://github.com/davisking/dlib
2.训练自己的模型
- imglab制作数据集:https://github.com/davisking/dlib/tree/master/tools/imglab
- 训练及测试:https://github.com/davisking/dlib/blob/master/python_examples/train_object_detector.py
- 现有模型:https://github.com/davisking/dlib-models
3.代码
#!/usr/bin/python
import pyrealsense2 as rs
import numpy as np
import cv2
import time
import darknet as dn
import dlib
import rospy
from cv_bridge import CvBridge
import sensor_msgs
from object_msgs.msg import ObjectsInBoxes,ObjectInBox
import geometry_msgs
# Declare pointcloud object, for calculating pointclouds and texture mappings
pc = rs.pointcloud()
# We want the points object to be persistent so we can display the last cloud when a frame drops
points = rs.points()
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 15)
config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 15)
# Start streaming
pipe_profile = pipeline.start(config)
# Create an align object
# rs.align allows us to perform alignment of depth frames to others frames
# The "align_to" is the stream type to which we plan to align depth frames.
align_to = rs.stream.color
align = rs