当前位置: 首页 > news >正文

江苏城乡与住房建设厅网站文登城乡建设局网站

江苏城乡与住房建设厅网站,文登城乡建设局网站,云主机服务器租用,黑帽seo培训网原创博客:转载请标明出处:http://www.cnblogs.com/zxouxuewei/ 关键点#xff1a;是多个方向上亮度变化强的区域。 opencv:版本是2.4. 光学流函数#xff1a;calcOpticalFlowPyrLK()。#xff08;关键点侦测器使用goodFeaturesToTrack()#xff09;二者结合。 相应的启动文…原创博客:转载请标明出处:http://www.cnblogs.com/zxouxuewei/   关键点是多个方向上亮度变化强的区域。 opencv:版本是2.4. 光学流函数calcOpticalFlowPyrLK()。关键点侦测器使用goodFeaturesToTrack()二者结合。 相应的启动文件为lk_tracker.launch 首先确保你的kinect驱动或者uvc相机驱动能正常启动如果你使用的是kinect请运行openni驱动 roslaunch openni_launch openni.launch   如果你没有安装kinect深度相机驱动请看我前面的博文。 然后运行下面的launch文件 roslaunch rbx1_vision good_features.launch 当视频出现时通过鼠标画矩形将图像中的某个对象框住。这个矩形表示所选的区域你会看到这个区域中会出现一些绿色的小圆点他们是goodFeaturesToTrack()。侦测器在该区域中发现的关键点。然后试着移动你所选择的区域你会看到光学流函数calcOpticalFlowPyrLK()跟踪关键点。 以下是我的运行结果 移动后 下面让我们来看看代码主要是lk_tracker.py脚本 #!/usr/bin/env python lk_tracker.py - Version 1.1 2013-12-20Based on the OpenCV lk_track.py demo codeCreated for the Pi Robot Project: http://www.pirobot.orgCopyright (c) 2011 Patrick Goebel. All rights reserved.This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details at:http://www.gnu.org/licenses/gpl.htmlimport rospy import cv2 import cv2.cv as cv import numpy as np from rbx1_vision.good_features import GoodFeaturesclass LKTracker(GoodFeatures):def __init__(self, node_name):super(LKTracker, self).__init__(node_name)self.show_text rospy.get_param(~show_text, True)self.feature_size rospy.get_param(~feature_size, 1)# LK parametersself.lk_winSize rospy.get_param(~lk_winSize, (10, 10))self.lk_maxLevel rospy.get_param(~lk_maxLevel, 2)self.lk_criteria rospy.get_param(~lk_criteria, (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 20, 0.01))self.lk_params dict( winSize self.lk_winSize, maxLevel self.lk_maxLevel, criteria self.lk_criteria) self.detect_interval 1self.keypoints Noneself.detect_box Noneself.track_box Noneself.mask Noneself.grey Noneself.prev_grey Nonedef process_image(self, cv_image):try:# If we dont yet have a detection box (drawn by the user# with the mouse), keep waitingif self.detect_box is None:return cv_image# Create a greyscale version of the imageself.grey cv2.cvtColor(cv_image, cv2.COLOR_BGR2GRAY)# Equalize the grey histogram to minimize lighting effectsself.grey cv2.equalizeHist(self.grey)# If we havent yet started tracking, set the track box to the# detect box and extract the keypoints within itif self.track_box is None or not self.is_rect_nonzero(self.track_box):self.track_box self.detect_boxself.keypoints self.get_keypoints(self.grey, self.track_box)else:if self.prev_grey is None:self.prev_grey self.grey# Now that have keypoints, track them to the next frame# using optical flowself.track_box self.track_keypoints(self.grey, self.prev_grey)# Process any special keyboard commands for this moduleif self.keystroke ! -1:try:cc chr(self.keystroke 255).lower()if cc c:# Clear the current keypointsself.keypoints Noneself.track_box Noneself.detect_box Noneexcept:passself.prev_grey self.greyexcept:passreturn cv_image def track_keypoints(self, grey, prev_grey):# We are tracking points between the previous frame and the# current frameimg0, img1 prev_grey, grey# Reshape the current keypoints into a numpy array required# by calcOpticalFlowPyrLK()p0 np.float32([p for p in self.keypoints]).reshape(-1, 1, 2)# Calculate the optical flow from the previous frame to the current framep1, st, err cv2.calcOpticalFlowPyrLK(img0, img1, p0, None, **self.lk_params)# Do the reverse calculation: from the current frame to the previous frametry:p0r, st, err cv2.calcOpticalFlowPyrLK(img1, img0, p1, None, **self.lk_params)# Compute the distance between corresponding points in the two flowsd abs(p0-p0r).reshape(-1, 2).max(-1)# If the distance between pairs of points is 1 pixel, set# a value in the good array to True, otherwise Falsegood d 1# Initialize a list to hold new keypointsnew_keypoints list()# Cycle through all current and new keypoints and only keep# those that satisfy the good condition abovefor (x, y), good_flag in zip(p1.reshape(-1, 2), good):if not good_flag:continuenew_keypoints.append((x, y))# Draw the keypoint on the imagecv2.circle(self.marker_image, (x, y), self.feature_size, (0, 255, 0, 0), cv.CV_FILLED, 8, 0)# Set the global keypoint list to the new list self.keypoints new_keypoints# Convert the keypoints list to a numpy arraykeypoints_array np.float32([p for p in self.keypoints]).reshape(-1, 1, 2) # If we have enough points, find the best fit ellipse around themif len(self.keypoints) 6:track_box cv2.fitEllipse(keypoints_array)else:# Otherwise, find the best fitting rectangletrack_box cv2.boundingRect(keypoints_array)except:track_box Nonereturn track_boxif __name__ __main__:try:node_name lk_trackerLKTracker(node_name)rospy.spin()except KeyboardInterrupt:print Shutting down LK Tracking node.cv.DestroyAllWindows() 转载于:https://www.cnblogs.com/zxouxuewei/p/5409961.html
http://www.zqtcl.cn/news/700526/

相关文章:

  • 网站深度功能建筑人才网市场
  • 学校网站建设的意义和应用服务平台管理系统
  • 网站内容规划要包括什么内容wordpress5.2 php版本
  • 山西建设部网站超值的镇江网站建设
  • 做淘宝要网站网站推广外链怎么做
  • 深圳做网站推广哪家好自建网站优缺点
  • 网站建设询价函什么网站可以做会计题目
  • 电脑网站视频怎么下载珠海免费网站制作
  • wordpress menu icon咸阳seo
  • php制作网站网站开发与客户沟通
  • 百度网站建设平台微盟微商城官网
  • 三明网站seo上海中学分数线
  • 青岛谷歌网站建设网站建站公司排名
  • 成都旅游网站建设规划windows优化大师官方
  • 福永网站建设公司哪家好财务公司承兑汇票
  • 青岛快速建站模板制作公司网页什么价位
  • 网站建设公司的经营范围wordpress设置文本编辑器
  • 做网站用微软雅黑侵权吗wordpress 同类文章
  • 免费下载建设银行官方网站自己做网站犯法吗
  • 手机网站html代码附近做广告牌的店
  • 建设和优化网站的步骤wordpress 模板 含数据库
  • 太原制作网站的工作室wordpress弹幕播放器
  • 英语网站开发菏泽做网站优化的
  • 宜昌建设网站公司做网站语言服务器 空间
  • 湖南做网站价格广州网站建设哪家便宜
  • 建筑工程素材资源网站中山做网站建设联系电话
  • 做网站关键词集团网站群建设方案
  • 网站开发有哪些课程网站开发好要租服务器吗
  • 鲜花店网站建设的规模设想网站之间的差异
  • 网站怎么在百度做推广郑州建网站