Commit 2e1b0948 authored by Larkin Heintzman's avatar Larkin Heintzman

image saving node wip

parent 58a74a63
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<!-- define all names parameter --> <!-- define all names parameter -->
<rosparam command="load" param="nameList"> <rosparam command="load" param="nameList">
["nerudaKube"] ["baseStation"]
</rosparam> </rosparam>
<!-- load machine names, plath, neruda, and home versions --> <!-- load machine names, plath, neruda, and home versions -->
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<!-- launch neruda vehicle nodes --> <!-- launch neruda vehicle nodes -->
<include file="$(find base_station)/launch/remote_image_test.launch"> <include file="$(find base_station)/launch/remote_image_test.launch">
<arg name="machine_name" value="nerudaKube"/> <arg name="machine_name" value="baseStation"/>
<arg name="machine_id" value="0"/> <arg name="machine_id" value="0"/>
</include> </include>
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
<machine name="yeatsHouse" address="192.168.1.198" env-loader="/opt/ros/noetic/yeats_house_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/> <machine name="yeatsHouse" address="192.168.1.198" env-loader="/opt/ros/noetic/yeats_house_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="yeatsModem" address="192.168.111.203" env-loader="/opt/ros/noetic/yeats_modem_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/> <machine name="yeatsModem" address="192.168.111.203" env-loader="/opt/ros/noetic/yeats_modem_env.sh" user="larkin" default="never" timeout="20" password="Meepp973"/>
<machine name="baseStation" address="localhost" env-loader="/opt/ros/noetic/env.sh" user="llh" default="never" timeout="20" password="Meepp973"/>
<!-- kubernetes connections, interface tbd --> <!-- kubernetes connections, interface tbd -->
<machine name="nerudaKube" address="service-drone" env-loader="/opt/ros/noetic/kube_setup.sh" user="ssher" default="never" timeout="20" password="password"/> <machine name="nerudaKube" address="service-drone" env-loader="/opt/ros/noetic/kube_setup.sh" user="ssher" default="never" timeout="20" password="password"/>
......
#! /usr/bin/python3 #! /usr/bin/python3
#! /home/llh/anaconda3/bin/python
# just saves the image instead of opening viewer window, for kubernetes node # just saves the image instead of opening viewer window, for kubernetes node
import rospy, sys, math, cv2, numpy as np, std_msgs.msg import rospy, sys, math, cv2, numpy as np, std_msgs.msg
from sensor_msgs.msg import Image from sensor_msgs.msg import Image
from std_msgs.msg import Header
import os.path, getpass
from cv_bridge import CvBridge, CvBridgeError from cv_bridge import CvBridge, CvBridgeError
class ImageViewer(): class ImageViewer():
...@@ -11,26 +15,34 @@ class ImageViewer(): ...@@ -11,26 +15,34 @@ class ImageViewer():
self.subscriber = rospy.Subscriber("usb_camera/image_raw", Image, self.imageCallback) self.subscriber = rospy.Subscriber("usb_camera/image_raw", Image, self.imageCallback)
self.params = None self.params = None
self.image = None self.image = None
self.seq = None
def imageCallback(self, frame): def imageCallback(self, frame):
# self.params = self.getParams() # self.params = self.getParams()
try: try:
self.image = self.bridge.imgmsg_to_cv2(frame, "bgr8") self.image = self.bridge.imgmsg_to_cv2(frame, "bgr8")
self.seq = frame.header.seq
except CvBridgeError as err: except CvBridgeError as err:
rospy.loginfo("there was error!") rospy.loginfo("there was error!")
rospy.loginfo(err) rospy.loginfo(err)
def main(): def main():
iv = ImageViewer() iv = ImageViewer()
rospy.init_node("imageViewer") rospy.init_node("imageSaver")
folderName = "/home/" + getpass.getuser() + "/imageDump"
# cv2.namedWindow("image window") # cv2.namedWindow("image window")
cv2.waitKey(200) cv2.waitKey(200)
while not rospy.is_shutdown(): while not rospy.is_shutdown():
if iv.image is not None: if iv.image is not None:
# cv2.imshow("image window", iv.image) # cv2.imshow("image window", iv.image)
cv2.imwrite("/home/$USER/camera_image.jpeg", iv.image) if np.mod(iv.seq, 32) == 0:
cv2.waitKey(10) if os.path.isdir(folderName):
# print ("File exist")
cv2.imwrite(folderName + "/camera_image_{seq}.jpeg".format(seq = iv.seq), iv.image)
cv2.waitKey(1000)
else:
print ("File not exist")
# cv2.destroyAllWindows() # cv2.destroyAllWindows()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment