网站定位包括哪些内容wordpress加导航菜单
- 作者: 五速梦信息网
- 时间: 2026年04月20日 08:11
当前位置: 首页 > news >正文
网站定位包括哪些内容,wordpress加导航菜单,哪里有seo排名优化,音乐网站开发编程语言1、引言 通过opencv_apps#xff0c;你可以在ROS中以最简单的方式运行OpenCV提供的许多功能#xff0c;也就是说#xff0c;运行一个与功能相对应的launch启动文件#xff0c;就可以跳过为OpenCV的许多功能编写OpenCV应用程序代码#xff0c;非常的方便。 对于想熟悉每个…1、引言 通过opencv_apps你可以在ROS中以最简单的方式运行OpenCV提供的许多功能也就是说运行一个与功能相对应的launch启动文件就可以跳过为OpenCV的许多功能编写OpenCV应用程序代码非常的方便。 对于想熟悉每个细节的伙伴们可以去看源码对于熟悉视觉操作很有帮助。 官方说明http://wiki.ros.org/opencv_apps github源码https://github.com/ros-perception/opencv_apps 2、启动操作 2.1、opencv_apps.launch 先来启动摄像头等相关操作需要启动opencv_apps.launch文件我们先来了解下 gedit /home/jetson/workspace/catkin_ws/src/jetbot_ros/launch/opencv_apps.launch launcharg nameimg_flip defaultFalse/arg nameimg_transform defaultTrue/group if\((arg img_transform)arg nameimg_topic default/csi_cam_0/image_raw/include file\)(find jetson_nano_csi_cam)/launch/jetson_csi_cam.launch/node nameimg_transform pkgjetbot_ros typeimg_transform.py outputscreenparam nameimg_flip typebool value\((arg img_flip)/param nameimg_topic typestring value\)(arg img_topic)//node/group /launch 这里include节点包含一个jetson_csi_cam.launch启动文件以及一个名为img_transform的节点 其中jetson_csi_cam.launch我们查看下里面的内容 cat /home/jetson/workspace/catkin_ws/src/jetson_nano_csi_cam_ros/launch/jetson_csi_cam.launch 里面是一些摄像头的参数设置和启动摄像头通过GSCAM开源包将GStreamer图像流引入到ROS中转换成sensor_msgs/Image类型的Image话题发布到ROS中供其他节点使用。 2.2、img_transform.py 然后就是做这些操作的节点我们来看下它的源码 gedit /home/jetson/workspace/catkin_ws/src/jetbot_ros/scripts/img_transform.py #!/usr/bin/env python
-- coding: utf-8 --
import rospy import cv2 as cv from cv_bridge import CvBridge from sensor_msgs.msg import Imagedef topic(msg):if not isinstance(msg, Image):returnbridge CvBridge()frame bridge.imgmsg_to_cv2(msg, bgr8)# Canonical input image sizeframe cv.resize(frame, (640, 480))if img_flip True: frame cv.flip(frame, 1)# opencv mat - ros msgmsg bridge.cv2_to_imgmsg(frame, bgr8)pub_img.publish(msg)if name main:rospy.init_node(pub_img, anonymousFalse)img_topic rospy.get_param(~img_topic, /csi_cam_0/image_raw)img_flip rospy.get_param(~img_flip, False)sub_img rospy.Subscriber(img_topic, Image, topic)pub_img rospy.Publisher(/image, Image, queue_size10)rate rospy.Rate(2)rospy.spin() 这里就是定义一个pub_img节点订阅CSI摄像头相关的话题然后通过Image话题进行发布供其余节点使用。其中获取参数rospy.get_param(~img_topic, /csi_cam_0/image_raw)如果没有在~img_topic获取到就使用/csi_cam_0/image_raw默认值。同样的rospy.get_param(~img_flip, False)如果没有获取到~img_flip的值就默认为False 2.3、打开相机 熟悉摄像头的相关操作之后我们就来做一些准备工作开启相机roslaunch jetbot_ros opencv_apps.launch 查看方式rqt_image_view如下图 或者网页查看rosrun web_video_server web_video_server 然后使用IP端口就可以查看了如下图 然后点击里面的话题就可以看到摄像视频了如下图 我们来看下开启了哪些话题rostopic list /csi_cam_0/camera_info /csi_cam_0/image_raw /csi_cam_0/image_raw/compressed /csi_cam_0/image_raw/compressed/parameter_descriptions /csi_cam_0/image_raw/compressed/parameter_updates /csi_cam_0/image_raw/compressedDepth /csi_cam_0/image_raw/compressedDepth/parameter_descriptions /csi_cam_0/image_raw/compressedDepth/parameter_updates /csi_cam_0/image_raw/theora /csi_cam_0/image_raw/theora/parameter_descriptions /csi_cam_0/image_raw/theora/parameter_updates /image /rosout /rosout_agg 是一些关于csi摄像头相关的话题接下来我们对里面大量的示例做一个演示 3、哈里斯角点 因为我们都是在opencv_apps包里面所以先来这个所在工作区间的这个包的launch目录里面。 查看下有哪些启动文件ls /home/jetson/workspace/catkin_ws/src/opencv_apps/launch/ adding_images.launch hough_circles.launch camshift.launch hough_lines.launch contour_moments.launch hsv_color_filter.launch convex_hull.launch lk_flow.launch corner_harris.launch people_detect.launch discrete_fourier_transform.launch phase_corr.launch edge_detection.launch pyramids.launch face_detection.launch rgb_color_filter.launch face_recognition.launch segment_objects.launch fback_flow.launch simple_flow.launch find_contours.launch smoothing.launch general_contours.launch threshold.launch goodfeature_track.launch watershed_segmentation.launch hls_color_filter.launch 可以看到对图像操作的功能还是挺多的有霍夫圆、霍夫直线、轮廓矩、LK光流、哈里斯角点、边缘、人物、面部识别等等 3.1、corner_harris.launch 判断某个点是图像中的角点这里的对角点的检测我们花多点时间重点来说明下后面的节点基本就是展示为主。roslaunch opencv_apps corner_harris.launch 启动如下使用一张棋盘格式的图片让它识别 可以看到图片中的角点有很多的小圆圈给标注着这里的角点检测的多少和准确度取决于上面的threshold阈值大小可以自行调节调小了角点数量就会多相对而言准确度也在下降调大阈值角点数量就相应减少准确度要高。 我们来看下这个启动文件里面的内容 cat /home/jetson/workspace/catkin_ws/src/opencv_apps/launch/corner_harris.launch launcharg namenode_name defaultcorner_harris /arg nameimage defaultimage docThe image topic. Should be remapped to the name of the real image topic. /arg nameuse_camera_info defaultfalse docIndicates that the camera_info topic should be subscribed to to get the default input_frame_id. Otherwise the frame from the image message will be used. /arg namedebug_view defaulttrue docSpecify whether the node displays a window to show image /arg namequeue_size default3 docSpecigy queue_size of input image subscribers /arg namethreshold default200 docThreshold value of a circle around cornerss norm /!– corner_harris.cpp –node name\((arg node_name) pkgopencv_apps typecorner_harris remap fromimage to\)(arg image) /param nameuse_camera_info value\((arg use_camera_info) /param namedebug_view value\)(arg debug_view) /param namequeue_size value$(arg queue_size) //node /launch 3.2、corner_harris.cpp 前面是一些参数设置后面是一个node节点部分其中typecorner_harris可以知道使用的是C写的因为如果是Python写的就是typecorner_harris.py这样的形式当然那里也注释说明了是corner_harris.cpp 其中C代码文件的地址ls /home/jetson/workspace/catkin_ws/build/opencv_apps 我们来看下这个哈里斯角点的实际代码gedit /home/jetson/workspace/catkin_ws/build/opencv_apps/corner_harris.cpp /*********************************************************************
- Software License Agreement (BSD License) *
- Copyright © 2016, Kentaro Wada.
- All rights reserved. *
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met: *
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
- * Neither the name of the Kentaro Wada nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission. *
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE. ********************************************************************/#include ros/ros.h #include nodelet/loader.hint main(int argc, char **argv) {ros::init(argc, argv, corner_harris, ros::init_options::AnonymousName);if (ros::names::remap(image) image) {ROS_WARN(Topic image has not been remapped! Typical command-line usage:\n\t$ rosrun image_rotate image_rotate image:image topic [transport]);}// need to use 1 worker thread to prevent freezing in imshow, calling imshow from mutiple threads//nodelet::Loader manager(false);ros::param::set(~num_worker_threads, 1); // need to call Loader(bool provide_ros_api true);nodelet::Loader manager(true);nodelet::M_string remappings;nodelet::V_string my_argv(argv 1, argv argc);my_argv.push_back(–shutdown-on-close); // Internalmanager.load(ros::this_node::getName(), opencv_apps/corner_harris, remappings, my_argv);ros::spin();return 0; }这段代码就是初始化corner_harris节点image话题的重映射等然后用圆圈来标注角点这个操作会用到接下来要讲的一个插件。 3.3、corner_harris_nodelet.cpp 上面的核心代码会用到Nodelet关于这个Nodelet插件的解释 允许用户在ROS节点中添加自定义功能Nodelet使得开发人员能够将复杂的代码封装到可重用的插件中这些插件可以像其他ROS节点一样进行部署和通信开发人员可以编写更加模块化和可维护的代码提高ROS系统的可扩展性和可重用性。 更关键的是效率问题Nodelet提供一种方法可以让多个算法程序在一个进程中使用共享指针shared_ptr来实现零拷贝通信以降低因为拷贝传输大数据比如图像流点云等而延迟的问题换句话说就是将多个node捆绑在一起管理使得同一个manager里面的话题的数据传输更快因为不会在进程内传递消息时进行复制而产生的效率下降。 查看插件文件ls /home/jetson/workspace/catkin_ws/src/opencv_apps/src/nodelet 我们打开哈里斯角点的插件代码来看下 gedit /home/jetson/workspace/catkin_ws/src/opencv_apps/src/nodelet/corner_harris_nodelet.cpp // -- coding:utf-8-unix; mode: c; indent-tabs-mode: nil; c-basic-offset: 2; -- /********************************************************************
- Software License Agreement (BSD License) *
- Copyright © 2016, JSK Lab.
- All rights reserved. *
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met: *
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
- * Neither the name of the Kei Okada nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission. *
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE. ******************************************************************/ #include ros/ros.h #include opencv_apps/nodelet.h #include image_transport/image_transport.h #include sensor_msgs/image_encodings.h #include cv_bridge/cv_bridge.h#include opencv2/highgui/highgui.hpp #include opencv2/imgproc/imgproc.hpp#include dynamic_reconfigure/server.h #include opencv_apps/CornerHarrisConfig.h// https://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/TrackingMotion/cornerHarris_Demo.cpp / function cornerHarris_Demo.cpp* brief Demo code for detecting corners using Harris-Stephens method* author OpenCV team*/namespace opencv_apps { class CornerHarrisNodelet : public opencv_apps::Nodelet {image_transport::Publisher imgpub;image_transport::Subscriber imgsub;image_transport::CameraSubscriber camsub;ros::Publisher msgpub;boost::shared_ptrimagetransport::ImageTransport it;typedef opencv_apps::CornerHarrisConfig Config;typedef dynamicreconfigure::ServerConfig ReconfigureServer;Config config;boost::shared_ptrReconfigureServer reconfigureserver;int queuesize;bool debugview;std::string windowname;static bool need_configupdate;int threshold_;void reconfigureCallback(Config new_config, uint32t level){config newconfig;threshold config_.threshold;}const std::string frameWithDefault(const std::string frame, const std::string image_frame){if (frame.empty())return image_frame;return frame;}void imageCallbackWithInfo(const sensor_msgs::ImageConstPtr msg, const sensor_msgs::CameraInfoConstPtr cam_info){doWork(msg, cam_info-header.frame_id);}void imageCallback(const sensor_msgs::ImageConstPtr msg){doWork(msg, msg-header.frame_id);}static void trackbarCallback(int /unused/, void* /unused/){need_configupdate true;}void doWork(const sensor_msgs::ImageConstPtr image_msg, const std::string input_frame_from_msg){// Work on the image.try{// Convert the image into something opencv can handle.cv::Mat frame cv_bridge::toCvShare(image_msg, sensor_msgs::image_encodings::BGR8)-image;// Do the workcv::Mat dst, dst_norm, dst_norm_scaled;dst cv::Mat::zeros(frame.size(), CV_32FC1);cv::Mat src_gray;if (frame.channels() 1){cv::cvtColor(frame, src_gray, cv::COLOR_BGR2GRAY);}else{src_gray frame;cv::cvtColor(src_gray, frame, cv::COLOR_GRAY2BGR);}/// Detector parametersint block_size 2;int aperture_size 3;double k 0.04;/// Detecting cornerscv::cornerHarris(src_gray, dst, block_size, aperture_size, k, cv::BORDER_DEFAULT);/// Normalizingcv::normalize(dst, dst_norm, 0, 255, cv::NORM_MINMAX, CV_32FC1, cv::Mat());cv::convertScaleAbs(dst_norm, dst_norm_scaled);/// Drawing a circle around cornersfor (int j 0; j dst_norm.rows; j){for (int i 0; i dst_norm.cols; i){if ((int)dstnorm.atfloat(j, i) threshold){cv::circle(frame, cv::Point(i, j), 5, cv::Scalar(0), 2, 8, 0);}}}/// Create windowif (debugview){cv::namedWindow(windowname, cv::WINDOW_AUTOSIZE);const int max_threshold 255;if (need_configupdate){config.threshold threshold;reconfigureserver-updateConfig(config_);need_configupdate false;}cv::createTrackbar(Threshold:, windowname, threshold_, max_threshold, trackbarCallback);}if (debugview){cv::imshow(windowname, frame);int c cv::waitKey(1);}// Publish the image.sensor_msgs::Image::Ptr out_img cv_bridge::CvImage(image_msg-header, sensor_msgs::image_encodings::BGR8, frame).toImageMsg();imgpub.publish(out_img);}catch (cv::Exception e){NODELET_ERROR(Image processing error: %s %s %s %i, e.err.c_str(), e.func.c_str(), e.file.c_str(), e.line);}}void subscribe() // NOLINT(modernize-use-override){NODELETDEBUG(Subscribing to image topic.);if (config.use_camera_info)camsub it_-subscribeCamera(image, queuesize, CornerHarrisNodelet::imageCallbackWithInfo, this);elseimgsub it_-subscribe(image, queuesize, CornerHarrisNodelet::imageCallback, this);}void unsubscribe() // NOLINT(modernize-use-override){NODELET_DEBUG(Unsubscribing from image topic.);imgsub.shutdown();camsub.shutdown();}public:virtual void onInit() // NOLINT(modernize-use-override){Nodelet::onInit();it_ boost::shared_ptrimage_transport::ImageTransport(new imagetransport::ImageTransport(*nh));pnh_-param(queue_size, queuesize, 3);pnh_-param(debug_view, debugview, false);if (debugview){alwayssubscribe true;}windowname CornerHarris Demo;reconfigureserver boost::make_shareddynamicreconfigure::ServerConfig (*pnh);dynamic_reconfigure::ServerConfig::CallbackType f boost::bind(CornerHarrisNodelet::reconfigureCallback, this, _1, _2);reconfigureserver-setCallback(f);imgpub advertiseImage(*pnh_, image, 1);onInitPostProcess();} }; bool CornerHarrisNodelet::need_configupdate false; } // namespace opencv_appsnamespace corner_harris { class CornerHarrisNodelet : public opencv_apps::CornerHarrisNodelet { public:virtual void onInit() // NOLINT(modernize-use-override){ROS_WARN(DeprecationWarning: Nodelet corner_harris/corner_harris is deprecated, and renamed to opencv_apps/corner_harris.);opencv_apps::CornerHarrisNodelet::onInit();} }; } // namespace corner_harris#include pluginlib/class_list_macros.h PLUGINLIB_EXPORT_CLASS(opencv_apps::CornerHarrisNodelet, nodelet::Nodelet); PLUGINLIB_EXPORT_CLASS(corner_harris::CornerHarrisNodelet, nodelet::Nodelet); 主要关注其中检测角点的方法 cv::cornerHarris(src_gray, dst, block_size, aperture_size, k, cv::BORDER_DEFAULT); 参数说明如下 src_gray输入的灰度Mat矩阵或浮点图像dst存储着哈里斯角点检测的结果跟源图的尺寸和类型一样block_size邻域的大小aperture_sizeSobel边缘检测滤波器大小kHarris中间参数经验值0.04~0.06cv::BORDER_DEFAULT插值类型 我们也可以看到在发布和订阅时用到的就是指针。 发布时 sensor_msgs::Image::Ptr out_img cv_bridge::CvImage(image_msg-header, sensor_msgs::image_encodings::BGR8, frame).toImageMsg(); imgpub.publish(outimg); 订阅时 Nodelet::onInit(); it boost::shared_ptrimage_transport::ImageTransport(new imagetransport::ImageTransport(*nh));if (config_.use_camera_info)camsub it_-subscribeCamera(image, queuesize, CornerHarrisNodelet::imageCallbackWithInfo, this);elseimgsub it_-subscribe(image, queuesize, CornerHarrisNodelet::imageCallback, this); 这样我们在消息传递时就只需要传指针了当然这里是针对同一台设备的进程间通信如果是不同设备那还是需要解引用传输实际内容因为我们知道ROS的分布节点进行通信的协议是XML-RPC本质也是HTTP协议只不过编码格式是XML类型它们之间的传输还得是拷贝内容进行通信。 查看节点关系rqt_graph我这里将调试节点隐藏显得更清晰点如下图 可以看到CSI摄像头图像获取需要经过转换之后最终通过/Image话题发布给哈里斯角点算法处理。 识别角点的原理简单来说就是在特征窗口里面如果灰度发生了较大的变化就认为这里是一个角点有兴趣的可以查阅harris.cpp 4、霍夫直线检测 接下来的部分就没有上述那么去分析了只是熟悉下常用的几个功能。 霍夫直线的检测在计算机视觉和图像处理中用途广泛可以用于边缘检测、直线检测等。 实际场景中可以通过从图像中检测出边缘然后通过识别直线或曲线将这些边缘连接起来形成完整的物体。 另外无人驾驶的发展对于自动化检测道路、车道线等应用也有着广泛的应用。 启动launch文件roslaunch opencv_apps hough_lines.launch 很好的检测到了我身上的衣服以及上面的“中国”文字如下图 5、图像轮廓矩 contour_moments.launch是启动识别图像中轮廓的矩函数这里的轮廓矩也可以理解成轮廓的特征它也有着很广泛的应用目标识别提取图像中物体的轮廓特征可以对目标进行识别和分类。目标检测通过检测物体的形状和轮廓来确定目标的位置。图像分割因为可以对不同的区域进行目标的识别所以也可以帮助其进行图像的分割。医学领域可以用来识别图像中的组织器官和患病部位从而提取特征进行医学的诊断。 启动roslaunch opencv_apps contour_moments.launch如下图 6、LK光流 LK光流是描述目标运动的方法利用LK光流可以实现对目标的追踪从而知道目标的位姿。 LK光流法的前提条件如下亮度恒定一个像素点随着时间的变化其亮度值像素灰度值是不能变化的。小运动时间的变化不会引起位置的剧烈变化。这样才能利用相邻帧之间的位置变化引起的灰度值变化去求取灰度对位置的偏导数。空间一致前一帧的相邻像素点在后一帧也是相邻的因为为了求解xy方向的速度需要建立方程组而空间一致假设就可以利用邻域n个像素点来建立n个方程。 启动roslaunch opencv_apps lk_flow.launch如下图 7、相机相位位移 检测相机移动的快慢或者里面目标的运动快慢 启动roslaunch opencv_apps phase_corr.launch如下图 移动越快圆就越大 大概的介绍就先到这儿吧另外一些关于OpenCV的文章有兴趣的可以查阅OpenCV自带的HAAR级联分类器对脸部(人脸、猫脸等)的检测识别OpenCV的HSV颜色空间在无人车中颜色识别的应用
- 上一篇: 网站顶一下代码专业团队图片原图
- 下一篇: 网站定位分析是什么旅游外贸网站建设推广
相关文章
-
网站顶一下代码专业团队图片原图
网站顶一下代码专业团队图片原图
- 技术栈
- 2026年04月20日
-
网站顶部可关闭广告浅谈博物馆网站建设的意义
网站顶部可关闭广告浅谈博物馆网站建设的意义
- 技术栈
- 2026年04月20日
-
网站顶部广告无忧代理 在线
网站顶部广告无忧代理 在线
- 技术栈
- 2026年04月20日
-
网站定位分析是什么旅游外贸网站建设推广
网站定位分析是什么旅游外贸网站建设推广
- 技术栈
- 2026年04月20日
-
网站定位模板大连建设学院网站
网站定位模板大连建设学院网站
- 技术栈
- 2026年04月20日
-
网站定制公司哪家好wordpress导航菜单函数
网站定制公司哪家好wordpress导航菜单函数
- 技术栈
- 2026年04月20日






