ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

pnambiar's profile - activity

2022-07-14 15:19:28 -0500 marked best answer Combining the depth and color data

I'm trying to use the following piece of code for acquiring depth as well as the color data from kinect. I would now like to use the depth information to extract some points/pixel in the color image after a keyboard input ('c') a) What is the best way to pass information from callback2 to callback ? b) How do I ensure that the depth data(callback2) is obtained before callback is executed?

Thanks, -P

import roslib
import sys
import rospy
import cv2
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
import numpy as np
import math;
import cv2;
import matplotlib.pyplot as plt;
import sys;
import caffe;
import socket;

class image_converter:

  def __init__(self):
    cv2.namedWindow("Image window", 1)
    print 'start bridge and subscribe'
    self.bridge = CvBridge()
    self.depth_sub = rospy.Subscriber("/camera/depth_registered/image_raw",Image,self.callback2,queue_size=1)
    self.image_sub = rospy.Subscriber("/camera/rgb/image_color",Image,self.callback,queue_size=1)


  def callback2(self,data):
    try:
        depth_image_raw = self.bridge.imgmsg_to_cv2(data, "passthrough")
        depth_image = depth_image_raw.astype(np.uint8)
        cv2.imshow("Depth window", depth_image)
        key = cv2.waitKey(3)
        if (key == 99): # 'c'
            # save depth data as numpy array

    except CvBridgeError, e:
      print e


  def callback(self,data):

    try:
      image = self.bridge.imgmsg_to_cv2(data, "bgr8")
    except CvBridgeError, e:
      print e

    cv_image = image[:,:,:];

    if (key == 99): # 'c'
       # Use the depth data and get the corresponding points in the color image

def main(args):
  ic = image_converter()
  rospy.init_node('image_converter', anonymous=True)
  try:
    rospy.spin()
      except KeyboardInterrupt:
    print "Shutting down"
  cv2.destroyAllWindows()

if __name__ == '__main__':
    main(sys.argv)
2021-04-23 19:03:04 -0500 received badge  Famous Question (source)
2021-03-14 08:55:01 -0500 received badge  Notable Question (source)
2021-03-14 08:55:01 -0500 received badge  Famous Question (source)
2021-03-14 08:55:01 -0500 received badge  Popular Question (source)
2020-08-31 16:27:30 -0500 edited question PCL not updating

PCL not updating I am able to view my lidar pointcloud using this script but not update it. viewer-> spin() does not

2020-08-31 16:26:00 -0500 asked a question PCL not updating

PCL not updating I am able to view my lidar pointcloud using this script but not update it. viewer-> spin() does not

2020-08-09 09:46:40 -0500 received badge  Notable Question (source)
2020-08-09 09:46:40 -0500 received badge  Popular Question (source)
2020-08-09 09:43:42 -0500 received badge  Famous Question (source)
2020-07-20 06:31:40 -0500 received badge  Notable Question (source)
2020-07-19 18:13:08 -0500 received badge  Popular Question (source)
2020-07-19 06:11:50 -0500 asked a question visualize lidar point cloud data

visualize lidar point cloud data What would be the best way to visualize lidar data? I am using cv_bridge for images. d

2020-06-29 08:48:50 -0500 received badge  Famous Question (source)
2019-09-20 02:38:11 -0500 marked best answer Problem viewing images using python-opencv

I have trouble viewing color images from R200 realsense camera using the python-opencv interface. The window is blank when I run this script. When I comment out'cv2.namedWindow("Image window", 1)', it shows the first image.

-P

import roslib
import sys
import rospy
import cv2
from std_msgs.msg import String
from geometry_msgs.msg import Twist
from sensor_msgs.msg import Image
from rospy.numpy_msg import numpy_msg
#from rospy_tutorials.msg import Floats
from cv_bridge import CvBridge, CvBridgeError
import numpy as np
import math;
import cv2;
#import matplotlib.pyplot as plt;
import sys;
#import caffe;
import socket;
#from sklearn import datasets;
import subprocess;

import message_filters
from rospy.numpy_msg import numpy_msg
import time
#####################

import os.path


class image_converter:

# Initializing variables, publishers and subscribers
  def __init__(self):
    print 'show window'
    cv2.namedWindow("Image window", 1)
#    print 'start bridge and subscribe'
    self.bridge = CvBridge()

    self.image_sub = rospy.Subscriber("/camera/rgb/image_color", Image, self.callback)


  # The main callback that processes the color and depth data.      
  def callback(self,color):


    start = time.time()
    # acquiring color and depth data (from ROS-python tutorial)
    try:

      frame = self.bridge.imgmsg_to_cv2(color, "bgr8")
    except CvBridgeError, e:
      print e

    frame = np.array(frame, dtype=np.uint8)

    cv2.imshow("Image window", frame)
    print 'test'
    cv2.waitKey(0)


def main(args):
  ic = image_converter()
  rospy.init_node('image_converter', anonymous=True)
  try:
    rospy.spin()
  except KeyboardInterrupt:
    print "Shutting down"
  cv2.destroyAllWindows()

if __name__ == '__main__':
    main(sys.argv)
2019-04-08 01:17:17 -0500 marked best answer streaming high resolution image data over a wireless connection

I am currently running a ROS package (publishing multiple topics including image topics) on multiple computers connected wirelessly using http://www.netwifiworks.com/PicoStati... . While I get pretty good frame rate on master computer, the frame rate is pretty low on the listener computer. What is the solution? Image compression/ -P

2019-03-01 12:36:00 -0500 marked best answer Interpreting ros error code

Here is the error code that I am getting [darknet_ros-2] process has died [pid 1733, exit code -11, cmd /home/nvidia/catkin_ws/devel/lib/darknet_ros/darknet_ros __name:=darknet_ros __log:=/home/nvidia/.ros/log/b9b03498-0cdc-11e8-9325-2816adcdeb8c/darknet_ros-2.log]. log file: /home/nvidia/.ros/log/b9b03498-0cdc-11e8-9325-2816adcdeb8c/darknet_ros-2*.log

The log file reports the following:

[rospy.client][INFO] 2018-01-29 20:27:28,806: init_node, name[/mipi_cap_node], pid[1732]
[xmlrpc][INFO] 2018-01-29 20:27:28,808: XML-RPC server binding to 0.0.0.0:0
[xmlrpc][INFO] 2018-01-29 20:27:28,810: Started XML-RPC server [http://192.168.1.32:44140/]
[rospy.impl.masterslave][INFO] 2018-01-29 20:27:28,810: _ready: http://192.168.1.32:44140/
[rospy.init][INFO] 2018-01-29 20:27:28,811: ROS Slave URI: [http://192.168.1.32:44140/]
[rospy.registration][INFO] 2018-01-29 20:27:28,813: Registering with master node http://192.168.1.29:11311
[xmlrpc][INFO] 2018-01-29 20:27:28,813: xml rpc node: starting XML-RPC server
[rospy.registration][INFO] 2018-01-29 20:27:28,814: Registering publisher topic [/camera/rgb/image_raw] type             [sensor_msgs/Image] with master
[rospy.init][INFO] 2018-01-29 20:27:28,911: registered with master
[rospy.rosout][INFO] 2018-01-29 20:27:28,912: initializing /rosout core topic
[rospy.rosout][INFO] 2018-01-29 20:27:28,917: connected to core topic /rosout
[rospy.simtime][INFO] 2018-01-29 20:27:28,921: /use_sim_time is not set, will not subscribe to simulated time [/clock] topic
[rospy.internal][INFO] 2018-01-29 20:27:29,139: topic[/rosout] adding connection to [/rosout], count 0
[rospy.internal][INFO] 2018-01-29 20:27:33,557: topic[/camera/rgb/image_raw] adding connection to [/darknet_ros], count 0
[rospy.internal][INFO] 2018-01-29 20:27:36,530: topic[/camera/rgb/image_raw] removing connection to /darknet_ros
[rospy.internal][INFO] 2018-01-29 20:27:44,671: topic[/camera/rgb/image_raw] adding connection to        [/rostopic_8635_1518100309363], count 0
[rospy.internal][INFO] 2018-01-29 20:27:46,893: topic[/camera/rgb/image_raw] removing connection to /rostopic_8635_1518100309363

[rospy.internal][INFO] 2018-01-29 20:27:49,532: topic[/camera/rgb/image_raw] adding connection to [/rostopic_8656_1518100314233], count 0 [rospy.internal][INFO] 2018-01-29 20:28:10,690: topic[/camera/rgb/image_raw] removing connection to /rostopic_8656_1518100314233 [rosout][WARNING] 2018-01-29 20:28:10,783: Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details. [rospy.internal][ERROR] 2018-01-29 20:28:10,788: Inbound TCP/IP connection failed: Traceback (most recent call last): File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_base.py", line 321, in _tcp_server_callback header = read_ros_handshake_header(sock, StringIO(), buff_size) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/network.py", line 364, in read_ros_handshake_header raise ROSHandshakeException("connection from sender terminated before handshake header received. %s bytes were received. Please check sender for additional details."%b.tell()) ROSHandshakeException: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.

[rospy.internal][INFO] 2018-01-29 20:28:22,484: topic[/camera/rgb/image_raw] adding connection to [/image_view_1518100347117379321], count 0 [rospy.internal][INFO] 2018-01-29 ... (more)

2019-02-25 10:38:58 -0500 received badge  Notable Question (source)
2018-11-12 22:21:11 -0500 received badge  Famous Question (source)
2018-11-12 22:21:11 -0500 received badge  Notable Question (source)
2018-10-17 15:23:44 -0500 asked a question Baxter Moveit-Commander Example script

Baxter Moveit-Commander Example script Is there a simple example python script available to plan trajectory and execute

2018-09-15 14:04:09 -0500 received badge  Famous Question (source)
2018-07-27 10:14:16 -0500 received badge  Popular Question (source)
2018-07-27 10:14:16 -0500 received badge  Notable Question (source)
2018-07-23 10:15:17 -0500 received badge  Popular Question (source)
2018-07-23 05:15:02 -0500 commented question roa wrapper for caffe 2

yes. I did not word it properly earlier. Any leads will be highly appreciated.

2018-07-23 04:35:23 -0500 received badge  Popular Question (source)
2018-07-22 21:31:45 -0500 commented question roa wrapper for caffe 2

@jayess Please refer to this post for the error that I am getting https://answers.ros.org/question/298104/cv_bridgeboost

2018-07-22 13:59:12 -0500 asked a question roa wrapper for caffe 2

roa wrapper for caffe 2 I am trying to create a ROS wrapper for caffe2 script (https://github.com/facebookresearch/Detec

2018-07-20 19:37:06 -0500 edited question cv_bridge.boost error

cv_bridge.boost error I am trying to create a ROS wrapper for caffe2 (Ros Kinetic, opencv version-3.4.1) and I get the f

2018-07-20 19:36:33 -0500 edited question cv_bridge.boost error

cv_bridge.boost error I am trying to create a ROS wrapper for caffe2 (Ros Kinetic, opencv version-3.4.1) and I get the f

2018-07-20 19:32:45 -0500 asked a question cv_bridge.boost error

cv_bridge.boost error I am trying to create a ROS wrapper for caffe2 (Ros Kinetic, opencv version-3.4.1) and I get the f

2018-07-20 18:56:31 -0500 received badge  Notable Question (source)
2018-07-20 18:56:31 -0500 received badge  Famous Question (source)
2018-06-24 21:15:49 -0500 received badge  Famous Question (source)
2018-06-08 10:30:25 -0500 received badge  Famous Question (source)
2018-05-18 15:36:56 -0500 received badge  Famous Question (source)
2018-03-14 21:35:28 -0500 received badge  Notable Question (source)
2018-02-28 20:17:57 -0500 marked best answer Best way to view and save hd kinect images

What is the best way to view and save hd images kinect 2? Driver used is: https://github.com/code-iai/iai_kinect2

2018-02-28 20:16:33 -0500 received badge  Famous Question (source)
2018-02-22 08:49:57 -0500 commented answer streaming high resolution image data over a wireless connection

I tried imagezero. Did not see a big difference in terms of speed. I will try ffmpeg or gstreamer

2018-02-21 12:32:36 -0500 commented answer streaming high resolution image data over a wireless connection

@gvdhoorn I have everything working with image transport theora. Now, the bottle neck is compression. For a stream of 6

2018-02-20 02:16:39 -0500 received badge  Popular Question (source)
2018-02-19 19:36:18 -0500 asked a question image compression using image transport

image compression using image transport I don't have the hardware to implement this, hence I am asking this question. I

2018-02-18 19:01:39 -0500 received badge  Famous Question (source)
2018-02-16 12:56:10 -0500 commented question streaming high resolution image data over a wireless connection

Sure! Done.

2018-02-16 12:55:47 -0500 edited question streaming high resolution image data over a wireless connection

Running ROS on multiple computers I am currently running a ROS package (publishing multiple topics including image top

2018-02-16 12:49:13 -0500 commented answer streaming high resolution image data over a wireless connection

Thanks for the suggestions. I will definitely take a look at it.

2018-02-16 10:23:34 -0500 commented answer streaming high resolution image data over a wireless connection

max data rate of 54 mbps is what we have for this wireless access point (https://dl.ubnt.com/datasheets/picostationm/pi