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

adding intro task files #170

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/packages/tauv_common/launch/vision/intro_task.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<launch>
<node pkg="tauv_common" type="intro_task" name="intro_task" output="screen">
</node>
</launch>
5 changes: 5 additions & 0 deletions src/packages/tauv_common/scripts/intro_task
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python3
from vision.intro_task import intro_task

if __name__ == "__main__":
intro_task.main()
Empty file.
44 changes: 44 additions & 0 deletions src/packages/tauv_common/src/vision/intro_task/intro_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python3

import rospy
import cv2
import numpy as np
from sensor_msgs.msg import Image
from cv_bridge import CvBridge

class find_red:
def __init__(self):
# "/kf/vehicle/oakd_bottom/color/camera_info"
self.c = CvBridge()
pub_name = "intro_task/new_image"
# sub_name = "/kf/vehicle/oakd_bottom/color/image_raw"
sub_name = "/kf/vehicle/oakd_bottom/stereo/right/image_color"

self.pub = rospy.Publisher(pub_name, Image, queue_size = 10)
self.imageSub = rospy.Subscriber(sub_name, Image, self.image_callback)
self.img = Image()
self.mask = Image()

def image_callback(self, msg):
self.img = self.c.imgmsg_to_cv2(msg, desired_encoding='bgr8')
# img_thresh = cv2.threshold(self.img, low = (100, 0, 0))
# self.img = np.where(self.img[self.img[:,:,0] > 50, self.img, 0])
# mask = cv2.threshold(self.img, 200, 255, cv2.THRESH_BINARY_INV)

hsv = cv2.cvtColor(self.img, cv2.COLOR_BGR2HSV)
lower_red = np.array([160, 50, 50])
upper_red = np.array([180, 255, 255])
self.mask = cv2.inRange(hsv, lower_red, upper_red)
img = cv2.bitwise_and(self.img, self.img, mask=self.mask)
self.img = self.c.cv2_to_imgmsg(img)

self.pub.publish(self.img)
# self.pub.publish(self.mask)



if __name__ == '__main__':
node_name = 'intro_task'
rospy.init_node(node_name)
find_red()
rospy.spin
28 changes: 28 additions & 0 deletions src/packages/tauv_common/src/vision/intro_task/intro_task2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python3

import rospy
import rviz
import cv2
import numpy as np
from sensor_msgs.msg import CameraInfo, Image
from cv_bridge import CvBridge

class handle_img:
def __init__(self):
self.c = CvBridge()

sub_name = "/kf/vehicle/oakd_bottom/color/new_image"

self.imageSub = rospy.Subscriber(sub_name, Image, self.image_callback)
self.img = Image()

def image_callback(self, msg):
self.img = msg
# self.frame



if __name__ == '__main__':
rospy.init_node('new image topic')
handle_img()
rospy.spin