colbybanbury / astrobee_CISC489

0 stars 0 forks source link

(input data) Find a way to export camera data #6

Open sjkuntz opened 6 years ago

sjkuntz commented 6 years ago

We need to be able to use this within a script w/ ML packages

sjkuntz commented 6 years ago

https://gist.github.com/rethink-imcmahon/77a1a4d5506258f3dc1f#file-ros_image_saver-py-L23

sjkuntz commented 6 years ago

steven@steven-Precision-5520:~/freeflyer_build/native$ rosservice call /mgt/img_sampler/dock_cam/configure True 1 360 360 200 steven@steven-Precision-5520:~/freeflyer_build/native$ rostopic pub /mgt/img_spler/dock_cam/image_stream sensor_msgs/Image "header: seq: 1 stamp: {secs: 0, nsecs: 0} frame_id: '' height: 1 width: 1 encoding: 'bgr8' is_bigendian: 0 step: 0 data: ''"

And the subscriber prints: steven@steven-Precision-5520:~/Documents/astrobee_CISC489$ python ros_image_sar.py Received an image! [ERROR] [1525269233.489214, 0.000000]: bad callback: <function image_callback at 0x7fb665142848> Traceback (most recent call last): File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback cb(msg) File "ros_image_saver.py", line 27, in image_callback cv2_img = bridge.imgmsg_to_cv2(msg, "bgr8") File "/opt/ros/kinetic/lib/python2.7/dist-packages/cv_bridge/core.py", line 171, in imgmsg_to_cv2 dtype=dtype, buffer=img_msg.data) TypeError: buffer is too small for requested array

sjkuntz commented 6 years ago

Tried this again, what I discovered is that we might be using the wrong image encoder. mono8 and mono16 are black/white image encodings. ROS images are byte arrays, and bag files save image streams of that type. From there, something like OpenCV can be used to turn ROS images into files?

sjkuntz commented 6 years ago

http://docs.ros.org/api/sensor_msgs/html/msg/Image.html

This is what we're trying to convert to jpeg

sjkuntz commented 6 years ago

http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython

sjkuntz commented 6 years ago

Images are now saving. /hw/cam_nav and /hw/cam_dock are the ideal nodes to subscribe to for pulling images.

/gnc/ekf should contain relevant position data.