安装环境 运行历程
ROS与深度相机入门教程-在ROS使用小觅深度相机 https://www.ncnynl.com/archives/201910/3435.html
ros安装
rosdep init ROS安装问题解决方案 rosdep init ROS安装问题解决方案 - 古月居
官方SDK说明
SDK 样例 — MYNT EYE D SDK 1.8.0 文档
ubuntu20.04安装
sdk安装
Ubuntu18.04安装小觅双目深度相机SDK——MYNT-EYE-D-SDK_wowbing2的博客-CSDN博客
其实这个博客也不能解决问题,只是提供了一个思路修改pcl库
最后编译没有成功
因为不用点云所以,我删除了samples的cmakelists里面pcl的部分,只是使用相机和深度部分
ros编译
解决roslunch的问题
sudo apt-get install ros-noetic-roslaunch
解决could not find a package configuration file provided by "image_transport" wit
sudo apt-get install ros-melodic-move-base-msgs#这句话可能是没有用的
sudo apt-get install ros-noetic-compressed-image-transport
Could not find a package configuration file provided by "nodelet" with any
of the following names:
sudo apt-get install ros-noetic-nodelet
缺少tdf模块
sudo apt-get install ros-noetic-tf2-*
安装rivz
fatal error: visualization_msgs/Marker.h: 没有那个文件或目录
sudo apt-get install ros-noetic-rviz
bag包录制
测试ROS例程
- 启动roscore
roscore
- 启动RViz
source ./wrappers/ros/devel/setup.bash
roslaunch mynteye_wrapper_d display.launch
- 启动相机节点
source ./wrappers/ros/devel/setup.bash
roslaunch mynteye_wrapper_d mynteye.launch
https://mp.csdn.net/mp_blog/creation/editor/115916013
录bag包
rostopic list
rosbag record -a
订阅部分节点
rosbag record /mynteye/left/image_color/compressed /mynteye/right/image_color /compressed
/mynteye/depth/image_raw/compressed
bag包录一分钟5g,sdk录一分钟860m
rosbag play [name]
SDK采集数据代码(自己修改后的)
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include "mynteyed/camera.h"
#include "mynteyed/utils.h"
#include "util/cam_utils.h"
#include "util/counter.h"
#include "util/cv_painter.h"
//test
#include <string> // std::string, std::to_string
MYNTEYE_USE_NAMESPACE
int main(int argc, char const* argv[]) {
Camera cam;
DeviceInfo dev_info;
if (!util::select(cam, &dev_info)) {
return 1;
}
util::print_stream_infos(cam, dev_info.index);
std::cout << "Open device: " << dev_info.index << ", "
<< dev_info.name << std::endl << std::endl;
OpenParams params(dev_info.index);
{
// Framerate: 30(default), [0,60], [30](STREAM_2560x720)
params.framerate = 30;
// Device mode, default DEVICE_ALL
// DEVICE_COLOR: IMAGE_LEFT_COLOR ✓ IMAGE_RIGHT_COLOR ? IMAGE_DEPTH x
// DEVICE_DEPTH: IMAGE_LEFT_COLOR x IMAGE_RIGHT_COLOR x IMAGE_DEPTH ✓
// DEVICE_ALL: IMAGE_LEFT_COLOR ✓ IMAGE_RIGHT_COLOR ? IMAGE_DEPTH ✓
// Note: ✓: available, x: unavailable, ?: depends on #stream_mode
// params.dev_mode = DeviceMode::DEVICE_ALL;
// Color mode: raw(default), rectified
// params.color_mode = ColorMode::COLOR_RECTIFIED;
// Stream mode: left color only
// params.stream_mode = StreamMode::STREAM_640x480; // vga
// params.stream_mode = StreamMode::STREAM_1280x720; // hd
// Stream mode: left+right color
// params.stream_mode = StreamMode::STREAM_1280x480; // vga
params.stream_mode = StreamMode::STREAM_2560x720; // hd
// Auto-exposure: true(default), false
// params.state_ae = false;
// Auto-white balance: true(default), false
// params.state_awb = false;
// IR Depth Only: true, false(default)
// Note: IR Depth Only mode support frame rate between 15fps and 30fps.
// When dev_mode != DeviceMode::DEVICE_ALL,
// IR Depth Only mode not be supported.
// When stream_mode == StreamMode::STREAM_2560x720,
// frame rate only be 15fps in this mode.
// When frame rate less than 15fps or greater than 30fps,
// IR Depth Only mode will be not available.
// params.ir_depth_only = true;
// Infrared intensity: 0(default), [0,10]
params.ir_intensity = 4;
// Colour depth image, default 5000. [0, 16384]
params.colour_depth_value = 5000;
}
// Enable what process logics
// cam.EnableProcessMode(ProcessMode::PROC_IMU_ALL);
// Enable image infos
cam.EnableImageInfo(true);
cam.Open(params);
std::cout << std::endl;
if (!cam.IsOpened()) {
std::cerr << "Error: Open camera failed" << std::endl;
return 1;
}
std::cout << "Open device success" << std::endl << std::endl;
std::cout << "Press ESC/Q on Windows to terminate" << std::endl;
bool is_left_ok = cam.IsStreamDataEnabled(ImageType::IMAGE_LEFT_COLOR);
bool is_right_ok = cam.IsStreamDataEnabled(ImageType::IMAGE_RIGHT_COLOR);
bool is_depth_ok = cam.IsStreamDataEnabled(ImageType::IMAGE_DEPTH);
if (is_left_ok) cv::namedWindow("left color");
if (is_right_ok) cv::namedWindow("right color");
if (is_depth_ok) cv::namedWindow("depth");
CVPainter painter;
util::Counter counter(params.framerate);
int nPic_count = 0;// 测试用的图片计数变量
std::string sPic_count;//计数 string 用于生成文件名
std::string sFilename;//文件名
std::string sFolderPath = "./test1/"; //主目录
std::string sFileLeft = "left/"; //左图目录
std::string sFileRight = "right/"; //右图目录
std::string sFileDepth = "depth/"; //深度图目录
// 创建文件夹
std::string command;
command = "mkdir -p " + sFolderPath + sFileLeft;
system(command.c_str());
command = "mkdir -p " + sFolderPath + sFileRight;
system(command.c_str());
command = "mkdir -p " + sFolderPath + sFileDepth;
system(command.c_str());
//目录创建完成
for (;;) {
cam.WaitForStream();
auto allow_count = false;
if (is_left_ok) {
auto left_color = cam.GetStreamData(ImageType::IMAGE_LEFT_COLOR);
if (left_color.img) {
allow_count = true;
cv::Mat left = left_color.img->To(ImageFormat::COLOR_BGR)->ToMat();
//test
sPic_count = std::to_string(nPic_count);
sFilename = sFolderPath + sFileLeft + sPic_count + ".jpg";
cv::imwrite(sFilename,left);
//test
painter.DrawSize(left, CVPainter::TOP_LEFT);
painter.DrawStreamData(left, left_color, CVPainter::TOP_RIGHT);
painter.DrawInformation(left, util::to_string(counter.fps()),
CVPainter::BOTTOM_RIGHT);
cv::imshow("left color", left);
}
}
if (is_right_ok) {
auto right_color = cam.GetStreamData(ImageType::IMAGE_RIGHT_COLOR);
if (right_color.img) {
allow_count = true;
cv::Mat right = right_color.img->To(ImageFormat::COLOR_BGR)->ToMat();
//test
sPic_count = std::to_string(nPic_count);
sFilename = sFolderPath + sFileRight + sPic_count + ".jpg";
cv::imwrite(sFilename,right);
//test
painter.DrawSize(right, CVPainter::TOP_LEFT);
painter.DrawStreamData(right, right_color, CVPainter::TOP_RIGHT);
cv::imshow("right color", right);
}
}
if (is_depth_ok) {
auto image_depth = cam.GetStreamData(ImageType::IMAGE_DEPTH);
if (image_depth.img) {
allow_count = true;
cv::Mat depth;
depth = image_depth.img->ToMat();
//test
sPic_count = std::to_string(nPic_count);
sFilename = sFolderPath + sFileDepth + sPic_count + ".jpg";
cv::imwrite(sFilename,depth);
//test
painter.DrawSize(depth, CVPainter::TOP_LEFT);
painter.DrawStreamData(depth, image_depth, CVPainter::TOP_RIGHT);
cv::imshow("depth", depth);
}
}
//test
nPic_count++;
//test
if (allow_count == true) {
counter.Update();
}
char key = static_cast<char>(cv::waitKey(1));
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
break;
}
}
cam.Close();
return 0;
}