Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #277

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ちょっと古い書き方ですが2行目には
# -*- coding: utf-8 -*-
を入れておくと良いです
http://osksn2.hep.sci.osaka-u.ac.jp/~taku/osx/python/encoding.html

#必要なpackageをimport
import rospy
from opencv_apps.msg import RotatedRectStamped
from image_view2.msg import ImageMarker2
from geometry_msgs.msg import Point

def cb(msg):
print msg.rect #矩形の情報を表示
marker = ImageMarker2() #markerの定義
marker.type = 0 #円形のmarker
marker.position = Point(msg.rect.center.x, msg.rect.center.y, 0) #矩形の中心にmarkerの中心を設定
pub.publish(marker) #markerを送信

rospy.init_node('client') #ノードを宣言
rospy.Subscriber('/camshift/track_box', RotatedRectStamped, cb) #(topic名, 型, callback関数)
pub = rospy.Publisher('/image_marker', ImageMarker2) #(topic名, 型, size)
rospy.spin() #nodeが終了するまで