我经历了一个奇怪的分割错误。在ROS节点中执行
ROS版本:kinetic,OpenCV版本:2.4,Ubuntu版本:16.04。
代码:
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <ros/ros.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
void ImageCallback(const sensor_msgs::ImageConstPtr& msg)
{
std::cerr<<"msg->header: "<<msg->header<<std::endl;
std::cerr<<"msg->height: "<<msg->height<<std::endl;
std::cerr<<"msg->width: "<<msg->width<<std::endl;
std::cerr<<"msg->encoding: "<<msg->encoding<<std::endl;
std::cerr<<"msg->is_bigendian: "<<int(msg->is_bigendian)<<std::endl;
std::cerr<<"msg->step: "<<msg->step<<std::endl;
std::cerr<<"msg->data.size(): "<<msg->data.size()<<std::endl;
std::cerr<<"msg->data[0,1,2]: "<<int(msg->data[0])<<" "<<int(msg->data[1])<<" "<<int(msg->data[2])<<std::endl;
std::cerr<<"msg->data[size()-1]: "<<int(msg->data[msg->data.size()-1])<<std::endl;
std::cerr<<"msg->data[size()-2]: "<<int(msg->data[msg->data.size()-2])<<std::endl;
std::cerr<<"msg->data[size()-3]: "<<int(msg->data[msg->data.size()-3])<<std::endl;
cv_bridge::CvImagePtr cv_ptr;
try
{
cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8);
std::cerr<<"debug.p1"<<std::endl;
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
std::cerr<<"cv_ptr: "<<cv_ptr<<std::endl;
std::cerr<<"cv_ptr->image: "<<cv_ptr->image<<std::endl;
cv::Mat frame= cv_ptr->image;
cv::imshow("camera",frame);
char c(cv::waitKey(1));
if(c=='\x1b'||c=='q') ros::shutdown();
}
int main(int argc, char**argv)
{
ros::init(argc, argv, "sub_img_node");
ros::NodeHandle node("~");
std::string img_topic("/camera/color/image_raw");
if(argc>1) img_topic= argv[1];
cv::namedWindow("camera",1);
ros::Subscriber sub_img= node.subscribe(img_topic, 1, &ImageCallback);
ros::spin();
return 0;
}
输出:
msg->header: seq: 352
stamp: 1610458354.727051013
frame_id: head_camera
msg->height: 480
msg->width: 640
msg->encoding: rgb8
msg->is_bigendian: 0
msg->step: 1920
msg->data.size(): 921600
msg->data[0,1,2]: 207 224 219
msg->data[size()-1]: 209
msg->data[size()-2]: 212
msg->data[size()-3]: 201
Segmentation fault (core dumped)
从结果中,我们可以看到主题
此外,我用gdb分析了核心转储:
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from bin/sub_img_node...done.
[New LWP 101971]
[New LWP 101976]
[New LWP 101983]
[New LWP 101984]
[New LWP 101981]
[New LWP 101972]
[New LWP 101982]
[New LWP 101974]
[New LWP 101975]
warning: Unexpected size of section `.reg-xstate/101971' in core file.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `bin/sub_img_node /usb_cam/image_raw'.
Program terminated with signal SIGSEGV, Segmentation fault.
warning: Unexpected size of section `.reg-xstate/101971' in core file.
#0 0x00007fb2f5026b44 in cv::_InputArray::type(int) const () from /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4
[Current thread is 1 (Thread 0x7fb2f628fac0 (LWP 101971))]
(gdb) bt
#0 0x00007fb2f5026b44 in cv::_InputArray::type(int) const () from /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4
#1 0x00007fb2efa655bc in cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) ()
from /opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_imgproc3.so.3.3
#2 0x00007fb2f5505cf3 in cv_bridge::toCvCopyImpl(cv::Mat const&, std_msgs::Header_<std::allocator<void> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
from /opt/ros/kinetic/lib/libcv_bridge.so
#3 0x00007fb2f5506103 in cv_bridge::toCvCopy(sensor_msgs::Image_<std::allocator<void> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /opt/ros/kinetic/lib/libcv_bridge.so
#4 0x00007fb2f55061e0 in cv_bridge::toCvCopy(boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /opt/ros/kinetic/lib/libcv_bridge.so
#5 0x00000000004074fb in ImageCallback (msg=...) at /home/akihikoy/prg/ay_test/ros/cpp_ros/test2/src/sub_img_node.cpp:49
#6 0x000000000040a91b in boost::function1<void, boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&>::operator() (a0=...,
this=<optimized out>) at /usr/include/boost/function/function_template.hpp:773
#7 boost::detail::function::void_function_obj_invoker1<boost::function<void (boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&)>, void, boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> >::invoke(boost::detail::function::function_buffer&, boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const>) (function_obj_ptr=..., a0=...) at /usr/include/boost/function/function_template.hpp:159
#8 0x000000000040af63 in boost::function1<void, boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> >::operator() (a0=..., this=<optimized out>)
at /usr/include/boost/function/function_template.hpp:773
#9 ros::SubscriptionCallbackHelperT<boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&, void>::call (this=0x12915e0, params=...)
at /opt/ros/kinetic/include/ros/subscription_callback_helper.h:144
#10 0x00007fb2f5ec2e2d in ros::SubscriptionQueue::call() () from /opt/ros/kinetic/lib/libroscpp.so
#11 0x00007fb2f5e686f8 in ros::CallbackQueue::callOneCB(ros::CallbackQueue::TLS*) () from /opt/ros/kinetic/lib/libroscpp.so
#12 0x00007fb2f5e6a0fb in ros::CallbackQueue::callAvailable(ros::WallDuration) () from /opt/ros/kinetic/lib/libroscpp.so
#13 0x00007fb2f5ec6ef9 in ros::SingleThreadedSpinner::spin(ros::CallbackQueue*) () from /opt/ros/kinetic/lib/libroscpp.so
#14 0x00007fb2f5eabedb in ros::spin() () from /opt/ros/kinetic/lib/libroscpp.so
#15 0x0000000000406276 in main (argc=2, argv=0x7ffe650933c8) at /home/akihikoy/prg/ay_test/ros/cpp_ros/test2/src/sub_img_node.cpp:78
但是我找不到错误的原因。有谁能提出解决办法吗?
我不知道为什么,但是我通过在
来解决这个问题。
详细程序:
$ sudo apt-get -f install libcv-bridge0d
$ cd /opt/ros/kinetic/lib/
$ sudo mv libcv_bridge.so{,.trouble}
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libcv_bridge.so.0d libcv_bridge.so
我在Python中也遇到了类似的问题,可以通过以下方式解决:
$ sudo apt-get -f install python-cv-bridge
我试图运行ionic build Android--release命令来构建apk,但是我得到了这个错误 构建失败 总时间:2.623秒错误:cmd:命令失败,退出代码为1错误输出:失败:生成失败,出现异常。 错误:配置root项目'Android'时出现问题。您尚未接受以下SDK组件的许可协议:[Android SDK Platform25]。在构建项目之前,您需要接受许可协议,并使用Andro
当我建立我的Xamarin Android应用程序在发布模式,我得到这个错误: /库/框架/单声道。framework/External/xbuild/Xamarin/Android/Xamarin。Android常见的目标:错误:执行任务链接程序集时出错:错误XA2006:引用元数据项“系统”。沃德·沙马林。形式。条目::从“MyApp,Version=1.0”设置_FontSize(Syste
我的控制台中出现以下错误。 失败:生成已完成,但有2次失败。 > 错误:任务“:React-Native-Video:CompileDebugJavaWithJavac”执行失败。 编译失败;有关详细信息,请参阅编译器错误输出。 尝试: > 错误:任务“:React-native-firebase:CompileDebugJavaWithJavac”执行失败。 编译失败;有关详细信息,请参阅编译器
我试图实现一个单页应用程序的角度。为了使我的工作流更好,我尝试实现了Gulp。 我在安装gulp插件时遇到了一些严重的npm错误,但这是另外一个故事,我意识到,无论有没有错误,它都是工作的。 我真正碰到的是useref插件。或者更确切地说,丑陋的插件。 我想这可能是gulp做的异步工作造成的。可能是uglify插件试图丑化此时此刻未完成的useref文件。怎么知道? 所以我把所有的东西都分开了,以
我构建了一个react原生应用程序,并将其与Firebase集成。当我使用npx react-native Run-IOS运行时,它在ios中运行良好。如果我直接在android studio中打开项目并运行它,它甚至可以在android中工作。但是当我运行命令run-android时,我得到以下错误: npx React-本机运行-Android 运行jetifier将库迁移到AndroidX的
最近,在Jenkins中运行的Maven构建作业失败了,但有以下例外,它们不能从Maven Central中提取依赖项,因此应该使用HTTPS。我不知道如何将请求从HTTP更改为HTTPS。在这件事上有人能指导我吗? [错误]无法解析的生成扩展: 插件或其依赖项之一无法解析: 未能收集: 未能读取: 无法将项目: 无法将项目->[帮助2] 正在等待Jenkins完成收集 Plugin或其依赖项之一
我使用eclipse,在我的java项目中有8个包。我试图用eclipse(Project)生成我的javadoc- 非法软件包名称:"sjavaeclipseeclipsepluginsorg.eclipse.core.databinding.property_1.4.200.v20130515-1857.jar;C:UsersPhilworkspaceBachelor_Thesislibjun