Comments (10)
Hi Tondy
I have tested cv_bridge_demo.py on Kinect only, and i am not sure that the depth image datatype has any change in Real sense !! Is the RGB stream working ??
from chefbot_ros_pkg.
Hello
Yes I have tested the rgb with this command : rosrun image_view image_view image:=/camera/rgb/image_raw
I can see a video running on a window.
from chefbot_ros_pkg.
Hi Tondy
What i mean was, whether the RGB stream working using the code.. You can comment the depth section and run the code !!
from chefbot_ros_pkg.
Hello Ok.
So I muted the depth function call back and ran the code. I receive this
[INFO] [WallTime: 1460130063.747957] Waiting for image topics...
nothing happens.
here the code:
import rospy
import sys
import cv2
import cv2.cv as cv
from sensor_msgs.msg import Image, CameraInfo
from cv_bridge import CvBridge, CvBridgeError
import numpy as np
class cvBridgeDemo():
def __init__(self):
self.node_name = "cv_bridge_demo"
rospy.init_node(self.node_name)
# What we do during shutdown
rospy.on_shutdown(self.cleanup)
# Create the OpenCV display window for the RGB image
self.cv_window_name = self.node_name
cv.NamedWindow(self.cv_window_name, cv.CV_WINDOW_NORMAL)
cv.MoveWindow(self.cv_window_name, 25, 75)
# And one for the depth image
cv.NamedWindow("Depth Image", cv.CV_WINDOW_NORMAL)
cv.MoveWindow("Depth Image", 25, 350)
# Create the cv_bridge object
self.bridge = CvBridge()
# Subscribe to the camera image and depth topics and set
# the appropriate callbacks
self.image_sub = rospy.Subscriber("/camera/rgb/image_color", Image, self.image_callback)
#self.depth_sub = rospy.Subscriber("/camera/depth/image_raw", Image, self.depth_callback)
rospy.loginfo("Waiting for image topics...")
def image_callback(self, ros_image):
# Use cv_bridge() to convert the ROS image to OpenCV format
try:
frame = self.bridge.imgmsg_to_cv2(ros_image, "bgr8")
except CvBridgeError, e:
print e
# Convert the image to a Numpy array since most cv2 functions
# require Numpy arrays.
frame = np.array(frame, dtype=np.uint8)
# Process the frame using the process_image() function
display_image = self.process_image(frame)
# Display the image.
cv2.imshow(self.node_name, display_image)
# Process any keyboard commands
self.keystroke = cv.WaitKey(5)
if 32 <= self.keystroke and self.keystroke < 128:
cc = chr(self.keystroke).lower()
if cc == 'q':
# The user has press the q key, so exit
rospy.signal_shutdown("User hit q key to quit.")
def depth_callback(self, ros_image):
# Use cv_bridge() to convert the ROS image to OpenCV format
try:
# The depth image is a single-channel float32 image
depth_image = self.bridge.imgmsg_to_cv2(ros_image, "32FC1")
except CvBridgeError, e:
print e
# Convert the depth image to a Numpy array since most cv2 functions
# require Numpy arrays.
depth_array = np.array(depth_image, dtype=np.float32)
# Normalize the depth image to fall between 0 (black) and 1 (white)
cv2.normalize(depth_array, depth_array, 0, 1, cv2.NORM_MINMAX)
# Process the depth image
depth_display_image = self.process_depth_image(depth_array)
# Display the result
cv2.imshow("Depth Image", depth_display_image)
def process_image(self, frame):
# Convert to greyscale
grey = cv2.cvtColor(frame, cv.CV_BGR2GRAY)
# Blur the image
grey = cv2.blur(grey, (7, 7))
# Compute edges using the Canny edge filter
edges = cv2.Canny(grey, 15.0, 30.0)
return edges
def process_depth_image(self, frame):
# Just return the raw image for this demo
return frame
def cleanup(self):
print "Shutting down vision node."
cv2.destroyAllWindows()
def main(args):
try:
cvBridgeDemo()
rospy.spin()
except KeyboardInterrupt:
print "Shutting down vision node."
cv.DestroyAllWindows()
if __name__ == '__main__':
main(sys.argv)
from chefbot_ros_pkg.
You have to change this line
self.image_sub = rospy.Subscriber("/camera/rgb/image_color", Image, self.image_callback)
Check whether the topic exist, other vice change to the color image topic !!!
from chefbot_ros_pkg.
Hello
So the topic /camera/rgb/image_color does exist but does not work so some reason. I changed the topic to /camera/rgb/image_raw and a get the edged out image without depth. So thatβs working.
from chefbot_ros_pkg.
Thanks
from chefbot_ros_pkg.
I think the following line making issue
depth_array = np.array(depth_image, dtype=np.float32)
This was working with Kinect. If you can send me a bag file of the depth image, i can work on it and correct it for realsense !!
Here is my mail id : [email protected]
from chefbot_ros_pkg.
Oh ok. Many thanks . I will send it by email. Many thanks.
from chefbot_ros_pkg.
Great !! Will work on it !!!
from chefbot_ros_pkg.
Related Issues (9)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chefbot_ros_pkg.